Function for computing the slow RHS for the evolution equations for the density, potential temperature and momentum.
117 BL_PROFILE_REGION(
"erf_slow_rhs_pre()");
119 const BCRec* bc_ptr_d = domain_bcs_type_d.data();
120 const BCRec* bc_ptr_h = domain_bcs_type_h.data();
125 const MultiFab* t_mean_mf =
nullptr;
126 if (most) t_mean_mf = most->get_mac_avg(level,2);
130 int end_comp = start_comp + num_comp - 1;
136 const bool l_use_terrain_fitted_coords = (z_phys_nd !=
nullptr);
137 const bool l_moving_terrain = (solverChoice.
terrain_type == TerrainType::MovingFittedMesh);
138 if (l_moving_terrain) AMREX_ALWAYS_ASSERT (l_use_terrain_fitted_coords);
141 const bool l_reflux = (solverChoice.
coupling_type == CouplingType::TwoWay);
147 const bool l_use_turb = ( tc.
les_type == LESType::Smagorinsky ||
148 tc.
les_type == LESType::Deardorff ||
152 const bool l_need_SmnSmn = ( tc.
les_type == LESType::Deardorff ||
155 const bool l_use_moisture = (solverChoice.
moisture_type != MoistureType::None);
156 const bool l_use_most = (most !=
nullptr);
160 const bool l_anelastic = solverChoice.
anelastic[level];
163 const Box& domain = geom.Domain();
164 const int domlo_z = domain.smallEnd(2);
165 const int domhi_z = domain.bigEnd(2);
167 const GpuArray<Real, AMREX_SPACEDIM> dxInv = geom.InvCellSizeArray();
168 const Real* dx = geom.CellSize();
173 const Array<Real,AMREX_SPACEDIM> grav{0.0, 0.0, -solverChoice.
gravity};
174 const GpuArray<Real,AMREX_SPACEDIM> grav_gpu{grav[0], grav[1], grav[2]};
181 const DistributionMapping& dm = S_data[
IntVars::cons].DistributionMap();
183 MultiFab Omega(convert(ba,IntVect(0,0,1)), dm, 1, 1);
185 std::unique_ptr<MultiFab> expr;
186 std::unique_ptr<MultiFab> dflux_x;
187 std::unique_ptr<MultiFab> dflux_y;
188 std::unique_ptr<MultiFab> dflux_z;
193 Tau11,Tau22,Tau33,Tau12,Tau13,Tau21,Tau23,Tau31,Tau32,
194 SmnSmn,eddyDiffs,geom,solverChoice,most,
195 detJ,mapfac_m,mapfac_u,mapfac_v);
197 dflux_x = std::make_unique<MultiFab>(convert(ba,IntVect(1,0,0)), dm,
nvars, 0);
198 dflux_y = std::make_unique<MultiFab>(convert(ba,IntVect(0,1,0)), dm,
nvars, 0);
199 dflux_z = std::make_unique<MultiFab>(convert(ba,IntVect(0,0,1)), dm,
nvars, 0);
206 Vector<Real> max_scal(nvar, 1.0e34); Gpu::DeviceVector<Real> max_scal_d(nvar);
207 Vector<Real> min_scal(nvar,-1.0e34); Gpu::DeviceVector<Real> min_scal_d(nvar);
208 if (l_use_mono_adv) {
211 GpuTuple<Real,Real> mm = ParReduce(TypeList<ReduceOpMax,ReduceOpMin>{},
212 TypeList<Real, Real>{},
214 [=] AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k) noexcept
215 -> GpuTuple<Real,Real>
217 return { ma_s_arr[box_no](i,j,k,ivar), ma_s_arr[box_no](i,j,k,ivar) };
219 max_scal[ivar] = get<0>(mm);
220 min_scal[ivar] = get<1>(mm);
223 Gpu::copy(Gpu::hostToDevice, max_scal.begin(), max_scal.end(), max_scal_d.begin());
224 Gpu::copy(Gpu::hostToDevice, min_scal.begin(), min_scal.end(), min_scal_d.begin());
225 Real* max_s_ptr = max_scal_d.data();
226 Real* min_s_ptr = min_scal_d.data();
235 #pragma omp parallel if (Gpu::notInLaunchRegion())
238 std::array<FArrayBox,AMREX_SPACEDIM> flux;
239 std::array<FArrayBox,AMREX_SPACEDIM> flux_tmp;
243 Box bx = mfi.tilebox();
244 Box tbx = mfi.nodaltilebox(0);
245 Box tby = mfi.nodaltilebox(1);
246 Box tbz = mfi.nodaltilebox(2);
249 if (tbz.smallEnd(2) == domain.smallEnd(2)) {
252 if (tbz.bigEnd(2) == domain.bigEnd(2)+1) {
256 const Array4<const Real> & cell_data = S_data[
IntVars::cons].array(mfi);
257 const Array4<const Real> & cell_prim = S_prim.array(mfi);
258 const Array4<Real> & cell_rhs = S_rhs[
IntVars::cons].array(mfi);
260 const Array4<const Real> & cell_old = S_old[
IntVars::cons].array(mfi);
262 const Array4<Real const>& xmom_src_arr = xmom_src.const_array(mfi);
263 const Array4<Real const>& ymom_src_arr = ymom_src.const_array(mfi);
264 const Array4<Real const>& zmom_src_arr = zmom_src.const_array(mfi);
266 const Array4<Real>& rho_u_old = S_old[
IntVars::xmom].array(mfi);
267 const Array4<Real>& rho_v_old = S_old[
IntVars::ymom].array(mfi);
271 S_scratch[
IntVars::xmom][mfi].template setVal<RunOn::Device>(0.0,tbx);
272 S_scratch[
IntVars::ymom][mfi].template setVal<RunOn::Device>(0.0,tby);
273 S_scratch[
IntVars::zmom][mfi].template setVal<RunOn::Device>(0.0,tbz);
280 const Array4<const Real> & u =
xvel.array(mfi);
281 const Array4<const Real> & v =
yvel.array(mfi);
282 const Array4<const Real> & w =
zvel.array(mfi);
284 const Array4<const Real>& rho_u = S_data[
IntVars::xmom].array(mfi);
285 const Array4<const Real>& rho_v = S_data[
IntVars::ymom].array(mfi);
286 const Array4<const Real>& rho_w = S_data[
IntVars::zmom].array(mfi);
289 const Array4<const Real>& mf_m = mapfac_m->const_array(mfi);
290 const Array4<const Real>& mf_u = mapfac_u->const_array(mfi);
291 const Array4<const Real>& mf_v = mapfac_v->const_array(mfi);
293 const Array4< Real>& omega_arr = Omega.array(mfi);
295 Array4<const Real> z_t;
297 z_t = z_t_mf->array(mfi);
299 z_t = Array4<const Real>{};
302 const Array4<Real>& rho_u_rhs = S_rhs[
IntVars::xmom].array(mfi);
303 const Array4<Real>& rho_v_rhs = S_rhs[
IntVars::ymom].array(mfi);
304 const Array4<Real>& rho_w_rhs = S_rhs[
IntVars::zmom].array(mfi);
306 const Array4<Real const>& mu_turb = l_use_turb ? eddyDiffs->const_array(mfi) : Array4<const Real>{};
309 const Array4<const Real>& z_nd = l_use_terrain_fitted_coords ? z_phys_nd->const_array(mfi) : Array4<const Real>{};
312 const Array4<const Real>& p0_arr = p0->const_array(mfi);
317 for (
int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
318 flux[dir].resize(surroundingNodes(bx,dir),2);
319 flux[dir].setVal<RunOn::Device>(0.);
320 if (l_use_mono_adv) {
321 flux_tmp[dir].resize(surroundingNodes(bx,dir),2);
322 flux_tmp[dir].setVal<RunOn::Device>(0.);
325 const GpuArray<const Array4<Real>, AMREX_SPACEDIM>
326 flx_arr{{AMREX_D_DECL(flux[0].array(), flux[1].array(), flux[2].array())}};
327 Array4<Real> tmpx = (l_use_mono_adv) ? flux_tmp[0].array() : Array4<Real>{};
328 Array4<Real> tmpy = (l_use_mono_adv) ? flux_tmp[1].array() : Array4<Real>{};
329 Array4<Real> tmpz = (l_use_mono_adv) ? flux_tmp[2].array() : Array4<Real>{};
330 const GpuArray<Array4<Real>, AMREX_SPACEDIM> flx_tmp_arr{{AMREX_D_DECL(tmpx,tmpy,tmpz)}};
337 Box gbx = mfi.tilebox(); gbx.grow(IntVect(1,1,1));
338 if (gbx.smallEnd(2) < 0) gbx.setSmall(2,0);
339 pprime.resize(gbx,1,The_Async_Arena());
340 const Array4<Real>& pptemp_arr = pprime.array();
341 ParallelFor(gbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
344 if (cell_data(i,j,k,
RhoTheta_comp) <= 0.) AMREX_DEVICE_PRINTF(
"BAD THETA AT %d %d %d %e %e \n",
345 i,j,k,cell_data(i,j,k,
RhoTheta_comp),cell_data(i,j,k+1,
RhoTheta_comp));
348 printf(
"BAD THETA AT %d %d %d %e %e \n",
349 i,j,k,cell_data(i,j,k,
RhoTheta_comp),cell_data(i,j,k+1,
RhoTheta_comp));
350 amrex::Abort(
"Bad theta in ERF_slow_rhs_pre");
353 Real qv_for_p = (l_use_moisture) ? cell_data(i,j,k,
RhoQ1_comp)/cell_data(i,j,k,
Rho_comp) : 0.0;
358 const Array4<const Real>& pp_arr = (l_anelastic) ? pp_inc.const_array(mfi) : pprime.const_array();
364 BL_PROFILE(
"slow_rhs_making_omega");
365 Box gbxo = surroundingNodes(bx,2); gbxo.grow(IntVect(1,1,1));
371 if (!l_use_terrain_fitted_coords) {
372 ParallelFor(gbxo, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
373 omega_arr(i,j,k) = rho_w(i,j,k);
378 Box gbxo_lo = gbxo; gbxo_lo.setBig(2,domain.smallEnd(2));
379 int lo_z_face = domain.smallEnd(2);
380 if (gbxo_lo.smallEnd(2) <= lo_z_face) {
381 ParallelFor(gbxo_lo, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
382 omega_arr(i,j,k) = 0.;
385 Box gbxo_hi = gbxo; gbxo_hi.setSmall(2,gbxo.bigEnd(2));
386 int hi_z_face = domain.bigEnd(2)+1;
387 if (gbxo_hi.bigEnd(2) >= hi_z_face) {
388 ParallelFor(gbxo_hi, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
389 omega_arr(i,j,k) = rho_w(i,j,k);
394 Box gbxo_mid = gbxo; gbxo_mid.setSmall(2,1); gbxo_mid.setBig(2,gbxo.bigEnd(2)-1);
395 ParallelFor(gbxo_mid, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
397 Real rho_at_face = 0.5 * (cell_data(i,j,k,
Rho_comp) + cell_data(i,j,k-1,
Rho_comp));
398 omega_arr(i,j,k) =
OmegaFromW(i,j,k,rho_w(i,j,k),rho_u,rho_v,z_nd,dxInv) -
399 rho_at_face * z_t(i,j,k);
403 if (gbxo_mid.smallEnd(2) <= domain.smallEnd(2)) {
404 gbxo_mid.setSmall(2,1);
406 if (gbxo_mid.bigEnd(2) >= domain.bigEnd(2)+1) {
407 gbxo_mid.setBig(2,gbxo.bigEnd(2)-1);
409 ParallelFor(gbxo_mid, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
410 omega_arr(i,j,k) =
OmegaFromW(i,j,k,rho_w(i,j,k),rho_u,rho_v,z_nd,dxInv);
421 Array4<Real> tau11,tau22,tau33;
422 Array4<Real> tau12,tau13,tau23;
424 tau11 = Tau11->array(mfi); tau22 = Tau22->array(mfi); tau33 = Tau33->array(mfi);
425 tau12 = Tau12->array(mfi); tau13 = Tau13->array(mfi); tau23 = Tau23->array(mfi);
427 tau11 = Array4<Real>{}; tau22 = Array4<Real>{}; tau33 = Array4<Real>{};
428 tau12 = Array4<Real>{}; tau13 = Array4<Real>{}; tau23 = Array4<Real>{};
431 Array4<Real> tau21,tau31,tau32;
433 tau21 = Tau21->array(mfi); tau31 = Tau31->array(mfi); tau32 = Tau32->array(mfi);
435 tau21 = Array4<Real>{}; tau31 = Array4<Real>{}; tau32 = Array4<Real>{};
439 Array4<Real> SmnSmn_a;
441 SmnSmn_a = SmnSmn->array(mfi);
443 SmnSmn_a = Array4<Real>{};
449 Array4<const Real> ax_arr;
450 Array4<const Real> ay_arr;
451 Array4<const Real> az_arr;
452 Array4<const Real> detJ_arr;
453 Array4<const EBCellFlag> cfg_arr;
456 EBCellFlagFab
const& cfg = ebfact.getMultiEBCellFlagFab()[mfi];
457 cfg_arr = cfg.const_array();
458 ax_arr = ebfact.getAreaFrac()[0]->const_array(mfi);
459 ay_arr = ebfact.getAreaFrac()[1]->const_array(mfi);
460 az_arr = ebfact.getAreaFrac()[2]->const_array(mfi);
461 detJ_arr = ebfact.getVolFrac().const_array(mfi);
463 ax_arr = ax->const_array(mfi);
464 ay_arr = ay->const_array(mfi);
465 az_arr = az->const_array(mfi);
466 detJ_arr = detJ->const_array(mfi);
470 rho_u, rho_v, omega_arr,
471 avg_xmom, avg_ymom, avg_zmom,
472 ax_arr, ay_arr, az_arr, detJ_arr,
473 dxInv, mf_m, mf_u, mf_v,
474 flx_arr, l_const_rho);
479 avg_xmom, avg_ymom, avg_zmom,
480 cell_data, cell_prim, cell_rhs,
481 l_use_mono_adv, max_s_ptr, min_s_ptr,
482 detJ_arr, dxInv, mf_m,
483 l_horiz_adv_type, l_vert_adv_type,
484 l_horiz_upw_frac, l_vert_upw_frac,
485 flx_arr, flx_tmp_arr, domain, bc_ptr_h);
488 avg_xmom, avg_ymom, avg_zmom,
490 cfg_arr, ax_arr, ay_arr, az_arr, detJ_arr, dxInv, mf_m,
491 l_horiz_adv_type, l_vert_adv_type,
492 l_horiz_upw_frac, l_vert_upw_frac,
493 flx_arr, domain, bc_ptr_h);
497 Array4<Real> diffflux_x = dflux_x->array(mfi);
498 Array4<Real> diffflux_y = dflux_y->array(mfi);
499 Array4<Real> diffflux_z = dflux_z->array(mfi);
501 Array4<Real> hfx_x = Hfx1->array(mfi);
502 Array4<Real> hfx_y = Hfx2->array(mfi);
503 Array4<Real> hfx_z = Hfx3->array(mfi);
505 Array4<Real> q1fx_x = (Q1fx1) ? Q1fx1->array(mfi) : Array4<Real>{};
506 Array4<Real> q1fx_y = (Q1fx2) ? Q1fx2->array(mfi) : Array4<Real>{};
507 Array4<Real> q1fx_z = (Q1fx3) ? Q1fx3->array(mfi) : Array4<Real>{};
509 Array4<Real> q2fx_z = (Q2fx3) ? Q2fx3->array(mfi) : Array4<Real>{};
510 Array4<Real> diss = Diss->array(mfi);
512 const Array4<const Real> tm_arr = t_mean_mf ? t_mean_mf->const_array(mfi) : Array4<const Real>{};
516 int n_comp = end_comp - n_start + 1;
518 if (l_use_terrain_fitted_coords) {
520 cell_data, cell_prim, cell_rhs,
521 diffflux_x, diffflux_y, diffflux_z,
522 z_nd, ax_arr, ay_arr, az_arr, detJ_arr,
523 dxInv, SmnSmn_a, mf_m, mf_u, mf_v,
524 hfx_x, hfx_y, hfx_z, q1fx_x, q1fx_y, q1fx_z, q2fx_z, diss,
525 mu_turb, solverChoice, level,
526 tm_arr, grav_gpu, bc_ptr_d, l_use_most);
529 cell_data, cell_prim, cell_rhs,
530 diffflux_x, diffflux_y, diffflux_z,
531 dxInv, SmnSmn_a, mf_m, mf_u, mf_v,
532 hfx_z, q1fx_z, q2fx_z, diss,
533 mu_turb, solverChoice, level,
534 tm_arr, grav_gpu, bc_ptr_d, l_use_most);
538 const Array4<Real const>& source_arr = cc_src.const_array(mfi);
539 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
546 if (l_use_terrain_fitted_coords && l_moving_terrain) {
547 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
549 cell_rhs(i,j,k,
Rho_comp) *= detJ_arr(i,j,k);
555 if ( l_anelastic && (nrk == 1) )
557 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
570 int lo_z_face = domain.smallEnd(2);
571 int hi_z_face = domain.bigEnd(2)+1;
574 rho_u_rhs, rho_v_rhs, rho_w_rhs,
576 rho_u, rho_v, omega_arr,
577 z_nd, ax_arr, ay_arr, az_arr, detJ_arr,
578 dxInv, mf_m, mf_u, mf_v,
579 l_horiz_adv_type, l_vert_adv_type,
580 l_horiz_upw_frac, l_vert_upw_frac,
590 if (l_use_terrain_fitted_coords) {
592 rho_u_rhs, rho_v_rhs, rho_w_rhs,
601 rho_u_rhs, rho_v_rhs, rho_w_rhs,
611 ParallelFor(tbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
615 Real gp_xi = dxInv[0] * (pp_arr(i,j,k) - pp_arr(i-1,j,k));
618 if (l_use_terrain_fitted_coords) {
622 Real gp_zeta_on_iface;
624 gp_zeta_on_iface = 0.5 * dxInv[2] * (
625 pp_arr(i-1,j,k+1) + pp_arr(i,j,k+1)
626 - pp_arr(i-1,j,k ) - pp_arr(i,j,k ) );
627 }
else if (k==domhi_z) {
628 gp_zeta_on_iface = 0.5 * dxInv[2] * (
629 pp_arr(i-1,j,k ) + pp_arr(i,j,k )
630 - pp_arr(i-1,j,k-1) - pp_arr(i,j,k-1) );
632 gp_zeta_on_iface = 0.25 * dxInv[2] * (
633 pp_arr(i-1,j,k+1) + pp_arr(i,j,k+1)
634 - pp_arr(i-1,j,k-1) - pp_arr(i,j,k-1) );
636 gpx -= (met_h_xi/ met_h_zeta) * gp_zeta_on_iface;
642 if (l_use_moisture) {
647 rho_u_rhs(i, j, k) += (-gpx - abl_pressure_grad[0]) / (1.0 + q)
648 + xmom_src_arr(i,j,k);
650 if (l_moving_terrain) {
652 rho_u_rhs(i, j, k) *= h_zeta;
655 if ( l_anelastic && (nrk == 1) ) {
656 rho_u_rhs(i,j,k) *= 0.5;
657 rho_u_rhs(i,j,k) += 0.5 / dt * (rho_u(i,j,k) - rho_u_old(i,j,k));
661 ParallelFor(tby, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
665 Real gp_eta = dxInv[1] * (pp_arr(i,j,k) - pp_arr(i,j-1,k));
668 if (l_use_terrain_fitted_coords) {
671 Real gp_zeta_on_jface;
673 gp_zeta_on_jface = 0.5 * dxInv[2] * (
674 pp_arr(i,j,k+1) + pp_arr(i,j-1,k+1)
675 - pp_arr(i,j,k ) - pp_arr(i,j-1,k ) );
676 }
else if (k==domhi_z) {
677 gp_zeta_on_jface = 0.5 * dxInv[2] * (
678 pp_arr(i,j,k ) + pp_arr(i,j-1,k )
679 - pp_arr(i,j,k-1) - pp_arr(i,j-1,k-1) );
681 gp_zeta_on_jface = 0.25 * dxInv[2] * (
682 pp_arr(i,j,k+1) + pp_arr(i,j-1,k+1)
683 - pp_arr(i,j,k-1) - pp_arr(i,j-1,k-1) );
685 gpy -= (met_h_eta / met_h_zeta) * gp_zeta_on_jface;
691 if (l_use_moisture) {
696 rho_v_rhs(i, j, k) += (-gpy - abl_pressure_grad[1]) / (1.0_rt + q) + ymom_src_arr(i,j,k);
698 if (l_moving_terrain) {
700 rho_v_rhs(i, j, k) *= h_zeta;
703 if ( l_anelastic && (nrk == 1) ) {
704 rho_v_rhs(i,j,k) *= 0.5;
705 rho_v_rhs(i,j,k) += 0.5 / dt * (rho_v(i,j,k) - rho_v_old(i,j,k));
715 if ( (bx.smallEnd(0) == domain.smallEnd(0)) &&
717 Box lo_x_dom_face(bx); lo_x_dom_face.setBig(0,bx.smallEnd(0));
718 ParallelFor(lo_x_dom_face, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
719 rho_u_rhs(i,j,k) = 0.;
722 if ( (bx.bigEnd(0) == domain.bigEnd(0)) &&
724 Box hi_x_dom_face(bx); hi_x_dom_face.setSmall(0,bx.bigEnd(0)+1); hi_x_dom_face.setBig(0,bx.bigEnd(0)+1);
725 ParallelFor(hi_x_dom_face, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
726 rho_u_rhs(i,j,k) = 0.;
729 if ( (bx.smallEnd(1) == domain.smallEnd(1)) &&
731 Box lo_y_dom_face(bx); lo_y_dom_face.setBig(1,bx.smallEnd(1));
732 ParallelFor(lo_y_dom_face, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
733 rho_v_rhs(i,j,k) = 0.;
736 if ( (bx.bigEnd(1) == domain.bigEnd(1)) &&
738 Box hi_y_dom_face(bx); hi_y_dom_face.setSmall(1,bx.bigEnd(1)+1); hi_y_dom_face.setBig(1,bx.bigEnd(1)+1);
739 ParallelFor(hi_y_dom_face, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
740 rho_v_rhs(i,j,k) = 0.;
745 ParallelFor(tbz, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
749 Real gpz = dxInv[2] * ( pp_arr(i,j,k)-pp_arr(i,j,k-1) ) / met_h_zeta;
752 if (l_use_moisture) {
756 rho_w_rhs(i, j, k) += (zmom_src_arr(i,j,k) - gpz - abl_pressure_grad[2]) / (1.0_rt + q);
758 if (l_use_terrain_fitted_coords && l_moving_terrain) {
759 rho_w_rhs(i, j, k) *= 0.5 * (detJ_arr(i,j,k) + detJ_arr(i,j,k-1));
763 auto const lo = lbound(bx);
764 auto const hi = ubound(bx);
769 const Array4<const Real>& rho_w_rhs_crse = zmom_crse_rhs->const_array(mfi);
771 Box b2d = bx; b2d.setRange(2,0);
773 if (lo.z > domlo_z) {
774 ParallelFor(b2d, [=] AMREX_GPU_DEVICE (
int i,
int j,
int )
776 rho_w_rhs(i,j,lo.z) = rho_w_rhs_crse(i,j,lo.z);
780 if (hi.z < domhi_z+1) {
781 ParallelFor(b2d, [=] AMREX_GPU_DEVICE (
int i,
int j,
int )
783 rho_w_rhs(i,j,hi.z+1) = rho_w_rhs_crse(i,j,hi.z+1);
789 BL_PROFILE(
"slow_rhs_pre_fluxreg");
793 if (l_reflux && nrk == 2) {
794 int strt_comp_reflux = (l_const_rho) ? 1 : 0;
795 int num_comp_reflux = 1;
796 if (level < finest_level) {
797 fr_as_crse->CrseAdd(mfi,
798 {{AMREX_D_DECL(&(flux[0]), &(flux[1]), &(flux[2]))}},
799 dx, dt, strt_comp_reflux, strt_comp_reflux, num_comp_reflux, RunOn::Device);
802 fr_as_fine->FineAdd(mfi,
803 {{AMREX_D_DECL(&(flux[0]), &(flux[1]), &(flux[2]))}},
804 dx, dt, strt_comp_reflux, strt_comp_reflux, num_comp_reflux, RunOn::Device);
810 Gpu::streamSynchronize();
void AdvectionSrcForRho(const amrex::Box &bx, const amrex::Array4< amrex::Real > &src, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &omega, const amrex::Array4< amrex::Real > &avg_xmom, const amrex::Array4< amrex::Real > &avg_ymom, const amrex::Array4< amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &ax_arr, const amrex::Array4< const amrex::Real > &ay_arr, const amrex::Array4< const amrex::Real > &az_arr, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_m, const amrex::Array4< const amrex::Real > &mf_u, const amrex::Array4< const amrex::Real > &mf_v, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const bool const_rho)
void AdvectionSrcForMom(const amrex::Box &bx, const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &rho, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_m, const amrex::Array4< const amrex::Real > &mf_u, const amrex::Array4< const amrex::Real > &mf_v, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, TerrainType &terrain_type, const int lo_z_face, const int hi_z_face, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h)
void AdvectionSrcForScalars(const amrex::Real &dt, const amrex::Box &bx, const int icomp, const int ncomp, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &cur_cons, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &src, const bool &use_mono_adv, amrex::Real *max_s_ptr, amrex::Real *min_s_ptr, const amrex::Array4< const amrex::Real > &vf_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_m, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const amrex::GpuArray< amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_tmp_arr, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h)
@ nvars
Definition: ERF_DataStruct.H:70
void DiffusionSrcForMom_N(const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &tau11, const amrex::Array4< const amrex::Real > &tau22, const amrex::Array4< const amrex::Real > &tau33, const amrex::Array4< const amrex::Real > &tau12, const amrex::Array4< const amrex::Real > &tau13, const amrex::Array4< const amrex::Real > &tau23, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const amrex::Array4< const amrex::Real > &mf_m, const amrex::Array4< const amrex::Real > &mf_u, const amrex::Array4< const amrex::Real > &mf_v)
void DiffusionSrcForState_N(const amrex::Box &bx, const amrex::Box &domain, int start_comp, int num_comp, const bool &exp_most, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &cell_rhs, const amrex::Array4< amrex::Real > &xflux, const amrex::Array4< amrex::Real > &yflux, const amrex::Array4< amrex::Real > &zflux, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &SmnSmn_a, const amrex::Array4< const amrex::Real > &mf_m, const amrex::Array4< const amrex::Real > &mf_u, const amrex::Array4< const amrex::Real > &mf_v, amrex::Array4< amrex::Real > &hfx_z, amrex::Array4< amrex::Real > &qfx1_z, amrex::Array4< amrex::Real > &qfx2_z, amrex::Array4< amrex::Real > &diss, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::Array4< const amrex::Real > &tm_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > grav_gpu, const amrex::BCRec *bc_ptr, const bool use_most)
void DiffusionSrcForMom_T(const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &tau11, const amrex::Array4< const amrex::Real > &tau22, const amrex::Array4< const amrex::Real > &tau33, const amrex::Array4< const amrex::Real > &tau12, const amrex::Array4< const amrex::Real > &tau13, const amrex::Array4< const amrex::Real > &tau21, const amrex::Array4< const amrex::Real > &tau23, const amrex::Array4< const amrex::Real > &tau31, const amrex::Array4< const amrex::Real > &tau32, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const amrex::Array4< const amrex::Real > &mf_m, const amrex::Array4< const amrex::Real > &mf_u, const amrex::Array4< const amrex::Real > &mf_v)
void DiffusionSrcForState_T(const amrex::Box &bx, const amrex::Box &domain, int start_comp, int num_comp, const bool &exp_most, const bool &rot_most, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &cell_rhs, const amrex::Array4< amrex::Real > &xflux, const amrex::Array4< amrex::Real > &yflux, const amrex::Array4< amrex::Real > &zflux, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const amrex::Array4< const amrex::Real > &SmnSmn_a, const amrex::Array4< const amrex::Real > &mf_m, const amrex::Array4< const amrex::Real > &mf_u, const amrex::Array4< const amrex::Real > &mf_v, amrex::Array4< amrex::Real > &hfx_x, amrex::Array4< amrex::Real > &hfx_y, amrex::Array4< amrex::Real > &hfx_z, amrex::Array4< amrex::Real > &qfx1_x, amrex::Array4< amrex::Real > &qfx1_y, amrex::Array4< amrex::Real > &qfx1_z, amrex::Array4< amrex::Real > &qfx2_z, amrex::Array4< amrex::Real > &diss, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::Array4< const amrex::Real > &tm_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > grav_gpu, const amrex::BCRec *bc_ptr, const bool use_most)
void EBAdvectionSrcForScalars(const amrex::Box &bx, const int icomp, const int ncomp, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &src, const amrex::Array4< const amrex::EBCellFlag > &cfg_arr, const amrex::Array4< const amrex::Real > &ax_arr, const amrex::Array4< const amrex::Real > &ay_arr, const amrex::Array4< const amrex::Real > &az_arr, const amrex::Array4< const amrex::Real > &vf_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_m, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh(const amrex::Real rhotheta, const amrex::Real qv=0.)
Definition: ERF_EOS.H:84
#define PrimQ1_comp
Definition: ERF_IndexDefines.H:53
#define PrimQ2_comp
Definition: ERF_IndexDefines.H:54
#define Rho_comp
Definition: ERF_IndexDefines.H:36
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:37
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:42
AdvType
Definition: ERF_IndexDefines.H:191
#define RhoKE_comp
Definition: ERF_IndexDefines.H:38
void erf_make_tau_terms(int level, int nrk, const Vector< BCRec > &domain_bcs_type_h, std::unique_ptr< MultiFab > &z_phys_nd, Vector< MultiFab > &S_data, const MultiFab &xvel, const MultiFab &yvel, const MultiFab &zvel, MultiFab *Tau11, MultiFab *Tau22, MultiFab *Tau33, MultiFab *Tau12, MultiFab *Tau13, MultiFab *Tau21, MultiFab *Tau23, MultiFab *Tau31, MultiFab *Tau32, MultiFab *SmnSmn, MultiFab *eddyDiffs, const Geometry geom, const SolverChoice &solverChoice, std::unique_ptr< ABLMost > &most, std::unique_ptr< MultiFab > &detJ, std::unique_ptr< MultiFab > &mapfac_m, std::unique_ptr< MultiFab > &mapfac_u, std::unique_ptr< MultiFab > &mapfac_v)
Definition: ERF_MakeTauTerms.cpp:12
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:101
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtKface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:173
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real OmegaFromW(int i, int j, int k, amrex::Real w, const amrex::Array4< const amrex::Real > u_arr, const amrex::Array4< const amrex::Real > v_arr, const amrex::Array4< const amrex::Real > z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv)
Definition: ERF_TerrainMetrics.H:374
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:87
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtJface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:130
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtJface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:158
AMREX_FORCE_INLINE amrex::IntVect TileNoZ()
Definition: ERF_TileNoZ.H:11
@ yvel_bc
Definition: ERF_IndexDefines.H:89
@ xvel_bc
Definition: ERF_IndexDefines.H:88
@ ext_dir
Definition: ERF_IndexDefines.H:180
@ ymom
Definition: ERF_IndexDefines.H:141
@ cons
Definition: ERF_IndexDefines.H:139
@ zmom
Definition: ERF_IndexDefines.H:142
@ xmom
Definition: ERF_IndexDefines.H:140
@ xvel
Definition: ERF_IndexDefines.H:130
@ zvel
Definition: ERF_IndexDefines.H:132
@ yvel
Definition: ERF_IndexDefines.H:131
AdvType dycore_vert_adv_type
Definition: ERF_AdvStruct.H:283
amrex::Real dycore_vert_upw_frac
Definition: ERF_AdvStruct.H:293
AdvType dycore_horiz_adv_type
Definition: ERF_AdvStruct.H:282
amrex::Real dycore_horiz_upw_frac
Definition: ERF_AdvStruct.H:292
Definition: ERF_DiffStruct.H:19
MolecDiffType molec_diff_type
Definition: ERF_DiffStruct.H:84
bool use_explicit_most
Definition: ERF_DataStruct.H:658
bool use_mono_adv
Definition: ERF_DataStruct.H:674
DiffChoice diffChoice
Definition: ERF_DataStruct.H:592
amrex::Real gravity
Definition: ERF_DataStruct.H:630
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_pressure_grad
Definition: ERF_DataStruct.H:683
amrex::Vector< TurbChoice > turbChoice
Definition: ERF_DataStruct.H:594
amrex::Vector< int > anelastic
Definition: ERF_DataStruct.H:602
int constant_density
Definition: ERF_DataStruct.H:604
AdvChoice advChoice
Definition: ERF_DataStruct.H:591
MoistureType moisture_type
Definition: ERF_DataStruct.H:677
static TerrainType terrain_type
Definition: ERF_DataStruct.H:580
bool use_rotate_most
Definition: ERF_DataStruct.H:661
CouplingType coupling_type
Definition: ERF_DataStruct.H:676
Definition: ERF_TurbStruct.H:31
PBLType pbl_type
Definition: ERF_TurbStruct.H:241
RANSType rans_type
Definition: ERF_TurbStruct.H:238
LESType les_type
Definition: ERF_TurbStruct.H:205