Function for computing the implicit contribution to the vertical diffusion of momentum, over terrain.
This function (explicitly instantiated below) handles staggering in x, y, or z through the template parameter, stagdir. NOTE: implicit diffusion of w has remains an experimental feature and has not been tested yet with terrain.
264 BL_PROFILE_VAR(
"ImplicitDiffForMom_T()",ImplicitDiffForMom_T);
283 constexpr
int ioff = (stagdir == 0) ? 1 : 0;
284 constexpr
int joff = (stagdir == 1) ? 1 : 0;
287 int ilo = bx.smallEnd(0);
288 int ihi = bx.bigEnd(0);
289 int jlo = bx.smallEnd(1);
290 int jhi = bx.bigEnd(1);
291 int klo = bx.smallEnd(2);
292 int khi = bx.bigEnd(2);
293 amrex::ignore_unused(ilo, ihi, jlo, jhi);
297 amrex::FArrayBox RHS_fab, soln_fab, coeffG_fab;
298 RHS_fab.resize(bx,1, amrex::The_Async_Arena());
299 soln_fab.resize(bx,1, amrex::The_Async_Arena());
300 coeffG_fab.resize(bx,1, amrex::The_Async_Arena());
301 auto const& RHS_a = RHS_fab.array();
302 auto const& soln_a = soln_fab.array();
303 auto const& coeffG_a = coeffG_fab.array();
305 Real dz_inv = cellSizeInv[2];
314 amrex::ignore_unused(foextrap_on_zlo,foextrap_on_zhi);
317 "Unexpected lower BC for momentum used with implicit vertical diffusion");
319 "Unexpected upper BC for momentum used with implicit vertical diffusion");
321 Real Fact = implicit_fac * dt * dz_inv;
324 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
327 for (
int j(jlo); j<=jhi; ++j) {
328 for (
int i(ilo); i<=ihi; ++i) {
369 Real rhoface, rhoAlpha_lo, rhoAlpha_hi;
370 Real detJface, met_h_zeta_lo, met_h_zeta_hi;
371 Real a_tmp, b_tmp, c_tmp, inv_b2_tmp;
373 detJface =
myhalf * (detJ(i,j,klo) + detJ(i-ioff,j-joff,klo));
376 cell_data, mu_turb, mu_eff,
385 c_tmp = -Fact * gfac * rhoAlpha_hi * dz_inv / met_h_zeta_hi;
387 RHS_a(i,j,klo) = detJface * face_data(i,j,klo);
390 if (ext_dir_on_zlo) {
391 RHS_a(i,j,klo) += Fact * gfac * (tau_corr(i,j,klo+1) - tau_corr(i,j,klo));
394 RHS_a(i,j,klo) =
zero;
397 a_tmp = -
two * Fact * rhoAlpha_lo * dz_inv / met_h_zeta_lo;
398 RHS_a(i,j,klo) +=
two * rhoAlpha_lo * face_data(i,j,klo-1) * dz_inv * dz_inv / met_h_zeta_lo;
400 }
else if (use_SurfLayer) {
402 RHS_a(i,j,klo) += Fact * gfac * (tau_corr(i,j,klo+1) - tau(i,j,klo));
403 RHS_a(i,j,klo) += Fact * tau(i,j,klo);
406 RHS_a(i,j,klo) += Fact * gfac * (tau_corr(i,j,klo+1) - tau_corr(i,j,klo));
410 if (use_ysu_mom_countergradient && stagdir < 2) {
412 const Real gam_hi =
myhalf * (mu_turb(i,j,klo,hgam_comp) + mu_turb(i,j,klo+1,hgam_comp));
413 RHS_a(i,j,klo) += Fact * gfac * rhoAlpha_hi * gam_hi / met_h_zeta_hi;
416 b_tmp = detJface * rhoface - a_tmp - c_tmp;
419 RHS_a(i,j,klo) /= b_tmp;
420 coeffG_a(i,j,klo) = c_tmp / b_tmp;
425 for (
int k(klo+1); k <
khi; k++) {
426 detJface =
myhalf * (detJ(i,j,k) + detJ(i-ioff,j-joff,k));
429 cell_data, mu_turb, mu_eff,
437 a_tmp = -Fact * rhoAlpha_lo * dz_inv / met_h_zeta_lo;
438 c_tmp = -Fact * rhoAlpha_hi * dz_inv / met_h_zeta_hi;
439 b_tmp = detJface * rhoface - a_tmp - c_tmp;
440 inv_b2_tmp =
one / (b_tmp - a_tmp * coeffG_a(i,j,k-1));
442 RHS_a(i,j,k) = detJface * face_data(i,j,k);
443 RHS_a(i,j,k) += Fact * gfac * (tau_corr(i,j,k+1) - tau_corr(i,j,k));
446 if (use_ysu_mom_countergradient && stagdir < 2) {
448 const Real gam_k = mu_turb(i, j, k, hgam_comp);
449 const Real gam_km1 = mu_turb(i, j, k-1, hgam_comp);
450 const Real gam_kp1 = mu_turb(i, j, k+1, hgam_comp);
451 const Real gam_hi =
myhalf * (gam_k + gam_kp1);
452 const Real gam_lo =
myhalf * (gam_k + gam_km1);
453 RHS_a(i,j,k) += Fact * gfac * (rhoAlpha_hi * gam_hi / met_h_zeta_hi - rhoAlpha_lo * gam_lo / met_h_zeta_lo);
456 RHS_a(i,j,k) = (RHS_a(i,j,k) - a_tmp * RHS_a(i,j,k-1)) * inv_b2_tmp;
457 coeffG_a(i,j,k) = c_tmp * inv_b2_tmp;
463 detJface =
myhalf * (detJ(i,j,
khi) + detJ(i-ioff,j-joff,
khi));
466 cell_data, mu_turb, mu_eff,
474 a_tmp = -Fact * gfac * rhoAlpha_lo * dz_inv / met_h_zeta_lo;
477 RHS_a(i,j,
khi) = detJface * face_data(i,j,
khi);
478 RHS_a(i,j,
khi) += Fact * gfac * (tau_corr(i,j,
khi+1) - tau_corr(i,j,
khi));
481 if (ext_dir_on_zhi) {
487 c_tmp = -
two * Fact * rhoAlpha_hi * dz_inv / met_h_zeta_hi;
488 RHS_a(i,j,
khi) +=
two * rhoAlpha_hi * face_data(i,j,
khi+1) * dz_inv * dz_inv / met_h_zeta_hi;
492 b_tmp = detJface * rhoface - a_tmp - c_tmp;
493 inv_b2_tmp =
one / (b_tmp - a_tmp * coeffG_a(i,j,
khi-1));
496 soln_a(i,j,
khi) = (RHS_a(i,j,
khi) - a_tmp * RHS_a(i,j,
khi-1)) * inv_b2_tmp;
501 for (
int k(
khi-1); k>=klo; --k) {
502 soln_a(i,j,k) = RHS_a(i,j,k) - coeffG_a(i,j,k) * soln_a(i,j,k+1);
507 for (
int k(klo); k<=
khi; ++k) {
509 face_data(i,j,k) = rhoface * soln_a(i,j,k);
constexpr amrex::Real three
Definition: ERF_Constants.H:11
constexpr amrex::Real two
Definition: ERF_Constants.H:10
constexpr amrex::Real one
Definition: ERF_Constants.H:9
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13
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)
Definition: ERF_GetRhoAlphaForFaces.H:5
#define Rho_comp
Definition: ERF_IndexDefines.H:36
const int khi
Definition: ERF_InitCustomPert_Bubble.H:21
ParallelFor(grown_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);})
bool l_turb
Definition: ERF_SetupVertDiff.H:9
bool l_consA
Definition: ERF_SetupVertDiff.H:8
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:184
AMREX_ASSERT_WITH_MESSAGE(wbar_cutoff_min > wbar_cutoff_max, "ERROR: wbar_cutoff_min < wbar_cutoff_max")
@ xvel_bc
Definition: ERF_IndexDefines.H:102
@ foextrap
Definition: ERF_IndexDefines.H:247
@ ext_dir
Definition: ERF_IndexDefines.H:248
@ ext_dir_prim
Definition: ERF_IndexDefines.H:251
@ HGAMU_v
Definition: ERF_IndexDefines.H:218
@ HGAMV_v
Definition: ERF_IndexDefines.H:219
Definition: ERF_DiffStruct.H:19
amrex::Real rho0_trans
Definition: ERF_DiffStruct.H:91
MolecDiffType molec_diff_type
Definition: ERF_DiffStruct.H:84
amrex::Real dynamic_viscosity
Definition: ERF_DiffStruct.H:96
DiffChoice diffChoice
Definition: ERF_DataStruct.H:1248
amrex::Vector< TurbChoice > turbChoice
Definition: ERF_DataStruct.H:1251
Definition: ERF_TurbStruct.H:82
bool use_kturb
Definition: ERF_TurbStruct.H:577