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.
210 constexpr
Real gfac = (stagdir == 2) ? 2.0/3.0 : 1.0;
213 constexpr
int ioff = (stagdir == 0) ? 1 : 0;
214 constexpr
int joff = (stagdir == 1) ? 1 : 0;
217 int ilo = bx.smallEnd(0);
218 int ihi = bx.bigEnd(0);
219 int jlo = bx.smallEnd(1);
220 int jhi = bx.bigEnd(1);
221 int klo = bx.smallEnd(2);
222 int khi = bx.bigEnd(2);
223 amrex::ignore_unused(ilo, ihi, jlo, jhi);
227 amrex::FArrayBox RHS_fab, soln_fab, coeffA_fab, coeffB_fab, inv_coeffB_fab, coeffC_fab;
228 RHS_fab.resize(bx,1, amrex::The_Async_Arena());
229 soln_fab.resize(bx,1, amrex::The_Async_Arena());
230 coeffA_fab.resize(bx,1, amrex::The_Async_Arena());
231 coeffB_fab.resize(bx,1, amrex::The_Async_Arena());
232 inv_coeffB_fab.resize(bx,1, amrex::The_Async_Arena());
233 coeffC_fab.resize(bx,1, amrex::The_Async_Arena());
234 auto const& RHS_a = RHS_fab.array();
235 auto const& soln_a = soln_fab.array();
236 auto const& coeffA_a = coeffA_fab.array();
237 auto const& coeffB_a = coeffB_fab.array();
238 auto const& inv_coeffB_a = inv_coeffB_fab.array();
239 auto const& coeffC_a = coeffC_fab.array();
241 const auto&
dom_lo = lbound(domain);
242 const auto&
dom_hi = ubound(domain);
243 Real dz_inv = cellSizeInv[2];
251 amrex::ignore_unused(foextrap_on_zhi);
253 AMREX_ASSERT_WITH_MESSAGE(ext_dir_on_zlo || ext_dir_on_zhi || use_SurfLayer,
254 "Unexpected lower BC used with implicit vertical diffusion");
255 AMREX_ASSERT_WITH_MESSAGE(foextrap_on_zhi,
256 "Unexpected upper BC used with implicit vertical diffusion");
257 if (stagdir < 2 && (ext_dir_on_zlo || ext_dir_on_zhi)) {
258 amrex::Warning(
"No-slip walls have not been fully tested");
262 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
265 for (
int j(jlo); j<=jhi; ++j) {
266 for (
int i(ilo); i<=ihi; ++i) {
269 for (
int k(klo); k <= khi; k++)
271 Real rhoface, detJface;
272 Real rhoAlpha_lo, rhoAlpha_hi;
273 Real met_h_zeta_lo, met_h_zeta_hi;
276 rhoface = 0.5 * (cell_data(i,j,k,
Rho_comp) + cell_data(i-ioff,j-joff,k,
Rho_comp));
277 detJface = 0.5 * (detJ(i,j,k) + detJ(i-ioff,j-joff,k));
281 rhoAlpha_lo, rhoAlpha_hi,
282 cell_data, mu_turb, mu_eff,
291 detJface = 0.5 * (detJ(i,j,k) + detJ(i,j,k-1));
295 rhoAlpha_lo, rhoAlpha_hi,
296 cell_data, mu_turb, mu_eff,
299 met_h_zeta_lo = detJ(i,j,k-1);
300 met_h_zeta_hi = detJ(i,j,k );;
307 RHS_a(i,j,k) = detJface * face_data(i,j,k);
336 RHS_a(i,j,k) += implicit_fac * gfac * (tau_corr(i,j,k+1) - tau_corr(i,j,k))*dz_inv * dt;
340 coeffA_a(i,j,k) = -implicit_fac * gfac * rhoAlpha_lo * dt * dz_inv * dz_inv/met_h_zeta_lo;
341 coeffC_a(i,j,k) = -implicit_fac * gfac * rhoAlpha_hi * dt * dz_inv * dz_inv/met_h_zeta_hi;
349 if (ext_dir_on_zlo) {
352 coeffC_a(i,j,klo) = 0.;
357 coeffC_a(i,j,klo) = -0.5 * detJface * detJface / met_h_zeta_hi;
358 RHS_a(i,j,klo) = detJface * face_data(i,j,klo-1);
360 }
else if (use_SurfLayer) {
362 Real uhi = 2.0 * face_data(i,j,klo ) / (cell_data(i,j,klo ,
Rho_comp) + cell_data(i-ioff,j-joff,klo ,
Rho_comp));
363 Real ulo = 2.0 * face_data(i,j,klo-1) / (cell_data(i,j,klo-1,
Rho_comp) + cell_data(i-ioff,j-joff,klo-1,
Rho_comp));
364 RHS_a(i,j,klo) += coeffA_a(i,j,klo) * (uhi - ulo);
368 coeffA_a(i,j,klo) = 0.;
371 if (ext_dir_on_zhi) {
373 coeffA_a(i,j,khi) = 0.;
378 coeffA_a(i,j,khi) = -0.5 * detJface * detJface / met_h_zeta_lo;
379 RHS_a(i,j,khi) = detJface * face_data(i,j,khi+1);
384 coeffC_a(i,j,khi) = 0.;
387 coeffB_a(i,j,k) = detJface * rhoface - coeffA_a(i,j,k) - coeffC_a(i,j,k);
390 SolveTridiag(i,j,klo,khi,soln_a,coeffA_a,coeffB_a,inv_coeffB_a,coeffC_a,RHS_a);
391 for (
int k(klo); k<=khi; ++k) {
393 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)
Definition: ERF_GetRhoAlphaForFaces.H:5
void ImplicitDiffForMom_T(const Box &bx, const Box &domain, const int level, const Real dt, const Array4< const Real > &cell_data, const Array4< Real > &face_data, const Array4< const Real > &tau_corr, const Array4< const Real > &z_nd, const Array4< const Real > &detJ, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const Array4< const Real > &mu_turb, const SolverChoice &solverChoice, const BCRec *bc_ptr, const bool use_SurfLayer, const Real implicit_fac)
Definition: ERF_ImplicitDiff_T.cpp:180
#define Rho_comp
Definition: ERF_IndexDefines.H:36
const auto & dom_hi
Definition: ERF_SetupVertDiff.H:2
bool l_turb
Definition: ERF_SetupVertDiff.H:8
const auto & dom_lo
Definition: ERF_SetupVertDiff.H:1
bool l_consA
Definition: ERF_SetupVertDiff.H:7
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void SolveTridiag(int i, int j, int klo, int khi, const amrex::Array4< amrex::Real > &soln_a, const amrex::Array4< const amrex::Real > &coeffA_a, const amrex::Array4< amrex::Real > &coeffB_a, const amrex::Array4< amrex::Real > &inv_coeffB_a, const amrex::Array4< const amrex::Real > &coeffC_a, const amrex::Array4< const amrex::Real > &RHS_a)
Definition: ERF_SolveTridiag.H:6
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:182
@ xvel_bc
Definition: ERF_IndexDefines.H:87
@ foextrap
Definition: ERF_IndexDefines.H:208
@ ext_dir
Definition: ERF_IndexDefines.H:209
@ ext_dir_prim
Definition: ERF_IndexDefines.H:211
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:992
amrex::Vector< TurbChoice > turbChoice
Definition: ERF_DataStruct.H:995
Definition: ERF_TurbStruct.H:41
bool use_kturb
Definition: ERF_TurbStruct.H:396