Skip to content

Commit 8bb2f25

Browse files
committed
add normal snapping for near grid aligned normals in MTHINC
1 parent 6d10d7b commit 8bb2f25

8 files changed

Lines changed: 88 additions & 213 deletions

File tree

src/common/m_constants.fpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ module m_constants
4646
integer, parameter :: WENO_TYPE = 1 !< Using WENO for reconstruction type
4747
integer, parameter :: MUSCL_TYPE = 2 !< Using MUSCL for reconstruction type
4848
! Interface Compression
49-
real(wp), parameter :: dflt_ic_eps = 1e-4_wp !< Ensure compression is only applied to surface cells in THINC
50-
real(wp), parameter :: dflt_ic_beta = 1.6_wp !< Sharpness parameter's default value used in THINC
51-
real(wp), parameter :: moncon_cutoff = 1e-8_wp !< Monotonicity constraint's limiter to prevent extremas in THINC
49+
real(wp), parameter :: dflt_ic_eps = 1e-4_wp !< Ensure compression is only applied to surface cells in THINC
50+
real(wp), parameter :: dflt_ic_beta = 1.6_wp !< Sharpness parameter's default value used in THINC
51+
real(wp), parameter :: moncon_cutoff = 1e-8_wp !< Monotonicity constraint's limiter to prevent extremas in THINC
52+
real(wp), parameter :: mthinc_align_tol = 1.e-8_wp !< Grid aligned snap tolerance for MTHINC normals
5253
! Chemistry
5354
real(wp), parameter :: dflt_T_guess = 1200._wp !< Default guess for temperature (when a previous value is not available)
5455

src/simulation/m_muscl.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ contains
211211
#:endfor
212212
end if
213213

214-
if (int_comp > 0 .and. v_size >= advxe) then
214+
if (int_comp > 0 .and. v_size >= eqn_idx%adv%end) then
215215
call nvtxStartRange("WENO-INTCOMP")
216216
#:for MUSCL_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')]
217217
if (muscl_dir == ${MUSCL_DIR}$) then

src/simulation/m_thinc.fpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ contains
212212

213213
type(scalar_field), dimension(:), intent(in) :: v_vf
214214
integer :: j, k, l
215-
real(wp) :: nr_x, nr_y, nr_z, nmag, ac
215+
real(wp) :: nr_x, nr_y, nr_z, nmag, nmax, ac
216216
type(int_bounds_info), dimension(3) :: id_norm
217217

218218
$:GPU_PARALLEL_LOOP(collapse=3, private='[j, k, l]')
@@ -239,7 +239,7 @@ contains
239239
end if
240240

241241
! Compute unit normal and solve for d at interior
242-
$:GPU_PARALLEL_LOOP(collapse=3, private='[j, k, l, nr_x, nr_y, nr_z, nmag, ac]', copyin='[id_norm]')
242+
$:GPU_PARALLEL_LOOP(collapse=3, private='[j, k, l, nr_x, nr_y, nr_z, nmag, nmax, ac]', copyin='[id_norm]')
243243
do l = id_norm(3)%beg, id_norm(3)%end
244244
do k = id_norm(2)%beg, id_norm(2)%end
245245
do j = id_norm(1)%beg, id_norm(1)%end
@@ -265,6 +265,16 @@ contains
265265
nr_y = nr_y/nmag
266266
nr_z = nr_z/nmag
267267

268+
! Snap near-grid-aligned normals to exact alignment
269+
nmax = max(abs(nr_x), abs(nr_y), abs(nr_z))
270+
if (abs(nr_x) < mthinc_align_tol*nmax) nr_x = 0._wp
271+
if (abs(nr_y) < mthinc_align_tol*nmax) nr_y = 0._wp
272+
if (abs(nr_z) < mthinc_align_tol*nmax) nr_z = 0._wp
273+
nmag = sqrt(nr_x*nr_x + nr_y*nr_y + nr_z*nr_z)
274+
nr_x = nr_x/nmag
275+
nr_y = nr_y/nmag
276+
nr_z = nr_z/nmag
277+
268278
mthinc_nhat(1, j, k, l) = nr_x
269279
mthinc_nhat(2, j, k, l) = nr_y
270280
mthinc_nhat(3, j, k, l) = nr_z

src/simulation/m_weno.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ contains
13721372
#:endif
13731373
end if
13741374

1375-
if (int_comp > 0 .and. v_size >= advxe) then
1375+
if (int_comp > 0 .and. v_size >= eqn_idx%adv%end) then
13761376
call nvtxStartRange("WENO-INTCOMP")
13771377
#:for WENO_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')]
13781378
if (weno_dir == ${WENO_DIR}$) then

tests/4C4F339C/golden-metadata.txt

Lines changed: 18 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/4E4FECA9/golden-metadata.txt

Lines changed: 17 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)