Function for computing the implicit contribution to the vertical diffusion of momentum, with a vertically stretched grid over flat terrain.
This function (explicitly instantiated below) handles staggering in x, y, or z through the template parameter, stagdir.
229 BL_PROFILE_VAR(
"ImplicitDiffForMom_S()",ImplicitDiffForMom_S);
246 constexpr
int ioff = (stagdir == 0) ? 1 : 0;
247 constexpr
int joff = (stagdir == 1) ? 1 : 0;
250 int ilo = bx.smallEnd(0);
251 int ihi = bx.bigEnd(0);
252 int jlo = bx.smallEnd(1);
253 int jhi = bx.bigEnd(1);
254 int klo = bx.smallEnd(2);
255 int khi = bx.bigEnd(2);
256 amrex::ignore_unused(ilo, ihi, jlo, jhi);
260 amrex::FArrayBox RHS_fab, soln_fab, coeffG_fab;
261 RHS_fab.resize(bx,1, amrex::The_Async_Arena());
262 soln_fab.resize(bx,1, amrex::The_Async_Arena());
263 coeffG_fab.resize(bx,1, amrex::The_Async_Arena());
264 auto const& RHS_a = RHS_fab.array();
265 auto const& soln_a = soln_fab.array();
266 auto const& coeffG_a = coeffG_fab.array();
268 auto dz_ptr = stretched_dz_d.data();
277 amrex::ignore_unused(foextrap_on_zlo,foextrap_on_zhi);
280 "Unexpected lower BC for momentum used with implicit vertical diffusion");
282 "Unexpected upper BC for momentum used with implicit vertical diffusion");
284 Real Fact = implicit_fac * dt;
287 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
290 for (
int j(jlo); j<=jhi; ++j) {
291 for (
int i(ilo); i<=ihi; ++i) {
328 Real rhoface, rhoAlpha_lo, rhoAlpha_hi;
329 Real dz_inv, dz_inv_lo, dz_inv_hi;
330 Real a_tmp, b_tmp, c_tmp, inv_b2_tmp;
334 cell_data, mu_turb, mu_eff,
337 dz_inv =
one / dz_ptr[klo];
339 dz_inv_hi =
two / (dz_ptr[klo] + dz_ptr[klo+1]);
342 c_tmp = -Fact * gfac * rhoAlpha_hi * dz_inv_hi * dz_inv;
344 RHS_a(i,j,klo) = face_data(i,j,klo);
347 if (ext_dir_on_zlo) {
348 RHS_a(i,j,klo) += Fact * gfac * (tau_corr(i,j,klo+1) - tau_corr(i,j,klo)) * dz_inv;
354 a_tmp = -
two * Fact * rhoAlpha_lo * dz_inv_lo * dz_inv;
355 RHS_a(i,j,klo) +=
two * rhoAlpha_lo * face_data(i,j,klo-1) * dz_inv_lo * dz_inv;
357 }
else if (use_SurfLayer) {
359 RHS_a(i,j,klo) += Fact * gfac * (tau_corr(i,j,klo+1) - tau(i,j,klo)) * dz_inv;
360 RHS_a(i,j,klo) += Fact * dz_inv * tau(i,j,klo);
363 RHS_a(i,j,klo) += Fact * gfac * (tau_corr(i,j,klo+1) - tau_corr(i,j,klo));
366 b_tmp = rhoface - a_tmp - c_tmp;
369 RHS_a(i,j,klo) /= b_tmp;
370 coeffG_a(i,j,klo) = c_tmp / b_tmp;
375 for (
int k(klo+1); k <
khi; k++) {
378 cell_data, mu_turb, mu_eff,
381 dz_inv =
one / dz_ptr[k];
382 dz_inv_lo =
two / (dz_ptr[k] + dz_ptr[k-1]);
383 dz_inv_hi =
two / (dz_ptr[k] + dz_ptr[k+1]);
385 a_tmp = -Fact * rhoAlpha_lo * dz_inv_lo * dz_inv;
386 c_tmp = -Fact * rhoAlpha_hi * dz_inv_hi * dz_inv;
387 b_tmp = rhoface - a_tmp - c_tmp;
388 inv_b2_tmp =
one / (b_tmp - a_tmp * coeffG_a(i,j,k-1));
390 RHS_a(i,j,k) = face_data(i,j,k);
391 RHS_a(i,j,k) += Fact * gfac * (tau_corr(i,j,k+1) - tau_corr(i,j,k)) * dz_inv;
393 RHS_a(i,j,k) = (RHS_a(i,j,k) - a_tmp * RHS_a(i,j,k-1)) * inv_b2_tmp;
394 coeffG_a(i,j,k) = c_tmp * inv_b2_tmp;
402 cell_data, mu_turb, mu_eff,
405 dz_inv =
one / dz_ptr[
khi];
406 dz_inv_lo =
two / (dz_ptr[
khi] + dz_ptr[
khi-1]);
409 a_tmp = -Fact * gfac * rhoAlpha_lo * dz_inv_lo * dz_inv;
412 RHS_a(i,j,
khi) = face_data(i,j,
khi);
413 RHS_a(i,j,
khi) += Fact * gfac * (tau_corr(i,j,
khi+1) - tau_corr(i,j,
khi)) * dz_inv;
416 if (ext_dir_on_zhi) {
422 c_tmp = -
two * Fact * rhoAlpha_hi * dz_inv_hi * dz_inv;
423 RHS_a(i,j,
khi) +=
two * rhoAlpha_hi * face_data(i,j,
khi+1) * dz_inv_hi * dz_inv;
427 b_tmp = rhoface - a_tmp - c_tmp;
428 inv_b2_tmp =
one / (b_tmp - a_tmp * coeffG_a(i,j,
khi-1));
431 soln_a(i,j,
khi) = (RHS_a(i,j,
khi) - a_tmp * RHS_a(i,j,
khi-1)) * inv_b2_tmp;
436 for (
int k(
khi-1); k>=klo; --k) {
437 soln_a(i,j,k) = RHS_a(i,j,k) - coeffG_a(i,j,k) * soln_a(i,j,k+1);
442 for (
int k(klo); k<=
khi; ++k) {
444 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_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:242
@ ext_dir
Definition: ERF_IndexDefines.H:243
@ ext_dir_prim
Definition: ERF_IndexDefines.H:246
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:1220
amrex::Vector< TurbChoice > turbChoice
Definition: ERF_DataStruct.H:1223
Definition: ERF_TurbStruct.H:82
bool use_kturb
Definition: ERF_TurbStruct.H:513