Skip to content

Commit f3cfba8

Browse files
Ib collisions (#1348)
Co-authored-by: Spencer Bryngelson <shb@gatech.edu>
1 parent 1023a4f commit f3cfba8

21 files changed

Lines changed: 955 additions & 79 deletions

docs/documentation/case.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ This is enabled by adding ``'elliptic_smoothing': "T",`` and ``'elliptic_smoothi
331331
| `moving_ibm` | Integer | Sets the method used for IB movement. |
332332
| `vel(i)` | Real | Initial velocity of the moving IB in the i-th direction. |
333333
| `angular_vel(i)` | Real | Initial angular velocity of the moving IB in the i-th direction. |
334+
| `coefficient_of_restitution` | Real | A number 0 to 1 describing how elastic IB collisions are |
335+
| `collision_model` | Integer | Integer to select the collision model being used for IB collisions. |
336+
| `collision_time` | Real | Amount of simulation time used to resolve collisions |
337+
| `ib_coefficient_of_friction` | Real | Coefficient of friction used in IB collisions |
334338

335339
These parameters should be prepended with `patch_ib(j)%` where $j$ is the patch index.
336340

@@ -361,6 +365,14 @@ Additional details on this specification can be found in [NACA airfoil](https://
361365

362366
- `angular_vel(i)` is the initial angular velocity of the IB about the x, y, z axes for i=1, 2, 3 in radians per second. When `moving_ibm` equals 2, this rotation rate is just the starting rate of the object, which will then change due to external torques. If `moving_ibm` equals 1, then this is constant if it is a number, or can be described analytically with an expression.
363367

368+
- `coefficient_of_restitution` is a number from 0 (exclusive) to 1 (inclusive) describing how elastic IB collisions are. 0 is for perfectly inellastic collisions while 1 is for perfectly ellastic collisions.
369+
370+
- `collision_model` is an integer to select the collision model being used for IB collisions. Using 0 disables collisions and collisiono checking. 1 enables the soft-sphere collision model, where all IBs must be circles or sphere and those IBs can collide with each other as well as walls.
371+
372+
- `collision_time` is approximately the amount of simulation time used to resolve collisions. This is handled by modifying the spring gonstant used to apply collision forces.
373+
374+
- `ib_coefficient_of_friction` is the coefficient of friction used in IB collisions.
375+
364376
### 5. Fluid Material's {#sec-fluid-materials}
365377

366378
| Parameter | Type | Description |

docs/module_categories.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"m_chemistry",
2727
"m_acoustic_src",
2828
"m_body_forces",
29-
"m_pressure_relaxation"
29+
"m_pressure_relaxation",
30+
"m_collisions"
3031
]
3132
},
3233
{
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import json
2+
import math
3+
4+
# This case file is based on verification cases run in
5+
# "Analytical solution for the problem of frictional-elastic collisions
6+
# of spherical particles using the linear model"
7+
# by Francesco Paolo Di Maio and Alberto Di Renzo
8+
9+
# This can be used to check collision rebound angles to recreate
10+
# figure 4 of that paper
11+
12+
Mu = 1.84e-05
13+
gam_a = 1.4
14+
15+
# lead-up-properties
16+
velocity = 3.9
17+
dt = 5.0e-6
18+
collision_time = 20.0 * dt
19+
20+
# parerticle properties
21+
radius = 5.0
22+
collision_angle_degrees = 30.0
23+
collision_angle_radians = collision_angle_degrees * math.pi / 180.0
24+
domain_size = 4.0 * radius
25+
lead_distance = 0.2 * radius
26+
27+
# simulation runs long enough to collide and travel about lead distance away again
28+
simulation_time = 2.0 * (lead_distance / velocity) + collision_time
29+
num_time_steps = int(simulation_time / dt)
30+
num_saves = 10
31+
t_step_save = int(num_time_steps / num_saves)
32+
33+
# Configuring case dictionary
34+
print(
35+
json.dumps(
36+
{
37+
# Logistics
38+
"run_time_info": "T",
39+
# Computational Domain Parameters
40+
"x_domain%beg": -0.5 * domain_size,
41+
"x_domain%end": 0.5 * domain_size,
42+
"y_domain%beg": 0.0,
43+
"y_domain%end": domain_size,
44+
"z_domain%beg": -0.5 * domain_size,
45+
"z_domain%end": 0.5 * domain_size,
46+
"cyl_coord": "F",
47+
"m": 60,
48+
"n": 60,
49+
"p": 60,
50+
"dt": dt,
51+
"t_step_start": 0,
52+
"t_step_stop": num_time_steps,
53+
"t_step_save": t_step_save,
54+
# Simulation Algorithm Parameters
55+
"num_patches": 1,
56+
# Use the 5 equation model
57+
"model_eqns": 2,
58+
"alt_soundspeed": "F",
59+
# One fluids: air
60+
"num_fluids": 1,
61+
"mpp_lim": "F",
62+
# Correct errors when computing speed of sound
63+
"mixture_err": "T",
64+
# Use TVD RK3 for time marching
65+
"time_stepper": 3,
66+
# Use WENO5
67+
"weno_order": 5,
68+
"weno_eps": 1.0e-16,
69+
"weno_avg": "T",
70+
"avg_state": 2,
71+
"mapped_weno": "T",
72+
"null_weights": "F",
73+
"mp_weno": "T",
74+
"riemann_solver": 2,
75+
"wave_speeds": 1,
76+
# We use ghost-cell
77+
"bc_x%beg": -3,
78+
"bc_x%end": -3,
79+
"bc_y%beg": -15,
80+
"bc_y%end": -15,
81+
"bc_z%beg": -3,
82+
"bc_z%end": -3,
83+
# Set IB to True and add 1 patch
84+
"ib": "T",
85+
"num_ibs": 1,
86+
# Formatted Database Files Structure Parameters
87+
"format": 1,
88+
"precision": 2,
89+
"prim_vars_wrt": "T",
90+
"E_wrt": "T",
91+
"parallel_io": "T",
92+
# Patch: Constant Tube filled with air
93+
# Specify the cylindrical air tube grid geometry
94+
"patch_icpp(1)%geometry": 9,
95+
"patch_icpp(1)%x_centroid": 0.0,
96+
"patch_icpp(1)%y_centroid": 0.5 * domain_size,
97+
"patch_icpp(1)%z_centroid": 0.0,
98+
"patch_icpp(1)%length_x": domain_size,
99+
"patch_icpp(1)%length_y": domain_size,
100+
"patch_icpp(1)%length_z": domain_size,
101+
# Specify the patch primitive variables
102+
"patch_icpp(1)%vel(1)": 0.0e00,
103+
"patch_icpp(1)%vel(2)": 0.0e00,
104+
"patch_icpp(1)%vel(3)": 0.0e00,
105+
"patch_icpp(1)%pres": 1.0e00,
106+
"patch_icpp(1)%alpha_rho(1)": 1.0e00,
107+
"patch_icpp(1)%alpha(1)": 1.0e00,
108+
# Patch: Sphere Immersed Boundary
109+
"patch_ib(1)%geometry": 8,
110+
"patch_ib(1)%x_centroid": -1.0 * lead_distance * math.sin(collision_angle_radians), # get a lead up distance to the collision
111+
"patch_ib(1)%y_centroid": radius + lead_distance * math.sin(collision_angle_radians),
112+
"patch_ib(1)%z_centroid": 0.0,
113+
"patch_ib(1)%radius": radius,
114+
"patch_ib(1)%slip": "F",
115+
"patch_ib(1)%mass": 1.0e6, # arbitrarily high mass to ignore fluid
116+
"patch_ib(1)%vel(1)": velocity * math.sin(collision_angle_radians),
117+
"patch_ib(1)%vel(2)": -velocity * math.cos(collision_angle_radians),
118+
"patch_ib(1)%moving_ibm": 2,
119+
# Collisions
120+
"collision_model": 1, # soft-sphere collision model
121+
"ib_coefficient_of_friction": 0.092,
122+
"collision_time": collision_time,
123+
"coefficient_of_restitution": 0.98, # almost perfectly elastic
124+
# Fluids Physical Parameters
125+
"fluid_pp(1)%gamma": 1.0e00 / (gam_a - 1.0e00), # 2.50(Not 1.40)
126+
"fluid_pp(1)%pi_inf": 0,
127+
}
128+
)
129+
)

src/common/m_constants.fpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ module m_constants
2323
integer, parameter :: fourier_rings = 5 !< Fourier filter ring limit
2424
integer, parameter :: num_fluids_max = 10 !< Maximum number of fluids in the simulation
2525
integer, parameter :: num_probes_max = 10 !< Maximum number of flow probes in the simulation
26-
integer, parameter :: num_patches_max = 1000 !< Maximum number of IC patches
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)
2728
integer, parameter :: num_bc_patches_max = 10 !< Maximum number of boundary condition patches
2829
integer, parameter :: max_2d_fourier_modes = 10 !< Max Fourier mode index for 2D modal patch (geometry 13)
2930
integer, parameter :: max_sph_harm_degree = 5 !< Max degree L for 3D spherical harmonic patch (geometry 14)

src/common/m_helper.fpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module m_helper
1818
public :: s_comp_n_from_prim, s_comp_n_from_cons, s_initialize_bubbles_model, s_initialize_nonpoly, s_simpson, s_transcoeff, &
1919
& s_int_to_str, s_transform_vec, s_transform_triangle, s_transform_model, s_swap, f_cross, f_create_transform_matrix, &
2020
& f_create_bbox, s_print_2D_array, f_xor, f_logical_to_int, associated_legendre, real_ylm, double_factorial, factorial, &
21-
& f_cut_on, f_cut_off, s_downsample_data, s_upsample_data
21+
& f_cut_on, f_cut_off, s_downsample_data, s_upsample_data, s_cross_product
2222

2323
contains
2424

@@ -297,7 +297,22 @@ contains
297297
298298
end function f_cross
299299
300-
!> Swap two real numbers.
300+
!> @brief Computes the cross product c = a x b of two 3D vectors.
301+
subroutine s_cross_product(a, b, c)
302+
303+
$:GPU_ROUTINE(parallelism='[seq]')
304+
real(wp), intent(in) :: a(3), b(3)
305+
real(wp), intent(out) :: c(3)
306+
307+
c(1) = a(2)*b(3) - a(3)*b(2)
308+
c(2) = a(3)*b(1) - a(1)*b(3)
309+
c(3) = a(1)*b(2) - a(2)*b(1)
310+
311+
end subroutine s_cross_product
312+
313+
!> This procedure swaps two real numbers.
314+
!! @param lhs Left-hand side.
315+
!! @param rhs Right-hand side.
301316
elemental subroutine s_swap(lhs, rhs)
302317
303318
real(wp), intent(inout) :: lhs, rhs

src/post_process/m_data_input.f90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ impure subroutine s_read_ib_data_files(file_loc_base, t_step)
108108
integer, intent(in), optional :: t_step
109109
character(LEN=len_trim(file_loc_base) + 20) :: file_loc
110110
logical :: file_exist
111-
integer :: ifile, ierr, data_size, var_MOK
111+
integer :: ifile, ierr, data_size
112112

113113
#ifdef MFC_MPI
114114
integer, dimension(MPI_STATUS_SIZE) :: status
115115
integer(KIND=MPI_OFFSET_KIND) :: disp
116-
integer :: m_MOK, n_MOK, p_MOK, MOK, WP_MOK, save_index
116+
integer(KIND=MPI_OFFSET_KIND) :: m_MOK, n_MOK, p_MOK, MOK, WP_MOK, var_MOK
117+
integer :: save_index
117118
#endif
118119

119120
if (.not. ib) return

src/pre_process/m_global_parameters.fpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ module m_global_parameters
153153

154154
!> @name Immersed Boundaries
155155
!> @{
156-
logical :: ib !< Turn immersed boundaries on
157-
integer :: num_ibs !< Number of immersed boundaries
158-
integer :: Np
159-
type(ib_patch_parameters), dimension(num_patches_max) :: patch_ib !< Immersed boundary patch parameters
160-
type(vec3_dt), allocatable, dimension(:) :: airfoil_grid_u, airfoil_grid_l
156+
logical :: ib !< Turn immersed boundaries on
157+
integer :: num_ibs !< Number of immersed boundaries
158+
integer :: Np
159+
type(ib_patch_parameters), dimension(num_ib_patches_max) :: patch_ib !< Immersed boundary patch parameters
160+
type(vec3_dt), allocatable, dimension(:) :: airfoil_grid_u, airfoil_grid_l
161161
!> @}
162162

163163
!> @name Non-polytropic bubble gas compression
@@ -435,7 +435,7 @@ contains
435435
ib = .false.
436436
num_ibs = dflt_int
437437

438-
do i = 1, num_patches_max
438+
do i = 1, num_ib_patches_max
439439
patch_ib(i)%geometry = dflt_int
440440
patch_ib(i)%x_centroid = dflt_real
441441
patch_ib(i)%y_centroid = dflt_real

src/pre_process/m_mpi_proxy.fpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ contains
112112
if (chemistry) then
113113
call MPI_BCAST(patch_icpp(i)%Y, size(patch_icpp(i)%Y), mpi_p, 0, MPI_COMM_WORLD, ierr)
114114
end if
115-
! Broadcast IB variables: patch_ib is indexed 1:num_patches_max, not 1:num_bc_patches_max, so these must live in the
116-
! num_patches_max loop.
115+
end do
116+
117+
do i = 1, num_ibs
117118
#:for VAR in ['vel', 'angular_vel', 'angles']
118119
call MPI_BCAST(patch_ib(i)%${VAR}$, size(patch_ib(i)%${VAR}$), mpi_p, 0, MPI_COMM_WORLD, ierr)
119120
#:endfor

0 commit comments

Comments
 (0)