From 1cefe88de49728eafb0cab4481f80f9f8b93873e Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Tue, 21 Aug 2018 23:02:51 -0300 Subject: [PATCH] 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 --- src/equations.F90 | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/equations.F90 b/src/equations.F90 index 5c536df..380677e 100644 --- a/src/equations.F90 +++ b/src/equations.F90 @@ -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), &