EQUATIONS: More control over the unphysical cell correction.

Give more control over the unphysical cell correction by allowing to
specify the minimum number of physical cells to perform averaging
(parameter "npavg") and the maximum distance to be considered from the
corrected cell (parameter "ngavg").

These two parameters allow to avoid averaging of extended unphysical
regions from two physical points.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2018-08-21 23:02:51 -03:00
parent 808c1583ba
commit 1cefe88de4

View File

@ -158,9 +158,12 @@ module equations
integer , save :: nrmax = 100
integer , save :: nrext = 2
! flags for corrections
! flag for unphysical cells correction, the maximum distance of neighbors for
! averaging region, and the minimum number of cells for averaging
!
logical , save :: fix_unphysical_cells = .false.
integer , save :: ngavg = 2
integer , save :: npavg = 4
! by default everything is private
!
@ -868,6 +871,16 @@ module equations
fix_unphysical_cells = .false.
end select
! get parameters for unphysical cells correction
!
call get_parameter_integer("ngavg", ngavg)
call get_parameter_integer("npavg", npavg)
! correct the above parameters to reasonable values
!
ngavg = max(1, ngavg)
npavg = max(2, npavg)
! print information about the equation module
!
if (verbose) then
@ -879,6 +892,10 @@ module equations
end if
write (*,"(4x,a20, 3x,'=',1x,a)") "fix unphysical cells" &
, trim(unphysical_fix)
if (fix_unphysical_cells) then
write (*,"(4x,a20, 3x,'=',1x,i4)") "ngavg ", ngavg
write (*,"(4x,a20, 3x,'=',1x,i4)") "npavg ", npavg
end if
end if
@ -1193,7 +1210,7 @@ module equations
!
np = 0
p = 1
do while (np <= 2 .and. p <= 4)
do while (np <= npavg .and. p <= ngavg)
il = max( 1, i - p)
iu = min(im, i + p)
jl = max( 1, j - p)
@ -1208,7 +1225,7 @@ module equations
! average primitive variables
!
if (np > 2) then
if (np >= npavg) then
do p = 1, nv
q(p,n) = sum(qq(p,il:iu,jl:ju,kl:ku), &