Skip to content

Commit c82a623

Browse files
Resolved some MPI errors and added a test of a particle in a cross flow
1 parent f25e61d commit c82a623

File tree

5 files changed

+301
-2
lines changed

5 files changed

+301
-2
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import json
2+
import math
3+
4+
Mu = 1.84e-05
5+
gam_a = 1.4
6+
7+
# Configuring case dictionary
8+
print(
9+
json.dumps(
10+
{
11+
# Logistics
12+
"run_time_info": "T",
13+
# Computational Domain Parameters
14+
# For these computations, the cylinder is placed at the (0,0,0)
15+
# domain origin.
16+
# axial direction
17+
"x_domain%beg": 0.0e00,
18+
"x_domain%end": 6.0e-03,
19+
# r direction
20+
"y_domain%beg": 0.0e00,
21+
"y_domain%end": 6.0e-03,
22+
"cyl_coord": "F",
23+
"m": 200,
24+
"n": 200,
25+
"p": 0,
26+
"dt": 6.0e-6,
27+
"t_step_start": 0,
28+
"t_step_stop": 10000, # 10000,
29+
"t_step_save": 100,
30+
# Simulation Algorithm Parameters
31+
# Only one patches are necessary, the air tube
32+
"num_patches": 1,
33+
# Use the 5 equation model
34+
"model_eqns": 2,
35+
"alt_soundspeed": "F",
36+
# One fluids: air
37+
"num_fluids": 1,
38+
# time step
39+
"mpp_lim": "F",
40+
# Correct errors when computing speed of sound
41+
"mixture_err": "T",
42+
# Use TVD RK3 for time marching
43+
"time_stepper": 3,
44+
# Use WENO5
45+
"weno_order": 5,
46+
"weno_eps": 1.0e-16,
47+
"weno_Re_flux": "T",
48+
"weno_avg": "T",
49+
"avg_state": 2,
50+
"mapped_weno": "T",
51+
"null_weights": "F",
52+
"mp_weno": "T",
53+
"riemann_solver": 2,
54+
"wave_speeds": 1,
55+
# We use ghost-cell
56+
"bc_x%beg": -3,
57+
"bc_x%end": -3,
58+
"bc_y%beg": -3,
59+
"bc_y%end": -3,
60+
# Set IB to True and add 1 patch
61+
"ib": "T",
62+
"num_ibs": 1,
63+
"viscous": "T",
64+
# Formatted Database Files Structure Parameters
65+
"format": 1,
66+
"precision": 2,
67+
"prim_vars_wrt": "T",
68+
"E_wrt": "T",
69+
"parallel_io": "T",
70+
# Patch: Constant Tube filled with air
71+
# Specify the cylindrical air tube grid geometry
72+
"patch_icpp(1)%geometry": 3,
73+
"patch_icpp(1)%x_centroid": 3.0e-03,
74+
# Uniform medium density, centroid is at the center of the domain
75+
"patch_icpp(1)%y_centroid": 3.0e-03,
76+
"patch_icpp(1)%length_x": 6.0e-03,
77+
"patch_icpp(1)%length_y": 6.0e-03,
78+
# Specify the patch primitive variables
79+
"patch_icpp(1)%vel(1)": 0.05e00,
80+
"patch_icpp(1)%vel(2)": 0.0e00,
81+
"patch_icpp(1)%pres": 1.0e00,
82+
"patch_icpp(1)%alpha_rho(1)": 1.0e00,
83+
"patch_icpp(1)%alpha(1)": 1.0e00,
84+
# Patch: Cylinder Immersed Boundary
85+
"patch_ib(1)%geometry": 2,
86+
"patch_ib(1)%x_centroid": 1.5e-03,
87+
"patch_ib(1)%y_centroid": 4.5e-03,
88+
"patch_ib(1)%radius": 0.3e-03,
89+
"patch_ib(1)%slip": "F",
90+
"patch_ib(1)%moving_ibm": 2,
91+
"patch_ib(1)%vel(2)": -0.1,
92+
"patch_ib(1)%angles(1)": 0.0, # x-axis rotation in radians
93+
"patch_ib(1)%angles(2)": 0.0, # y-axis rotation
94+
"patch_ib(1)%angles(3)": 0.0, # z-axis rotation
95+
"patch_ib(1)%angular_vel(1)": 0.0, # x-axis rotational velocity in radians per second
96+
"patch_ib(1)%angular_vel(2)": 0.0, # y-axis rotation
97+
"patch_ib(1)%angular_vel(3)": 0.0, # z-axis rotation
98+
"patch_ib(1)%mass": 0.0001, # z-axis rotation
99+
# Fluids Physical Parameters
100+
"fluid_pp(1)%gamma": 1.0e00 / (gam_a - 1.0e00), # 2.50(Not 1.40)
101+
"fluid_pp(1)%pi_inf": 0,
102+
"fluid_pp(1)%Re(1)": 2500000,
103+
}
104+
)
105+
)

src/common/m_mpi_common.fpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,30 @@ contains
472472
473473
end subroutine s_mpi_allreduce_sum
474474
475+
!> This subroutine follows the behavior of the s_mpi_allreduce_sum subroutine
476+
!> with the additional feature that it reduces an array of vectors.
477+
impure subroutine s_mpi_allreduce_vectors_sum(var_loc, var_glb, num_vectors, vector_length)
478+
479+
integer, intent(in) :: num_vectors, vector_length
480+
real(wp), dimension(:, :), intent(in) :: var_loc
481+
real(wp), dimension(:, :), intent(out) :: var_glb
482+
483+
#ifdef MFC_MPI
484+
integer :: ierr !< Generic flag used to identify and report MPI errors
485+
486+
! Performing the reduction procedure
487+
if (loc(var_loc) == loc(var_glb)) then
488+
call MPI_Allreduce(MPI_IN_PLACE, var_glb, num_vectors*vector_length, &
489+
mpi_p, MPI_SUM, MPI_COMM_WORLD, ierr)
490+
else
491+
call MPI_Allreduce(var_loc, var_glb, num_vectors*vector_length, &
492+
mpi_p, MPI_SUM, MPI_COMM_WORLD, ierr)
493+
end if
494+
495+
#endif
496+
497+
end subroutine s_mpi_allreduce_vectors_sum
498+
475499
!> The following subroutine takes the input local variable
476500
!! from all processors and reduces to the sum of all
477501
!! values. The reduced variable is recorded back onto the

src/simulation/m_ibm.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,8 @@ contains
10421042
$:END_GPU_PARALLEL_LOOP()
10431043
10441044
! reduce the forces across all MPI ranks
1045-
call s_mpi_allreduce_sum(forces, forces)
1046-
call s_mpi_allreduce_sum(torques, torques)
1045+
call s_mpi_allreduce_vectors_sum(forces, forces, num_ibs, 3)
1046+
call s_mpi_allreduce_vectors_sum(torques, torques, num_ibs, 3)
10471047
10481048
! apply the summed forces
10491049
do i = 1, num_ibs

tests/127A967A/golden-metadata.txt

Lines changed: 159 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)