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 (theta, every passive
13  // scalar and the moisture species, number concentrations included), the
14  // coefficients the explicit paths take from ResolveNativeScalarDiffusionPolicy()
15  Vector<Real> alpha_eff = VerticalMolecularAlphaByPrim(diffChoice);
16 
17  // Vertical eddy diffusivity component by primitive component. Every
18  // component above the passive scalars takes the Q category, including the
19  // non-moist species a scheme may append; the table spans NPRIMVAR_max,
20  // which tracks NVAR_max, so it always covers the full primitive range the
21  // callers can request. Every scalar slot (base and smoke) takes the
22  // Scalar category.
23  Vector<int> eddy_diff_idz(NPRIMVAR_max, EddyDiff::Q_v);
24  eddy_diff_idz[PrimTheta_comp] = EddyDiff::Theta_v;
25  eddy_diff_idz[PrimKE_comp] = EddyDiff::KE_v;
26  for (int ns = 0; ns < NSCALARS; ++ns) {
27  eddy_diff_idz[PrimScalar_comp + ns] = EddyDiff::Scalar_v;
28  }
29 
30  // Device vectors
31  Gpu::AsyncVector<Real> alpha_eff_d;
32  Gpu::AsyncVector<int> eddy_diff_idz_d;
33  alpha_eff_d.resize(alpha_eff.size());
34  eddy_diff_idz_d.resize(eddy_diff_idz.size());
35 
36  Gpu::copy(Gpu::hostToDevice, alpha_eff.begin() , alpha_eff.end() , alpha_eff_d.begin());
37  Gpu::copy(Gpu::hostToDevice, eddy_diff_idz.begin(), eddy_diff_idz.end(), eddy_diff_idz_d.begin());
38 
39  // Capture pointers for device code
40  [[maybe_unused]] Real* d_alpha_eff = alpha_eff_d.data();
41  [[maybe_unused]] int* d_eddy_diff_idz = eddy_diff_idz_d.data();
42 /** \endcond */
#define NPRIMVAR_max
Definition: ERF_IndexDefines.H:50
#define NSCALARS
Definition: ERF_IndexDefines.H:26
#define PrimTheta_comp
Definition: ERF_IndexDefines.H:79
#define PrimKE_comp
Definition: ERF_IndexDefines.H:80
#define PrimScalar_comp
Definition: ERF_IndexDefines.H:81
amrex::Vector< amrex::Real > VerticalMolecularAlphaByPrim(const DiffChoice &choice)
Definition: ERF_NativeScalarDiffusion.H:86
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ Theta_v
Definition: ERF_IndexDefines.H:290
@ Scalar_v
Definition: ERF_IndexDefines.H:292
@ Q_v
Definition: ERF_IndexDefines.H:293
@ KE_v
Definition: ERF_IndexDefines.H:291
@ ns
Definition: ERF_Morrison.H:50
Definition: ERF_DiffStruct.H:24
MolecDiffType molec_diff_type
Selected molecular transport model.
Definition: ERF_DiffStruct.H:96
Definition: ERF_TurbStruct.H:119
bool use_kturb
Whether any turbulence model is active.
Definition: ERF_TurbStruct.H:977