4 #ifndef ERF_PLOTFILE_SELECTION_H_
5 #define ERF_PLOTFILE_SELECTION_H_
10 #include <AMReX_Vector.H>
61 [[nodiscard]]
bool valid () const noexcept
67 inline Plot3DMoistureCapabilities
72 switch (moisture_type) {
73 case MoistureType::None:
75 case MoistureType::MoistNoCondensation:
81 case MoistureType::SatAdj:
86 case MoistureType::Kessler_NoRain:
90 case MoistureType::Kessler:
96 case MoistureType::SAM_NoPrecip_NoIce:
100 case MoistureType::SAM_NoIce:
106 case MoistureType::SAM:
117 case MoistureType::Morrison_NoIce:
125 case MoistureType::Morrison:
141 case MoistureType::WSM6:
152 case MoistureType::SuperDroplets:
161 amrex::Abort(
"Unknown MoistureType in plot3d_moisture_capabilities");
170 if (q < 1 || q > 11)
return -1;
177 if (
name ==
"density")
return 0;
178 if (
name ==
"rhotheta")
return 1;
179 if (
name ==
"rhoKE")
return 2;
180 if (
name ==
"rhoadv_0")
return 3;
182 if (
name.size() > 4 &&
name.compare(0, 4,
"rhoQ") == 0) {
183 const std::string suffix =
name.substr(4);
184 if (!suffix.empty() && std::all_of(suffix.cbegin(), suffix.cend(),
185 [] (
const char c) { return c >=
'0' && c <=
'9'; })) {
186 const int q = std::stoi(suffix);
218 const int moist_numconc_size)
220 if (moist_state_size <= 0 || moist_numconc_size < 0 ||
221 moist_numconc_size > moist_state_size) {
225 const int mass_count = moist_state_size - moist_numconc_size;
226 if (mass_count <= 0)
return {};
227 return {1, mass_count};
233 if (moist_state_size < 2)
return {};
234 return {1, moist_state_size > 3 ? 3 : 2};
239 const int moist_numconc_size)
243 if (!
total.valid())
return {};
245 const int first_precip_q = moist_state_size > 3 ? 4 : 3;
246 if (
total.last_q < first_precip_q)
return {};
247 return {first_precip_q,
total.last_q};
254 return range.
valid() &&
262 static constexpr
const char* names[] = {
263 "temp",
"theta",
"KE",
"scalar",
"soundspeed",
"reflectivity",
264 "max_reflectivity",
"mucape",
"vorticity_x",
"vorticity_y",
"vorticity_z",
265 "helicity",
"local_helicity",
"magvel",
"divU",
"pres_hse",
"dens_hse",
266 "theta_hse",
"qv_hse",
"pressure",
"pert_pres",
"pert_dens",
"buoyancy",
267 "eq_pot_temp",
"VPD",
"dpdx",
"dpdy",
"dpdz",
"pres_hse_x",
"pres_hse_y",
268 "pres_hse_z",
"z_phys",
"detJ",
"mapfac",
"lat_m",
"lon_m",
"pblh",
269 "shoc_cldfrac",
"shoc_ql",
"shoc_ql2",
"shoc_cond",
"wqls_sec",
"wthv_sec",
270 "w_sec",
"thl_sec",
"qw_sec",
"qwthl_sec",
"wthl_sec",
"wqw_sec",
"w3",
271 "brunt",
"isotropy",
"shear_prod",
"buoy_prod",
"diss_tke",
272 "terrain_IB_mask",
"volfrac"
275 for (
const char* candidate : names) {
276 if (
name == candidate)
return true;
279 #ifdef ERF_COMPUTE_ERROR
280 if (
name ==
"xvel_err" ||
name ==
"yvel_err" ||
name ==
"zvel_err" ||
281 name ==
"pp_err")
return true;
294 if (
name ==
"u_t_avg" ||
name ==
"v_t_avg" ||
name ==
"w_t_avg" ||
295 name ==
"umag_t_avg") {
298 if (
name ==
"qsrc_sw" ||
name ==
"qsrc_lw") {
308 const auto& moisture = caps.
moisture;
309 if (
name ==
"moist_density") {
310 return moisture.
vapor && moisture.cloud_liquid &&
327 return moisture.vapor &&
333 return moisture.cloud_liquid &&
338 return moisture.rain &&
346 if (
name ==
"rain_accum")
return moisture.rain_accumulation &&
348 if (
name ==
"snow_accum")
return moisture.snow_accumulation && caps.
qmoist_size >= 2;
349 if (
name ==
"graup_accum")
return moisture.graupel_accumulation && caps.
qmoist_size >= 3;
350 if (
name ==
"rel_humidity")
return moisture.relative_humidity_diagnostic &&
352 if (
name ==
"condensation_rate")
return moisture.condensation_rate_diagnostic && caps.
qmoist_size >= 4;
360 for (
const auto&
name : names) {
361 if (
name ==
"pressure" ||
name ==
"pert_pres" ||
363 name ==
"eq_pot_temp" ||
name ==
"VPD" ||
name ==
"qsat" ||
364 name ==
"rel_humidity") {
367 #ifdef ERF_COMPUTE_ERROR
368 if (
name ==
"pp_err")
return true;
374 inline amrex::Vector<std::string>
376 const amrex::Vector<std::string>& configured)
378 amrex::Vector<std::string> selected;
379 for (
const auto& count_name : requested) {
380 constexpr std::size_t suffix_size = 6;
381 if (count_name.size() > suffix_size &&
382 count_name.compare(count_name.size() - suffix_size, suffix_size,
"_count") == 0) {
383 const std::string container = count_name.substr(0, count_name.size() - suffix_size);
384 if (std::find(configured.cbegin(), configured.cend(), container) == configured.cend() ||
385 std::find(selected.cbegin(), selected.cend(), container) != selected.cend()) {
388 selected.push_back(container);
std::string name
Definition: ERF_Plotfile2DCatalog.cpp:101
@ total
Definition: ERF_NOAHMP_Fields.H:130
@ q
Definition: ERF_WSM6.H:184
Definition: ERF_PlotfileSelection.H:15
int plot3d_q_conserved_component_index(const int q)
Definition: ERF_PlotfileSelection.H:168
bool plot3d_moist_q_component_available(const Plot3DSelectionCapabilities &caps, const int q)
Definition: ERF_PlotfileSelection.H:209
int plot3d_conserved_component_index(const std::string &name)
Definition: ERF_PlotfileSelection.H:175
bool plot3d_source_component_available(const Plot3DSelectionCapabilities &caps, const int q)
Definition: ERF_PlotfileSelection.H:201
Plot3DQRange plot3d_precipitating_q_range(const int moist_state_size, const int moist_numconc_size)
Definition: ERF_PlotfileSelection.H:238
Plot3DMoistureCapabilities plot3d_moisture_capabilities(const MoistureType moisture_type)
Definition: ERF_PlotfileSelection.H:68
Plot3DQRange plot3d_nonprecipitating_q_range(const int moist_state_size)
Definition: ERF_PlotfileSelection.H:231
Plot3DQRange plot3d_total_mass_q_range(const int moist_state_size, const int moist_numconc_size)
Definition: ERF_PlotfileSelection.H:217
bool plot3d_has_moist_state(const Plot3DSelectionCapabilities &caps)
Definition: ERF_PlotfileSelection.H:195
bool plot3d_needs_pressure(const amrex::Vector< std::string > &names)
Definition: ERF_PlotfileSelection.H:358
bool plot3d_fixed_variable_available(const std::string &name, const Plot3DSelectionCapabilities &caps)
Definition: ERF_PlotfileSelection.H:288
bool plot3d_q_range_available(const Plot3DSelectionCapabilities &caps, const Plot3DQRange range)
Definition: ERF_PlotfileSelection.H:251
amrex::Vector< std::string > plot3d_selected_particle_count_names(const amrex::Vector< std::string > &requested, const amrex::Vector< std::string > &configured)
Definition: ERF_PlotfileSelection.H:375
bool plot3d_fixed_unconditional_diagnostic(const std::string &name)
Definition: ERF_PlotfileSelection.H:260
Definition: ERF_PlotfileSelection.H:18
bool snow_number
Definition: ERF_PlotfileSelection.H:29
bool rain_accumulation
Definition: ERF_PlotfileSelection.H:32
bool rain_number
Definition: ERF_PlotfileSelection.H:28
bool cloud_liquid
Definition: ERF_PlotfileSelection.H:20
bool cloud_number
Definition: ERF_PlotfileSelection.H:26
bool relative_humidity_diagnostic
Definition: ERF_PlotfileSelection.H:35
bool graupel
Definition: ERF_PlotfileSelection.H:24
bool snow_accumulation
Definition: ERF_PlotfileSelection.H:33
bool snow
Definition: ERF_PlotfileSelection.H:23
bool graupel_number
Definition: ERF_PlotfileSelection.H:30
bool condensation_rate_diagnostic
Definition: ERF_PlotfileSelection.H:36
bool ice_number
Definition: ERF_PlotfileSelection.H:27
bool vapor
Definition: ERF_PlotfileSelection.H:19
bool graupel_accumulation
Definition: ERF_PlotfileSelection.H:34
bool rain
Definition: ERF_PlotfileSelection.H:22
bool cloud_ice
Definition: ERF_PlotfileSelection.H:21
Definition: ERF_PlotfileSelection.H:57
int first_q
Definition: ERF_PlotfileSelection.H:58
bool valid() const noexcept
Definition: ERF_PlotfileSelection.H:61
int last_q
Definition: ERF_PlotfileSelection.H:59
Definition: ERF_PlotfileSelection.H:40
bool eddy_diffusivity_storage
Definition: ERF_PlotfileSelection.H:51
Plot3DMoistureCapabilities moisture
Definition: ERF_PlotfileSelection.H:47
int moist_state_size
Definition: ERF_PlotfileSelection.H:42
bool dissipation_storage
Definition: ERF_PlotfileSelection.H:52
int moist_numconc_size
Definition: ERF_PlotfileSelection.H:43
MoistureType moisture_type
Definition: ERF_PlotfileSelection.H:45
bool radiation_heating_storage
Definition: ERF_PlotfileSelection.H:50
int qmoist_size
Definition: ERF_PlotfileSelection.H:44
bool wall_distance_storage
Definition: ERF_PlotfileSelection.H:53
bool time_average_storage
Definition: ERF_PlotfileSelection.H:49
int conserved_state_size
Definition: ERF_PlotfileSelection.H:41