Skip to content

Commit 70589fd

Browse files
Debug wall collisions and particle state writing (#1745)
Co-authored-by: Spencer Bryngelson <sbryngelson@gmail.com>
1 parent e9fd9c3 commit 70589fd

7 files changed

Lines changed: 47 additions & 9 deletions

File tree

src/post_process/m_data_output.fpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ contains
409409
integer, dimension(num_procs) :: meshtypes
410410
integer :: i
411411
integer :: ierr
412+
integer :: extents_size
412413

413414
if (format == format_silo) then
414415
! For multidimensional data sets, the spatial extents of all of the grid(s) handled by the local processor(s) are
@@ -441,7 +442,8 @@ contains
441442

442443
err = DBSET2DSTRLEN(len(meshnames(1)))
443444
err = DBMKOPTLIST(2, out%optlist)
444-
err = DBADDIOPT(out%optlist, DBOPT_EXTENTS_SIZE, size(out%spatial_extents, 1))
445+
extents_size = size(out%spatial_extents, 1)
446+
err = DBADDIOPT(out%optlist, DBOPT_EXTENTS_SIZE, extents_size)
445447
err = DBADDDOPT(out%optlist, DBOPT_EXTENTS, out%spatial_extents)
446448
err = DBPUTMMESH(out%dbroot, 'rectilinear_grid', 16, num_procs, meshnames, len_trim(meshnames), meshtypes, &
447449
& out%optlist, ierr)
@@ -549,6 +551,7 @@ contains
549551
integer, dimension(num_procs) :: vartypes
550552
integer :: i, j, k
551553
integer :: ierr
554+
integer :: extents_size
552555

553556
if (format == format_silo) then
554557
! Determining the extents of the flow variable on each local process and gathering all this information on root process
@@ -567,7 +570,8 @@ contains
567570

568571
err = DBSET2DSTRLEN(len(varnames(1)))
569572
err = DBMKOPTLIST(2, out%optlist)
570-
err = DBADDIOPT(out%optlist, DBOPT_EXTENTS_SIZE, 2)
573+
extents_size = size(out%data_extents, 1)
574+
err = DBADDIOPT(out%optlist, DBOPT_EXTENTS_SIZE, extents_size)
571575
err = DBADDDOPT(out%optlist, DBOPT_EXTENTS, out%data_extents)
572576
err = DBPUTMVAR(out%dbroot, trim(varname), len_trim(varname), num_procs, varnames, len_trim(varnames), vartypes, &
573577
& out%optlist, ierr)

src/post_process/m_global_parameters.fpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,23 @@ contains
219219
fluid_pp(i)%mu_bulk = dflt_real
220220
end do
221221

222+
num_particle_clouds = 0
223+
do i = 1, num_particle_clouds_max
224+
particle_cloud(i)%x_centroid = 0._wp
225+
particle_cloud(i)%y_centroid = 0._wp
226+
particle_cloud(i)%z_centroid = 0._wp
227+
particle_cloud(i)%length_x = dflt_real
228+
particle_cloud(i)%length_y = dflt_real
229+
particle_cloud(i)%length_z = dflt_real
230+
particle_cloud(i)%num_particles = 0
231+
particle_cloud(i)%radius = dflt_real
232+
particle_cloud(i)%mass = dflt_real
233+
particle_cloud(i)%min_spacing = 0._wp
234+
particle_cloud(i)%moving_ibm = 0
235+
particle_cloud(i)%seed = 0
236+
particle_cloud(i)%packing_method = dflt_int
237+
end do
238+
222239
! Subgrid bubble parameters (bub_pp struct + scalar companions; bub_pp%R0ref is set in common
223240
! via R0ref; the scalar companions are per-target manual declarations)
224241
bub_pp%R0ref = dflt_real; R0ref = dflt_real
@@ -323,6 +340,13 @@ contains
323340
! defaulted on non-root ranks nor broadcast. Post-process never carries viscous stresses.
324341
viscous = .false.
325342

343+
! Particle clouds expand into individual IB patches at simulation startup, so num_ibs as read
344+
! from the case file counts only the namelist patches. Match the global count the simulation
345+
! arrives at (s_reduce_ib_patch_array) so the IB state records can be read back.
346+
do i = 1, num_particle_clouds
347+
num_ibs = num_ibs + particle_cloud(i)%num_particles
348+
end do
349+
326350
! Gamma/Pi_inf: force num_fluids=1 (post_process-specific side effect of the gamma-law model)
327351
if (model_eqns == model_eqns_gamma_law) num_fluids = 1
328352

src/post_process/m_mpi_proxy.fpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ contains
9393
#:endfor
9494
#:endfor
9595

96+
! manual: particle_cloud (runtime loop to num_particle_clouds; irregular member subset)
97+
do i = 1, num_particle_clouds
98+
#:for VAR in ['x_centroid', 'y_centroid', 'z_centroid', 'length_x', 'length_y', 'length_z', &
99+
& 'radius', 'mass', 'min_spacing']
100+
call MPI_BCAST(particle_cloud(i)%${VAR}$, 1, mpi_p, 0, MPI_COMM_WORLD, ierr)
101+
#:endfor
102+
call MPI_BCAST(particle_cloud(i)%num_particles, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
103+
call MPI_BCAST(particle_cloud(i)%moving_ibm, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
104+
call MPI_BCAST(particle_cloud(i)%seed, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
105+
call MPI_BCAST(particle_cloud(i)%packing_method, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
106+
end do
107+
96108
! manual: cfl_dt (runtime-computed logical), bc_io (BC-file existence)
97109
call MPI_BCAST(cfl_dt, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
98110
call MPI_BCAST(bc_io, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)

src/simulation/m_collisions.fpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,6 @@ contains
340340
integer :: gp_idx, i, j, k, patch_id
341341
real(wp) :: edge_location, overlap_distance
342342

343-
! iterate over all ghost points to detect the one that is most-overlapping in each direction
344-
345343
$:GPU_PARALLEL_LOOP(private='[patch_id, edge_location, overlap_distance]')
346344
do patch_id = 1, num_ibs
347345
#:for X, DIR, IDX in [('x', 1, 1), ('y', 2, 3), ('z', 3, 5)]

src/simulation/m_global_parameters.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ module m_global_parameters
121121
$:GPU_DECLARE(create='[bc_x%vb1, bc_x%vb2, bc_x%vb3, bc_x%ve1, bc_x%ve2, bc_x%ve3]')
122122
$:GPU_DECLARE(create='[bc_y%vb1, bc_y%vb2, bc_y%vb3, bc_y%ve1, bc_y%ve2, bc_y%ve3]')
123123
$:GPU_DECLARE(create='[bc_z%vb1, bc_z%vb2, bc_z%vb3, bc_z%ve1, bc_z%ve2, bc_z%ve3]')
124-
$:GPU_DECLARE(create='[ib_bc_x%beg, ib_bc_y%beg, ib_bc_z%beg]')
124+
$:GPU_DECLARE(create='[ib_bc_x%beg, ib_bc_x%end, ib_bc_y%beg, ib_bc_y%end, ib_bc_z%beg, ib_bc_z%end]')
125125
#elif defined(MFC_OpenMP)
126126
$:GPU_DECLARE(create='[bc_x, bc_y, bc_z]')
127127
$:GPU_DECLARE(create='[ib_bc_x, ib_bc_y, ib_bc_z]')

src/simulation/m_ibm.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ contains
7676
call nvtxStartRange("SETUP-IBM-MODULE")
7777

7878
! GPU routines require updated cell centers
79-
$:GPU_UPDATE(device='[num_ibs, num_gbl_ibs, x_cc, y_cc, dx, dy, ib_bc_x%beg, ib_bc_y%beg]')
79+
$:GPU_UPDATE(device='[num_ibs, num_gbl_ibs, x_cc, y_cc, dx, dy, ib_bc_x%beg, ib_bc_x%end, ib_bc_y%beg, ib_bc_y%end]')
8080
if (p /= 0) then
81-
$:GPU_UPDATE(device='[z_cc, dz, ib_bc_z%beg]')
81+
$:GPU_UPDATE(device='[z_cc, dz, ib_bc_z%beg, ib_bc_z%end]')
8282
end if
8383
$:GPU_UPDATE(device='[patch_ib(1:num_ibs), glb_bounds]')
8484

toolchain/mfc/params/definitions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,8 @@ def _decl(targets: set, *names: str) -> None:
13141314
"avg_state",
13151315
"alt_soundspeed",
13161316
"mixture_err",
1317+
"num_particle_clouds",
1318+
"particle_cloud",
13171319
)
13181320
_nv(
13191321
_PRE_SIM,
@@ -1395,10 +1397,8 @@ def _decl(targets: set, *names: str) -> None:
13951397
"coefficient_of_restitution",
13961398
"collision_time",
13971399
"ib_coefficient_of_friction",
1398-
"num_particle_clouds",
13991400
"ib_neighborhood_radius",
14001401
"many_ib_patch_parallelism",
1401-
"particle_cloud",
14021402
"tau_star",
14031403
"cont_damage_s",
14041404
"alpha_bar",

0 commit comments

Comments
 (0)