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  // used by ERF_AddTKESources.H
25  // Clamp the divisor to the smallest normal Real before the select: an optimised
26  // build if-converts the select into an unconditional 1/theta_ref (also when
27  // the select is on the divisor), which trips fpe_trap_zero with the default
28  // theta_ref = 0. The clamp is exact for any normal theta_ref > 0 and its
29  // reciprocal is finite in single and double precision.
30  [[maybe_unused]] const bool use_ref_theta = (turbChoice.theta_ref > 0);
31  [[maybe_unused]] const Real inv_theta_ref = one / amrex::max(turbChoice.theta_ref, std::numeric_limits<Real>::min());
32  [[maybe_unused]] const Real l_inv_theta0 = (use_ref_theta) ? inv_theta_ref : one;
33 
34  // vertical diffusivities are defined in ERF_SetupVertDiff.H
35  // The number of quantities following Scalar_h must be equal to the number
36  // of quantities in the conserved state following RhoScalar_comp -- this is
37  // currently all the moist quantities, which tops out at 11 for the Morrison model
38  Vector<int> eddy_diff_idx{EddyDiff::Theta_h, EddyDiff::KE_h, EddyDiff::Scalar_h,
43  Vector<int> eddy_diff_idy{EddyDiff::Theta_h, EddyDiff::KE_h, EddyDiff::Scalar_h,
48 
49  // Device vectors
50  Gpu::AsyncVector<int> eddy_diff_idx_d;
51  Gpu::AsyncVector<int> eddy_diff_idy_d;
52 
53  eddy_diff_idx_d.resize(eddy_diff_idx.size());
54  eddy_diff_idy_d.resize(eddy_diff_idy.size());
55 
56  Gpu::copy(Gpu::hostToDevice, eddy_diff_idx.begin(), eddy_diff_idx.end(), eddy_diff_idx_d.begin());
57  Gpu::copy(Gpu::hostToDevice, eddy_diff_idy.begin(), eddy_diff_idy.end(), eddy_diff_idy_d.begin());
58 
59  // Capture pointers for device code
60  int* d_eddy_diff_idx = eddy_diff_idx_d.data();
61  int* d_eddy_diff_idy = eddy_diff_idy_d.data();
62 /** \endcond */
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:30
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ Q_h
Definition: ERF_IndexDefines.H:248
@ Scalar_h
Definition: ERF_IndexDefines.H:247
@ Theta_h
Definition: ERF_IndexDefines.H:245
@ KE_h
Definition: ERF_IndexDefines.H:246