Skip to content

Commit 8d69e3b

Browse files
Diego VacaDiego Vaca
authored andcommitted
addressing comments
1 parent 80910d5 commit 8d69e3b

File tree

8 files changed

+136
-95
lines changed

8 files changed

+136
-95
lines changed

src/common/m_constants.fpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ module m_constants
4949
integer, parameter :: mapCells = 3 !< Number of cells around the bubble where the smoothening function will have effect
5050
real(wp), parameter :: R_uni = 8314._wp ! Universal gas constant - J/kmol/K
5151

52+
! Strang Splitting constants
53+
real(wp), parameter :: dflt_adap_dt_tol = 1e-4_wp !< Default tolerance for adaptive step size
54+
integer, parameter :: adap_dt_max_iters = 100 !< Maximum number of iterations
55+
5256
! Relativity
5357
integer, parameter :: relativity_cons_to_prim_max_iter = 100
5458

src/simulation/m_bubbles.fpp

Lines changed: 103 additions & 86 deletions
Large diffs are not rendered by default.

src/simulation/m_bubbles_EE.fpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ contains
6565
@:ALLOCATE(bub_p_src(0:m, 0:n, 0:p, 1:nb))
6666
@:ALLOCATE(bub_m_src(0:m, 0:n, 0:p, 1:nb))
6767

68+
if (adap_dt .and. f_is_default(adap_dt_tol)) adap_dt_tol = dflt_adap_dt_tol
69+
6870
end subroutine s_initialize_bubbles_EE_module
6971

7072
! Compute the bubble volume fraction alpha from the bubble number density n
@@ -166,6 +168,7 @@ contains
166168

167169
integer :: i, j, k, l, q, ii !< Loop variables
168170

171+
integer :: adap_dt_stop_max, adap_dt_stop !< fail-safe exit if max iteration count reached
169172
integer :: dmBub_id !< Dummy variables for unified subgrid bubble subroutines
170173
real(wp) :: dmMass_v, dmMass_n, dmBeta_c, dmBeta_t, dmCson
171174

@@ -186,7 +189,9 @@ contains
186189
end do
187190
end do
188191

189-
!$acc parallel loop collapse(3) gang vector default(present) private(Rtmp, Vtmp, myalpha_rho, myalpha)
192+
adap_dt_stop_max = 0
193+
!$acc parallel loop collapse(3) gang vector default(present) private(Rtmp, Vtmp, myalpha_rho, myalpha) &
194+
!$acc reduction(MAX:adap_dt_stop_max) copy(adap_dt_stop_max)
190195
do l = 0, p
191196
do k = 0, n
192197
do j = 0, m
@@ -283,8 +288,8 @@ contains
283288
pb, pbdot, alf, n_tait, B_tait, &
284289
bub_adv_src(j, k, l), divu%sf(j, k, l), &
285290
dmBub_id, dmMass_v, dmMass_n, dmBeta_c, &
286-
dmBeta_t, dmCson)
287-
291+
dmBeta_t, dmCson, adap_dt_stop)
292+
adap_dt_stop_max = max(adap_dt_stop_max, adap_dt_stop)
288293
q_cons_vf(rs(q))%sf(j, k, l) = nbub*myR
289294
q_cons_vf(vs(q))%sf(j, k, l) = nbub*myV
290295

@@ -311,6 +316,8 @@ contains
311316
end do
312317
end do
313318

319+
if (adap_dt .and. adap_dt_stop_max > 0) stop "Adaptive time stepping failed to converge"
320+
314321
if (.not. adap_dt) then
315322
!$acc parallel loop collapse(3) gang vector default(present)
316323
do l = 0, p

src/simulation/m_bubbles_EL.fpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ contains
135135
@:ALLOCATE(mtn_dposdt(1:nBubs_glb, 1:3, 1:lag_num_ts))
136136
@:ALLOCATE(mtn_dveldt(1:nBubs_glb, 1:3, 1:lag_num_ts))
137137
138+
if (adap_dt .and. f_is_default(adap_dt_tol)) adap_dt_tol = dflt_adap_dt_tol
139+
138140
! Starting bubbles
139141
call s_start_lagrange_inputs()
140142
call s_read_input_bubbles(q_cons_vf)
@@ -504,6 +506,8 @@ contains
504506
real(wp), dimension(contxe) :: myalpha_rho, myalpha
505507
real(wp), dimension(2) :: Re
506508
integer, dimension(3) :: cell
509+
510+
integer :: adap_dt_stop_max, adap_dt_stop !< fail-safe exit if max iteration count reached
507511
real(wp) :: dmalf, dmntait, dmBtait, dm_bub_adv_src, dm_divu !< Dummy variables for unified subgrid bubble subroutines
508512

509513
integer :: i, k, l
@@ -533,7 +537,9 @@ contains
533537
end if
534538

535539
! Radial motion model
536-
!$acc parallel loop gang vector default(present) private(k, myalpha_rho, myalpha, Re, cell) copyin(stage)
540+
adap_dt_stop_max = 0
541+
!$acc parallel loop gang vector default(present) private(k, myalpha_rho, myalpha, Re, cell) &
542+
!$acc reduction(MAX:adap_dt_stop_max) copy(adap_dt_stop_max) copyin(stage)
537543
do k = 1, nBubs
538544
! Keller-Miksis model
539545

@@ -571,7 +577,8 @@ contains
571577
call s_advance_step(myRho, myPinf, myR, myV, myR0, myPb, myPbdot, dmalf, &
572578
dmntait, dmBtait, dm_bub_adv_src, dm_divu, &
573579
k, myMass_v, myMass_n, myBeta_c, &
574-
myBeta_t, myCson)
580+
myBeta_t, myCson, adap_dt_stop)
581+
adap_dt_stop_max = max(adap_dt_stop_max, adap_dt_stop)
575582

576583
! Update bubble state
577584
intfc_rad(k, 1) = myR
@@ -594,6 +601,8 @@ contains
594601

595602
end do
596603

604+
if (adap_dt .and. adap_dt_stop_max > 0) stop "Adaptive time stepping failed to converge"
605+
597606
! Bubbles remain in a fixed position
598607
!$acc parallel loop collapse(2) gang vector default(present) private(k) copyin(stage)
599608
do k = 1, nBubs

src/simulation/m_global_parameters.fpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ module m_global_parameters
385385
logical :: polydisperse !< Polydisperse bubbles
386386
logical :: adv_n !< Solve the number density equation and compute alpha from number density
387387
logical :: adap_dt !< Adaptive step size control
388+
real(wp) :: adap_dt_tol !< Tolerance to control adaptive step size
388389

389390
integer :: bubble_model !< Gilmore or Keller--Miksis bubble model
390391
integer :: thermal !< Thermal behavior. 1 = adiabatic, 2 = isotherm, 3 = transfer
@@ -406,7 +407,7 @@ module m_global_parameters
406407
!$acc declare create(nb)
407408
#:endif
408409

409-
!$acc declare create(R0ref, Ca, Web, Re_inv, bubbles_euler, polytropic, polydisperse, qbmm, nmomsp, nmomtot, R0_type, bubble_model, thermal, poly_sigma, adv_n, adap_dt, pi_fac)
410+
!$acc declare create(R0ref, Ca, Web, Re_inv, bubbles_euler, polytropic, polydisperse, qbmm, nmomsp, nmomtot, R0_type, bubble_model, thermal, poly_sigma, adv_n, adap_dt, adap_dt_tol, pi_fac)
410411

411412
type(scalar_field), allocatable, dimension(:) :: mom_sp
412413
type(scalar_field), allocatable, dimension(:, :, :) :: mom_3d
@@ -637,6 +638,7 @@ contains
637638
638639
adv_n = .false.
639640
adap_dt = .false.
641+
adap_dt_tol = dflt_real
640642
641643
pi_fac = 1._wp
642644

src/simulation/m_mpi_proxy.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ contains
175175
& 'x_domain%beg', 'x_domain%end', 'y_domain%beg', 'y_domain%end', &
176176
& 'z_domain%beg', 'z_domain%end', 'x_a', 'x_b', 'y_a', 'y_b', 'z_a', &
177177
& 'z_b', 't_stop', 't_save', 'cfl_target', 'Bx0', &
178-
& 'tau_star', 'cont_damage_s', 'alpha_bar' ]
178+
& 'tau_star', 'cont_damage_s', 'alpha_bar', 'adap_dt_tol' ]
179179
call MPI_BCAST(${VAR}$, 1, mpi_p, 0, MPI_COMM_WORLD, ierr)
180180
#:endfor
181181

src/simulation/m_start_up.fpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ contains
168168
relax, relax_model, &
169169
palpha_eps, ptgalpha_eps, &
170170
R0_type, file_per_process, sigma, &
171-
pi_fac, adv_n, adap_dt, bf_x, bf_y, bf_z, &
171+
pi_fac, adv_n, adap_dt, adap_dt_tol, &
172+
bf_x, bf_y, bf_z, &
172173
k_x, k_y, k_z, w_x, w_y, w_z, p_x, p_y, p_z, &
173174
g_x, g_y, g_z, n_start, t_save, t_stop, &
174175
cfl_adap_dt, cfl_const_dt, cfl_target, &
@@ -1621,7 +1622,7 @@ contains
16211622
if (chemistry) then
16221623
!$acc update device(q_T_sf%sf)
16231624
end if
1624-
!$acc update device(nb, R0ref, Ca, Web, Re_inv, weight, R0, V0, bubbles_euler, polytropic, polydisperse, qbmm, R0_type, ptil, bubble_model, thermal, poly_sigma, adv_n, adap_dt, n_idx, pi_fac, low_Mach)
1625+
!$acc update device(nb, R0ref, Ca, Web, Re_inv, weight, R0, V0, bubbles_euler, polytropic, polydisperse, qbmm, R0_type, ptil, bubble_model, thermal, poly_sigma, adv_n, adap_dt, adap_dt_tol, n_idx, pi_fac, low_Mach)
16251626
!$acc update device(R_n, R_v, phi_vn, phi_nv, Pe_c, Tw, pv, M_n, M_v, k_n, k_v, pb0, mass_n0, mass_v0, Pe_T, Re_trans_T, Re_trans_c, Im_trans_T, Im_trans_c, omegaN , mul0, ss, gamma_v, mu_v, gamma_m, gamma_n, mu_n, gam)
16261627

16271628
!$acc update device(acoustic_source, num_source)

toolchain/mfc/run/case_dicts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ def analytic(self):
244244
'ptgalpha_eps': ParamType.REAL,
245245
'pi_fac': ParamType.REAL,
246246
'adap_dt': ParamType.LOG,
247+
'adap_dt_tol': ParamType.REAL,
247248
'ib': ParamType.LOG,
248249
'num_ibs': ParamType.INT,
249250
'n_start': ParamType.INT,

0 commit comments

Comments
 (0)