@@ -17,6 +17,8 @@ module m_bubbles
1717
1818 use m_helper_basic !< Functions to compare floating point numbers
1919
20+ use m_bubbles_EL_kernels
21+
2022 implicit none
2123
2224 real (wp) :: chi_vw !< Bubble wall properties (Ando 2010 )
@@ -40,7 +42,7 @@ contains
4042 !! @param f_bub_adv_src Source for bubble volume fraction
4143 !! @param f_divu Divergence of velocity
4244 !! @param fCson Speed of sound from fP (EL)
43- elemental function f_rddot (fRho , fP , fR , fV , fR0 , fpb , fpbdot , alf , fntait , fBtait , f_bub_adv_src , f_divu , fCson )
45+ function f_rddot (fRho , fP , fR , fV , fR0 , fpb , fpbdot , alf , fntait , fBtait , f_bub_adv_src , f_divu , fCson )
4446 $:GPU_ROUTINE(parallelism= ' [seq]' )
4547 real (wp), intent (in ) :: fRho, fP, fR, fV, fR0, fpb, fpbdot, alf
4648 real (wp), intent (in ) :: fntait, fBtait, f_bub_adv_src, f_divu
@@ -84,7 +86,7 @@ contains
8486 !! @param fR Current bubble radius
8587 !! @param fV Current bubble velocity
8688 !! @param fpb Internal bubble pressure
87- elemental function f_cpbw (fR0 , fR , fV , fpb )
89+ function f_cpbw (fR0 , fR , fV , fpb )
8890 $:GPU_ROUTINE(parallelism= ' [seq]' )
8991 real (wp), intent (in ) :: fR0, fR, fV, fpb
9092
@@ -103,7 +105,7 @@ contains
103105 !! @param fCpinf Driving bubble pressure
104106 !! @param fntait Tait EOS parameter
105107 !! @param fBtait Tait EOS parameter
106- elemental function f_H (fCpbw , fCpinf , fntait , fBtait )
108+ function f_H (fCpbw , fCpinf , fntait , fBtait )
107109 $:GPU_ROUTINE(parallelism= ' [seq]' )
108110 real (wp), intent (in ) :: fCpbw, fCpinf, fntait, fBtait
109111
@@ -123,7 +125,7 @@ contains
123125 !! @param fntait Tait EOS parameter
124126 !! @param fBtait Tait EOS parameter
125127 !! @param fH Bubble enthalpy
126- elemental function f_cgas (fCpinf , fntait , fBtait , fH )
128+ function f_cgas (fCpinf , fntait , fBtait , fH )
127129 $:GPU_ROUTINE(parallelism= ' [seq]' )
128130 real (wp), intent (in ) :: fCpinf, fntait, fBtait, fH
129131
@@ -146,7 +148,7 @@ contains
146148 !! @param fBtait Tait EOS parameter
147149 !! @param advsrc Advection equation source term
148150 !! @param divu Divergence of velocity
149- elemental function f_cpinfdot (fRho , fP , falf , fntait , fBtait , advsrc , divu )
151+ function f_cpinfdot (fRho , fP , falf , fntait , fBtait , advsrc , divu )
150152 $:GPU_ROUTINE(parallelism= ' [seq]' )
151153 real (wp), intent (in ) :: fRho, fP, falf, fntait, fBtait, advsrc, divu
152154
@@ -176,7 +178,7 @@ contains
176178 !! @param fV Current bubble velocity
177179 !! @param fR0 Equilibrium bubble radius
178180 !! @param fpbdot Time derivative of the internal bubble pressure
179- elemental function f_Hdot (fCpbw , fCpinf , fCpinf_dot , fntait , fBtait , fR , fV , fR0 , fpbdot )
181+ function f_Hdot (fCpbw , fCpinf , fCpinf_dot , fntait , fBtait , fR , fV , fR0 , fpbdot )
180182 $:GPU_ROUTINE(parallelism= ' [seq]' )
181183 real (wp), intent (in ) :: fCpbw, fCpinf, fCpinf_dot, fntait, fBtait
182184 real (wp), intent (in ) :: fR, fV, fR0, fpbdot
@@ -211,7 +213,7 @@ contains
211213 !! @param fR Current bubble radius
212214 !! @param fV Current bubble velocity
213215 !! @param fCpbw Boundary wall pressure
214- elemental function f_rddot_RP (fCp , fRho , fR , fV , fCpbw )
216+ function f_rddot_RP (fCp , fRho , fR , fV , fCpbw )
215217 $:GPU_ROUTINE(parallelism= ' [seq]' )
216218 real (wp), intent (in ) :: fCp, fRho, fR, fV, fCpbw
217219
@@ -234,7 +236,7 @@ contains
234236 !! @param fcgas Current gas sound speed
235237 !! @param fntait Tait EOS parameter
236238 !! @param fBtait Tait EOS parameter
237- elemental function f_rddot_G (fCpbw , fR , fV , fH , fHdot , fcgas , fntait , fBtait )
239+ function f_rddot_G (fCpbw , fR , fV , fH , fHdot , fcgas , fntait , fBtait )
238240 $:GPU_ROUTINE(parallelism= ' [seq]' )
239241 real (wp), intent (in ) :: fCpbw, fR, fV, fH, fHdot
240242 real (wp), intent (in ) :: fcgas, fntait, fBtait
@@ -257,7 +259,7 @@ contains
257259 !! @param fR Current bubble radius
258260 !! @param fV Current bubble velocity
259261 !! @param fpb Internal bubble pressure
260- elemental function f_cpbw_KM (fR0 , fR , fV , fpb )
262+ function f_cpbw_KM (fR0 , fR , fV , fpb )
261263 $:GPU_ROUTINE(parallelism= ' [seq]' )
262264 real (wp), intent (in ) :: fR0, fR, fV, fpb
263265 real (wp) :: f_cpbw_KM
@@ -284,7 +286,7 @@ contains
284286 !! @param fV Current bubble velocity
285287 !! @param fR0 Equilibrium bubble radius
286288 !! @param fC Current sound speed
287- elemental function f_rddot_KM (fpbdot , fCp , fCpbw , fRho , fR , fV , fR0 , fC )
289+ function f_rddot_KM (fpbdot , fCp , fCpbw , fRho , fR , fV , fR0 , fC )
288290 $:GPU_ROUTINE(parallelism= ' [seq]' )
289291 real (wp), intent (in ) :: fpbdot, fCp, fCpbw
290292 real (wp), intent (in ) :: fRho, fR, fV, fR0, fC
@@ -318,7 +320,7 @@ contains
318320 !> Subroutine that computes bubble wall properties for vapor bubbles
319321 !! @param pb_in Internal bubble pressure
320322 !! @param iR0 Current bubble size index
321- elemental subroutine s_bwproperty (pb_in , iR0 , chi_vw_out , k_mw_out , rho_mw_out )
323+ subroutine s_bwproperty (pb_in , iR0 , chi_vw_out , k_mw_out , rho_mw_out )
322324 $:GPU_ROUTINE(parallelism= ' [seq]' )
323325 real (wp), intent (in ) :: pb_in
324326 integer , intent (in ) :: iR0
@@ -349,7 +351,7 @@ contains
349351 !! @param fbeta_c Mass transfer coefficient (EL)
350352 !! @param fR_m Mixture gas constant (EL)
351353 !! @param fgamma_m Mixture gamma (EL)
352- elemental subroutine s_vflux (fR , fV , fpb , fmass_v , iR0 , vflux , fmass_g , fbeta_c , fR_m , fgamma_m )
354+ subroutine s_vflux (fR , fV , fpb , fmass_v , iR0 , vflux , fmass_g , fbeta_c , fR_m , fgamma_m )
353355 $:GPU_ROUTINE(parallelism= ' [seq]' )
354356 real (wp), intent (in ) :: fR
355357 real (wp), intent (in ) :: fV
@@ -407,7 +409,8 @@ contains
407409 !! @param fbeta_t Mass transfer coefficient (EL)
408410 !! @param fR_m Mixture gas constant (EL)
409411 !! @param fgamma_m Mixture gamma (EL)
410- elemental function f_bpres_dot (fvflux , fR , fV , fpb , fmass_v , iR0 , fbeta_t , fR_m , fgamma_m )
412+ function f_bpres_dot (fvflux , fR , fV , fpb , fmass_v , iR0 , fbeta_t , fR_m , fgamma_m )
413+ !$DIR INLINENEVER f_bpres_dot
411414 $:GPU_ROUTINE(parallelism= ' [seq]' )
412415 real (wp), intent (in ) :: fvflux
413416 real (wp), intent (in ) :: fR
@@ -463,27 +466,32 @@ contains
463466 !! @param fbeta_t Heat transfer coefficient (EL)
464467 !! @param fCson Speed of sound (EL)
465468 !! @param adap_dt_stop Fail- safe exit if max iteration count reached
466- subroutine s_advance_step (fRho , fP , fR , fV , fR0 , fpb , fpbdot , alf , &
467- fntait , fBtait , f_bub_adv_src , f_divu , &
468- bub_id , fmass_v , fmass_g , fbeta_c , &
469- fbeta_t , fCson , adap_dt_stop )
470- $:GPU_ROUTINE(function_name = ' s_advance_step ' ,parallelism = ' [seq] ' , &
471- & cray_inline = True )
469+ function f_advance_step (fRho , fP , fR , fV , fR0 , fpb , fpbdot , alf , &
470+ fntait , fBtait , f_bub_adv_src , f_divu , &
471+ bub_id , fmass_v , fmass_g , fbeta_c , &
472+ fbeta_t , fCson , fRe , fPos , &
473+ fVel , cell , q_prim_vf ) result(adap_dt_stop)
474+ $:GPU_ROUTINE(parallelism = ' [seq] ' )
472475
473476 real (wp), intent (inout ) :: fR, fV, fpb, fmass_v
474477 real (wp), intent (in ) :: fRho, fP, fR0, fpbdot, alf
475478 real (wp), intent (in ) :: fntait, fBtait, f_bub_adv_src, f_divu
476479 integer , intent (in ) :: bub_id
477480 real (wp), intent (in ) :: fmass_g, fbeta_c, fbeta_t, fCson
478- integer , intent (inout ) :: adap_dt_stop
481+ real (wp), intent (inout ), dimension (3 ), optional :: fPos, fVel
482+ real (wp), intent (in ), optional :: fRe
483+ integer , intent (in ), dimension (3 ), optional :: cell
484+ type(scalar_field), intent (in ), dimension (sys_size), optional :: q_prim_vf
479485
480486 real (wp), dimension (5 ) :: err !< Error estimates for adaptive time stepping
481487 real (wp) :: t_new !< Updated time step size
482488 real (wp) :: h0, h !< Time step size
483489 real (wp), dimension (4 ) :: myR_tmp1, myV_tmp1, myR_tmp2, myV_tmp2 !< Bubble radius, radial velocity, and radial acceleration for the inner loop
484490 real (wp), dimension (4 ) :: myPb_tmp1, myMv_tmp1, myPb_tmp2, myMv_tmp2 !< Gas pressure and vapor mass for the inner loop (EL)
485- real (wp) :: fR2, fV2, fpb2, fmass_v2
486- integer :: iter_count
491+ real (wp) :: fR2, fV2, fpb2, fmass_v2, f_bTemp
492+ real (wp), dimension (3 ) :: vTemp, aTemp
493+ integer :: adap_dt_stop
494+ integer :: l, iter_count
487495
488496 call s_initial_substep_h(fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, &
489497 fntait, fBtait, f_bub_adv_src, f_divu, fCson, h0)
@@ -565,6 +573,42 @@ contains
565573 ! Update pb and mass_v
566574 fpb = myPb_tmp1(4 )
567575 fmass_v = myMv_tmp1(4 )
576+
577+ select case (lag_vel_model)
578+ case (1 )
579+ do l = 1 , num_dims
580+ vTemp(l) = f_interpolate_velocity(fR, cell, l, q_prim_vf)
581+ end do
582+ do l = 1 , num_dims
583+ fVel(l) = vTemp(l)
584+ fPos(l) = fPos(l) + h* vTemp(l)
585+ end do
586+ case (2 )
587+ do l = 1 , num_dims
588+ f_bTemp = f_get_bubble_force(fPos(l), fR, fV, fVel(l), fmass_g, fmass_v, &
589+ fRe, fRho, cell, l, q_prim_vf)
590+ aTemp(l) = f_bTemp/ (fmass_g + fmass_v)
591+ end do
592+ do l = 1 , num_dims
593+ fVel(l) = fVel(l) + h* aTemp(l)
594+ fPos(l) = fPos(l) + h* fVel(l)
595+ end do
596+ case (3 )
597+ do l = 1 , num_dims
598+ f_bTemp = f_get_bubble_force(fPos(l), fR, fV, fVel(l), fmass_g, fmass_v, &
599+ fRe, fRho, cell, l, q_prim_vf)
600+ aTemp(l) = 2._wp * f_bTemp/ (fmass_g + fmass_v) - 3 * fV* fVel(l)/ fR
601+ end do
602+ do l = 1 , num_dims
603+ fVel(l) = fVel(l) + h* aTemp(l)
604+ fPos(l) = fPos(l) + h* fVel(l)
605+ end do
606+ case default
607+ do l = 1 , num_dims
608+ fVel(l) = fVel(l)
609+ fPos(l) = fPos(l)
610+ end do
611+ end select
568612 end if
569613
570614 ! Update step size for the next sub- step
@@ -588,7 +632,7 @@ contains
588632
589633 if (iter_count >= adap_dt_max_iters) adap_dt_stop = 1
590634
591- end subroutine s_advance_step
635+ end function f_advance_step
592636
593637 !> Choose the initial time step size for the adaptive time stepping routine
594638 !! (See Heirer, E. Hairer S.P.Nørsett G. Wanner, Solving Ordinary
@@ -613,10 +657,10 @@ contains
613657 $:GPU_ROUTINE(function_name= ' s_initial_substep_h' ,parallelism= ' [seq]' , &
614658 & cray_inline= True)
615659
616- real (wp), intent (IN ) :: fRho, fP, fR, fV, fR0, fpb, fpbdot, alf
617- real (wp), intent (IN ) :: fntait, fBtait, f_bub_adv_src, f_divu
618- real (wp), intent (IN ) :: fCson
619- real (wp), intent (OUT ) :: h
660+ real (wp), intent (in ) :: fRho, fP, fR, fV, fR0, fpb, fpbdot, alf
661+ real (wp), intent (in ) :: fntait, fBtait, f_bub_adv_src, f_divu
662+ real (wp), intent (in ) :: fCson
663+ real (wp), intent (out ) :: h
620664
621665 real (wp), dimension (2 ) :: h_size !< Time step size (h0, h1)
622666 real (wp), dimension (3 ) :: d_norms !< norms (d_0, d_1, d_2)
@@ -697,12 +741,12 @@ contains
697741 $:GPU_ROUTINE(function_name= ' s_advance_substep' ,parallelism= ' [seq]' , &
698742 & cray_inline= True)
699743
700- real (wp), intent (OUT ) :: err
701- real (wp), intent (IN ) :: fRho, fP, fR, fV, fR0, fpb, fpbdot, alf
702- real (wp), intent (IN ) :: fntait, fBtait, f_bub_adv_src, f_divu, h
703- integer , intent (IN ) :: bub_id
704- real (wp), intent (IN ) :: fmass_v, fmass_g, fbeta_c, fbeta_t, fCson
705- real (wp), dimension (4 ), intent (OUT ) :: myR_tmp, myV_tmp, myPb_tmp, myMv_tmp
744+ real (wp), intent (out ) :: err
745+ real (wp), intent (in ) :: fRho, fP, fR, fV, fR0, fpb, fpbdot, alf
746+ real (wp), intent (in ) :: fntait, fBtait, f_bub_adv_src, f_divu, h
747+ integer , intent (in ) :: bub_id
748+ real (wp), intent (in ) :: fmass_v, fmass_g, fbeta_c, fbeta_t, fCson
749+ real (wp), dimension (4 ), intent (out ) :: myR_tmp, myV_tmp, myPb_tmp, myMv_tmp
706750
707751 real (wp), dimension (4 ) :: myA_tmp, mydPbdt_tmp, mydMvdt_tmp
708752 real (wp) :: err_R, err_V
@@ -802,14 +846,15 @@ contains
802846 !! @param fbeta_c Mass transfer coefficient
803847 !! @param fbeta_t Heat transfer coefficient
804848 !! @param fdPbdt_tmp Rate of change of the internal bubble pressure
849+ !! @param fdMvdt_tmp Rate of change of the mass of vapor in the bubble
805850 !! @param advance_EL Rate of change of the mass of vapor in the bubble
806- elemental subroutine s_advance_EL (fR_tmp , fV_tmp , fPb_tmp , fMv_tmp , bub_id , &
807- fmass_g , fbeta_c , fbeta_t , fdPbdt_tmp , advance_EL )
851+ subroutine s_advance_EL (fR_tmp , fV_tmp , fPb_tmp , fMv_tmp , bub_id , &
852+ fmass_g , fbeta_c , fbeta_t , fdPbdt_tmp , advance_EL )
808853 $:GPU_ROUTINE(parallelism= ' [seq]' )
809- real (wp), intent (IN ) :: fR_tmp, fV_tmp, fPb_tmp, fMv_tmp
810- real (wp), intent (IN ) :: fmass_g, fbeta_c, fbeta_t
811- integer , intent (IN ) :: bub_id
812- real (wp), intent (INOUT ) :: fdPbdt_tmp
854+ real (wp), intent (in ) :: fR_tmp, fV_tmp, fPb_tmp, fMv_tmp
855+ real (wp), intent (in ) :: fmass_g, fbeta_c, fbeta_t
856+ integer , intent (in ) :: bub_id
857+ real (wp), intent (inout ) :: fdPbdt_tmp
813858 real (wp), intent (out ) :: advance_EL
814859 real (wp) :: fVapFlux, myR_m, mygamma_m
815860
0 commit comments