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, y, or z through the template parameter, stagdir.
247 BL_PROFILE_VAR(
"ImplicitDiffForMom_N()",ImplicitDiffForMom_N);
258 constexpr
Real molec_fac = (stagdir == 2) ?
two :
one;
269 constexpr
int ioff = (stagdir == 0) ? 1 : 0;
270 constexpr
int joff = (stagdir == 1) ? 1 : 0;
273 int ilo = bx.smallEnd(0);
274 int ihi = bx.bigEnd(0);
275 int jlo = bx.smallEnd(1);
276 int jhi = bx.bigEnd(1);
277 int klo = bx.smallEnd(2);
278 int khi = bx.bigEnd(2);
279 amrex::ignore_unused(ilo, ihi, jlo, jhi);
283 amrex::FArrayBox RHS_fab, soln_fab, coeffG_fab;
284 RHS_fab.resize(bx,1, amrex::The_Async_Arena());
285 soln_fab.resize(bx,1, amrex::The_Async_Arena());
286 coeffG_fab.resize(bx,1, amrex::The_Async_Arena());
287 auto const& RHS_a = RHS_fab.array();
288 auto const& soln_a = soln_fab.array();
289 auto const& coeffG_a = coeffG_fab.array();
291 Real dz_inv = cellSizeInv[2];
300 amrex::ignore_unused(foextrap_on_zlo,foextrap_on_zhi);
303 "Unexpected lower BC for momentum used with implicit vertical diffusion");
305 "Unexpected upper BC for momentum used with implicit vertical diffusion");
307 Real Fact = implicit_fac * dt * dz_inv;
310 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
313 for (
int j(jlo); j<=jhi; ++j) {
314 for (
int i(ilo); i<=ihi; ++i) {
351 Real rhoface, rhoAlpha_lo, rhoAlpha_hi;
352 Real a_tmp, b_tmp, c_tmp, inv_b2_tmp;
356 cell_data, mu_turb, mu_eff,
360 c_tmp = -Fact * gfac * rhoAlpha_hi * dz_inv;
362 RHS_a(i,j,klo) = face_data(i,j,klo);
365 if (ext_dir_on_zlo) {
366 RHS_a(i,j,klo) += Fact * gfac * (tau_corr(i,j,klo+1) - tau_corr(i,j,klo));
369 RHS_a(i,j,klo) =
zero;
372 a_tmp = -
two * Fact * rhoAlpha_lo * dz_inv;
374 + cell_data(i-ioff,j-joff,klo-1,
Rho_comp) );
375 const Real wall_velocity = face_data(i,j,klo-1) / rho_wall;
376 RHS_a(i,j,klo) -= a_tmp * wall_velocity;
378 }
else if (use_SurfLayer) {
380 RHS_a(i,j,klo) += Fact * gfac * (tau_corr(i,j,klo+1) - tau(i,j,klo));
381 RHS_a(i,j,klo) += Fact * tau(i,j,klo);
384 RHS_a(i,j,klo) += Fact * gfac * (tau_corr(i,j,klo+1) - tau_corr(i,j,klo));
388 if (use_ysu_mom_countergradient && stagdir < 2) {
390 const Real gam_hi =
myhalf * (mu_turb(i,j,klo,hgam_comp) + mu_turb(i,j,klo+1,hgam_comp));
391 RHS_a(i,j,klo) += Fact * gfac * dz_inv * rhoAlpha_hi * gam_hi;
394 b_tmp = rhoface - a_tmp - c_tmp;
397 RHS_a(i,j,klo) /= b_tmp;
398 coeffG_a(i,j,klo) = c_tmp / b_tmp;
403 for (
int k(klo+1); k <
khi; k++) {
406 cell_data, mu_turb, mu_eff,
409 a_tmp = -Fact * rhoAlpha_lo * dz_inv;
410 c_tmp = -Fact * rhoAlpha_hi * dz_inv;
411 b_tmp = rhoface - a_tmp - c_tmp;
412 inv_b2_tmp =
one/ (b_tmp - a_tmp * coeffG_a(i,j,k-1));
414 RHS_a(i,j,k) = face_data(i,j,k);
415 RHS_a(i,j,k) += Fact * gfac * (tau_corr(i,j,k+1) - tau_corr(i,j,k));
418 if (use_ysu_mom_countergradient && stagdir < 2) {
420 const Real gam_k = mu_turb(i, j, k, hgam_comp);
421 const Real gam_km1 = mu_turb(i, j, k-1, hgam_comp);
422 const Real gam_kp1 = mu_turb(i, j, k+1, hgam_comp);
423 const Real gam_hi =
myhalf * (gam_k + gam_kp1);
424 const Real gam_lo =
myhalf * (gam_k + gam_km1);
425 RHS_a(i,j,k) += Fact * gfac * dz_inv * (rhoAlpha_hi * gam_hi - rhoAlpha_lo * gam_lo);
428 RHS_a(i,j,k) = (RHS_a(i,j,k) - a_tmp * RHS_a(i,j,k-1)) * inv_b2_tmp;
429 coeffG_a(i,j,k) = c_tmp * inv_b2_tmp;
437 cell_data, mu_turb, mu_eff,
440 a_tmp = -Fact * gfac * rhoAlpha_lo * dz_inv;
443 RHS_a(i,j,
khi) = face_data(i,j,
khi);
444 RHS_a(i,j,
khi) += Fact * gfac * (tau_corr(i,j,
khi+1) - tau_corr(i,j,
khi));
447 if (ext_dir_on_zhi) {
453 c_tmp = -
two * Fact * rhoAlpha_hi * dz_inv;
456 const Real wall_velocity = face_data(i,j,
khi+1) / rho_wall;
457 RHS_a(i,j,
khi) -= c_tmp * wall_velocity;
461 b_tmp = rhoface - a_tmp - c_tmp;
462 inv_b2_tmp =
one/ (b_tmp - a_tmp * coeffG_a(i,j,
khi-1));
465 soln_a(i,j,
khi) = (RHS_a(i,j,
khi) - a_tmp * RHS_a(i,j,
khi-1)) * inv_b2_tmp;
470 for (
int k(
khi-1); k>=klo; --k) {
471 soln_a(i,j,k) = RHS_a(i,j,k) - coeffG_a(i,j,k) * soln_a(i,j,k+1);
476 for (
int k(klo); k<=
khi; ++k) {
478 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:22
#define Rho_comp
Definition: ERF_IndexDefines.H:36
const int khi
Definition: ERF_InitCustomPert_Bubble.H:21
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);})
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:248
@ ext_dir
Definition: ERF_IndexDefines.H:249
@ ext_dir_prim
Definition: ERF_IndexDefines.H:252
@ HGAMU_v
Definition: ERF_IndexDefines.H:219
@ HGAMV_v
Definition: ERF_IndexDefines.H:220
Definition: ERF_DiffStruct.H:22
MolecDiffType molec_diff_type
Selected molecular transport model.
Definition: ERF_DiffStruct.H:94
amrex::Real dynamic_viscosity
Dynamic viscosity for momentum diffusion [kg/(m-s)].
Definition: ERF_DiffStruct.H:106
amrex::Real rho0_trans
Reference density used to compute dynamic diffusion coefficients [kg/m3].
Definition: ERF_DiffStruct.H:101
amrex::Vector< TurbChoice > turbChoice
Turbulence options for each AMR level.
Definition: ERF_DataStruct.H:1393
DiffChoice diffChoice
Diffusion-related options.
Definition: ERF_DataStruct.H:1390
Definition: ERF_TurbStruct.H:114
bool use_kturb
Whether any turbulence model is active.
Definition: ERF_TurbStruct.H:660