Skip to content

Commit 0d27a5e

Browse files
Merged with ib refactor
2 parents 3f61225 + 4a73bf3 commit 0d27a5e

30 files changed

Lines changed: 1700 additions & 369 deletions

docs/documentation/case.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ This is enabled by adding ``'elliptic_smoothing': "T",`` and ``'elliptic_smoothi
313313
| ---: | :----: | :--- |
314314
| `num_ibs` | Integer | Number of immersed boundary patches |
315315
| `num_stl_models` | Integer | Number of STL/OBJ model entries in the `stl_models` array |
316+
| `num_particle_beds` | Integer | Number of particle bed specifications to generate immersed boundary patches from |
317+
| `ib_neighborhood_radius` | Integer | Parameter that controls the neighborhood size for IB detection. |
316318
| `geometry` | Integer | Geometry configuration of the patch.|
317319
| `x[y,z]_centroid` | Real | Centroid of the applied geometry in the [x,y,z]-direction. |
318320
| `length_x[y,z]` | Real | Length, if applicable, in the [x,y,z]-direction. |
@@ -374,6 +376,8 @@ Additional details on this specification can be found in [NACA airfoil](https://
374376

375377
- `ib_coefficient_of_friction` is the coefficient of friction used in IB collisions.
376378

379+
- `ib_neighborhood_radius` controls the size of the neighborhood size. This value defaults to 1, which indicates that any given rank is aware of IB's up to 1 ranks away. This parameter is required to strong-scale a case when IB's eventually grow to be larger than one full processor domain wide.
380+
377381
### 5. Fluid Material's {#sec-fluid-materials}
378382

379383
| Parameter | Type | Description |
@@ -644,7 +648,7 @@ To restart the simulation from $k$-th time step, see @ref running "Restarting Ca
644648
| `alpha_wrt(i)` | Logical | Add the volume fraction of fluid $i$ to the database |
645649
| `gamma_wrt` | Logical | Add the specific heat ratio function to the database |
646650
| `heat_ratio_wrt` | Logical | Add the specific heat ratio to the database |
647-
| `ib_state_wrt` | Logical | Write IB state and loads to a datafile at each time step |
651+
| `ib_state_wrt` | Logical | Parameter to handle writing IB state on saves and outputting the state as a point mesh to SILO files. |
648652
| `pi_inf_wrt` | Logical | Add the liquid stiffness function to the database |
649653
| `pres_inf_wrt` | Logical | Add the liquid stiffness to the formatted database |
650654
| `c_wrt` | Logical | Add the sound speed to the database |
@@ -712,7 +716,7 @@ If `file_per_process` is true, then pre_process, simulation, and post_process mu
712716

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

715-
- `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.
719+
- `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.
716720

717721
- `output_partial_domain` activates the output of part of the domain specified by `[x,y,z]_output%%beg` and `[x,y,z]_output%%end`.
718722
This is useful for large domains where only a portion of the domain is of interest.

docs/module_categories.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"m_compute_cbc",
3939
"m_boundary_common",
4040
"m_ibm",
41+
"m_particle_bed",
4142
"m_igr",
4243
"m_ib_patches",
4344
"m_compute_levelset"
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
import json
2+
import math
3+
4+
# 2D shock wave interacting with a bed of 20 free-floating circular particles.
5+
6+
gam_a = 1.4
7+
8+
# Shock parameters (Mach 1.5)
9+
mach_number = 1.5
10+
pre_shock_pressure = 1
11+
pre_shock_density = 1.4
12+
pre_shock_speed = 0.0
13+
post_shock_pressure = 2.4583
14+
post_shock_density = 2.6069
15+
post_shock_speed = 0.6944
16+
17+
domain_size = 4.0
18+
wave_front = -1.5
19+
20+
total_time = 1.5
21+
num_time_steps = 2000
22+
dt = float(total_time / num_time_steps)
23+
num_saves = 100
24+
steps_to_save = int(num_time_steps / num_saves)
25+
26+
# Soft-sphere collision parameters (from 3D_mibm_sphere_head_on_collision)
27+
collision_time = 20.0 * dt
28+
29+
# Particle bed parameters
30+
bed_x = 0.5
31+
bed_y = 0.0
32+
bed_lx = 2.0
33+
bed_ly = 3.5
34+
particle_radius = 0.15
35+
particle_mass = 0.25
36+
particle_min_spacing = 0.05
37+
38+
print(
39+
json.dumps(
40+
{
41+
# Logistics
42+
"run_time_info": "T",
43+
# Computational Domain Parameters
44+
"x_domain%beg": -domain_size * 0.5,
45+
"x_domain%end": domain_size * 0.5,
46+
"y_domain%beg": -domain_size * 0.5,
47+
"y_domain%end": domain_size * 0.5,
48+
"cyl_coord": "F",
49+
"m": 256,
50+
"n": 256,
51+
"p": 0,
52+
"dt": dt,
53+
"t_step_start": 0,
54+
"t_step_stop": num_time_steps,
55+
"t_step_save": steps_to_save,
56+
# Simulation Algorithm Parameters
57+
"num_patches": 2,
58+
"model_eqns": 2,
59+
"alt_soundspeed": "F",
60+
"num_fluids": 1,
61+
"mpp_lim": "F",
62+
"mixture_err": "T",
63+
"time_stepper": 3,
64+
"weno_order": 5,
65+
"weno_eps": 1.0e-16,
66+
"weno_Re_flux": "T",
67+
"weno_avg": "T",
68+
"avg_state": 2,
69+
"mapped_weno": "T",
70+
"null_weights": "F",
71+
"mp_weno": "T",
72+
"riemann_solver": 2,
73+
"wave_speeds": 1,
74+
"bc_x%beg": -17,
75+
"bc_x%end": -8,
76+
"bc_y%beg": -15,
77+
"bc_y%end": -15,
78+
# Immersed boundaries — all circles come from the particle bed
79+
"ib": "T",
80+
"num_ibs": 0,
81+
"viscous": "T",
82+
# Collision model (soft-sphere, from 3D_mibm_sphere_head_on_collision)
83+
"collision_model": 1,
84+
"coefficient_of_restitution": 0.9,
85+
"collision_time": collision_time,
86+
"ib_coefficient_of_friction": 0.1,
87+
# Particle bed: 20 free-floating circles placed randomly in region
88+
"num_particle_beds": 1,
89+
"particle_bed(1)%x_centroid": bed_x,
90+
"particle_bed(1)%y_centroid": bed_y,
91+
"particle_bed(1)%z_centroid": 0.0,
92+
"particle_bed(1)%length_x": bed_lx,
93+
"particle_bed(1)%length_y": bed_ly,
94+
"particle_bed(1)%length_z": 0.0,
95+
"particle_bed(1)%num_particles": 20,
96+
"particle_bed(1)%radius": particle_radius,
97+
"particle_bed(1)%mass": particle_mass,
98+
"particle_bed(1)%min_spacing": particle_min_spacing,
99+
"particle_bed(1)%moving_ibm": 2,
100+
"particle_bed(1)%seed": 42,
101+
# Output
102+
"format": 1,
103+
"precision": 2,
104+
"prim_vars_wrt": "T",
105+
"E_wrt": "T",
106+
"ib_state_wrt": "F",
107+
"parallel_io": "T",
108+
# IC Patch 1: post-shock region (left of wave front)
109+
"patch_icpp(1)%geometry": 3,
110+
"patch_icpp(1)%x_centroid": 0.5 * wave_front - 0.25 * domain_size,
111+
"patch_icpp(1)%y_centroid": 0.0,
112+
"patch_icpp(1)%length_x": 0.5 * domain_size + wave_front,
113+
"patch_icpp(1)%length_y": domain_size,
114+
"patch_icpp(1)%vel(1)": post_shock_speed,
115+
"patch_icpp(1)%vel(2)": 0.0,
116+
"patch_icpp(1)%pres": post_shock_pressure,
117+
"patch_icpp(1)%alpha_rho(1)": post_shock_density,
118+
"patch_icpp(1)%alpha(1)": 1.0,
119+
# IC Patch 2: pre-shock region (right of wave front)
120+
"patch_icpp(2)%geometry": 3,
121+
"patch_icpp(2)%x_centroid": 0.5 * wave_front + 0.25 * domain_size,
122+
"patch_icpp(2)%y_centroid": 0.0,
123+
"patch_icpp(2)%length_x": 0.5 * domain_size - wave_front,
124+
"patch_icpp(2)%length_y": domain_size,
125+
"patch_icpp(2)%vel(1)": pre_shock_speed,
126+
"patch_icpp(2)%vel(2)": 0.0,
127+
"patch_icpp(2)%pres": pre_shock_pressure,
128+
"patch_icpp(2)%alpha_rho(1)": pre_shock_density,
129+
"patch_icpp(2)%alpha(1)": 1.0,
130+
# Fluid properties: air
131+
"fluid_pp(1)%gamma": 1.0 / (gam_a - 1.0),
132+
"fluid_pp(1)%pi_inf": 0,
133+
"fluid_pp(1)%Re(1)": 2500000,
134+
}
135+
)
136+
)

examples/2D_mibm_shock_cylinder/case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"precision": 2,
8888
"prim_vars_wrt": "T",
8989
"E_wrt": "T",
90-
"ib_state_wrt": "T",
90+
"ib_state_wrt": "F",
9191
"parallel_io": "T",
9292
# Patch: Constant Tube filled with air
9393
# Specify the cylindrical air tube grid geometry

src/common/include/case.fpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
! For pre-process.
66
#:def analytical()
7-
87
#:enddef
98

109
! For moving immersed boundaries in simulation
1110
#:def mib_analytical()
12-
1311
#:enddef

src/common/m_constants.fpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,22 @@ module m_constants
1616
real(wp), parameter :: verysmall = 1.e-12_wp !< Very small number
1717
!> Radius cutoff to avoid division by zero for 3D spherical harmonic patch (geometry 14)
1818
real(wp), parameter :: small_radius = 1.e-32_wp
19-
integer, parameter :: num_stcls_min = 5 !< Minimum # of stencils
20-
integer, parameter :: path_len = 400 !< Maximum path length
21-
integer, parameter :: name_len = 50 !< Maximum name length
22-
integer, parameter :: dflt_int = -100 !< Default integer value
23-
integer, parameter :: fourier_rings = 5 !< Fourier filter ring limit
24-
integer, parameter :: num_fluids_max = 10 !< Maximum number of fluids in the simulation
25-
integer, parameter :: num_probes_max = 10 !< Maximum number of flow probes in the simulation
26-
integer, parameter :: num_patches_max = 10 !< Maximum number of IC patches
27-
integer, parameter :: num_ib_patches_max = 50000 !< Maximum number of immersed boundary patches (patch_ib)
28-
integer, parameter :: num_ib_airfoils_max = 5 !< Maximum number of ib_airfoil instances
29-
integer, parameter :: num_stl_models_max = 10 !< Maximum number of stl_models instances
19+
integer, parameter :: num_stcls_min = 5 !< Minimum # of stencils
20+
integer, parameter :: path_len = 400 !< Maximum path length
21+
integer, parameter :: name_len = 50 !< Maximum name length
22+
integer, parameter :: dflt_int = -100 !< Default integer value
23+
integer, parameter :: fourier_rings = 5 !< Fourier filter ring limit
24+
integer, parameter :: num_fluids_max = 10 !< Maximum number of fluids in the simulation
25+
integer, parameter :: num_probes_max = 10 !< Maximum number of flow probes in the simulation
26+
integer, parameter :: num_patches_max = 10 !< Maximum number of IC patches
27+
integer, parameter :: num_ib_airfoils_max = 5 !< Maximum number of ib_airfoil instances
28+
integer, parameter :: num_stl_models_max = 10
29+
!> Maximum number of immersed boundary patches (legacy, not used for patch_ib sizing)
30+
integer, parameter :: num_ib_patches_max = 2050000
31+
!> Fixed capacity of patch_ib (namelist patches + local particle bed subset after reduction)
32+
integer, parameter :: num_ib_patches_max_namelist = 54000
33+
integer, parameter :: num_local_ibs_max = 2000 !< Maximum number of immersed boundary patches (patch_ib)
34+
integer, parameter :: num_particle_beds_max = 10 !< Maximum number of particle bed patch specifications
3035
integer, parameter :: num_bc_patches_max = 10 !< Maximum number of boundary condition patches
3136
integer, parameter :: max_2d_fourier_modes = 10 !< Max Fourier mode index for 2D modal patch (geometry 13)
3237
integer, parameter :: max_sph_harm_degree = 5 !< Max degree L for 3D spherical harmonic patch (geometry 14)

src/common/m_derived_types.fpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,10 @@ module m_derived_types
202202

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

212210
! GPU-friendly flattened arrays
213211
integer :: ntrs !< Copy of model%ntrs
@@ -295,9 +293,10 @@ module m_derived_types
295293
end type ib_stl_parameters
296294

297295
type ib_patch_parameters
298-
299296
integer :: geometry !< Type of geometry for the patch
297+
integer :: gbl_patch_id
300298
real(wp) :: x_centroid, y_centroid, z_centroid !< Geometric center coordinates of the patch
299+
301300
!> Centroid locations of intermediate steps in the time_stepper module
302301
real(wp) :: step_x_centroid, step_y_centroid, step_z_centroid
303302
real(wp), dimension(1:3) :: centroid_offset !< offset of center of mass from computed cell center for odd-shaped IBs
@@ -321,6 +320,17 @@ module m_derived_types
321320
real(wp), dimension(1:3) :: step_angular_vel !< velocity array used to store intermediate steps in the time_stepper module
322321
end type ib_patch_parameters
323322

323+
type particle_bed_parameters
324+
real(wp) :: x_centroid, y_centroid, z_centroid !< Center of the particle bed region
325+
real(wp) :: length_x, length_y, length_z !< Dimensions of the particle bed region
326+
integer :: num_particles !< Number of particles to generate
327+
real(wp) :: radius !< Particle radius
328+
real(wp) :: mass !< Particle mass
329+
real(wp) :: min_spacing !< Minimum surface-to-surface gap (particle centers are 2*radius + min_spacing apart)
330+
integer :: moving_ibm !< Motion flag: 0=static, 1=moving (forces), 2=forced path
331+
integer :: seed !< Random seed for reproducible placement
332+
end type particle_bed_parameters
333+
324334
!> Derived type annexing the physical parameters (PP) of the fluids. These include the specific heat ratio function and liquid
325335
!! stiffness function.
326336
type physical_parameters

src/common/m_model.fpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,10 @@ contains
982982
dx_local = minval(dx); dy_local = minval(dy)
983983
if (p /= 0) dz_local = minval(dz)
984984

985+
if (num_stl_models == 0) return
986+
985987
allocate (stl_bounding_boxes(num_stl_models,1:3,1:3))
988+
@:ALLOCATE(models(num_stl_models))
986989

987990
do stl_id = 1, num_stl_models
988991
allocate (models(stl_id)%model)
@@ -1047,6 +1050,7 @@ contains
10471050
write (*, "(A, 3(2X, F20.10))") " > Cen:", (grid_mm(:,1) + grid_mm(:,2))/2._wp
10481051
write (*, "(A, 3(2X, F20.10))") " > Max:", grid_mm(:,2)
10491052
end if
1053+
if (proc_rank == 0) print *, " * Transforming model."
10501054

10511055
stl_bounding_boxes(stl_id, 1,1:3) = [bbox%min(1), (bbox%min(1) + bbox%max(1))/2._wp, bbox%max(1)]
10521056
stl_bounding_boxes(stl_id, 2,1:3) = [bbox%min(2), (bbox%min(2) + bbox%max(2))/2._wp, bbox%max(2)]

src/common/m_mpi_common.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ contains
9494
proc_rank = 0
9595
#endif
9696

97+
$:GPU_UPDATE(device='[num_procs, proc_rank]')
98+
9799
end subroutine s_mpi_initialize
98100

99101
!> Set up MPI I/O data views and variable pointers for parallel file output.

0 commit comments

Comments
 (0)