Skip to content

Commit 85e3989

Browse files
author
Diego Vaca
committed
Lagrange bubble model fixing PR part 1, solving test issue
1 parent f49281b commit 85e3989

File tree

6 files changed

+108
-108
lines changed

6 files changed

+108
-108
lines changed

src/simulation/m_bubbles_EL.fpp

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ contains
9494
integer :: nBubs_glb, i
9595
9696
! Setting number of time-stages for selected time-stepping scheme
97-
lag_num_ts = 1
97+
lag_num_ts = time_stepper
9898
if (time_stepper == 4) lag_num_ts = num_ts_rkck
9999
100100
! Allocate space for the Eulerian fields needed to map the effect of the bubbles
@@ -463,26 +463,20 @@ contains
463463
!! @param q_cons_vf Conservative variables
464464
!! @param q_prim_vf Primitive variables
465465
!! @param rhs_vf Calculated change of conservative variables
466-
!! @param step_rkck Current step in the RKCK algorithm
467-
subroutine s_compute_el_coupled_solver(q_cons_vf, q_prim_vf, rhs_vf, step_rkck)
466+
!! @param stage Current stage in the time-stepper algorithm
467+
subroutine s_compute_el_coupled_solver(q_cons_vf, q_prim_vf, rhs_vf, stage)
468468

469469
type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf
470470
type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf
471471
type(scalar_field), dimension(sys_size), intent(inout) :: rhs_vf
472-
integer, intent(in), optional :: step_rkck
472+
integer, intent(in) :: stage
473473

474474
real(kind(0.d0)) :: gammaparticle, vaporflux, heatflux
475-
integer :: i, j, k, l, step
475+
integer :: i, j, k, l
476476
real(kind(0.d0)) :: preterm1, term2, paux, pint, Romega, term1_fac, Rb
477477

478478
call nvtxStartRange("DYNAMICS-LAGRANGE-BUBBLES")
479479

480-
if (present(step_rkck)) then
481-
step = step_rkck
482-
else
483-
step = 1
484-
end if
485-
486480
!< BUBBLE DYNAMICS
487481

488482
! Subgrid p_inf model from Maeda and Colonius (2018).
@@ -506,36 +500,36 @@ contains
506500
end if
507501

508502
! Gaseous core evolution
509-
!$acc parallel loop gang vector default(present) private(k) copyin(step)
503+
!$acc parallel loop gang vector default(present) private(k) copyin(stage)
510504
do k = 1, nBubs
511505
call s_compute_interface_fluxes(k, vaporflux, heatflux, gammaparticle)
512-
gas_dpdt(k, step) = -3.0d0*gammaparticle/intfc_rad(k, 2)* &
513-
(gas_p(k, 2)*intfc_vel(k, 2) - &
514-
heatflux - (lag_params%Rvapor*lag_params%Thost)*vaporflux)
515-
gas_dmvdt(k, step) = 4.0d0*pi*intfc_rad(k, 2)**2*vaporflux
506+
gas_dpdt(k, stage) = -3.0d0*gammaparticle/intfc_rad(k, 2)* &
507+
(gas_p(k, 2)*intfc_vel(k, 2) - &
508+
heatflux - (lag_params%Rvapor*lag_params%Thost)*vaporflux)
509+
gas_dmvdt(k, stage) = 4.0d0*pi*intfc_rad(k, 2)**2*vaporflux
516510
end do
517511

518512
! Radial motion model
519513
if (lag_params%bubble_model == 1) then
520-
!$acc parallel loop gang vector default(present) private(k) copyin(step)
514+
!$acc parallel loop gang vector default(present) private(k) copyin(stage)
521515
do k = 1, nBubs
522-
call s_compute_KM(k, step, q_prim_vf)
523-
intfc_draddt(k, step) = intfc_vel(k, 2)
516+
call s_compute_KM(k, stage, q_prim_vf)
517+
intfc_draddt(k, stage) = intfc_vel(k, 2)
524518
end do
525519
else
526-
!$acc parallel loop gang vector default(present) private(k) copyin(step)
520+
!$acc parallel loop gang vector default(present) private(k) copyin(stage)
527521
do k = 1, nBubs
528-
intfc_dveldt(k, step) = 0.0d0
529-
intfc_draddt(k, step) = 0.0d0
522+
intfc_dveldt(k, stage) = 0.0d0
523+
intfc_draddt(k, stage) = 0.0d0
530524
end do
531525
end if
532526

533527
! Bubbles remain in a fixed position
534-
!$acc parallel loop collapse(2) gang vector default(present) private(k) copyin(step)
528+
!$acc parallel loop collapse(2) gang vector default(present) private(k) copyin(stage)
535529
do k = 1, nBubs
536530
do l = 1, 3
537-
mtn_dposdt(k, l, step) = 0.0d0
538-
mtn_dveldt(k, l, step) = 0.0d0
531+
mtn_dposdt(k, l, stage) = 0.0d0
532+
mtn_dveldt(k, l, stage) = 0.0d0
539533
end do
540534
end do
541535

@@ -933,6 +927,7 @@ contains
933927
if (time_stepper == 1) then ! 1st order TVD RK
934928
!$acc parallel loop gang vector default(present) private(k)
935929
do k = 1, nBubs
930+
!u{1} = u{n} + dt * RHS{n}
936931
intfc_rad(k, 1) = intfc_rad(k, 1) + dt*intfc_draddt(k, 1)
937932
intfc_vel(k, 1) = intfc_vel(k, 1) + dt*intfc_dveldt(k, 1)
938933
mtn_pos(k, 1:3, 1) = mtn_pos(k, 1:3, 1) + dt*mtn_dposdt(k, 1:3, 1)
@@ -955,6 +950,7 @@ contains
955950
if (stage == 1) then
956951
!$acc parallel loop gang vector default(present) private(k)
957952
do k = 1, nBubs
953+
!u{1} = u{n} + dt * RHS{n}
958954
intfc_rad(k, 2) = intfc_rad(k, 1) + dt*intfc_draddt(k, 1)
959955
intfc_vel(k, 2) = intfc_vel(k, 1) + dt*intfc_dveldt(k, 1)
960956
mtn_pos(k, 1:3, 2) = mtn_pos(k, 1:3, 1) + dt*mtn_dposdt(k, 1:3, 1)
@@ -967,12 +963,13 @@ contains
967963
elseif (stage == 2) then
968964
!$acc parallel loop gang vector default(present) private(k)
969965
do k = 1, nBubs
970-
intfc_rad(k, 1) = (intfc_rad(k, 1) + intfc_rad(k, 2) + dt*intfc_draddt(k, 1))/2d0
971-
intfc_vel(k, 1) = (intfc_vel(k, 1) + intfc_vel(k, 2) + dt*intfc_dveldt(k, 1))/2d0
972-
mtn_pos(k, 1:3, 1) = (mtn_pos(k, 1:3, 1) + mtn_pos(k, 1:3, 2) + dt*mtn_dposdt(k, 1:3, 1))/2d0
973-
mtn_vel(k, 1:3, 1) = (mtn_vel(k, 1:3, 1) + mtn_vel(k, 1:3, 2) + dt*mtn_dveldt(k, 1:3, 1))/2d0
974-
gas_p(k, 1) = (gas_p(k, 1) + gas_p(k, 2) + dt*gas_dpdt(k, 1))/2d0
975-
gas_mv(k, 1) = (gas_mv(k, 1) + gas_mv(k, 2) + dt*gas_dmvdt(k, 1))/2d0
966+
!u{1} = u{n} + (1/2) * dt * (RHS{n} + RHS{1})
967+
intfc_rad(k, 1) = intfc_rad(k, 1) + dt*(intfc_draddt(k, 1) + intfc_draddt(k, 2))/2d0
968+
intfc_vel(k, 1) = intfc_vel(k, 1) + dt*(intfc_dveldt(k, 1) + intfc_dveldt(k, 2))/2d0
969+
mtn_pos(k, 1:3, 1) = mtn_pos(k, 1:3, 1) + dt*(mtn_dposdt(k, 1:3, 1) + mtn_dposdt(k, 1:3, 2))/2d0
970+
mtn_vel(k, 1:3, 1) = mtn_vel(k, 1:3, 1) + dt*(mtn_dveldt(k, 1:3, 1) + mtn_dveldt(k, 1:3, 2))/2d0
971+
gas_p(k, 1) = gas_p(k, 1) + dt*(gas_dpdt(k, 1) + gas_dpdt(k, 2))/2d0
972+
gas_mv(k, 1) = gas_mv(k, 1) + dt*(gas_dmvdt(k, 1) + gas_dmvdt(k, 2))/2d0
976973
if (intfc_rad(k, 1) <= 0.0d0) stop "Negative bubble radius encountered, please reduce dt"
977974
end do
978975
@@ -991,35 +988,38 @@ contains
991988
if (stage == 1) then
992989
!$acc parallel loop gang vector default(present) private(k)
993990
do k = 1, nBubs
994-
intfc_rad(k, 2) = intfc_rad(k, 2) + dt*intfc_draddt(k, 1)
995-
intfc_vel(k, 2) = intfc_vel(k, 2) + dt*intfc_dveldt(k, 1)
996-
mtn_pos(k, 1:3, 2) = mtn_pos(k, 1:3, 2) + dt*mtn_dposdt(k, 1:3, 1)
997-
mtn_vel(k, 1:3, 2) = mtn_vel(k, 1:3, 2) + dt*mtn_dveldt(k, 1:3, 1)
998-
gas_p(k, 2) = gas_p(k, 2) + dt*gas_dpdt(k, 1)
999-
gas_mv(k, 2) = gas_mv(k, 2) + dt*gas_dmvdt(k, 1)
991+
!u{1} = u{n} + dt * RHS{n}
992+
intfc_rad(k, 2) = intfc_rad(k, 1) + dt*intfc_draddt(k, 1)
993+
intfc_vel(k, 2) = intfc_vel(k, 1) + dt*intfc_dveldt(k, 1)
994+
mtn_pos(k, 1:3, 2) = mtn_pos(k, 1:3, 1) + dt*mtn_dposdt(k, 1:3, 1)
995+
mtn_vel(k, 1:3, 2) = mtn_vel(k, 1:3, 1) + dt*mtn_dveldt(k, 1:3, 1)
996+
gas_p(k, 2) = gas_p(k, 1) + dt*gas_dpdt(k, 1)
997+
gas_mv(k, 2) = gas_mv(k, 1) + dt*gas_dmvdt(k, 1)
1000998
if (intfc_rad(k, 2) <= 0.0d0) stop "Negative bubble radius encountered, please reduce dt"
1001999
end do
10021000
10031001
elseif (stage == 2) then
10041002
!$acc parallel loop gang vector default(present) private(k)
10051003
do k = 1, nBubs
1006-
intfc_rad(k, 2) = (3d0*intfc_rad(k, 1) + intfc_rad(k, 2) + dt*intfc_draddt(k, 1))/4d0
1007-
intfc_vel(k, 2) = (3d0*intfc_vel(k, 1) + intfc_vel(k, 2) + dt*intfc_dveldt(k, 1))/4d0
1008-
mtn_pos(k, 1:3, 2) = (3d0*mtn_pos(k, 1:3, 1) + mtn_pos(k, 1:3, 2) + dt*mtn_dposdt(k, 1:3, 1))/4d0
1009-
mtn_vel(k, 1:3, 2) = (3d0*mtn_vel(k, 1:3, 1) + mtn_vel(k, 1:3, 2) + dt*mtn_dveldt(k, 1:3, 1))/4d0
1010-
gas_p(k, 2) = (3d0*gas_p(k, 1) + gas_p(k, 2) + dt*gas_dpdt(k, 1))/4d0
1011-
gas_mv(k, 2) = (3d0*gas_mv(k, 1) + dt*gas_dmvdt(k, 1))/4d0
1004+
!u{2} = u{n} + (1/4) * dt * [RHS{n} + RHS{1}]
1005+
intfc_rad(k, 2) = intfc_rad(k, 1) + dt*(intfc_draddt(k, 1) + intfc_draddt(k, 2))/4d0
1006+
intfc_vel(k, 2) = intfc_vel(k, 1) + dt*(intfc_dveldt(k, 1) + intfc_dveldt(k, 2))/4d0
1007+
mtn_pos(k, 1:3, 2) = mtn_pos(k, 1:3, 1) + dt*(mtn_dposdt(k, 1:3, 1) + mtn_dposdt(k, 1:3, 2))/4d0
1008+
mtn_vel(k, 1:3, 2) = mtn_vel(k, 1:3, 1) + dt*(mtn_dveldt(k, 1:3, 1) + mtn_dveldt(k, 1:3, 2))/4d0
1009+
gas_p(k, 2) = gas_p(k, 1) + dt*(gas_dpdt(k, 1) + gas_dpdt(k, 2))/4d0
1010+
gas_mv(k, 2) = gas_mv(k, 1) + dt*(gas_dmvdt(k, 1) + gas_dmvdt(k, 2))/4d0
10121011
if (intfc_rad(k, 2) <= 0.0d0) stop "Negative bubble radius encountered, please reduce dt"
10131012
end do
10141013
elseif (stage == 3) then
10151014
!$acc parallel loop gang vector default(present) private(k)
10161015
do k = 1, nBubs
1017-
intfc_rad(k, 1) = (intfc_rad(k, 1) + 2d0*intfc_rad(k, 2) + 2d0*dt*intfc_draddt(k, 1))/3d0
1018-
intfc_vel(k, 1) = (intfc_vel(k, 1) + 2d0*intfc_vel(k, 2) + 2d0*dt*intfc_dveldt(k, 1))/3d0
1019-
mtn_pos(k, 1:3, 1) = (mtn_pos(k, 1:3, 1) + 2d0*mtn_pos(k, 1:3, 2) + 2d0*dt*mtn_dposdt(k, 1:3, 1))/3d0
1020-
mtn_vel(k, 1:3, 1) = (mtn_vel(k, 1:3, 1) + 2d0*mtn_vel(k, 1:3, 2) + 2d0*dt*mtn_dveldt(k, 1:3, 1))/3d0
1021-
gas_p(k, 1) = (gas_p(k, 1) + 2d0*gas_p(k, 2) + 2d0*dt*gas_dpdt(k, 1))/3d0
1022-
gas_mv(k, 1) = (gas_mv(k, 1) + 2d0*gas_mv(k, 2) + 2d0*dt*gas_dmvdt(k, 1))/3d0
1016+
!u{n+1} = u{n} + (2/3) * dt * [(1/4)* RHS{n} + (1/4)* RHS{1} + RHS{2}]
1017+
intfc_rad(k, 1) = intfc_rad(k, 1) + (2d0/3d0)*dt*(intfc_draddt(k, 1)/4d0 + intfc_draddt(k, 2)/4d0 + intfc_draddt(k, 3))
1018+
intfc_vel(k, 1) = intfc_vel(k, 1) + (2d0/3d0)*dt*(intfc_dveldt(k, 1)/4d0 + intfc_dveldt(k, 2)/4d0 + intfc_dveldt(k, 3))
1019+
mtn_pos(k, 1:3, 1) = mtn_pos(k, 1:3, 1) + (2d0/3d0)*dt*(mtn_dposdt(k, 1:3, 1)/4d0 + mtn_dposdt(k, 1:3, 2)/4d0 + mtn_dposdt(k, 1:3, 3))
1020+
mtn_vel(k, 1:3, 1) = mtn_vel(k, 1:3, 1) + (2d0/3d0)*dt*(mtn_dveldt(k, 1:3, 1)/4d0 + mtn_dveldt(k, 1:3, 2)/4d0 + mtn_dveldt(k, 1:3, 3))
1021+
gas_p(k, 1) = gas_p(k, 1) + (2d0/3d0)*dt*(gas_dpdt(k, 1)/4d0 + gas_dpdt(k, 2)/4d0 + gas_dpdt(k, 3))
1022+
gas_mv(k, 1) = gas_mv(k, 1) + (2d0/3d0)*dt*(gas_dmvdt(k, 1)/4d0 + gas_dmvdt(k, 2)/4d0 + gas_dmvdt(k, 3))
10231023
if (intfc_rad(k, 1) <= 0.0d0) stop "Negative bubble radius encountered, please reduce dt"
10241024
end do
10251025

src/simulation/m_time_steppers.fpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ contains
326326
end if
327327

328328
if (bubbles_lagrange) then
329-
call s_compute_el_coupled_solver(q_cons_ts(1)%vf, q_prim_vf, rhs_vf)
330-
call s_update_lag_tdv_rk(1)
329+
call s_compute_el_coupled_solver(q_cons_ts(1)%vf, q_prim_vf, rhs_vf, stage=1)
330+
call s_update_lag_tdv_rk(stage=1)
331331
end if
332332

333333
!$acc parallel loop collapse(4) gang vector default(present)
@@ -432,8 +432,8 @@ contains
432432
end if
433433

434434
if (bubbles_lagrange) then
435-
call s_compute_el_coupled_solver(q_cons_ts(1)%vf, q_prim_vf, rhs_vf)
436-
call s_update_lag_tdv_rk(1)
435+
call s_compute_el_coupled_solver(q_cons_ts(1)%vf, q_prim_vf, rhs_vf, stage=1)
436+
call s_update_lag_tdv_rk(stage=1)
437437
end if
438438

439439
!$acc parallel loop collapse(4) gang vector default(present)
@@ -508,8 +508,8 @@ contains
508508
call s_compute_rhs(q_cons_ts(2)%vf, q_prim_vf, rhs_vf, pb_ts(2)%sf, rhs_pb, mv_ts(2)%sf, rhs_mv, t_step, time_avg)
509509

510510
if (bubbles_lagrange) then
511-
call s_compute_el_coupled_solver(q_cons_ts(2)%vf, q_prim_vf, rhs_vf)
512-
call s_update_lag_tdv_rk(2)
511+
call s_compute_el_coupled_solver(q_cons_ts(2)%vf, q_prim_vf, rhs_vf, stage=2)
512+
call s_update_lag_tdv_rk(stage=2)
513513
end if
514514

515515
!$acc parallel loop collapse(4) gang vector default(present)
@@ -621,8 +621,8 @@ contains
621621
end if
622622

623623
if (bubbles_lagrange) then
624-
call s_compute_el_coupled_solver(q_cons_ts(1)%vf, q_prim_vf, rhs_vf)
625-
call s_update_lag_tdv_rk(1)
624+
call s_compute_el_coupled_solver(q_cons_ts(1)%vf, q_prim_vf, rhs_vf, stage=1)
625+
call s_update_lag_tdv_rk(stage=1)
626626
end if
627627

628628
!$acc parallel loop collapse(4) gang vector default(present)
@@ -697,8 +697,8 @@ contains
697697
call s_compute_rhs(q_cons_ts(2)%vf, q_prim_vf, rhs_vf, pb_ts(2)%sf, rhs_pb, mv_ts(2)%sf, rhs_mv, t_step, time_avg)
698698

699699
if (bubbles_lagrange) then
700-
call s_compute_el_coupled_solver(q_cons_ts(2)%vf, q_prim_vf, rhs_vf)
701-
call s_update_lag_tdv_rk(2)
700+
call s_compute_el_coupled_solver(q_cons_ts(2)%vf, q_prim_vf, rhs_vf, stage=2)
701+
call s_update_lag_tdv_rk(stage=2)
702702
end if
703703

704704
!$acc parallel loop collapse(4) gang vector default(present)
@@ -774,8 +774,8 @@ contains
774774
call s_compute_rhs(q_cons_ts(2)%vf, q_prim_vf, rhs_vf, pb_ts(2)%sf, rhs_pb, mv_ts(2)%sf, rhs_mv, t_step, time_avg)
775775

776776
if (bubbles_lagrange) then
777-
call s_compute_el_coupled_solver(q_cons_ts(2)%vf, q_prim_vf, rhs_vf)
778-
call s_update_lag_tdv_rk(3)
777+
call s_compute_el_coupled_solver(q_cons_ts(2)%vf, q_prim_vf, rhs_vf, stage=3)
778+
call s_update_lag_tdv_rk(stage=3)
779779
end if
780780

781781
!$acc parallel loop collapse(4) gang vector default(present)

tests/81579DD9/golden-metadata.txt

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

tests/81579DD9/golden.txt

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

0 commit comments

Comments
 (0)