From c3095a385e9b5aa52793896ab526282950bbbdaf Mon Sep 17 00:00:00 2001 From: Ben Wilfong Date: Sun, 22 Nov 2026 15:36:08 -0500 Subject: [PATCH] rename s_populate_f_igr_buffers to generalize to scalar fields --- src/common/m_boundary_common.fpp | 40 ++++++++--------- src/common/m_boundary_primitives.fpp | 66 ++++++++++++++-------------- src/simulation/m_igr.fpp | 2 +- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/common/m_boundary_common.fpp b/src/common/m_boundary_common.fpp index 40e1018ea8..d91810f20b 100644 --- a/src/common/m_boundary_common.fpp +++ b/src/common/m_boundary_common.fpp @@ -19,7 +19,7 @@ module m_boundary_common implicit none private; public :: s_initialize_boundary_common_module, s_populate_variables_buffers, s_populate_capillary_buffers, & - & s_populate_F_igr_buffers, s_populate_grid_variables_buffers, s_finalize_boundary_common_module, s_populate_beta_buffers + & s_populate_scalar_buffers, s_populate_grid_variables_buffers, s_finalize_boundary_common_module, s_populate_beta_buffers public :: bc_buffers @@ -274,39 +274,39 @@ contains end subroutine s_populate_capillary_bc_direction - !> Populate ghost cell buffers for the Jacobian scalar field used in the IGR elliptic solver. - impure subroutine s_populate_F_igr_buffers(bc_type, jac_sf) + !> Populate ghost cell buffers of a single scalar field (physical boundaries and MPI halos). + impure subroutine s_populate_scalar_buffers(bc_type, scalar_sf) type(integer_field), dimension(1:num_dims,1:2), intent(in) :: bc_type - type(scalar_field), dimension(1:), intent(inout) :: jac_sf + type(scalar_field), dimension(1:), intent(inout) :: scalar_sf - call s_populate_F_igr_bc_direction(1, -1, bc_x, bc_type(1, 1), jac_sf) - call s_populate_F_igr_bc_direction(1, 1, bc_x, bc_type(1, 2), jac_sf) + call s_populate_scalar_bc_direction(1, -1, bc_x, bc_type(1, 1), scalar_sf) + call s_populate_scalar_bc_direction(1, 1, bc_x, bc_type(1, 2), scalar_sf) if (n == 0) return #:if not MFC_CASE_OPTIMIZATION or num_dims > 1 - call s_populate_F_igr_bc_direction(2, -1, bc_y, bc_type(2, 1), jac_sf) - call s_populate_F_igr_bc_direction(2, 1, bc_y, bc_type(2, 2), jac_sf) + call s_populate_scalar_bc_direction(2, -1, bc_y, bc_type(2, 1), scalar_sf) + call s_populate_scalar_bc_direction(2, 1, bc_y, bc_type(2, 2), scalar_sf) #:endif if (p == 0) return #:if not MFC_CASE_OPTIMIZATION or num_dims > 2 - call s_populate_F_igr_bc_direction(3, -1, bc_z, bc_type(3, 1), jac_sf) - call s_populate_F_igr_bc_direction(3, 1, bc_z, bc_type(3, 2), jac_sf) + call s_populate_scalar_bc_direction(3, -1, bc_z, bc_type(3, 1), scalar_sf) + call s_populate_scalar_bc_direction(3, 1, bc_z, bc_type(3, 2), scalar_sf) #:endif - end subroutine s_populate_F_igr_buffers + end subroutine s_populate_scalar_buffers - !> Populate ghost cell buffers for one IGR Jacobian BC direction and location, via MPI exchange for processor boundaries or by - !! dispatching the per-cell IGR Jacobian BC routines over the boundary face. - impure subroutine s_populate_F_igr_bc_direction(bc_dir, bc_loc, bc_bounds, bc_type_edge, jac_sf) + !> Populate ghost cell buffers of a scalar field for one BC direction and location, via MPI exchange for processor boundaries or + !! by dispatching the per-cell scalar BC routines over the boundary face. + impure subroutine s_populate_scalar_bc_direction(bc_dir, bc_loc, bc_bounds, bc_type_edge, scalar_sf) integer, intent(in) :: bc_dir, bc_loc type(int_bounds_info), intent(in) :: bc_bounds type(integer_field), intent(in) :: bc_type_edge - type(scalar_field), dimension(1:), intent(inout) :: jac_sf + type(scalar_field), dimension(1:), intent(inout) :: scalar_sf integer :: bc_edge, k_beg, k_end, l_beg, l_end, k, l, j, bc_code if (bc_loc == -1) then @@ -316,7 +316,7 @@ contains end if if (bc_edge >= 0) then - call s_mpi_sendrecv_variables_buffers(jac_sf, bc_dir, bc_loc, 1) + call s_mpi_sendrecv_variables_buffers(scalar_sf, bc_dir, bc_loc, 1) return end if @@ -341,17 +341,17 @@ contains select case (bc_code) case (BC_PERIODIC) - call s_F_igr_periodic(jac_sf, bc_dir, bc_loc, k, l) + call s_scalar_periodic(scalar_sf, bc_dir, bc_loc, k, l) case (BC_REFLECTIVE) - call s_F_igr_reflective(jac_sf, bc_dir, bc_loc, k, l) + call s_scalar_reflective(scalar_sf, bc_dir, bc_loc, k, l) case default - call s_F_igr_ghost_cell_extrapolation(jac_sf, bc_dir, bc_loc, k, l) + call s_scalar_ghost_cell_extrapolation(scalar_sf, bc_dir, bc_loc, k, l) end select end do end do $:END_GPU_PARALLEL_LOOP() - end subroutine s_populate_F_igr_bc_direction + end subroutine s_populate_scalar_bc_direction !> Populate the buffers of the grid variables, which are constituted of the cell-boundary locations and cell-width !! distributions, based on the boundary conditions. diff --git a/src/common/m_boundary_primitives.fpp b/src/common/m_boundary_primitives.fpp index e534ba0bba..db70e86c8e 100644 --- a/src/common/m_boundary_primitives.fpp +++ b/src/common/m_boundary_primitives.fpp @@ -1274,11 +1274,11 @@ contains end subroutine s_color_function_ghost_cell_extrapolation - !> Apply periodic boundary conditions to the IGR Jacobian field by copying values from the opposite domain boundary. - subroutine s_F_igr_periodic(jac_sf, bc_dir, bc_loc, k, l) + !> Apply periodic boundary conditions to a scalar field by copying values from the opposite domain boundary. + subroutine s_scalar_periodic(scalar_sf, bc_dir, bc_loc, k, l) - $:GPU_ROUTINE(function_name='s_F_igr_periodic', parallelism='[seq]', cray_inline=True) - type(scalar_field), dimension(1:), intent(inout) :: jac_sf + $:GPU_ROUTINE(function_name='s_scalar_periodic', parallelism='[seq]', cray_inline=True) + type(scalar_field), dimension(1:), intent(inout) :: scalar_sf integer, intent(in) :: bc_dir, bc_loc integer, intent(in) :: k, l integer :: j @@ -1286,42 +1286,42 @@ contains if (bc_dir == 1) then if (bc_loc == -1) then do j = 1, buff_size - jac_sf(1)%sf(-j, k, l) = jac_sf(1)%sf(m - j + 1, k, l) + scalar_sf(1)%sf(-j, k, l) = scalar_sf(1)%sf(m - j + 1, k, l) end do else do j = 1, buff_size - jac_sf(1)%sf(m + j, k, l) = jac_sf(1)%sf(j - 1, k, l) + scalar_sf(1)%sf(m + j, k, l) = scalar_sf(1)%sf(j - 1, k, l) end do end if else if (bc_dir == 2) then if (bc_loc == -1) then do j = 1, buff_size - jac_sf(1)%sf(k, -j, l) = jac_sf(1)%sf(k, n - j + 1, l) + scalar_sf(1)%sf(k, -j, l) = scalar_sf(1)%sf(k, n - j + 1, l) end do else do j = 1, buff_size - jac_sf(1)%sf(k, n + j, l) = jac_sf(1)%sf(k, j - 1, l) + scalar_sf(1)%sf(k, n + j, l) = scalar_sf(1)%sf(k, j - 1, l) end do end if else if (bc_loc == -1) then do j = 1, buff_size - jac_sf(1)%sf(k, l, -j) = jac_sf(1)%sf(k, l, p - j + 1) + scalar_sf(1)%sf(k, l, -j) = scalar_sf(1)%sf(k, l, p - j + 1) end do else do j = 1, buff_size - jac_sf(1)%sf(k, l, p + j) = jac_sf(1)%sf(k, l, j - 1) + scalar_sf(1)%sf(k, l, p + j) = scalar_sf(1)%sf(k, l, j - 1) end do end if end if - end subroutine s_F_igr_periodic + end subroutine s_scalar_periodic - !> Apply reflective boundary conditions to the IGR Jacobian field by mirroring values across the boundary. - subroutine s_F_igr_reflective(jac_sf, bc_dir, bc_loc, k, l) + !> Apply reflective boundary conditions to a scalar field by mirroring values across the boundary. + subroutine s_scalar_reflective(scalar_sf, bc_dir, bc_loc, k, l) - $:GPU_ROUTINE(function_name='s_F_igr_reflective', parallelism='[seq]', cray_inline=True) - type(scalar_field), dimension(1:), intent(inout) :: jac_sf + $:GPU_ROUTINE(function_name='s_scalar_reflective', parallelism='[seq]', cray_inline=True) + type(scalar_field), dimension(1:), intent(inout) :: scalar_sf integer, intent(in) :: bc_dir, bc_loc integer, intent(in) :: k, l integer :: j @@ -1329,42 +1329,42 @@ contains if (bc_dir == 1) then if (bc_loc == -1) then do j = 1, buff_size - jac_sf(1)%sf(-j, k, l) = jac_sf(1)%sf(j - 1, k, l) + scalar_sf(1)%sf(-j, k, l) = scalar_sf(1)%sf(j - 1, k, l) end do else do j = 1, buff_size - jac_sf(1)%sf(m + j, k, l) = jac_sf(1)%sf(m - (j - 1), k, l) + scalar_sf(1)%sf(m + j, k, l) = scalar_sf(1)%sf(m - (j - 1), k, l) end do end if else if (bc_dir == 2) then if (bc_loc == -1) then do j = 1, buff_size - jac_sf(1)%sf(k, -j, l) = jac_sf(1)%sf(k, j - 1, l) + scalar_sf(1)%sf(k, -j, l) = scalar_sf(1)%sf(k, j - 1, l) end do else do j = 1, buff_size - jac_sf(1)%sf(k, n + j, l) = jac_sf(1)%sf(k, n - (j - 1), l) + scalar_sf(1)%sf(k, n + j, l) = scalar_sf(1)%sf(k, n - (j - 1), l) end do end if else if (bc_loc == -1) then do j = 1, buff_size - jac_sf(1)%sf(k, l, -j) = jac_sf(1)%sf(k, l, j - 1) + scalar_sf(1)%sf(k, l, -j) = scalar_sf(1)%sf(k, l, j - 1) end do else do j = 1, buff_size - jac_sf(1)%sf(k, l, p + j) = jac_sf(1)%sf(k, l, p - (j - 1)) + scalar_sf(1)%sf(k, l, p + j) = scalar_sf(1)%sf(k, l, p - (j - 1)) end do end if end if - end subroutine s_F_igr_reflective + end subroutine s_scalar_reflective - !> Extrapolate the IGR Jacobian field into ghost cells by copying boundary values. - subroutine s_F_igr_ghost_cell_extrapolation(jac_sf, bc_dir, bc_loc, k, l) + !> Extrapolate a scalar field into ghost cells by copying boundary values. + subroutine s_scalar_ghost_cell_extrapolation(scalar_sf, bc_dir, bc_loc, k, l) - $:GPU_ROUTINE(function_name='s_F_igr_ghost_cell_extrapolation', parallelism='[seq]', cray_inline=True) - type(scalar_field), dimension(1:), intent(inout) :: jac_sf + $:GPU_ROUTINE(function_name='s_scalar_ghost_cell_extrapolation', parallelism='[seq]', cray_inline=True) + type(scalar_field), dimension(1:), intent(inout) :: scalar_sf integer, intent(in) :: bc_dir, bc_loc integer, intent(in) :: k, l integer :: j @@ -1372,36 +1372,36 @@ contains if (bc_dir == 1) then if (bc_loc == -1) then do j = 1, buff_size - jac_sf(1)%sf(-j, k, l) = jac_sf(1)%sf(0, k, l) + scalar_sf(1)%sf(-j, k, l) = scalar_sf(1)%sf(0, k, l) end do else do j = 1, buff_size - jac_sf(1)%sf(m + j, k, l) = jac_sf(1)%sf(m, k, l) + scalar_sf(1)%sf(m + j, k, l) = scalar_sf(1)%sf(m, k, l) end do end if else if (bc_dir == 2) then if (bc_loc == -1) then do j = 1, buff_size - jac_sf(1)%sf(k, -j, l) = jac_sf(1)%sf(k, 0, l) + scalar_sf(1)%sf(k, -j, l) = scalar_sf(1)%sf(k, 0, l) end do else do j = 1, buff_size - jac_sf(1)%sf(k, n + j, l) = jac_sf(1)%sf(k, n, l) + scalar_sf(1)%sf(k, n + j, l) = scalar_sf(1)%sf(k, n, l) end do end if else if (bc_loc == -1) then do j = 1, buff_size - jac_sf(1)%sf(k, l, -j) = jac_sf(1)%sf(k, l, 0) + scalar_sf(1)%sf(k, l, -j) = scalar_sf(1)%sf(k, l, 0) end do else do j = 1, buff_size - jac_sf(1)%sf(k, l, p + j) = jac_sf(1)%sf(k, l, p) + scalar_sf(1)%sf(k, l, p + j) = scalar_sf(1)%sf(k, l, p) end do end if end if - end subroutine s_F_igr_ghost_cell_extrapolation + end subroutine s_scalar_ghost_cell_extrapolation subroutine s_beta_periodic(q_beta, kahan_comp, bc_dir, bc_loc, k, l, nvar) diff --git a/src/simulation/m_igr.fpp b/src/simulation/m_igr.fpp index 62c3ae7570..ca30b5b05d 100644 --- a/src/simulation/m_igr.fpp +++ b/src/simulation/m_igr.fpp @@ -331,7 +331,7 @@ contains ! AMR fine advance: the jac ghost shell holds frozen Dirichlet data from the coarse sigma (s_amr_igr_swap_sigma); a ! BC/halo populate would write coarse-indexed data on the swapped block grid - if (.not. amr_in_fine_advance) call s_populate_F_igr_buffers(bc_type, jac_sf) + if (.not. amr_in_fine_advance) call s_populate_scalar_buffers(bc_type, jac_sf) if (igr_iter_solver == 1) then ! Jacobi iteration $:GPU_PARALLEL_LOOP(private='[j, k, l]', collapse=3)