ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SurfaceDiagnosticSource.H
Go to the documentation of this file.
1 #ifndef ERF_SURFACE_DIAGNOSTIC_SOURCE_H_
2 #define ERF_SURFACE_DIAGNOSTIC_SOURCE_H_
3 
4 #include <AMReX_GpuQualifiers.H>
5 #include <AMReX_REAL.H>
6 
8 {
9 
10 // Diagnostic-only provenance codes written to 2D plotfiles.
11 // These numeric values are a user-visible plotfile convention. Renumbering
12 // them is a breaking output change. The mask is cell-centered and must not
13 // affect flux calculations, boundary conditions, state updates, or staggered
14 // stress-face source mixing.
15 enum class SurfaceDiagnosticSource : int
16 {
17  Missing = 0,
18  SurfaceLayerLand = 1,
19  LSMLand = 2,
21  SurfaceLayerSea = 4,
22  Custom = 5,
23  RICO = 6
24 };
25 
26 /**
27  * Convert a diagnostic source enum to its integer code.
28  *
29  * @param[in] source diagnostic source enum value
30  */
31 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
32 int
34 {
35  return static_cast<int>(source);
36 }
37 
38 /**
39  * Convert a diagnostic source enum to the Real value written to plotfiles.
40  *
41  * @param[in] source diagnostic source enum value
42  */
43 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
46 {
47  return static_cast<amrex::Real>(to_int(source));
48 }
49 
50 /**
51  * Classify the provenance of a scalar surface flux.
52  *
53  * @param[in] is_custom whether the custom flux mode is active
54  * @param[in] is_rico whether the RICO flux mode is active
55  * @param[in] is_land whether the cell is classified as land
56  * @param[in] has_lsm_flux whether an LSM flux array is available
57  * @param[in] lsm_flux_is_valid whether the LSM flux value is valid
58  */
59 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
61 classify_scalar_source (bool is_custom,
62  bool is_rico,
63  bool is_land,
64  bool has_lsm_flux,
65  bool lsm_flux_is_valid) noexcept
66 {
67  if (is_land && has_lsm_flux && lsm_flux_is_valid) {
69  }
70  if (is_custom) {
72  }
73  if (is_rico) {
75  }
76  if (is_land && has_lsm_flux && !lsm_flux_is_valid) {
78  }
79  if (is_land) {
81  }
83 }
84 
85 /**
86  * Return the string name for a diagnostic source enum value.
87  *
88  * @param[in] source diagnostic source enum value
89  */
90 inline const char*
92 {
93  switch (source) {
94  case SurfaceDiagnosticSource::Missing: return "missing";
95  case SurfaceDiagnosticSource::SurfaceLayerLand: return "surface_layer_land";
96  case SurfaceDiagnosticSource::LSMLand: return "lsm_land";
97  case SurfaceDiagnosticSource::SurfaceLayerFallback: return "surface_layer_fallback";
98  case SurfaceDiagnosticSource::SurfaceLayerSea: return "surface_layer_sea";
99  case SurfaceDiagnosticSource::Custom: return "custom";
100  case SurfaceDiagnosticSource::RICO: return "rico";
101  }
102  return "unknown";
103 }
104 
105 } // namespace surface_diagnostics
106 
107 #endif
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Definition: ERF_SurfaceDiagnosticSource.H:8
const char * source_name(SurfaceDiagnosticSource source) noexcept
Definition: ERF_SurfaceDiagnosticSource.H:91
SurfaceDiagnosticSource
Definition: ERF_SurfaceDiagnosticSource.H:16
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real to_plot_value(SurfaceDiagnosticSource source) noexcept
Definition: ERF_SurfaceDiagnosticSource.H:45
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE SurfaceDiagnosticSource classify_scalar_source(bool is_custom, bool is_rico, bool is_land, bool has_lsm_flux, bool lsm_flux_is_valid) noexcept
Definition: ERF_SurfaceDiagnosticSource.H:61
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int to_int(SurfaceDiagnosticSource source) noexcept
Definition: ERF_SurfaceDiagnosticSource.H:33
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool lsm_flux_is_valid(bool has_flux, bool is_land, amrex::Real flux, amrex::Real undefined)
Definition: ERF_SurfaceLayerStress.H:35