Merge branch 'master' into reconnection
This commit is contained in:
commit
ad5118cdf1
@ -1380,28 +1380,26 @@ module equations
|
||||
!
|
||||
! Arguments:
|
||||
!
|
||||
! it - the time step number;
|
||||
! id - the block id where the states are being checked;
|
||||
! qq - the output array of primitive variables;
|
||||
! uu - the input array of conservative variables;
|
||||
! step - the time step number;
|
||||
! pdata - the data block;
|
||||
! status - the call status;
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine correct_unphysical_states(it, id, qq, uu, status)
|
||||
subroutine correct_unphysical_states(step, pdata, status)
|
||||
|
||||
use blocks , only : block_data
|
||||
use coordinates, only : nn => bcells
|
||||
use helpers , only : print_message
|
||||
use coordinates, only : ax, ay, az
|
||||
|
||||
implicit none
|
||||
|
||||
integer(kind=4) , intent(in) :: it, id
|
||||
real(kind=8), dimension(:,:,:,:), intent(inout) :: qq
|
||||
real(kind=8), dimension(:,:,:,:), intent(inout) :: uu
|
||||
integer , intent(out) :: status
|
||||
integer(kind=4) , intent(in) :: step
|
||||
type(block_data), pointer, intent(inout) :: pdata
|
||||
integer , intent(out) :: status
|
||||
|
||||
character(len=255) :: msg, sfmt
|
||||
character(len=16) :: sit, sid, snc
|
||||
integer :: n, p, nc, np
|
||||
integer :: i, il, iu
|
||||
integer :: j, jl, ju
|
||||
@ -1418,6 +1416,10 @@ module equations
|
||||
|
||||
integer , dimension(:,:), allocatable :: idx
|
||||
real(kind=8), dimension(:,:), allocatable :: q, u
|
||||
real(kind=8), dimension(nn) :: x, y
|
||||
#if NDIMS == 3
|
||||
real(kind=8), dimension(nn) :: z
|
||||
#endif /* NDIMS == 3 */
|
||||
|
||||
character(len=*), parameter :: loc = &
|
||||
'EQUATIONS::correct_unphysical_states()'
|
||||
@ -1438,21 +1440,19 @@ module equations
|
||||
#endif /* NDIMS == 3 */
|
||||
|
||||
if (ipr > 0) then
|
||||
physical(:,:,:) = qq(idn,:,:,:) > 0.0d+00 .and. qq(ipr,:,:,:) > 0.0d+00
|
||||
physical(:,:,:) = pdata%q(idn,:,:,:) > 0.0d+00 .and. &
|
||||
pdata%q(ipr,:,:,:) > 0.0d+00
|
||||
else
|
||||
physical(:,:,:) = qq(idn,:,:,:) > 0.0d+00
|
||||
physical(:,:,:) = pdata%q(idn,:,:,:) > 0.0d+00
|
||||
end if
|
||||
|
||||
nc = count(.not. physical)
|
||||
|
||||
if (nc > 0) then
|
||||
|
||||
write(sit,'(i15)') it
|
||||
write(sid,'(i15)') id
|
||||
write(snc,'(i15)') nc
|
||||
sfmt = '("Unphysical cells in block ID:",a," (",a," counted)' &
|
||||
// ' at time step ",a,".")'
|
||||
write(msg,sfmt) trim(adjustl(sid)), trim(adjustl(snc)), trim(adjustl(sit))
|
||||
sfmt = '("Unphysical cells in block ID:",i0," (",i0," counted) ' // &
|
||||
'at time step ",i0,".")'
|
||||
write(msg,sfmt) pdata%meta%id, nc, step
|
||||
call print_message(loc, msg)
|
||||
|
||||
allocate(q(nv,nc), u(nv,nc), idx(3,nc), stat=status)
|
||||
@ -1462,6 +1462,12 @@ module equations
|
||||
return
|
||||
end if
|
||||
|
||||
x(:) = pdata%meta%xmin + ax(pdata%meta%level,:)
|
||||
y(:) = pdata%meta%ymin + ay(pdata%meta%level,:)
|
||||
#if NDIMS == 3
|
||||
z(:) = pdata%meta%zmin + az(pdata%meta%level,:)
|
||||
#endif /* NDIMS == 3 */
|
||||
|
||||
n = 0
|
||||
#if NDIMS == 3
|
||||
do k = 1, nn
|
||||
@ -1473,6 +1479,10 @@ module equations
|
||||
|
||||
n = n + 1
|
||||
|
||||
write(msg,'("n: ",i0,"[i,j,k]: ",3i0,"[x,y,z]: ",3es12.4)') &
|
||||
n, i, j, k, x(i), y(j), z(k)
|
||||
call print_message(loc, msg)
|
||||
|
||||
idx(:,n) = [ i, j, k ]
|
||||
|
||||
! increase the region until we find at least three physical cells, but no more
|
||||
@ -1504,13 +1514,11 @@ module equations
|
||||
|
||||
do p = 1, nv
|
||||
#if NDIMS == 3
|
||||
q(p,n) = sum(qq(p,il:iu,jl:ju,kl:ku), &
|
||||
physical(il:iu,jl:ju,kl:ku)) &
|
||||
/ np
|
||||
q(p,n) = sum(pdata%q(p,il:iu,jl:ju,kl:ku), &
|
||||
physical(il:iu,jl:ju,kl:ku)) / np
|
||||
#else /* NDIMS == 3 */
|
||||
q(p,n) = sum(qq(p,il:iu,jl:ju, 1 ), &
|
||||
physical(il:iu,jl:ju, 1 )) &
|
||||
/ np
|
||||
q(p,n) = sum(pdata%q(p,il:iu,jl:ju, 1 ), &
|
||||
physical(il:iu,jl:ju, 1 )) / np
|
||||
#endif /* NDIMS == 3 */
|
||||
end do
|
||||
|
||||
@ -1521,17 +1529,17 @@ module equations
|
||||
!
|
||||
msg = "Not sufficient number of physical neighbors!"
|
||||
call print_message(loc, msg)
|
||||
sfmt = '("Block ID:",a,", cell position = ( ",3(i4," ")," ).")'
|
||||
write(msg,sfmt) trim(adjustl(sid)), i, j, k
|
||||
sfmt = '("Block ID:",i0,", cell position = ( ",3(i4," ")," ).")'
|
||||
write(msg,sfmt) pdata%meta%id, i, j, k
|
||||
call print_message(loc, msg)
|
||||
write(msg,"('Q = ',10(1x,1es24.16e3))") qq(:,i,j,k)
|
||||
write(msg,"('Q = ',10(1x,1es24.16e3))") pdata%q(:,i,j,k)
|
||||
call print_message(loc, msg)
|
||||
msg = "Applying lower bounds for positive variables."
|
||||
call print_message(loc, msg)
|
||||
|
||||
q( : ,n) = qq( : ,i,j,k)
|
||||
q(idn,n) = max(dmin, qq(idn,i,j,k))
|
||||
if (ipr > 0) q(ipr,n) = max(pmin, qq(ipr,i,j,k))
|
||||
q( : ,n) = pdata%q( : ,i,j,k)
|
||||
q(idn,n) = max(pdata%q(idn,i,j,k), dmin)
|
||||
if (ipr > 0) q(ipr,n) = max(pdata%q(ipr,i,j,k), pmin)
|
||||
|
||||
end if ! not sufficient number of physical cells for averaging
|
||||
|
||||
@ -1550,8 +1558,8 @@ module equations
|
||||
j = idx(2,n)
|
||||
k = idx(3,n)
|
||||
|
||||
qq(:,i,j,k) = q(:,n)
|
||||
uu(:,i,j,k) = u(:,n)
|
||||
pdata%q(:,i,j,k) = q(:,n)
|
||||
pdata%u(:,i,j,k) = u(:,n)
|
||||
end do
|
||||
|
||||
deallocate(q, u, idx, stat=status)
|
||||
|
@ -4138,7 +4138,7 @@ module evolution
|
||||
pmeta => pdata%meta
|
||||
|
||||
if (.not. pdata%physical) then
|
||||
call correct_unphysical_states(step, pmeta%id, pdata%q, pdata%u, s)
|
||||
call correct_unphysical_states(step, pdata, s)
|
||||
!$omp critical
|
||||
if (s /= 0) status = 1
|
||||
!$omp end critical
|
||||
|
Loading…
x
Reference in New Issue
Block a user