ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ShocConstants.H
Go to the documentation of this file.
1 #ifndef ERF_SHOC_CONSTANTS_H_
2 #define ERF_SHOC_CONSTANTS_H_
3 
4 #include <AMReX_GpuQualifiers.H>
5 #include <AMReX_REAL.H>
6 
7 namespace shoc::constants {
8 
9 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
10 amrex::Real min_tke () noexcept { return amrex::Real(4.0e-4); }
11 
12 // Relative margin above min_tke() used to decide whether a level is still
13 // turbulently active. Above the boundary layer both the explicit TKE update
14 // and the implicit TKE solve clamp TKE to exactly min_tke(), so a bare
15 // "tke > min_tke()" test is settled by the last bit of the tridiagonal
16 // solution. Host and device builds differ there by one ulp, because the CUDA
17 // build contracts to FMA and the host build does not, and that flips the
18 // diagnosed active top from step to step. The margin keeps the comparison off
19 // that measure-zero boundary.
20 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
22 {
23 #ifdef AMREX_USE_FLOAT
24  return amrex::Real(1.0e-4);
25 #else
26  return amrex::Real(1.0e-6);
27 #endif
28 }
29 
30 // Smallest TKE that counts as turbulently active. See active_tke_rel_margin().
31 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
33 {
34  return min_tke() * (amrex::Real(1.0) + active_tke_rel_margin());
35 }
36 
37 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
38 amrex::Real latent_ice () noexcept { return amrex::Real(3.34e5); }
39 
40 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
41 amrex::Real min_temp () noexcept { return amrex::Real(180.0); }
42 
43 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
44 amrex::Real freezing_temp () noexcept { return amrex::Real(273.15); }
45 
46 } // namespace shoc::constants
47 
48 #endif
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Definition: ERF_ShocConstants.H:7
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real freezing_temp() noexcept
Definition: ERF_ShocConstants.H:44
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real latent_ice() noexcept
Definition: ERF_ShocConstants.H:38
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real min_temp() noexcept
Definition: ERF_ShocConstants.H:41
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real active_tke_rel_margin() noexcept
Definition: ERF_ShocConstants.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real min_tke() noexcept
Definition: ERF_ShocConstants.H:10
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real active_tke_threshold() noexcept
Definition: ERF_ShocConstants.H:32