ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_IBSEBWallFunction.H
Go to the documentation of this file.
1 #ifndef ERF_IBSEB_WALLFUNCTION_H
2 #define ERF_IBSEB_WALLFUNCTION_H
3 
4 #include <AMReX_REAL.H>
5 #include <AMReX_GpuQualifiers.H>
6 #include <AMReX_Algorithm.H>
7 #include <cmath>
8 
9 /**
10  * \file ERF_IBSEBWallFunction.H
11  * \brief Explicit stability factors of the face wall function.
12  */
13 namespace ibseb {
14 
15 /**
16  * Louis (1979) stability factors on the bulk Richardson number.
17  *
18  * The exchange coefficients are the neutral ones times a factor:
19  * ``u*^2 = a^2 U^2 F_m`` and ``u* theta* = a_h^2 U dtheta F_h``. Unstable
20  * (``Ri_b < 0``):
21  * ``F = 1 - b Ri_b / (1 + C* a^2 b sqrt(|Ri_b| z / z0))`` with ``b = 9.4``,
22  * ``C* = 7.4`` for momentum and ``5.3`` for heat. Stable:
23  * ``F_m = F_h = 1 / (1 + b/2 Ri_b)^2``. Both are 1 at ``Ri_b = 0`` and
24  * continuous there. No iteration: the factors come straight from the
25  * resolved state.
26  *
27  * @param[in] Rib Bulk Richardson number between the surface and the reference height.
28  * @param[in] z_over_z0 Reference height over the momentum roughness length.
29  * @param[in] a2 Neutral momentum drag coefficient ``(kappa / ln(z / z0))^2``.
30  * @param[out] Fm Momentum factor.
31  * @param[out] Fh Heat factor.
32  */
33 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
34 void louis_factors (amrex::Real Rib, amrex::Real z_over_z0, amrex::Real a2,
35  amrex::Real& Fm, amrex::Real& Fh) noexcept
36 {
37  const amrex::Real one = amrex::Real(1.0);
38  const amrex::Real b = amrex::Real(9.4);
39  const amrex::Real cs_m = amrex::Real(7.4);
40  const amrex::Real cs_h = amrex::Real(5.3);
41  // The square root is formed from a clipped argument so a speculatively
42  // evaluated unstable arm never takes the root of a negative number.
43  const amrex::Real s = std::sqrt(amrex::max(-Rib, amrex::Real(0.0)) * z_over_z0);
44  if (Rib < amrex::Real(0.0)) {
45  Fm = one - b * Rib / (one + cs_m * a2 * b * s);
46  Fh = one - b * Rib / (one + cs_h * a2 * b * s);
47  } else {
48  const amrex::Real q = one + amrex::Real(0.5) * b * Rib;
49  Fm = one / (q * q);
50  Fh = Fm;
51  }
52 }
53 
54 } // namespace ibseb
55 
56 #endif
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
@ q
Definition: ERF_WSM6.H:296
Definition: ERF_IBSEBBalance.H:51
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void louis_factors(amrex::Real Rib, amrex::Real z_over_z0, amrex::Real a2, amrex::Real &Fm, amrex::Real &Fh) noexcept
Definition: ERF_IBSEBWallFunction.H:34
real(c_double), parameter a2
Definition: ERF_module_model_constants.F90:95