ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_WallThermodynamics.H
Go to the documentation of this file.
1 #ifndef ERF_WALL_THERMODYNAMICS_H_
2 #define ERF_WALL_THERMODYNAMICS_H_
3 
4 #include <AMReX_Array.H>
5 #include <AMReX_GpuQualifiers.H>
6 #include <AMReX_REAL.H>
7 
8 #include <type_traits>
9 
11 
12 // These compact enums and the face record are copied into GPU kernels. Keep
13 // parsing strings and all other host-only state outside this representation.
14 enum class ThermalMode : unsigned char {
17  Adiabatic
18 };
19 
20 enum class MoistureMode : unsigned char {
24 };
25 
26 enum class MomentumModel : unsigned char {
28  BulkAero,
30 };
31 
32 enum class ScalarModel : unsigned char {
34  BulkAero,
36 };
37 
38 enum class CoefficientProvider : unsigned char {
39  None,
40  Fixed,
41  MOST
42 };
43 
46  amrex::Real temperature_K = amrex::Real(0.0);
47 };
48 
49 // Non-owning device views for sidewall scalar fluxes. MOST is restricted to
50 // the horizontal plates; supported sidewall drag and rate laws need no panel
51 // temperature. Null offsets select the original uniform-temperature wall law.
53  amrex::Real temperature_K;
54  amrex::Real fraction;
55 };
56 
58  const int* offsets = nullptr;
59  const TemperaturePanel* panels = nullptr;
60  int k_lo = 0;
61 };
62 
63 using SidewallBandViews = amrex::GpuArray<TemperatureBandView, 4>; // xlo, xhi, ylo, yhi
64 static_assert(std::is_trivially_copyable_v<TemperatureBandView>);
65 
69  amrex::Real C_D = amrex::Real(0.0);
70  amrex::Real z0_m = amrex::Real(0.0);
71  amrex::Real molecular_speed = amrex::Real(0.0); // nu / half-cell distance [m/s]
72  amrex::Real resolved_row_rate = amrex::Real(0.0); // ordinary no-slip stencil [1/s]; guard only
73 };
74 
78  amrex::Real coefficient = amrex::Real(0.0);
79  amrex::Real z0 = amrex::Real(0.0);
80  // Both speeds have units of m/s (alpha / half-cell distance); at most one is active.
81  amrex::Real molecular_speed = amrex::Real(0.0); // additive part of a combined bulk law only
82  // Resolved-only reference for the corner timestep. The resolved flux already uses alpha.
83  amrex::Real resolved_speed = amrex::Real(0.0);
84 };
85 
86 struct FaceWall {
89  amrex::Real wetness = amrex::Real(1.0); // Prescribed RH over liquid on wet walls.
93  amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> wall_velocity{};
94 
95  // Activity, not ownership: an adiabatic face still replaces the heat flux with zero.
96  AMREX_GPU_HOST_DEVICE constexpr bool heat_is_conductive () const noexcept
98 
99  AMREX_GPU_HOST_DEVICE constexpr bool vapor_is_wet () const noexcept
101 
102  AMREX_GPU_HOST_DEVICE constexpr bool momentum_uses_most () const noexcept
103  {
106  }
107 
108  AMREX_GPU_HOST_DEVICE constexpr bool heat_uses_most () const noexcept
109  {
112  }
113 
114  AMREX_GPU_HOST_DEVICE constexpr bool vapor_uses_most () const noexcept
115  {
118  }
119 
120  AMREX_GPU_HOST_DEVICE constexpr bool momentum_requires_speed () const noexcept
122 
123  AMREX_GPU_HOST_DEVICE constexpr bool heat_requires_speed () const noexcept
125 
126  AMREX_GPU_HOST_DEVICE constexpr bool vapor_requires_speed () const noexcept
128 
129  AMREX_GPU_HOST_DEVICE constexpr bool has_wall_rate_channel () const noexcept
131 };
132 
133 using Boundary = amrex::GpuArray<FaceWall, 2 * AMREX_SPACEDIM>;
134 
135 static_assert(std::is_trivially_copyable_v<ThermalBoundary>);
136 static_assert(std::is_standard_layout_v<ThermalBoundary>);
137 static_assert(std::is_trivially_copyable_v<MomentumTransfer>);
138 static_assert(std::is_standard_layout_v<MomentumTransfer>);
139 static_assert(std::is_trivially_copyable_v<ScalarTransfer>);
140 static_assert(std::is_standard_layout_v<ScalarTransfer>);
141 static_assert(std::is_trivially_copyable_v<FaceWall>);
142 static_assert(std::is_standard_layout_v<FaceWall>);
143 
144 } // namespace erf_wall_thermodynamics
145 
146 #endif
Definition: ERF_WallThermodynamics.H:10
MomentumModel
Definition: ERF_WallThermodynamics.H:26
amrex::GpuArray< TemperatureBandView, 4 > SidewallBandViews
Definition: ERF_WallThermodynamics.H:63
CoefficientProvider
Definition: ERF_WallThermodynamics.H:38
ScalarModel
Definition: ERF_WallThermodynamics.H:32
MoistureMode
Definition: ERF_WallThermodynamics.H:20
ThermalMode
Definition: ERF_WallThermodynamics.H:14
amrex::GpuArray< FaceWall, 2 *AMREX_SPACEDIM > Boundary
Definition: ERF_WallThermodynamics.H:133
Definition: ERF_WallThermodynamics.H:86
constexpr AMREX_GPU_HOST_DEVICE bool heat_is_conductive() const noexcept
Definition: ERF_WallThermodynamics.H:96
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > wall_velocity
Definition: ERF_WallThermodynamics.H:93
ScalarTransfer vapor
Definition: ERF_WallThermodynamics.H:92
ScalarTransfer heat
Definition: ERF_WallThermodynamics.H:91
constexpr AMREX_GPU_HOST_DEVICE bool has_wall_rate_channel() const noexcept
Definition: ERF_WallThermodynamics.H:129
constexpr AMREX_GPU_HOST_DEVICE bool heat_uses_most() const noexcept
Definition: ERF_WallThermodynamics.H:108
constexpr AMREX_GPU_HOST_DEVICE bool vapor_is_wet() const noexcept
Definition: ERF_WallThermodynamics.H:99
constexpr AMREX_GPU_HOST_DEVICE bool momentum_uses_most() const noexcept
Definition: ERF_WallThermodynamics.H:102
MoistureMode moisture
Definition: ERF_WallThermodynamics.H:88
MomentumTransfer momentum
Definition: ERF_WallThermodynamics.H:90
amrex::Real wetness
Definition: ERF_WallThermodynamics.H:89
constexpr AMREX_GPU_HOST_DEVICE bool vapor_uses_most() const noexcept
Definition: ERF_WallThermodynamics.H:114
ThermalBoundary thermal
Definition: ERF_WallThermodynamics.H:87
constexpr AMREX_GPU_HOST_DEVICE bool vapor_requires_speed() const noexcept
Definition: ERF_WallThermodynamics.H:126
constexpr AMREX_GPU_HOST_DEVICE bool momentum_requires_speed() const noexcept
Definition: ERF_WallThermodynamics.H:120
constexpr AMREX_GPU_HOST_DEVICE bool heat_requires_speed() const noexcept
Definition: ERF_WallThermodynamics.H:123
Definition: ERF_WallThermodynamics.H:66
amrex::Real resolved_row_rate
Definition: ERF_WallThermodynamics.H:72
amrex::Real z0_m
Definition: ERF_WallThermodynamics.H:70
CoefficientProvider provider
Definition: ERF_WallThermodynamics.H:68
amrex::Real C_D
Definition: ERF_WallThermodynamics.H:69
MomentumModel model
Definition: ERF_WallThermodynamics.H:67
amrex::Real molecular_speed
Definition: ERF_WallThermodynamics.H:71
Definition: ERF_WallThermodynamics.H:75
amrex::Real coefficient
Definition: ERF_WallThermodynamics.H:78
CoefficientProvider provider
Definition: ERF_WallThermodynamics.H:77
amrex::Real z0
Definition: ERF_WallThermodynamics.H:79
amrex::Real resolved_speed
Definition: ERF_WallThermodynamics.H:83
amrex::Real molecular_speed
Definition: ERF_WallThermodynamics.H:81
ScalarModel model
Definition: ERF_WallThermodynamics.H:76
Definition: ERF_WallThermodynamics.H:57
const TemperaturePanel * panels
Definition: ERF_WallThermodynamics.H:59
const int * offsets
Definition: ERF_WallThermodynamics.H:58
int k_lo
Definition: ERF_WallThermodynamics.H:60
Definition: ERF_WallThermodynamics.H:52
amrex::Real temperature_K
Definition: ERF_WallThermodynamics.H:53
amrex::Real fraction
Definition: ERF_WallThermodynamics.H:54
Definition: ERF_WallThermodynamics.H:44
amrex::Real temperature_K
Definition: ERF_WallThermodynamics.H:46
ThermalMode mode
Definition: ERF_WallThermodynamics.H:45