ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ShocTypes.H
Go to the documentation of this file.
1 #ifndef ERF_SHOC_TYPES_H_
2 #define ERF_SHOC_TYPES_H_
3 
4 #include "ERF_DataStruct.H"
5 
6 #include <AMReX_FArrayBox.H>
7 #include <AMReX_Geometry.H>
8 #include <AMReX_GpuQualifiers.H>
9 #include <AMReX_ParmParse.H>
10 #include <AMReX_Vector.H>
11 
12 #include <algorithm>
13 #include <cctype>
14 #include <string>
15 
17 {
22 
27 
34 
35  bool shoc_1p5tke = false;
36  bool extra_shoc_diags = false;
37  bool apply_tms = false;
38  bool check_flux_state = false;
40  bool debug_summary = false;
42  bool signed_tke_production = false;
45  bool debug_bad_column = false;
57 };
58 
59 inline bool
61  std::string& error_message)
62 {
65  error_message =
66  "erf.shoc.transport_mode = host_diffusion requires erf.shoc.momentum_transport = host_diffusion";
67  return false;
68  }
69  return true;
70 }
71 
73 {
74  int nx = 0;
75  int ny = 0;
76  int ncell = 0;
77  int nlev = 0;
78  int imin = 0;
79  int jmin = 0;
80  int kmin = 0;
81  int kmax = -1;
82 };
83 
85 {
87 
88  // Absolute physical cell-center and interface heights [m].
89  amrex::FArrayBox zt;
90  amrex::FArrayBox zi;
91  amrex::FArrayBox dz;
92  amrex::FArrayBox p_mid;
93  amrex::FArrayBox p_int;
94  amrex::FArrayBox rho;
95  amrex::FArrayBox theta;
96  amrex::FArrayBox exner;
97  amrex::FArrayBox theta_v;
98  amrex::FArrayBox thetal;
99  amrex::FArrayBox qv;
100  amrex::FArrayBox qc;
101  amrex::FArrayBox qi;
102  amrex::FArrayBox qw;
103  amrex::FArrayBox tabs;
104  amrex::FArrayBox tke;
105  amrex::FArrayBox u;
106  amrex::FArrayBox v;
107  amrex::FArrayBox w;
108  amrex::FArrayBox host_dse;
109 
110  // Native SHOC PBL height in meters above local ground (AGL).
111  amrex::FArrayBox pblh;
112  amrex::FArrayBox obklen;
113  amrex::FArrayBox ustar;
114  amrex::FArrayBox shoc_mix;
115  amrex::FArrayBox brunt;
116  amrex::FArrayBox isotropy;
117  amrex::FArrayBox tk;
118  amrex::FArrayBox tkh;
119  amrex::FArrayBox shear_prod;
120  amrex::FArrayBox buoy_prod;
121  amrex::FArrayBox diss_tke;
122  amrex::FArrayBox wthv_sec;
123  amrex::FArrayBox shoc_cldfrac;
124  amrex::FArrayBox shoc_ql;
125  amrex::FArrayBox shoc_ql2;
126  amrex::FArrayBox wqls_sec;
127  amrex::FArrayBox shoc_cond;
128  amrex::FArrayBox shoc_evap;
129 
130  amrex::FArrayBox thl_sec;
131  amrex::FArrayBox qw_sec;
132  amrex::FArrayBox qwthl_sec;
133  amrex::FArrayBox wthl_sec;
134  amrex::FArrayBox wqw_sec;
135  amrex::FArrayBox uw_sec;
136  amrex::FArrayBox vw_sec;
137  amrex::FArrayBox wtke_sec;
138  amrex::FArrayBox w3;
139  amrex::FArrayBox w_sec;
140 
141  amrex::FArrayBox thetal_base;
142  amrex::FArrayBox theta_base;
143  amrex::FArrayBox qv_base;
144  amrex::FArrayBox qc_base;
145  amrex::FArrayBox qi_base;
146  amrex::FArrayBox u_base;
147  amrex::FArrayBox v_base;
148  amrex::FArrayBox tke_base_state;
149 
150  amrex::FArrayBox theta_tend;
151  amrex::FArrayBox qv_tend;
152  amrex::FArrayBox qc_tend;
153  amrex::FArrayBox qi_tend;
154  amrex::FArrayBox u_tend;
155  amrex::FArrayBox v_tend;
156  amrex::FArrayBox tke_tend;
157  amrex::FArrayBox surf_sens_flux;
158  amrex::FArrayBox surf_lat_flux;
159  amrex::FArrayBox surf_tau_u;
160  amrex::FArrayBox surf_tau_v;
161 };
162 
163 inline void
165 {
166  amrex::ParmParse pp("erf.shoc");
167 
168  pp.query("lambda_low", opts.lambda_low);
169  pp.query("lambda_high", opts.lambda_high);
170  pp.query("lambda_slope", opts.lambda_slope);
171  pp.query("lambda_thresh", opts.lambda_thresh);
172  pp.query("thl2tune", opts.thl2tune);
173  pp.query("qw2tune", opts.qw2tune);
174  pp.query("qwthl2tune", opts.qwthl2tune);
175  pp.query("w2tune", opts.w2tune);
176  pp.query("length_fac", opts.length_fac);
177  pp.query("c_diag_3rd_mom", opts.c_diag_3rd_mom);
178  pp.query("coeff_kh", opts.coeff_kh);
179  pp.query("coeff_km", opts.coeff_km);
180  pp.query("top_taper_depth", opts.top_taper_depth);
181  pp.query("top_taper_min_factor", opts.top_taper_min_factor);
182  pp.query("shoc_1p5tke", opts.shoc_1p5tke);
183  pp.query("extra_shoc_diags", opts.extra_shoc_diags);
184  pp.query("apply_tms", opts.apply_tms);
185  pp.query("check_flux_state", opts.check_flux_state);
186  pp.query("column_conservation_check", opts.column_conservation_check);
187  pp.query("debug_summary", opts.debug_summary);
188  pp.query("allow_tendency_microphysics_overlap", opts.allow_tendency_microphysics_overlap);
189  pp.query("signed_tke_production", opts.signed_tke_production);
190  pp.query("debug_bad_column", opts.debug_bad_column);
191  pp.query("debug_bad_column_abort", opts.debug_bad_column_abort);
192  pp.query("debug_bad_column_max_reports", opts.debug_bad_column_max_reports);
193  pp.query("debug_bad_column_theta_tend_threshold", opts.debug_bad_column_theta_tend_threshold);
194  pp.query("debug_bad_column_q_tend_threshold", opts.debug_bad_column_q_tend_threshold);
195  pp.query("debug_bad_column_brunt_threshold", opts.debug_bad_column_brunt_threshold);
196  pp.query("debug_bad_column_min_dz", opts.debug_bad_column_min_dz);
197  pp.query("debug_bad_column_scalar_moment_threshold", opts.debug_bad_column_scalar_moment_threshold);
198  pp.query("debug_disable_pdf_cloud_increment", opts.debug_disable_pdf_cloud_increment);
199  pp.query("debug_disable_theta_state_update", opts.debug_disable_theta_state_update);
200  pp.query("debug_disable_moisture_state_update", opts.debug_disable_moisture_state_update);
201  pp.query("debug_disable_tke_state_update", opts.debug_disable_tke_state_update);
202 
203  // SolverChoice parses these too, since the dycore must know which component
204  // owns vertical diffusion before any SHOC driver exists. Both go through the
205  // same reader so the two views of the inputs cannot diverge.
207 }
208 
209 inline void
211 {
212  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.lambda_low > 0.0, "erf.shoc.lambda_low must be positive");
214  "erf.shoc.lambda_high must be >= lambda_low");
215  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.length_fac > 0.0, "erf.shoc.length_fac must be positive");
216  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.coeff_kh >= 0.0, "erf.shoc.coeff_kh must be non-negative");
217  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.coeff_km >= 0.0, "erf.shoc.coeff_km must be non-negative");
219  "erf.shoc.top_taper_depth must be non-negative");
221  opts.top_taper_min_factor <= 1.0,
222  "erf.shoc.top_taper_min_factor must be in [0, 1]");
224  "erf.shoc.debug_bad_column_max_reports must be positive");
226  "erf.shoc.debug_bad_column_theta_tend_threshold must be positive");
228  "erf.shoc.debug_bad_column_q_tend_threshold must be positive");
230  "erf.shoc.debug_bad_column_brunt_threshold must be positive");
232  "erf.shoc.debug_bad_column_min_dz must be positive");
234  "erf.shoc.debug_bad_column_scalar_moment_threshold must be positive");
235  std::string error_message;
237  error_message.c_str());
238 }
239 
240 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
241 bool
242 shoc_valid_comp (int comp, int ncomp)
243 {
244  return comp >= 0 && comp < ncomp;
245 }
246 
247 template <typename T>
248 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
249 T
250 shoc_clamp (T value, T lo, T hi)
251 {
252  return amrex::max(lo, amrex::min(value, hi));
253 }
254 
255 #endif
ParmParse pp("prob")
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_cloud_chamber_config.active, "Cloud Chamber: initializer reached without a parsed configuration")
amrex::Real Real
Definition: ERF_ShocInterface.H:19
ShocMomentumTransport
Definition: ERF_ShocTransportStruct.H:17
bool shoc_uses_host_diffusion(ShocTransportMode mode)
Definition: ERF_ShocTransportStruct.H:51
void read_shoc_transport_modes(ShocTransportMode &transport_mode, ShocMomentumTransport &momentum_transport)
Read the native SHOC transport modes from the erf.shoc input namespace.
Definition: ERF_ShocTransportStruct.H:138
bool shoc_uses_momentum_host_diffusion(ShocMomentumTransport mode)
Definition: ERF_ShocTransportStruct.H:63
ShocTransportMode
Definition: ERF_ShocTransportStruct.H:11
void validate_shoc_runtime_options(const ShocRuntimeOptions &opts)
Definition: ERF_ShocTypes.H:210
bool validate_shoc_runtime_options_message(const ShocRuntimeOptions &opts, std::string &error_message)
Definition: ERF_ShocTypes.H:60
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool shoc_valid_comp(int comp, int ncomp)
Definition: ERF_ShocTypes.H:242
void read_shoc_runtime_options(ShocRuntimeOptions &opts)
Definition: ERF_ShocTypes.H:164
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T shoc_clamp(T value, T lo, T hi)
Definition: ERF_ShocTypes.H:250
@ T
Definition: ERF_IndexDefines.H:128
Definition: ERF_ShocTypes.H:85
amrex::FArrayBox theta_v
Definition: ERF_ShocTypes.H:97
amrex::FArrayBox theta
Definition: ERF_ShocTypes.H:95
amrex::FArrayBox qc_tend
Definition: ERF_ShocTypes.H:152
amrex::FArrayBox theta_base
Definition: ERF_ShocTypes.H:142
amrex::FArrayBox v_tend
Definition: ERF_ShocTypes.H:155
amrex::FArrayBox shoc_cond
Definition: ERF_ShocTypes.H:127
amrex::FArrayBox qi
Definition: ERF_ShocTypes.H:101
amrex::FArrayBox buoy_prod
Definition: ERF_ShocTypes.H:120
amrex::FArrayBox dz
Definition: ERF_ShocTypes.H:91
amrex::FArrayBox diss_tke
Definition: ERF_ShocTypes.H:121
amrex::FArrayBox w_sec
Definition: ERF_ShocTypes.H:139
amrex::FArrayBox tk
Definition: ERF_ShocTypes.H:117
amrex::FArrayBox w3
Definition: ERF_ShocTypes.H:138
amrex::FArrayBox vw_sec
Definition: ERF_ShocTypes.H:136
amrex::FArrayBox surf_lat_flux
Definition: ERF_ShocTypes.H:158
amrex::FArrayBox ustar
Definition: ERF_ShocTypes.H:113
amrex::FArrayBox shoc_evap
Definition: ERF_ShocTypes.H:128
amrex::FArrayBox shoc_mix
Definition: ERF_ShocTypes.H:114
amrex::FArrayBox v_base
Definition: ERF_ShocTypes.H:147
amrex::FArrayBox wthv_sec
Definition: ERF_ShocTypes.H:122
amrex::FArrayBox shear_prod
Definition: ERF_ShocTypes.H:119
amrex::FArrayBox rho
Definition: ERF_ShocTypes.H:94
amrex::FArrayBox tke_base_state
Definition: ERF_ShocTypes.H:148
amrex::FArrayBox wqw_sec
Definition: ERF_ShocTypes.H:134
amrex::FArrayBox qv_base
Definition: ERF_ShocTypes.H:143
amrex::FArrayBox shoc_ql
Definition: ERF_ShocTypes.H:124
amrex::FArrayBox uw_sec
Definition: ERF_ShocTypes.H:135
amrex::FArrayBox w
Definition: ERF_ShocTypes.H:107
amrex::FArrayBox host_dse
Definition: ERF_ShocTypes.H:108
amrex::FArrayBox pblh
Definition: ERF_ShocTypes.H:111
amrex::FArrayBox qc
Definition: ERF_ShocTypes.H:100
amrex::FArrayBox surf_tau_v
Definition: ERF_ShocTypes.H:160
amrex::FArrayBox isotropy
Definition: ERF_ShocTypes.H:116
amrex::FArrayBox tke
Definition: ERF_ShocTypes.H:104
amrex::FArrayBox p_int
Definition: ERF_ShocTypes.H:93
amrex::FArrayBox qw_sec
Definition: ERF_ShocTypes.H:131
amrex::FArrayBox qi_base
Definition: ERF_ShocTypes.H:145
amrex::FArrayBox tkh
Definition: ERF_ShocTypes.H:118
amrex::FArrayBox exner
Definition: ERF_ShocTypes.H:96
amrex::FArrayBox u_base
Definition: ERF_ShocTypes.H:146
amrex::FArrayBox tke_tend
Definition: ERF_ShocTypes.H:156
amrex::FArrayBox qi_tend
Definition: ERF_ShocTypes.H:153
amrex::FArrayBox qc_base
Definition: ERF_ShocTypes.H:144
amrex::FArrayBox u_tend
Definition: ERF_ShocTypes.H:154
ShocColumnLayout layout
Definition: ERF_ShocTypes.H:86
amrex::FArrayBox zi
Definition: ERF_ShocTypes.H:90
amrex::FArrayBox tabs
Definition: ERF_ShocTypes.H:103
amrex::FArrayBox surf_sens_flux
Definition: ERF_ShocTypes.H:157
amrex::FArrayBox qw
Definition: ERF_ShocTypes.H:102
amrex::FArrayBox v
Definition: ERF_ShocTypes.H:106
amrex::FArrayBox zt
Definition: ERF_ShocTypes.H:89
amrex::FArrayBox qv
Definition: ERF_ShocTypes.H:99
amrex::FArrayBox p_mid
Definition: ERF_ShocTypes.H:92
amrex::FArrayBox wtke_sec
Definition: ERF_ShocTypes.H:137
amrex::FArrayBox u
Definition: ERF_ShocTypes.H:105
amrex::FArrayBox theta_tend
Definition: ERF_ShocTypes.H:150
amrex::FArrayBox obklen
Definition: ERF_ShocTypes.H:112
amrex::FArrayBox wqls_sec
Definition: ERF_ShocTypes.H:126
amrex::FArrayBox surf_tau_u
Definition: ERF_ShocTypes.H:159
amrex::FArrayBox qv_tend
Definition: ERF_ShocTypes.H:151
amrex::FArrayBox wthl_sec
Definition: ERF_ShocTypes.H:133
amrex::FArrayBox thl_sec
Definition: ERF_ShocTypes.H:130
amrex::FArrayBox shoc_ql2
Definition: ERF_ShocTypes.H:125
amrex::FArrayBox thetal_base
Definition: ERF_ShocTypes.H:141
amrex::FArrayBox qwthl_sec
Definition: ERF_ShocTypes.H:132
amrex::FArrayBox brunt
Definition: ERF_ShocTypes.H:115
amrex::FArrayBox shoc_cldfrac
Definition: ERF_ShocTypes.H:123
amrex::FArrayBox thetal
Definition: ERF_ShocTypes.H:98
Definition: ERF_ShocTypes.H:73
int imin
Definition: ERF_ShocTypes.H:78
int nlev
Definition: ERF_ShocTypes.H:77
int kmax
Definition: ERF_ShocTypes.H:81
int ncell
Definition: ERF_ShocTypes.H:76
int jmin
Definition: ERF_ShocTypes.H:79
int ny
Definition: ERF_ShocTypes.H:75
int nx
Definition: ERF_ShocTypes.H:74
int kmin
Definition: ERF_ShocTypes.H:80
Definition: ERF_ShocTypes.H:17
int debug_bad_column_max_reports
Definition: ERF_ShocTypes.H:47
ShocTransportMode transport_mode
Definition: ERF_ShocTypes.H:43
bool debug_disable_moisture_state_update
Definition: ERF_ShocTypes.H:55
bool shoc_1p5tke
Definition: ERF_ShocTypes.H:35
amrex::Real debug_bad_column_q_tend_threshold
Definition: ERF_ShocTypes.H:49
amrex::Real coeff_kh
Definition: ERF_ShocTypes.H:30
amrex::Real top_taper_depth
Definition: ERF_ShocTypes.H:32
amrex::Real debug_bad_column_scalar_moment_threshold
Definition: ERF_ShocTypes.H:52
amrex::Real lambda_high
Definition: ERF_ShocTypes.H:19
amrex::Real w2tune
Definition: ERF_ShocTypes.H:26
amrex::Real debug_bad_column_min_dz
Definition: ERF_ShocTypes.H:51
amrex::Real qwthl2tune
Definition: ERF_ShocTypes.H:25
bool debug_disable_pdf_cloud_increment
Definition: ERF_ShocTypes.H:53
amrex::Real c_diag_3rd_mom
Definition: ERF_ShocTypes.H:29
ShocMomentumTransport momentum_transport
Definition: ERF_ShocTypes.H:44
bool column_conservation_check
Definition: ERF_ShocTypes.H:39
amrex::Real lambda_thresh
Definition: ERF_ShocTypes.H:21
bool extra_shoc_diags
Definition: ERF_ShocTypes.H:36
amrex::Real coeff_km
Definition: ERF_ShocTypes.H:31
bool debug_disable_theta_state_update
Definition: ERF_ShocTypes.H:54
amrex::Real debug_bad_column_theta_tend_threshold
Definition: ERF_ShocTypes.H:48
amrex::Real lambda_slope
Definition: ERF_ShocTypes.H:20
amrex::Real lambda_low
Definition: ERF_ShocTypes.H:18
bool debug_bad_column
Definition: ERF_ShocTypes.H:45
bool signed_tke_production
Definition: ERF_ShocTypes.H:42
amrex::Real debug_bad_column_brunt_threshold
Definition: ERF_ShocTypes.H:50
bool debug_disable_tke_state_update
Definition: ERF_ShocTypes.H:56
bool apply_tms
Definition: ERF_ShocTypes.H:37
bool debug_bad_column_abort
Definition: ERF_ShocTypes.H:46
bool allow_tendency_microphysics_overlap
Definition: ERF_ShocTypes.H:41
bool check_flux_state
Definition: ERF_ShocTypes.H:38
amrex::Real length_fac
Definition: ERF_ShocTypes.H:28
amrex::Real top_taper_min_factor
Definition: ERF_ShocTypes.H:33
amrex::Real thl2tune
Definition: ERF_ShocTypes.H:23
amrex::Real qw2tune
Definition: ERF_ShocTypes.H:24
bool debug_summary
Definition: ERF_ShocTypes.H:40