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.
200 constexpr
Real gfac = (stagdir == 2) ? 2.0/3.0 : 1.0;
203 constexpr
int ioff = (stagdir == 0) ? 1 : 0;
204 constexpr
int joff = (stagdir == 1) ? 1 : 0;
207 int ilo = bx.smallEnd(0);
208 int ihi = bx.bigEnd(0);
209 int jlo = bx.smallEnd(1);
210 int jhi = bx.bigEnd(1);
211 int klo = bx.smallEnd(2);
212 int khi = bx.bigEnd(2);
213 amrex::ignore_unused(ilo, ihi, jlo, jhi);
217 amrex::FArrayBox RHS_fab, soln_fab, coeffA_fab, coeffB_fab, inv_coeffB_fab, coeffC_fab;
218 RHS_fab.resize(bx,1, amrex::The_Async_Arena());
219 soln_fab.resize(bx,1, amrex::The_Async_Arena());
220 coeffA_fab.resize(bx,1, amrex::The_Async_Arena());
221 coeffB_fab.resize(bx,1, amrex::The_Async_Arena());
222 inv_coeffB_fab.resize(bx,1, amrex::The_Async_Arena());
223 coeffC_fab.resize(bx,1, amrex::The_Async_Arena());
224 auto const& RHS_a = RHS_fab.array();
225 auto const& soln_a = soln_fab.array();
226 auto const& coeffA_a = coeffA_fab.array();
227 auto const& coeffB_a = coeffB_fab.array();
228 auto const& inv_coeffB_a = inv_coeffB_fab.array();
229 auto const& coeffC_a = coeffC_fab.array();
231 const auto&
dom_lo = lbound(domain);
232 const auto&
dom_hi = ubound(domain);
233 auto dz_ptr = stretched_dz_d.data();
241 amrex::ignore_unused(foextrap_on_zhi);
243 AMREX_ASSERT_WITH_MESSAGE(ext_dir_on_zlo || ext_dir_on_zhi || use_SurfLayer,
244 "Unexpected lower BC used with implicit vertical diffusion");
245 AMREX_ASSERT_WITH_MESSAGE(foextrap_on_zhi,
246 "Unexpected upper BC used with implicit vertical diffusion");
247 if (stagdir < 2 && (ext_dir_on_zlo || ext_dir_on_zhi)) {
248 amrex::Warning(
"No-slip walls have not been fully tested");
252 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
255 for (
int j(jlo); j<=jhi; ++j) {
256 for (
int i(ilo); i<=ihi; ++i) {
259 for (
int k(klo); k <= khi; k++)
264 Real rhoAlpha_lo, rhoAlpha_hi;
266 cell_data, mu_turb, mu_eff,
269 Real dz_inv = 1.0 / dz_ptr[k];
271 : 2.0 / (dz_ptr[k] + dz_ptr[k-1]);
273 : 2.0 / (dz_ptr[k] + dz_ptr[k+1]);
278 RHS_a(i,j,k) = face_data(i,j,k);
305 RHS_a(i,j,k) += implicit_fac * gfac * (tau_corr(i,j,k+1) - tau_corr(i,j,k))*dz_inv * dt;
309 coeffA_a(i,j,k) = -implicit_fac * gfac * rhoAlpha_lo * dt * dz_inv * dz_inv_lo;
310 coeffC_a(i,j,k) = -implicit_fac * gfac * rhoAlpha_hi * dt * dz_inv * dz_inv_hi;
314 if (ext_dir_on_zlo) {
317 coeffC_a(i,j,klo) = 0.;
322 coeffC_a(i,j,klo) = -0.5 * dz_inv_hi / dz_inv;
323 RHS_a(i,j,klo) = face_data(i,j,klo-1);
325 }
else if (use_SurfLayer) {
327 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));
328 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));
329 RHS_a(i,j,klo) += coeffA_a(i,j,klo) * (uhi - ulo);
333 coeffA_a(i,j,klo) = 0.;
336 if (ext_dir_on_zhi) {
338 coeffA_a(i,j,khi) = 0.;
343 coeffA_a(i,j,khi) = -0.5 * dz_inv_lo / dz_inv;
344 RHS_a(i,j,khi) = face_data(i,j,khi+1);
349 coeffC_a(i,j,khi) = 0.;
352 coeffB_a(i,j,k) = rhoface - coeffA_a(i,j,k) - coeffC_a(i,j,k);
355 SolveTridiag(i,j,klo,khi,soln_a,coeffA_a,coeffB_a,inv_coeffB_a,coeffC_a,RHS_a);
356 for (
int k(klo); k<=khi; ++k) {
358 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_S(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 Gpu::DeviceVector< Real > &stretched_dz_d, const Array4< const Real > &mu_turb, const SolverChoice &solverChoice, const BCRec *bc_ptr, const bool use_SurfLayer, const Real implicit_fac)
Definition: ERF_ImplicitDiff_S.cpp:172
#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
@ 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