Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4273c84
Remove interior point conservative variable protection for stationary…
danieljvickers Mar 15, 2026
4b2f519
Merge branch 'master' of github.com:danieljvickers/MFC
danieljvickers Mar 15, 2026
ba0cacb
Merge branch 'MFlowCode:master' into master
danieljvickers Mar 17, 2026
e6988ba
Merge branch 'MFlowCode:master' into master
danieljvickers Mar 17, 2026
0ce6f11
Merge branch 'MFlowCode:master' into master
danieljvickers Mar 18, 2026
16bd456
Merge branch 'MFlowCode:master' into master
danieljvickers Mar 24, 2026
f0e117d
Merge branch 'MFlowCode:master' into master
danieljvickers Apr 1, 2026
b42028a
Merge branch 'MFlowCode:master' into master
danieljvickers Apr 15, 2026
8728091
Merge branch 'MFlowCode:master' into master
danieljvickers Apr 21, 2026
f652274
Initial separation for patch_ibs
danieljvickers Apr 21, 2026
3baf894
Added IB patch reduction at the start of the simulation so that ranks…
danieljvickers Apr 22, 2026
2365f2c
intermittent commit
danieljvickers Apr 22, 2026
71bae6a
we now write the global IB index, not the local one to ib_markers, as…
danieljvickers Apr 22, 2026
0779098
Refactored ib reduction to use neighbor bounds
danieljvickers Apr 23, 2026
d9ac1c2
prototype of send-receive replacing all-to-all
danieljvickers Apr 23, 2026
ee0bc0c
Compilation errors resolved
danieljvickers Apr 23, 2026
8303cea
Resolved out of bounds error
danieljvickers Apr 24, 2026
1c1801c
added send test algorithm for alternative MPI communication
danieljvickers Apr 24, 2026
f014ca9
Fixed early segfault due to uninitialized IB patch array
danieljvickers Apr 24, 2026
d36fe0b
Debugged rank ownership bug and invalid number of global IBs
danieljvickers Apr 24, 2026
cc76bf3
Fixed global patch ID not being present on other ranks
danieljvickers Apr 24, 2026
e6e0613
Merge branch 'master' into local-aware-ibm
sbryngelson Apr 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/documentation/case.md
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ To restart the simulation from $k$-th time step, see @ref running "Restarting Ca
| `alpha_wrt(i)` | Logical | Add the volume fraction of fluid $i$ to the database |
| `gamma_wrt` | Logical | Add the specific heat ratio function to the database |
| `heat_ratio_wrt` | Logical | Add the specific heat ratio to the database |
| `ib_state_wrt` | Logical | Write IB state and loads to a datafile at each time step |
| `ib_state_wrt` | Logical | Parameter to handle writing IB state on saves and outputting the state as a point mesh to SILO files. |
| `pi_inf_wrt` | Logical | Add the liquid stiffness function to the database |
| `pres_inf_wrt` | Logical | Add the liquid stiffness to the formatted database |
| `c_wrt` | Logical | Add the sound speed to the database |
Expand Down Expand Up @@ -706,7 +706,7 @@ If `file_per_process` is true, then pre_process, simulation, and post_process mu

- `probe_wrt` activates the output of state variables at coordinates specified by `probe(i)%[x;y,z]`.

- `ib_state_wrt` activates the output of data specified by patch_ib(i)%force(:) (and torque, vel, angular_vel, angles, [x,y,z]_centroid) into a single binary datafile for all IBs at all timesteps. During post_processing, this file is converted into separate time histories for each IB.
- `ib_state_wrt` is used to trigger post-processing of the IB state to be written out as a point mesh in the SILO files. When no IBs are moving, it also triggers force and torque calculation so that those values may be written to the output state files.

- `output_partial_domain` activates the output of part of the domain specified by `[x,y,z]_output%%beg` and `[x,y,z]_output%%end`.
This is useful for large domains where only a portion of the domain is of interest.
Expand Down
1 change: 1 addition & 0 deletions src/common/m_constants.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module m_constants
integer, parameter :: num_probes_max = 10 !< Maximum number of flow probes in the simulation
integer, parameter :: num_patches_max = 10 !< Maximum number of IC patches
integer, parameter :: num_ib_patches_max = 50000 !< Maximum number of immersed boundary patches (patch_ib)
integer, parameter :: num_local_ibs_max = 2000 !< Maximum number of immersed boundary patches (patch_ib)
integer, parameter :: num_bc_patches_max = 10 !< Maximum number of boundary condition patches
integer, parameter :: max_2d_fourier_modes = 10 !< Max Fourier mode index for 2D modal patch (geometry 13)
integer, parameter :: max_sph_harm_degree = 5 !< Max degree L for 3D spherical harmonic patch (geometry 14)
Expand Down
13 changes: 6 additions & 7 deletions src/common/m_derived_types.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,10 @@ module m_derived_types

type :: t_model_array
! Original CPU-side fields (unchanged)
type(t_model), allocatable :: model !< STL/OBJ geometry model
real(wp), allocatable, dimension(:,:,:) :: boundary_v !< Boundary vertices
real(wp), allocatable, dimension(:,:) :: interpolated_boundary_v !< Interpolated boundary vertices
integer :: boundary_edge_count !< Number of boundary edges
integer :: total_vertices !< Total vertex count
integer :: interpolate !< Interpolation flag
type(t_model), allocatable :: model !< STL/OBJ geometry model
real(wp), allocatable, dimension(:,:,:) :: boundary_v !< Boundary vertices
integer :: boundary_edge_count !< Number of boundary edges
integer :: total_vertices !< Total vertex count

! GPU-friendly flattened arrays
integer :: ntrs !< Copy of model%ntrs
Expand Down Expand Up @@ -272,9 +270,10 @@ module m_derived_types
end type ic_patch_parameters

type ib_patch_parameters

integer :: geometry !< Type of geometry for the patch
integer :: gbl_patch_id
real(wp) :: x_centroid, y_centroid, z_centroid !< Geometric center coordinates of the patch

!> Centroid locations of intermediate steps in the time_stepper module
real(wp) :: step_x_centroid, step_y_centroid, step_z_centroid
real(wp), dimension(1:3) :: centroid_offset !< offset of center of mass from computed cell center for odd-shaped IBs
Expand Down
3 changes: 2 additions & 1 deletion src/common/m_model.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,10 +983,11 @@ contains
dx_local = minval(dx); dy_local = minval(dy)
if (p /= 0) dz_local = minval(dz)

allocate (stl_bounding_boxes(num_ibs,1:3,1:3))
allocate (stl_bounding_boxes(num_gbl_ibs,1:3,1:3))

do patch_id = 1, num_ibs
if (patch_ib(patch_id)%geometry == 5 .or. patch_ib(patch_id)%geometry == 12) then
print *, proc_rank, patch_id, num_ibs, patch_ib(patch_id)%geometry
allocate (models(patch_id)%model)
print *, " * Reading model: " // trim(patch_ib(patch_id)%model_filepath)

Expand Down
32 changes: 19 additions & 13 deletions src/simulation/m_global_parameters.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ module m_global_parameters
$:GPU_DECLARE(create='[ib_bc_x, ib_bc_y, ib_bc_z]')
#endif
type(bounds_info) :: x_domain, y_domain, z_domain
$:GPU_DECLARE(create='[x_domain, y_domain, z_domain]')
type(bounds_info) :: neighbor_domain_x, neighbor_domain_y, neighbor_domain_z
$:GPU_DECLARE(create='[x_domain, y_domain, z_domain, neighbor_domain_x, neighbor_domain_y, neighbor_domain_z]')
real(wp) :: x_a, y_a, z_a
real(wp) :: x_b, y_b, z_b
logical :: parallel_io !< Format of the data files
Expand Down Expand Up @@ -336,18 +337,21 @@ module m_global_parameters

!> @name Immersed Boundaries
!> @{
logical :: ib
integer :: num_ibs
integer :: collision_model
real(wp) :: coefficient_of_restitution
real(wp) :: collision_time
real(wp) :: ib_coefficient_of_friction
logical :: ib_state_wrt
type(ib_patch_parameters), dimension(num_ib_patches_max) :: patch_ib !< Immersed boundary patch parameters
type(vec3_dt), allocatable, dimension(:) :: airfoil_grid_u, airfoil_grid_l
integer :: Np

$:GPU_DECLARE(create='[ib, num_ibs, patch_ib, Np, airfoil_grid_u, airfoil_grid_l]')
logical :: ib
integer :: num_ibs !< number of IBs that the current processor is aware of
integer :: num_gbl_ibs !< number of IBs in the overall simulation
integer :: num_local_ibs !< number of IBs that lie inside the processor domain
integer :: collision_model
real(wp) :: coefficient_of_restitution
real(wp) :: collision_time
real(wp) :: ib_coefficient_of_friction
logical :: ib_state_wrt
type(ib_patch_parameters), allocatable, dimension(:) :: patch_ib !< Immersed boundary patch parameters
integer, dimension(num_local_ibs_max) :: local_ib_patch_ids !< lookup table of IBs in the local compute domain
type(vec3_dt), allocatable, dimension(:) :: airfoil_grid_u, airfoil_grid_l
integer :: Np

$:GPU_DECLARE(create='[ib, num_ibs, num_gbl_ibs, num_local_ibs, patch_ib, Np, airfoil_grid_u, airfoil_grid_l, local_ib_patch_ids]')
$:GPU_DECLARE(create='[ib_coefficient_of_friction]')
!> @}

Expand Down Expand Up @@ -787,7 +791,9 @@ contains
relativity = .false.
#:endif

allocate (patch_ib(num_ib_patches_max))
do i = 1, num_ib_patches_max
patch_ib(i)%gbl_patch_id = i
patch_ib(i)%geometry = dflt_int
patch_ib(i)%x_centroid = 0._wp
patch_ib(i)%y_centroid = 0._wp
Expand Down
40 changes: 15 additions & 25 deletions src/simulation/m_ib_patches.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ contains
radius = patch_ib(patch_id)%radius

! encode the periodicity information into the patch_id
call s_encode_patch_periodicity(patch_id, xp, yp, 0, encoded_patch_id)
call s_encode_patch_periodicity(patch_ib(patch_id)%gbl_patch_id, xp, yp, 0, encoded_patch_id)

! find the indices to the left and right of the IB in i, j, k
il = -gp_layers - 1
Expand Down Expand Up @@ -221,7 +221,7 @@ contains
end if

! encode the periodicity information into the patch_id
call s_encode_patch_periodicity(patch_id, xp, yp, 0, encoded_patch_id)
call s_encode_patch_periodicity(patch_ib(patch_id)%gbl_patch_id, xp, yp, 0, encoded_patch_id)

! find the indices to the left and right of the IB in i, j, k
il = -gp_layers - 1
Expand Down Expand Up @@ -376,7 +376,7 @@ contains
end if

! encode the periodicity information into the patch_id
call s_encode_patch_periodicity(patch_id, xp, yp, zp, encoded_patch_id)
call s_encode_patch_periodicity(patch_ib(patch_id)%gbl_patch_id, xp, yp, zp, encoded_patch_id)

! find the indices to the left and right of the IB in i, j, k
il = -gp_layers - 1
Expand Down Expand Up @@ -466,7 +466,7 @@ contains
inverse_rotation(:,:) = patch_ib(patch_id)%rotation_matrix_inverse(:,:)

! encode the periodicity information into the patch_id
call s_encode_patch_periodicity(patch_id, xp, yp, 0, encoded_patch_id)
call s_encode_patch_periodicity(patch_ib(patch_id)%gbl_patch_id, xp, yp, 0, encoded_patch_id)

! find the indices to the left and right of the IB in i, j, k
il = -gp_layers - 1
Expand Down Expand Up @@ -510,24 +510,20 @@ contains
real(wp) :: radius
real(wp), dimension(1:3) :: center

! Variables to initialize the pressure field that corresponds to the bubble-collapse test case found in Tiwari et al. (2013)

! Transferring spherical patch's radius, centroid, smoothing patch identity and smoothing coefficient information

center(1) = patch_ib(patch_id)%x_centroid + real(xp, wp)*(x_domain%end - x_domain%beg)
center(2) = patch_ib(patch_id)%y_centroid + real(yp, wp)*(y_domain%end - y_domain%beg)
center(3) = patch_ib(patch_id)%z_centroid + real(zp, wp)*(z_domain%end - z_domain%beg)
radius = patch_ib(patch_id)%radius

! completely skip particles no in the domain
! completely skip particles not in the domain
if (center(1) - radius > x_cc(m + gp_layers + 1) .or. center(1) + radius < x_cc(-gp_layers - 1) .or. center(2) &
& - radius > y_cc(n + gp_layers + 1) .or. center(2) + radius < y_cc(-gp_layers - 1) .or. center(3) - radius > z_cc(p &
& + gp_layers + 1) .or. center(3) + radius < z_cc(-gp_layers - 1)) then
return
end if

! encode the periodicity information into the patch_id
call s_encode_patch_periodicity(patch_id, xp, yp, zp, encoded_patch_id)
call s_encode_patch_periodicity(patch_ib(patch_id)%gbl_patch_id, xp, yp, zp, encoded_patch_id)

! find the indices to the left and right of the IB in i, j, k
il = -gp_layers - 1
Expand All @@ -542,18 +538,12 @@ contains

! Checking whether the sphere covers a particular cell in the domain and verifying whether the current patch has permission
! to write to that cell. If both queries check out, the primitive variables of the current patch are assigned to this cell.
$:GPU_PARALLEL_LOOP(private='[i, j, k, cart_y, cart_z]', copyin='[encoded_patch_id, center, radius]', collapse=3)
$:GPU_PARALLEL_LOOP(private='[i, j, k]', copyin='[encoded_patch_id, center, radius]', collapse=3)
do k = kl, kr
do j = jl, jr
do i = il, ir
if (grid_geometry == 3) then
call s_convert_cylindrical_to_cartesian_coord(y_cc(j), z_cc(k))
else
cart_y = y_cc(j)
cart_z = z_cc(k)
end if
! Updating the patch identities bookkeeping variable
if (((x_cc(i) - center(1))**2 + (cart_y - center(2))**2 + (cart_z - center(3))**2 <= radius**2)) then
if (((x_cc(i) - center(1))**2 + (y_cc(j) - center(2))**2 + (z_cc(k) - center(3))**2 <= radius**2)) then
ib_markers%sf(i, j, k) = encoded_patch_id
end if
end do
Expand Down Expand Up @@ -586,7 +576,7 @@ contains
inverse_rotation(:,:) = patch_ib(patch_id)%rotation_matrix_inverse(:,:)

! encode the periodicity information into the patch_id
call s_encode_patch_periodicity(patch_id, xp, yp, zp, encoded_patch_id)
call s_encode_patch_periodicity(patch_ib(patch_id)%gbl_patch_id, xp, yp, zp, encoded_patch_id)

! find the indices to the left and right of the IB in i, j, k
il = -gp_layers - 1
Expand Down Expand Up @@ -656,7 +646,7 @@ contains
inverse_rotation(:,:) = patch_ib(patch_id)%rotation_matrix_inverse(:,:)

! encode the periodicity information into the patch_id
call s_encode_patch_periodicity(patch_id, xp, yp, zp, encoded_patch_id)
call s_encode_patch_periodicity(patch_ib(patch_id)%gbl_patch_id, xp, yp, zp, encoded_patch_id)

il = -gp_layers - 1
jl = -gp_layers - 1
Expand Down Expand Up @@ -724,7 +714,7 @@ contains
inverse_rotation(:,:) = patch_ib(patch_id)%rotation_matrix_inverse(:,:)

! encode the periodicity information into the patch_id
call s_encode_patch_periodicity(patch_id, xp, yp, 0, encoded_patch_id)
call s_encode_patch_periodicity(patch_ib(patch_id)%gbl_patch_id, xp, yp, 0, encoded_patch_id)

! find the indices to the left and right of the IB in i, j, k
il = -gp_layers - 1
Expand Down Expand Up @@ -781,7 +771,7 @@ contains
threshold = patch_ib(patch_id)%model_threshold

! encode the periodicity information into the patch_id
call s_encode_patch_periodicity(patch_id, xp, yp, 0, encoded_patch_id)
call s_encode_patch_periodicity(patch_ib(patch_id)%gbl_patch_id, xp, yp, 0, encoded_patch_id)

il = -gp_layers - 1
jl = -gp_layers - 1
Expand Down Expand Up @@ -858,7 +848,7 @@ contains
rotation(:,:) = patch_ib(patch_id)%rotation_matrix(:,:)

! encode the periodicity information into the patch_id
call s_encode_patch_periodicity(patch_id, xp, yp, zp, encoded_patch_id)
call s_encode_patch_periodicity(patch_ib(patch_id)%gbl_patch_id, xp, yp, zp, encoded_patch_id)

il = -gp_layers - 1
jl = -gp_layers - 1
Expand Down Expand Up @@ -1039,7 +1029,7 @@ contains
temp_y_per = y_periodicity; if (y_periodicity == -1) temp_y_per = 2
temp_z_per = z_periodicity; if (z_periodicity == -1) temp_z_per = 2

offset = (num_ibs + 1)*temp_x_per + 3*(num_ibs + 1)*temp_y_per + 9*(num_ibs + 1)*temp_z_per
offset = (num_gbl_ibs + 1)*temp_x_per + 3*(num_gbl_ibs + 1)*temp_y_per + 9*(num_gbl_ibs + 1)*temp_z_per
encoded_patch_id = patch_id + offset

end subroutine s_encode_patch_periodicity
Expand All @@ -1054,7 +1044,7 @@ contains
integer, intent(out), optional :: x_periodicity, y_periodicity, z_periodicity
integer :: offset, remainder, xp, yp, zp, base

base = num_ibs + 1
base = num_gbl_ibs + 1

patch_id = mod(encoded_patch_id - 1, base) + 1
offset = (encoded_patch_id - patch_id)/base
Expand Down
Loading
Loading