Skip to content

Commit 7c9660d

Browse files
authored
Merge branch 'master' into weno-beta-sos
2 parents f176036 + 87f299f commit 7c9660d

17 files changed

Lines changed: 760 additions & 190 deletions

File tree

.github/workflows/test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172

173173
include:
174174
- os: ubuntu
175-
mpi: no-mpi
175+
mpi: mpi
176176
precision: single
177177
debug: no-debug
178178
intel: false
@@ -386,11 +386,12 @@ jobs:
386386
- name: Test
387387
if: '!matrix.nvhpc'
388388
run: |
389-
/bin/bash mfc.sh test -v --max-attempts 3 -j $(nproc) $ONLY_CHANGES $TEST_ALL $TEST_PCT
389+
/bin/bash mfc.sh test -v --max-attempts 3 -j $(nproc) $ONLY_CHANGES $TEST_ALL $TEST_PCT $PRECISION
390390
env:
391391
TEST_ALL: ${{ matrix.mpi == 'mpi' && '--test-all' || '' }}
392392
TEST_PCT: ${{ matrix.debug == 'reldebug' && '-% 20' || '' }}
393393
ONLY_CHANGES: ${{ github.event_name == 'pull_request' && '--only-changes' || '' }}
394+
PRECISION: ${{ matrix.precision != '' && format('--{0}', matrix.precision) || '' }}
394395

395396
# ── NVHPC build + test (via docker exec into long-lived container) ──
396397
- name: Build (NVHPC)

examples/2D_advection_muscl/case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"t_step_save": 100,
2222
# Simulation Algorithm Parameters
2323
"num_patches": 2,
24-
"model_eqns": 3,
24+
"model_eqns": 2,
2525
"alt_soundspeed": "F",
2626
"num_fluids": 2,
2727
"mpp_lim": "T",

src/simulation/m_ib_patches.fpp

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ module m_ib_patches
2121

2222
implicit none
2323

24-
private; public :: s_apply_ib_patches, s_update_ib_rotation_matrix, f_convert_cyl_to_cart, s_instantiate_STL_models, &
25-
& s_decode_patch_periodicity
26-
27-
real(wp) :: cart_y, cart_z
28-
$:GPU_DECLARE(create='[cart_y, cart_z]')
29-
! Variables to be used to hold cell locations in Cartesian coordinates if 3D simulation is using cylindrical coordinates
24+
private; public :: s_apply_ib_patches, s_update_ib_rotation_matrix, s_instantiate_STL_models, s_decode_patch_periodicity
3025

3126
contains
3227

@@ -542,18 +537,12 @@ contains
542537
543538
! Checking whether the sphere covers a particular cell in the domain and verifying whether the current patch has permission
544539
! to write to that cell. If both queries check out, the primitive variables of the current patch are assigned to this cell.
545-
$:GPU_PARALLEL_LOOP(private='[i, j, k, cart_y, cart_z]', copyin='[encoded_patch_id, center, radius]', collapse=3)
540+
$:GPU_PARALLEL_LOOP(private='[i, j, k]', copyin='[encoded_patch_id, center, radius]', collapse=3)
546541
do k = kl, kr
547542
do j = jl, jr
548543
do i = il, ir
549-
if (grid_geometry == 3) then
550-
call s_convert_cylindrical_to_cartesian_coord(y_cc(j), z_cc(k))
551-
else
552-
cart_y = y_cc(j)
553-
cart_z = z_cc(k)
554-
end if
555544
! Updating the patch identities bookkeeping variable
556-
if (((x_cc(i) - center(1))**2 + (cart_y - center(2))**2 + (cart_z - center(3))**2 <= radius**2)) then
545+
if (((x_cc(i) - center(1))**2 + (y_cc(j) - center(2))**2 + (z_cc(k) - center(3))**2 <= radius**2)) then
557546
ib_markers%sf(i, j, k) = encoded_patch_id
558547
end if
559548
end do
@@ -603,19 +592,12 @@ contains
603592
! Checking whether the cuboid covers a particular cell in the domain and verifying whether the current patch has permission
604593
! to write to to that cell. If both queries check out, the primitive variables of the current patch are assigned to this
605594
! cell.
606-
$:GPU_PARALLEL_LOOP(private='[i, j, k, xyz_local, cart_y, cart_z]', copyin='[encoded_patch_id, center, length, &
607-
& inverse_rotation]', collapse=3)
595+
$:GPU_PARALLEL_LOOP(private='[i, j, k, xyz_local]', copyin='[encoded_patch_id, center, length, inverse_rotation]', &
596+
& collapse=3)
608597
do k = kl, kr
609598
do j = jl, jr
610599
do i = il, ir
611-
if (grid_geometry == 3) then
612-
! TODO :: This does not work and is not covered by any tests. This should be fixed
613-
call s_convert_cylindrical_to_cartesian_coord(y_cc(j), z_cc(k))
614-
else
615-
cart_y = y_cc(j)
616-
cart_z = z_cc(k)
617-
end if
618-
xyz_local = [x_cc(i), cart_y, cart_z] - center ! get coordinate frame centered on IB
600+
xyz_local = [x_cc(i), y_cc(j), z_cc(k)] - center ! get coordinate frame centered on IB
619601
xyz_local = matmul(inverse_rotation, xyz_local) ! rotate the frame into the IB's coordinates
620602
621603
if (-0.5*length(1) <= xyz_local(1) .and. 0.5*length(1) >= xyz_local(1) .and. -0.5*length(2) <= xyz_local(2) &
@@ -672,18 +654,12 @@ contains
672654
! Checking whether the cylinder covers a particular cell in the domain and verifying whether the current patch has the
673655
! permission to write to that cell. If both queries check out, the primitive variables of the current patch are assigned to
674656
! this cell.
675-
$:GPU_PARALLEL_LOOP(private='[i, j, k, xyz_local, cart_y, cart_z]', copyin='[encoded_patch_id, center, length, radius, &
657+
$:GPU_PARALLEL_LOOP(private='[i, j, k, xyz_local]', copyin='[encoded_patch_id, center, length, radius, &
676658
& inverse_rotation]', collapse=3)
677659
do k = kl, kr
678660
do j = jl, jr
679661
do i = il, ir
680-
if (grid_geometry == 3) then
681-
call s_convert_cylindrical_to_cartesian_coord(y_cc(j), z_cc(k))
682-
else
683-
cart_y = y_cc(j)
684-
cart_z = z_cc(k)
685-
end if
686-
xyz_local = [x_cc(i), cart_y, cart_z] - center ! get coordinate frame centered on IB
662+
xyz_local = [x_cc(i), y_cc(j), z_cc(k)] - center ! get coordinate frame centered on IB
687663
xyz_local = matmul(inverse_rotation, xyz_local) ! rotate the frame into the IB's coordinates
688664
689665
if (((.not. f_is_default(length(1)) .and. xyz_local(2)**2 + xyz_local(3)**2 <= radius**2 .and. &
@@ -963,30 +939,6 @@ contains
963939

964940
end subroutine s_update_ib_rotation_matrix
965941

966-
!> Convert cylindrical (r, theta) coordinates to Cartesian (y, z)
967-
subroutine s_convert_cylindrical_to_cartesian_coord(cyl_y, cyl_z)
968-
969-
$:GPU_ROUTINE(parallelism='[seq]')
970-
971-
real(wp), intent(in) :: cyl_y, cyl_z
972-
973-
cart_y = cyl_y*sin(cyl_z)
974-
cart_z = cyl_y*cos(cyl_z)
975-
976-
end subroutine s_convert_cylindrical_to_cartesian_coord
977-
978-
!> Convert a 3D cylindrical coordinate vector (x, r, theta) to Cartesian (x, y, z)
979-
pure function f_convert_cyl_to_cart(cyl) result(cart)
980-
981-
$:GPU_ROUTINE(parallelism='[seq]')
982-
983-
real(wp), dimension(1:3), intent(in) :: cyl
984-
real(wp), dimension(1:3) :: cart
985-
986-
cart = (/cyl(1), cyl(2)*sin(cyl(3)), cyl(2)*cos(cyl(3))/)
987-
988-
end function f_convert_cyl_to_cart
989-
990942
subroutine get_bounding_indices(left_bound, right_bound, cell_centers, left_index, right_index)
991943

992944
real(wp), intent(in) :: left_bound, right_bound

src/simulation/m_muscl.fpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module m_muscl
1717
use m_mpi_proxy
1818
use m_helper
1919
use m_thinc
20+
use m_nvtx
2021

2122
private; public :: s_initialize_muscl_module, s_muscl, s_finalize_muscl_module
2223

src/simulation/m_rhs.fpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,16 @@ contains
670670
& qR_rsx_vf, qR_rsy_vf, qR_rsz_vf, id)
671671
end if
672672
else
673-
if (all(Re_size == 0)) then
673+
if (int_comp > 0) then
674+
! THINC reads cont and adv from v_rs_ws; must reconstruct full sys_size range to populate both
675+
iv%beg = 1; iv%end = sys_size
676+
call s_reconstruct_cell_boundary_values(q_prim_qp%vf(1:sys_size), qL_rsx_vf, qL_rsy_vf, qL_rsz_vf, &
677+
& qR_rsx_vf, qR_rsy_vf, qR_rsz_vf, id)
678+
! Surface tension requires first-order energy; overwrite the higher-order result from the full pass above
679+
iv%beg = eqn_idx%E; iv%end = eqn_idx%E
680+
call s_reconstruct_cell_boundary_values_first_order(q_prim_qp%vf(eqn_idx%E), qL_rsx_vf, qL_rsy_vf, &
681+
& qL_rsz_vf, qR_rsx_vf, qR_rsy_vf, qR_rsz_vf, id)
682+
else if (all(Re_size == 0)) then
674683
iv%beg = 1; iv%end = eqn_idx%E - 1
675684
call s_reconstruct_cell_boundary_values(q_prim_qp%vf(iv%beg:iv%end), qL_rsx_vf, qL_rsy_vf, qL_rsz_vf, &
676685
& qR_rsx_vf, qR_rsy_vf, qR_rsz_vf, id)

src/simulation/m_thinc.fpp

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,14 @@ module m_thinc
3030
real(wp) :: gq3_pts(3) = [-5e-1_wp*0.7745966692414834_wp, 0._wp, 5e-1_wp*0.7745966692414834_wp]
3131
!> Weights: 5/18, 8/18, 5/18
3232
real(wp) :: gq3_wts(3) = [5._wp/18._wp, 8._wp/18._wp, 5._wp/18._wp]
33-
!> ln(2)
34-
real(wp) :: ln2 = 0.6931471805599453_wp
35-
$:GPU_DECLARE(create='[gq3_pts, gq3_wts, ln2]')
33+
$:GPU_DECLARE(copyin='[gq3_pts, gq3_wts]')
3634

3735
real(wp), allocatable, dimension(:,:,:,:) :: mthinc_nhat !> Unit normal vector
3836
real(wp), allocatable, dimension(:,:,:) :: mthinc_d !> Interface position parameter
3937
$:GPU_DECLARE(create='[mthinc_nhat, mthinc_d]')
4038

4139
contains
4240

43-
!> @brief Stable computation of ln(cosh(x))
44-
function f_log_cosh(x) result(res)
45-
46-
$:GPU_ROUTINE(parallelism='[seq]')
47-
real(wp), intent(in) :: x
48-
real(wp) :: res, ax
49-
50-
ax = abs(x)
51-
if (ax > 20._wp) then
52-
res = ax - ln2
53-
else
54-
res = ax + log(1._wp + exp(-2._wp*ax)) - ln2
55-
end if
56-
57-
end function f_log_cosh
58-
5941
!> @brief Stable difference: log_cosh(a+h) - log_cosh(a-h) = 2*atanh(tanh(a)*tanh(h)). Avoids catastrophic cancellation when h
6042
!! is small relative to a.
6143
function f_log_cosh_diff(a, h) result(res)
@@ -259,16 +241,19 @@ contains
259241
ac = v_vf(eqn_idx%adv%beg)%sf(j, k, l)
260242

261243
if (ac >= ic_eps .and. ac <= 1._wp - ic_eps) then
262-
nr_x = (v_vf(eqn_idx%adv%beg)%sf(j + 1, k, l) - v_vf(eqn_idx%adv%beg)%sf(j - 1, k, l))*5e-1_wp
244+
nr_x = (v_vf(eqn_idx%adv%beg)%sf(j + 1, k, l) - v_vf(eqn_idx%adv%beg)%sf(j - 1, k, &
245+
& l))*(x_cb(j) - x_cb(j - 1))/(x_cc(j + 1) - x_cc(j - 1))
263246

264247
nr_y = 0._wp
265248
if (n > 0) then
266-
nr_y = (v_vf(eqn_idx%adv%beg)%sf(j, k + 1, l) - v_vf(eqn_idx%adv%beg)%sf(j, k - 1, l))*5e-1_wp
249+
nr_y = (v_vf(eqn_idx%adv%beg)%sf(j, k + 1, l) - v_vf(eqn_idx%adv%beg)%sf(j, k - 1, &
250+
& l))*(y_cb(k) - y_cb(k - 1))/(y_cc(k + 1) - y_cc(k - 1))
267251
end if
268252

269253
nr_z = 0._wp
270254
if (p > 0) then
271-
nr_z = (v_vf(eqn_idx%adv%beg)%sf(j, k, l + 1) - v_vf(eqn_idx%adv%beg)%sf(j, k, l - 1))*5e-1_wp
255+
nr_z = (v_vf(eqn_idx%adv%beg)%sf(j, k, l + 1) - v_vf(eqn_idx%adv%beg)%sf(j, k, &
256+
& l - 1))*(z_cb(l) - z_cb(l - 1))/(z_cc(l + 1) - z_cc(l - 1))
272257
end if
273258

274259
nmag = sqrt(nr_x*nr_x + nr_y*nr_y + nr_z*nr_z)

0 commit comments

Comments
 (0)