Skip to content

Commit 1280b70

Browse files
committed
refactor: introduce body_force_t; rename bf_x/y/z to bf%x/y/z
Group the three body-force axis structs (bf_x, bf_y, bf_z) into a single body_force_t container variable bf, matching the bc%x/y/z compound naming pattern. Updates all Fortran source, Python toolchain, examples, and docs.
1 parent e9fed56 commit 1280b70

14 files changed

Lines changed: 105 additions & 100 deletions

File tree

docs/documentation/case.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -987,15 +987,15 @@ This parameter enables the use of true `pi_\infty` in bubble dynamics models whe
987987

988988
| Parameter | Type | Description |
989989
| ---: | :---: | :--- |
990-
| `bf_[x,y,z]%%enabled` | Logical | Enable body forces in the [x,y,z] direction |
991-
| `bf_[x,y,z]%%k` | Real | Magnitude of oscillating acceleration |
992-
| `bf_[x,y,z]%%w` | Real | Frequency of oscillating acceleration |
993-
| `bf_[x,y,z]%%p` | Real | Phase shift of oscillating acceleration |
994-
| `bf_[x,y,z]%%g` | Real | Magnitude of background acceleration |
990+
| `bf%%[x,y,z]%%enabled` | Logical | Enable body forces in the [x,y,z] direction |
991+
| `bf%%[x,y,z]%%k` | Real | Magnitude of oscillating acceleration |
992+
| `bf%%[x,y,z]%%w` | Real | Frequency of oscillating acceleration |
993+
| `bf%%[x,y,z]%%p` | Real | Phase shift of oscillating acceleration |
994+
| `bf%%[x,y,z]%%g` | Real | Magnitude of background acceleration |
995995

996-
`bf_[x,y,z]%%k`, `bf_[x,y,z]%%w`, `bf_[x,y,z]%%p`, and `bf_[x,y,z]%%g` define an oscillating acceleration in the `[x,y,z]` direction with the form
996+
`bf%%[x,y,z]%%k`, `bf%%[x,y,z]%%w`, `bf%%[x,y,z]%%p`, and `bf%%[x,y,z]%%g` define an oscillating acceleration in the `[x,y,z]` direction with the form
997997

998-
\f[ a_{[x,y,z]} = bf_{[x,y,z]}\%g + bf_{[x,y,z]}\%k\sin\left(bf_{[x,y,z]}\%w \cdot t + bf_{[x,y,z]}\%p\right). \f]
998+
\f[ a_{[x,y,z]} = bf\%[x,y,z]\%g + bf\%[x,y,z]\%k\sin\left(bf\%[x,y,z]\%w \cdot t + bf\%[x,y,z]\%p\right). \f]
999999

10001000
By convention, positive accelerations in the `x[y,z]` direction are in the positive `x[y,z]` direction.
10011001

docs/documentation/equations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ Uses Lax-Friedrichs flux (replaces WENO + Riemann solver).
746746

747747
---
748748

749-
## 13. Body Forces (`bf_x`, `bf_y`, `bf_z`)
749+
## 13. Body Forces (`bf%%x`, `bf%%y`, `bf%%z`)
750750

751751
**Source:** `src/simulation/m_body_forces.fpp`
752752

examples/2D_rayleigh_taylor/case.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@
7979
"fluid_pp(2)%pi_inf": 0.0e00,
8080
"fluid_pp(2)%Re(1)": 1 / 0.0073,
8181
# Body Forces
82-
"bf_y%enabled": "T",
83-
"bf_y%k": 0.0,
84-
"bf_y%w": 0.0,
85-
"bf_y%p": 0.0,
86-
"bf_y%g": -9.81,
82+
"bf%y%enabled": "T",
83+
"bf%y%k": 0.0,
84+
"bf%y%w": 0.0,
85+
"bf%y%p": 0.0,
86+
"bf%y%g": -9.81,
8787
# Water Patch
8888
"patch_icpp(1)%geometry": 3,
8989
"patch_icpp(1)%hcid": 204,

examples/3D_rayleigh_taylor_muscl/case.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@
8484
"fluid_pp(2)%pi_inf": 0.0e00,
8585
"fluid_pp(2)%Re(1)": 1 / 0.0073,
8686
# Body Forces
87-
"bf_y%enabled": "T",
88-
"bf_y%k": 0.0,
89-
"bf_y%w": 0.0,
90-
"bf_y%p": 0.0,
91-
"bf_y%g": -98.1,
87+
"bf%y%enabled": "T",
88+
"bf%y%k": 0.0,
89+
"bf%y%w": 0.0,
90+
"bf%y%p": 0.0,
91+
"bf%y%g": -98.1,
9292
# Water Patch
9393
"patch_icpp(1)%geometry": 9,
9494
"patch_icpp(1)%hcid": 300,

src/common/m_derived_types.fpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ module m_derived_types
186186
logical :: enabled
187187
end type body_force_axis
188188

189+
!> Groups the x, y, z body force structs for passing as a single argument.
190+
type body_force_t
191+
type(body_force_axis) :: x, y, z
192+
end type body_force_t
193+
189194
!> Groups per-body allocatable arrays (x, y, z) for one IB dynamics quantity
190195
type ib_dynamics_t
191196
real(wp), allocatable, dimension(:) :: x, y, z

src/simulation/m_body_forces.fpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ contains
4545
real(wp), intent(in) :: t
4646

4747
#:for DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')]
48-
if (bf_${XYZ}$%enabled) then
49-
accel_bf(${DIR}$) = bf_${XYZ}$%g + bf_${XYZ}$%k*sin(bf_${XYZ}$%w*t - bf_${XYZ}$%p)
48+
if (bf%${XYZ}$%enabled) then
49+
accel_bf(${DIR}$) = bf%${XYZ}$%g + bf%${XYZ}$%k*sin(bf%${XYZ}$%w*t - bf%${XYZ}$%p)
5050
end if
5151
#:endfor
5252

@@ -98,7 +98,7 @@ contains
9898
end do
9999
$:END_GPU_PARALLEL_LOOP()
100100

101-
if (bf_x%enabled) then ! x-direction body forces
101+
if (bf%x%enabled) then ! x-direction body forces
102102

103103
$:GPU_PARALLEL_LOOP(private='[j, k, l]', collapse=3)
104104
do l = 0, p
@@ -113,7 +113,7 @@ contains
113113
$:END_GPU_PARALLEL_LOOP()
114114
end if
115115

116-
if (bf_y%enabled) then ! y-direction body forces
116+
if (bf%y%enabled) then ! y-direction body forces
117117

118118
$:GPU_PARALLEL_LOOP(private='[j, k, l]', collapse=3)
119119
do l = 0, p
@@ -129,7 +129,7 @@ contains
129129
$:END_GPU_PARALLEL_LOOP()
130130
end if
131131

132-
if (bf_z%enabled) then ! z-direction body forces
132+
if (bf%z%enabled) then ! z-direction body forces
133133

134134
$:GPU_PARALLEL_LOOP(private='[j, k, l]', collapse=3)
135135
do l = 0, p

src/simulation/m_global_parameters.fpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ module m_global_parameters
172172
integer :: num_igr_warm_start_iters !< number of warm start iterations for elliptic solve
173173
real(wp) :: alf_factor !< alpha factor for IGR
174174
logical :: bodyForces
175-
type(body_force_axis) :: bf_x, bf_y, bf_z !< body force parameters per direction
175+
type(body_force_t) :: bf !< body force parameters per direction
176176
real(wp), dimension(3) :: accel_bf
177177
$:GPU_DECLARE(create='[accel_bf]')
178178

@@ -666,10 +666,10 @@ contains
666666
surface_tension = .false.
667667

668668
bodyForces = .false.
669-
bf_x%enabled = .false.; bf_y%enabled = .false.; bf_z%enabled = .false.
670-
bf_x%k = 0._wp; bf_x%w = 0._wp; bf_x%p = 0._wp; bf_x%g = 0._wp
671-
bf_y%k = 0._wp; bf_y%w = 0._wp; bf_y%p = 0._wp; bf_y%g = 0._wp
672-
bf_z%k = 0._wp; bf_z%w = 0._wp; bf_z%p = 0._wp; bf_z%g = 0._wp
669+
bf%x%enabled = .false.; bf%y%enabled = .false.; bf%z%enabled = .false.
670+
bf%x%k = 0._wp; bf%x%w = 0._wp; bf%x%p = 0._wp; bf%x%g = 0._wp
671+
bf%y%k = 0._wp; bf%y%w = 0._wp; bf%y%p = 0._wp; bf%y%g = 0._wp
672+
bf%z%k = 0._wp; bf%z%w = 0._wp; bf%z%p = 0._wp; bf%z%g = 0._wp
673673

674674
fft_wrt = .false.
675675

src/simulation/m_ibm.fpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,13 +1015,13 @@ contains
10151015

10161016
! consider body forces after reducing to avoid double counting
10171017
do i = 1, num_ibs
1018-
if (bf_x%enabled) then
1018+
if (bf%x%enabled) then
10191019
forces(i, 1) = forces(i, 1) + accel_bf(1)*patch_ib(i)%mass
10201020
end if
1021-
if (bf_y%enabled) then
1021+
if (bf%y%enabled) then
10221022
forces(i, 2) = forces(i, 2) + accel_bf(2)*patch_ib(i)%mass
10231023
end if
1024-
if (bf_z%enabled) then
1024+
if (bf%z%enabled) then
10251025
forces(i, 3) = forces(i, 3) + accel_bf(3)*patch_ib(i)%mass
10261026
end if
10271027
end do

src/simulation/m_mpi_proxy.fpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ contains
6363

6464
call MPI_BCAST(case_dir, len(case_dir), MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr)
6565

66-
#:for VAR in ['bf_x%k', 'bf_x%w', 'bf_x%p', 'bf_x%g', &
67-
& 'bf_y%k', 'bf_y%w', 'bf_y%p', 'bf_y%g', &
68-
& 'bf_z%k', 'bf_z%w', 'bf_z%p', 'bf_z%g']
66+
#:for VAR in ['bf%x%k', 'bf%x%w', 'bf%x%p', 'bf%x%g', &
67+
& 'bf%y%k', 'bf%y%w', 'bf%y%p', 'bf%y%g', &
68+
& 'bf%z%k', 'bf%z%w', 'bf%z%p', 'bf%z%g']
6969
call MPI_BCAST(${VAR}$, 1, mpi_p, 0, MPI_COMM_WORLD, ierr)
7070
#:endfor
7171

@@ -87,7 +87,7 @@ contains
8787
& 'parallel_io', 'hypoelasticity', 'bubbles_euler', 'polytropic', &
8888
& 'polydisperse', 'qbmm', 'acoustic_source', 'probe_wrt', 'integral_wrt', &
8989
& 'prim_vars_wrt', 'weno_avg', 'file_per_process', 'relax', &
90-
& 'adv_n', 'adap_dt', 'ib', 'bodyForces', 'bf_x%enabled', 'bf_y%enabled', 'bf_z%enabled', &
90+
& 'adv_n', 'adap_dt', 'ib', 'bodyForces', 'bf%x%enabled', 'bf%y%enabled', 'bf%z%enabled', &
9191
& 'bc%x%beg_side%grcbc', 'bc%x%end_side%grcbc', 'bc%x%end_side%grcbc_vel', &
9292
& 'bc%y%beg_side%grcbc', 'bc%y%end_side%grcbc', 'bc%y%end_side%grcbc_vel', &
9393
& 'bc%z%beg_side%grcbc', 'bc%z%end_side%grcbc', 'bc%z%end_side%grcbc_vel', &

src/simulation/m_start_up.fpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ contains
108108
#:endif
109109
Ca, Web, Re_inv, acoustic_source, acoustic, num_source, polytropic, thermal, integral, integral_wrt, num_integrals, &
110110
& polydisperse, poly_sigma, qbmm, relax, relax_model, palpha_eps, ptgalpha_eps, file_per_process, sigma, pi_fac, &
111-
& adv_n, adap_dt, adap_dt_tol, adap_dt_max_iters, bf_x, bf_y, bf_z, n_start, t_save, t_stop, cfl_adap_dt, &
112-
& cfl_const_dt, cfl_target, surface_tension, bubbles_lagrange, lag_params, hyperelasticity, R0ref, num_bc_patches, &
113-
& Bx0, cont_damage, tau_star, cont_damage_s, alpha_bar, hyper_cleaning, hyper_cleaning_speed, hyper_cleaning_tau, &
114-
& alf_factor, num_igr_iters, num_igr_warm_start_iters, int_comp, ic_eps, ic_beta, nv_uvm_out_of_core, &
115-
& nv_uvm_igr_temps_on_gpu, nv_uvm_pref_gpu, down_sample, fft_wrt
111+
& adv_n, adap_dt, adap_dt_tol, adap_dt_max_iters, bf, n_start, t_save, t_stop, cfl_adap_dt, cfl_const_dt, cfl_target, &
112+
& surface_tension, bubbles_lagrange, lag_params, hyperelasticity, R0ref, num_bc_patches, Bx0, cont_damage, tau_star, &
113+
& cont_damage_s, alpha_bar, hyper_cleaning, hyper_cleaning_speed, hyper_cleaning_tau, alf_factor, num_igr_iters, &
114+
& num_igr_warm_start_iters, int_comp, ic_eps, ic_beta, nv_uvm_out_of_core, nv_uvm_igr_temps_on_gpu, nv_uvm_pref_gpu, &
115+
& down_sample, fft_wrt
116116

117117
inquire (FILE=trim(file_path), EXIST=file_exist)
118118

@@ -129,7 +129,7 @@ contains
129129

130130
close (1)
131131

132-
if (bf_x%enabled .or. bf_y%enabled .or. bf_z%enabled) then
132+
if (bf%x%enabled .or. bf%y%enabled .or. bf%z%enabled) then
133133
bodyForces = .true.
134134
end if
135135

0 commit comments

Comments
 (0)