Function for computing the implicit contribution to the vertical diffusion of momentum, with a uniform grid and no terrain.
This function (explicitly instantiated below) handles staggering in x or y through the template parameter, stagdir.
333 const bool has_wall_face =
static_cast<bool>(wall_face);
335 BL_PROFILE_VAR(
"ImplicitDiffForMom_N()",ImplicitDiffForMom_N);
350 constexpr
int ioff = (stagdir == 0) ? 1 : 0;
351 constexpr
int joff = (stagdir == 1) ? 1 : 0;
354 int ilo = bx.smallEnd(0);
355 int ihi = bx.bigEnd(0);
356 int jlo = bx.smallEnd(1);
357 int jhi = bx.bigEnd(1);
358 int box_klo = bx.smallEnd(2);
359 int box_khi = bx.bigEnd(2);
360 amrex::ignore_unused(ilo, ihi, jlo, jhi);
364 const int dom_klo = domain.smallEnd(2);
365 const int dom_khi = domain.bigEnd(2);
369 amrex::FArrayBox RHS_fab, soln_fab, coeffG_fab;
370 RHS_fab.resize(bx,1, amrex::The_Async_Arena());
371 soln_fab.resize(bx,1, amrex::The_Async_Arena());
372 coeffG_fab.resize(bx,1, amrex::The_Async_Arena());
373 auto const& RHS_a = RHS_fab.array();
374 auto const& soln_a = soln_fab.array();
375 auto const& coeffG_a = coeffG_fab.array();
377 Real dz_inv = cellSizeInv[2];
386 amrex::ignore_unused(foextrap_on_zlo,foextrap_on_zhi);
389 "Unexpected lower BC for momentum used with implicit vertical diffusion");
391 "Unexpected upper BC for momentum used with implicit vertical diffusion");
393 Real Fact = implicit_fac * dt * dz_inv;
396 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
399 for (
int j(jlo); j<=jhi; ++j) {
400 for (
int i(ilo); i<=ihi; ++i) {
410 const int klo = amrex::max(box_klo, col_kext(i-ioff,j-joff,0,0),
411 col_kext(i ,j ,0,0));
412 const int khi = amrex::min(box_khi, col_kext(i-ioff,j-joff,0,1),
413 col_kext(i ,j ,0,1));
417 if (
khi <=
klo) {
return; }
419 if (
khi <=
klo) {
continue; }
456 Real rhoface, rhoAlpha_lo, rhoAlpha_hi;
457 Real a_tmp, b_tmp, c_tmp, inv_b2_tmp;
461 cell_data, mu_turb, mu_eff,
465 c_tmp = -Fact * rhoAlpha_hi * dz_inv;
466 if (has_wall_face) { c_tmp *= wall_face(i,j,
klo+1); }
468 RHS_a(i,j,
klo) = face_data(i,j,
klo);
472 if (
klo != dom_klo) {
475 a_tmp = -Fact * rhoAlpha_lo * dz_inv;
476 RHS_a(i,j,
klo) += Fact * (tau_corr(i,j,
klo+1) - tau_corr(i,j,
klo));
479 RHS_a(i,j,
klo) -= a_tmp * (face_data(i,j,
klo-1) / rho_below);
480 }
else if (ext_dir_on_zlo) {
481 RHS_a(i,j,
klo) += Fact * (tau_corr(i,j,
klo+1) - tau_corr(i,j,
klo));
486 a_tmp = Fact * rhoAlpha_lo * dz_inv * wc.c_wall;
487 c_tmp += Fact * rhoAlpha_lo * dz_inv * wc.c_1;
490 const Real wall_velocity = face_data(i,j,
klo-1) / rho_wall;
491 RHS_a(i,j,
klo) -= a_tmp * wall_velocity;
492 }
else if (use_SurfLayer) {
494 RHS_a(i,j,
klo) += Fact * (tau_corr(i,j,
klo+1) - tau(i,j,
klo));
495 RHS_a(i,j,
klo) += Fact * tau(i,j,
klo);
498 RHS_a(i,j,
klo) += Fact * (tau_corr(i,j,
klo+1) - tau_corr(i,j,
klo));
510 if (use_ysu_mom_countergradient) {
513 const Real gam_klo =
myhalf * (mu_turb(i,j,
klo ,hgam_comp) + mu_turb(i-ioff,j-joff,
klo ,hgam_comp));
514 const Real gam_kp1 =
myhalf * (mu_turb(i,j,
klo+1,hgam_comp) + mu_turb(i-ioff,j-joff,
klo+1,hgam_comp));
515 const Real gam_hi =
myhalf * (gam_klo + gam_kp1);
516 RHS_a(i,j,
klo) -= Fact * rhoAlpha_hi * gam_hi;
517 if (
klo != dom_klo) {
518 const Real gam_km1 =
myhalf * (mu_turb(i,j,
klo-1,hgam_comp) + mu_turb(i-ioff,j-joff,
klo-1,hgam_comp));
519 const Real gam_lo =
myhalf * (gam_klo + gam_km1);
520 RHS_a(i,j,
klo) += Fact * rhoAlpha_lo * gam_lo;
525 if (has_wall_face) { a_tmp *= wall_face(i,j,
klo); }
526 b_tmp = rhoface - a_tmp - c_tmp;
529 RHS_a(i,j,
klo) /= b_tmp;
530 coeffG_a(i,j,
klo) = c_tmp / b_tmp;
535 for (
int k(
klo+1); k <
khi; k++) {
538 cell_data, mu_turb, mu_eff,
541 a_tmp = -Fact * rhoAlpha_lo * dz_inv;
542 c_tmp = -Fact * rhoAlpha_hi * dz_inv;
544 a_tmp *= wall_face(i,j,k);
545 c_tmp *= wall_face(i,j,k+1);
547 b_tmp = rhoface - a_tmp - c_tmp;
548 inv_b2_tmp =
one/ (b_tmp - a_tmp * coeffG_a(i,j,k-1));
550 RHS_a(i,j,k) = face_data(i,j,k);
551 RHS_a(i,j,k) += Fact * (tau_corr(i,j,k+1) - tau_corr(i,j,k));
554 if (use_ysu_mom_countergradient) {
557 const Real gam_k =
myhalf * (mu_turb(i,j,k ,hgam_comp) + mu_turb(i-ioff,j-joff,k ,hgam_comp));
558 const Real gam_km1 =
myhalf * (mu_turb(i,j,k-1,hgam_comp) + mu_turb(i-ioff,j-joff,k-1,hgam_comp));
559 const Real gam_kp1 =
myhalf * (mu_turb(i,j,k+1,hgam_comp) + mu_turb(i-ioff,j-joff,k+1,hgam_comp));
560 const Real gam_hi =
myhalf * (gam_k + gam_kp1);
561 const Real gam_lo =
myhalf * (gam_k + gam_km1);
562 RHS_a(i,j,k) -= Fact * (rhoAlpha_hi * gam_hi - rhoAlpha_lo * gam_lo);
565 RHS_a(i,j,k) = (RHS_a(i,j,k) - a_tmp * RHS_a(i,j,k-1)) * inv_b2_tmp;
566 coeffG_a(i,j,k) = c_tmp * inv_b2_tmp;
574 cell_data, mu_turb, mu_eff,
577 a_tmp = -Fact * rhoAlpha_lo * dz_inv;
579 if (has_wall_face) { a_tmp *= wall_face(i,j,
khi); }
581 RHS_a(i,j,
khi) = face_data(i,j,
khi);
582 RHS_a(i,j,
khi) += Fact * (tau_corr(i,j,
khi+1) - tau_corr(i,j,
khi));
586 if (
khi != dom_khi) {
589 c_tmp = -Fact * rhoAlpha_hi * dz_inv;
592 RHS_a(i,j,
khi) -= c_tmp * (face_data(i,j,
khi+1) / rho_above);
593 }
else if (ext_dir_on_zhi) {
598 c_tmp = Fact * rhoAlpha_hi * dz_inv * wc.
c_wall;
599 a_tmp += Fact * rhoAlpha_hi * dz_inv * wc.
c_1;
602 const Real wall_velocity = face_data(i,j,
khi+1) / rho_wall;
603 RHS_a(i,j,
khi) -= c_tmp * wall_velocity;
612 if (use_ysu_mom_countergradient) {
615 const Real gam_khi =
myhalf * (mu_turb(i,j,
khi ,hgam_comp) + mu_turb(i-ioff,j-joff,
khi ,hgam_comp));
616 const Real gam_km1 =
myhalf * (mu_turb(i,j,
khi-1,hgam_comp) + mu_turb(i-ioff,j-joff,
khi-1,hgam_comp));
617 const Real gam_lo =
myhalf * (gam_khi + gam_km1);
618 RHS_a(i,j,
khi) += Fact * rhoAlpha_lo * gam_lo;
619 if (
khi != dom_khi) {
620 const Real gam_kp1 =
myhalf * (mu_turb(i,j,
khi+1,hgam_comp) + mu_turb(i-ioff,j-joff,
khi+1,hgam_comp));
621 const Real gam_hi =
myhalf * (gam_khi + gam_kp1);
622 RHS_a(i,j,
khi) -= Fact * rhoAlpha_hi * gam_hi;
626 b_tmp = rhoface - a_tmp - c_tmp;
627 inv_b2_tmp =
one/ (b_tmp - a_tmp * coeffG_a(i,j,
khi-1));
630 soln_a(i,j,
khi) = (RHS_a(i,j,
khi) - a_tmp * RHS_a(i,j,
khi-1)) * inv_b2_tmp;
635 for (
int k(
khi-1); k>=
klo; --k) {
636 soln_a(i,j,k) = RHS_a(i,j,k) - coeffG_a(i,j,k) * soln_a(i,j,k+1);
641 for (
int k(
klo); k<=
khi; ++k) {
643 face_data(i,j,k) = rhoface * soln_a(i,j,k);
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void getRhoAlphaForFaces(int i, int j, int k, int ioff, int joff, amrex::Real &rhoAlpha_lo, amrex::Real &rhoAlpha_hi, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &mu_turb, const amrex::Real mu_eff, bool l_consA, bool l_turb, const int eddy_comp=EddyDiff::Mom_v)
Definition: ERF_GetRhoAlphaForFaces.H:23
#define Rho_comp
Definition: ERF_IndexDefines.H:53
const int khi
Definition: ERF_InitCustomPert_Bubble.H:25
const int klo
Definition: ERF_InitCustomPert_KE.H:9
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
AMREX_ASSERT_WITH_MESSAGE(wbar_cutoff_min > wbar_cutoff_max, "ERROR: wbar_cutoff_min < wbar_cutoff_max")
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE WallGradCoeffs WallGradientCoeffsUniform() noexcept
Definition: ERF_WallGradientCoeffs.H:46
@ xvel_bc
Definition: ERF_IndexDefines.H:126
@ foextrap
Definition: ERF_IndexDefines.H:339
@ ext_dir
Definition: ERF_IndexDefines.H:340
@ ext_dir_prim
Definition: ERF_IndexDefines.H:343
@ HGAMU_v
Definition: ERF_IndexDefines.H:302
@ HGAMV_v
Definition: ERF_IndexDefines.H:303
Definition: ERF_DiffStruct.H:24
MolecDiffType molec_diff_type
Selected molecular transport model.
Definition: ERF_DiffStruct.H:96
amrex::Real dynamic_viscosity
Dynamic viscosity for momentum diffusion [kg/(m-s)].
Definition: ERF_DiffStruct.H:108
amrex::Real rho0_trans
Reference density used to compute dynamic diffusion coefficients [kg/m3].
Definition: ERF_DiffStruct.H:103
amrex::Vector< TurbChoice > turbChoice
Turbulence options for each AMR level.
Definition: ERF_DataStruct.H:2620
DiffChoice diffChoice
Diffusion-related options.
Definition: ERF_DataStruct.H:2617
Definition: ERF_TurbStruct.H:119
bool use_kturb
Whether any turbulence model is active.
Definition: ERF_TurbStruct.H:977
Definition: ERF_WallGradientCoeffs.H:25
amrex::Real c_wall
Definition: ERF_WallGradientCoeffs.H:26
amrex::Real c_1
Definition: ERF_WallGradientCoeffs.H:28