ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SetupDiff.H
Go to the documentation of this file.
1 /** \cond */
2  // include common definitions used in the implicit diffusion solve
3 #include "ERF_SetupVertDiff.H"
4 
5  const Real dx_inv = cellSizeInv[0];
6  const Real dy_inv = cellSizeInv[1];
7 
8  [[maybe_unused]] const bool SurfLayer_xlo = use_SurfLayer && SurfLayer[amrex::Orientation::xlo()] != nullptr;
9  [[maybe_unused]] const bool SurfLayer_ylo = use_SurfLayer && SurfLayer[amrex::Orientation::ylo()] != nullptr;
10  [[maybe_unused]] const bool SurfLayer_zlo = use_SurfLayer && SurfLayer[amrex::Orientation::zlo()] != nullptr;
11  [[maybe_unused]] const bool SurfLayer_xhi = use_SurfLayer && SurfLayer[amrex::Orientation::xhi()] != nullptr;
12  [[maybe_unused]] const bool SurfLayer_yhi = use_SurfLayer && SurfLayer[amrex::Orientation::yhi()] != nullptr;
13  [[maybe_unused]] const bool SurfLayer_zhi = use_SurfLayer && SurfLayer[amrex::Orientation::zhi()] != nullptr;
14 
15  const Box xbx = surroundingNodes(bx,0);
16  const Box ybx = surroundingNodes(bx,1);
17  const Box zbx = surroundingNodes(bx,2);
18 
19  [[maybe_unused]] const int end_comp = start_comp + num_comp - 1;
20  [[maybe_unused]] bool l_use_keqn = turbChoice.use_keqn;
21  [[maybe_unused]] bool l_implicit_diss = turbChoice.use_keqn && turbChoice.implicit_tke_dissipation;
22  [[maybe_unused]] bool l_use_mynn = turbChoice.use_pbl_tke;
23 
24  // Clamp the divisor to the smallest normal Real before the select: an optimised
25  // build if-converts the select into an unconditional 1/theta_ref (also when
26  // the select is on the divisor), which trips fpe_trap_zero with the default
27  // theta_ref = 0. The clamp is exact for any normal theta_ref > 0 and its
28  // reciprocal is finite in single and double precision.
29  [[maybe_unused]] const bool use_ref_theta = (turbChoice.theta_ref > 0);
30  [[maybe_unused]] const Real inv_theta_ref = one / amrex::max(turbChoice.theta_ref, std::numeric_limits<Real>::min());
31  [[maybe_unused]] const Real l_inv_theta0 = (use_ref_theta) ? inv_theta_ref : one;
32 
33  // Horizontal companions of eddy_diff_idz, which is built along with
34  // alpha_eff in ERF_SetupVertDiff.H; see the notes there. The two
35  // horizontal directions use the same components.
36  Vector<int> eddy_diff_idx(NPRIMVAR_max, EddyDiff::Q_h);
37  eddy_diff_idx[PrimTheta_comp] = EddyDiff::Theta_h;
38  eddy_diff_idx[PrimKE_comp] = EddyDiff::KE_h;
39  eddy_diff_idx[PrimScalar_comp] = EddyDiff::Scalar_h;
40  Vector<int> eddy_diff_idy(eddy_diff_idx);
41 
42  // The tables are indexed by primitive component, i.e. by qty_index-1, so the
43  // highest index this call can reach is end_comp-1.
44  AMREX_ALWAYS_ASSERT(eddy_diff_idx.size() == eddy_diff_idz.size());
45  AMREX_ALWAYS_ASSERT(eddy_diff_idx.size() == alpha_eff.size());
46  AMREX_ALWAYS_ASSERT(end_comp-1 < static_cast<int>(alpha_eff.size()));
47 
48  // Device vectors
49  Gpu::AsyncVector<int> eddy_diff_idx_d;
50  Gpu::AsyncVector<int> eddy_diff_idy_d;
51 
52  eddy_diff_idx_d.resize(eddy_diff_idx.size());
53  eddy_diff_idy_d.resize(eddy_diff_idy.size());
54 
55  Gpu::copy(Gpu::hostToDevice, eddy_diff_idx.begin(), eddy_diff_idx.end(), eddy_diff_idx_d.begin());
56  Gpu::copy(Gpu::hostToDevice, eddy_diff_idy.begin(), eddy_diff_idy.end(), eddy_diff_idy_d.begin());
57 
58  // Capture pointers for device code
59  [[maybe_unused]] int* d_eddy_diff_idx = eddy_diff_idx_d.data();
60  [[maybe_unused]] int* d_eddy_diff_idy = eddy_diff_idy_d.data();
61 /** \endcond */
#define NPRIMVAR_max
Definition: ERF_IndexDefines.H:39
#define PrimTheta_comp
Definition: ERF_IndexDefines.H:61
#define PrimKE_comp
Definition: ERF_IndexDefines.H:62
#define PrimScalar_comp
Definition: ERF_IndexDefines.H:63
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ Q_h
Definition: ERF_IndexDefines.H:251
@ Scalar_h
Definition: ERF_IndexDefines.H:250
@ Theta_h
Definition: ERF_IndexDefines.H:248
@ KE_h
Definition: ERF_IndexDefines.H:249