ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SetupVertDiff.H
Go to the documentation of this file.
1 /** \cond */
2  const auto& dom_lo = lbound(domain);
3  const auto& dom_hi = ubound(domain);
4  amrex::ignore_unused(dom_lo, dom_hi);
5 
6  DiffChoice diffChoice = solverChoice.diffChoice;
7  TurbChoice turbChoice = solverChoice.turbChoice[level];
8 
9  bool l_consA = (diffChoice.molec_diff_type == MolecDiffType::ConstantAlpha);
10  bool l_turb = turbChoice.use_kturb;
11 
12  // Molecular diffusivity by primitive component. Only theta, the passive
13  // scalar and the water species through Q6 have one defined; everything
14  // else -- KE, the number concentrations, and any non-moist species a
15  // scheme appends after its water species -- is left at zero. This
16  // matches ResolveNativeScalarDiffusionPolicy() in
17  // ERF_NativeScalarDiffusion.H, which the explicit paths use instead of
18  // these tables.
19  Vector<Real> alpha_eff(NPRIMVAR_max, zero);
20  {
21  const Real alpha_T_eff = l_consA ? diffChoice.alpha_T : diffChoice.rhoAlpha_T;
22  const Real alpha_C_eff = l_consA ? diffChoice.alpha_C : diffChoice.rhoAlpha_C;
23 
24  alpha_eff[PrimTheta_comp] = alpha_T_eff;
25  alpha_eff[PrimScalar_comp] = alpha_C_eff;
26  for (int i = PrimQ1_comp; i <= PrimQ6_comp; ++i) {
27  alpha_eff[i] = alpha_C_eff;
28  }
29  }
30 
31  // Vertical eddy diffusivity component by primitive component. Every
32  // component above the passive scalar takes the Q category, including the
33  // non-moist species a scheme may append; the table spans NPRIMVAR_max,
34  // which tracks NVAR_max, so it always covers the full primitive range the
35  // callers can request.
36  Vector<int> eddy_diff_idz(NPRIMVAR_max, EddyDiff::Q_v);
37  eddy_diff_idz[PrimTheta_comp] = EddyDiff::Theta_v;
38  eddy_diff_idz[PrimKE_comp] = EddyDiff::KE_v;
39  eddy_diff_idz[PrimScalar_comp] = EddyDiff::Scalar_v;
40 
41  // Device vectors
42  Gpu::AsyncVector<Real> alpha_eff_d;
43  Gpu::AsyncVector<int> eddy_diff_idz_d;
44  alpha_eff_d.resize(alpha_eff.size());
45  eddy_diff_idz_d.resize(eddy_diff_idz.size());
46 
47  Gpu::copy(Gpu::hostToDevice, alpha_eff.begin() , alpha_eff.end() , alpha_eff_d.begin());
48  Gpu::copy(Gpu::hostToDevice, eddy_diff_idz.begin(), eddy_diff_idz.end(), eddy_diff_idz_d.begin());
49 
50  // Capture pointers for device code
51  [[maybe_unused]] Real* d_alpha_eff = alpha_eff_d.data();
52  [[maybe_unused]] int* d_eddy_diff_idz = eddy_diff_idz_d.data();
53 /** \endcond */
#define PrimQ1_comp
Definition: ERF_IndexDefines.H:64
#define NPRIMVAR_max
Definition: ERF_IndexDefines.H:39
#define PrimQ6_comp
Definition: ERF_IndexDefines.H:69
#define PrimTheta_comp
Definition: ERF_IndexDefines.H:61
#define PrimKE_comp
Definition: ERF_IndexDefines.H:62
#define PrimScalar_comp
Definition: ERF_IndexDefines.H:63
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ Theta_v
Definition: ERF_IndexDefines.H:253
@ Scalar_v
Definition: ERF_IndexDefines.H:255
@ Q_v
Definition: ERF_IndexDefines.H:256
@ KE_v
Definition: ERF_IndexDefines.H:254
Definition: ERF_DiffStruct.H:22
MolecDiffType molec_diff_type
Selected molecular transport model.
Definition: ERF_DiffStruct.H:94
amrex::Real rhoAlpha_T
Dynamic temperature diffusion coefficient [kg/(m-s)].
Definition: ERF_DiffStruct.H:104
amrex::Real alpha_C
Kinematic scalar diffusivity [m2/s].
Definition: ERF_DiffStruct.H:98
amrex::Real alpha_T
Kinematic temperature diffusivity [m2/s].
Definition: ERF_DiffStruct.H:97
amrex::Real rhoAlpha_C
Dynamic scalar diffusion coefficient [kg/(m-s)].
Definition: ERF_DiffStruct.H:105
Definition: ERF_TurbStruct.H:115
bool use_kturb
Whether any turbulence model is active.
Definition: ERF_TurbStruct.H:921