ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
erf_plotfile Namespace Reference

Classes

struct  Plot3DSelectionCapabilities
 What the active run can supply to a 3D plotfile. More...
 

Functions

bool radiation_heating_storage_available (RadiationType rad_model)
 Whether the SW/LW heating-rate storage (qsrc_sw, qsrc_lw) exists: every erf.radiation_model other than None (RRTMGP, Simple, TwoStream) allocates the same qheating_rates array. More...
 
void plot3d_set_state_capabilities (Plot3DSelectionCapabilities &caps, const MoistureComponentIndices &mi, const int qstate_moist_size, const int qstate_size)
 Record the conserved-state layout of a run on its capabilities. More...
 
bool plot3d_batch_resets_interval_means (int plotfiles_written, bool interval_diagnostic_consumed, bool compute_mean_vars, const std::string &reset_mode)
 
int plot3d_q_conserved_component_index (const int q)
 Conserved-state component holding the q-th moist variable, or -1 if q is outside the fixed RhoQ1..RhoQ11 layout. More...
 
amrex::Vector< std::string > plot3d_conserved_state_names ()
 Names of the raw conserved-state variables, in component order. More...
 
int plot3d_conserved_component_index (const std::string &name)
 Conserved-state component behind a raw state variable name ("density", "rhotheta", "smoke", "rhoQ3", ...), or -1 if the name is not one. The smoke scalar is written as stored, i.e. as a mass concentration (rho times the mixing ratio), like rhoadv_0. More...
 
bool plot3d_fixed_unconditional_diagnostic (const std::string &name)
 Diagnostics that every run can write, moist or dry. More...
 
bool plot3d_interval_mean_diagnostic (const std::string &name)
 Whether a named 3D plot variable can be written by this run. More...
 
bool plot3d_selection_has_interval_mean_diagnostic (const amrex::Vector< std::string > &names)
 
bool plot3d_fixed_variable_available (const std::string &name, const Plot3DSelectionCapabilities &caps)
 
bool plot3d_needs_pressure (const amrex::Vector< std::string > &names)
 Whether any requested variable needs the pressure field computed. More...
 
amrex::Vector< std::string > plot3d_selected_particle_count_names (const amrex::Vector< std::string > &requested, const amrex::Vector< std::string > &configured)
 

Function Documentation

◆ plot3d_batch_resets_interval_means()

bool erf_plotfile::plot3d_batch_resets_interval_means ( int  plotfiles_written,
bool  interval_diagnostic_consumed,
bool  compute_mean_vars,
const std::string &  reset_mode 
)
inline
99 {
100  return plotfiles_written > 0 && interval_diagnostic_consumed &&
101  compute_mean_vars && reset_mode == "plotfile";
102 }

Referenced by ERF::ResetIntervalMeansAfter3DPlotfileBatch().

Here is the caller graph for this function:

◆ plot3d_conserved_component_index()

int erf_plotfile::plot3d_conserved_component_index ( const std::string &  name)
inline

Conserved-state component behind a raw state variable name ("density", "rhotheta", "smoke", "rhoQ3", ...), or -1 if the name is not one. The smoke scalar is written as stored, i.e. as a mass concentration (rho times the mixing ratio), like rhoadv_0.

147 {
148  if (name == "density") return Rho_comp;
149  if (name == "rhotheta") return RhoTheta_comp;
150  if (name == "rhoKE") return RhoKE_comp;
151  if (name == "rhoadv_0") return RhoScalar_comp;
152 #ifdef ERF_USE_FIRE
153  if (name == "smoke") return RhoSmoke_comp;
154 #endif
155 
156  if (name.size() > 4 && name.compare(0, 4, "rhoQ") == 0) {
157  // Parse the digits by hand, stopping once past the RhoQ11 limit, so a
158  // long numeric suffix cannot overflow int (std::stoi would throw)
159  int q = 0;
160  for (std::size_t i = 4; i < name.size(); ++i) {
161  const char c = name[i];
162  if (c < '0' || c > '9') return -1;
163  q = 10 * q + (c - '0');
164  if (q > 11) return -1;
165  }
167  }
168 
169  return -1;
170 }
#define RhoScalar_comp
Definition: ERF_IndexDefines.H:57
#define Rho_comp
Definition: ERF_IndexDefines.H:53
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:54
#define RhoKE_comp
Definition: ERF_IndexDefines.H:55
std::string name
Definition: ERF_Plotfile2DCatalog.cpp:116
@ q
Definition: ERF_WSM6.H:294
int plot3d_q_conserved_component_index(const int q)
Conserved-state component holding the q-th moist variable, or -1 if q is outside the fixed RhoQ1....
Definition: ERF_PlotfileSelection.H:109

Referenced by ERF::FillPlot3DVars(), and plot3d_fixed_variable_available().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plot3d_conserved_state_names()

amrex::Vector<std::string> erf_plotfile::plot3d_conserved_state_names ( )
inline

Names of the raw conserved-state variables, in component order.

The optional smoke scalar (RhoSmoke_comp, under ERF_USE_FIRE) sits between rhoadv_0 and rhoQ1 exactly as in ERF_IndexDefines.H. Every name here must map to a component in plot3d_conserved_component_index, or it can never be plotted.

125 {
126  amrex::Vector<std::string> names = {"density", "rhotheta", "rhoKE", "rhoadv_0"};
127 #ifdef ERF_USE_FIRE
128  names.push_back("smoke");
129 #endif
130  names.insert(names.end(), {
131  "rhoQ1", "rhoQ2", "rhoQ3",
132  "rhoQ4", "rhoQ5", "rhoQ6",
133  "rhoQ7", "rhoQ8", "rhoQ9",
134  "rhoQ10", "rhoQ11"
135  });
136  return names;
137 }

◆ plot3d_fixed_unconditional_diagnostic()

bool erf_plotfile::plot3d_fixed_unconditional_diagnostic ( const std::string &  name)
inline

Diagnostics that every run can write, moist or dry.

177 {
178  static constexpr const char* names[] = {
179  "temp", "theta", "KE", "scalar", "soundspeed", "reflectivity",
180  "max_reflectivity", "mucape", "vorticity_x", "vorticity_y", "vorticity_z",
181  "helicity", "local_helicity", "vort_stretching",
182  "magvel", "divU", "pres_hse", "dens_hse",
183  "theta_hse", "pi_hse", "qv_hse", "pressure", "pert_pres", "pert_dens", "buoyancy",
184  "eq_pot_temp", "VPD", "dpdx", "dpdy", "dpdz", "pres_hse_x", "pres_hse_y",
185  "pres_hse_z", "z_phys", "detJ", "h_xi", "h_eta", "h_zeta",
186  "mapfac", "lat_m", "lon_m", "pblh",
187  "shoc_cldfrac", "shoc_ql", "shoc_ql2", "shoc_cond", "wqls_sec", "wthv_sec",
188  "w_sec", "thl_sec", "qw_sec", "qwthl_sec", "wthl_sec", "wqw_sec", "w3",
189  "brunt", "isotropy", "shear_prod", "buoy_prod", "diss_tke",
190  "terrain_IB_mask", "volfrac",
191  "ibseb_nfaces", "ibseb_tskin", "ibseb_sw_abs", "ibseb_shadow",
192  "ibseb_lw_net", "ibseb_f_sky", "ibseb_H", "ibseb_G",
193  "Tau11", "Tau12", "Tau13", "Tau21", "Tau22", "Tau23",
194  "Tau31", "Tau32", "Tau33", "hfx1", "hfx2", "hfx3",
195  "q1fx1", "q1fx2", "q1fx3", "q2fx3"
196  };
197 
198  for (const char* candidate : names) {
199  if (name == candidate) return true;
200  }
201 
202  return false;
203 }

Referenced by plot3d_fixed_variable_available().

Here is the caller graph for this function:

◆ plot3d_fixed_variable_available()

bool erf_plotfile::plot3d_fixed_variable_available ( const std::string &  name,
const Plot3DSelectionCapabilities &  caps 
)
inline
241 {
242  const MoistureComponentIndices& mi = caps.moisture_indices;
243 
244  // Raw conserved-state components. Inside the moist window the moisture map
245  // decides, since allocated-but-never-integrated slots must not be published
246  // as data. Below the window the state is always allocated dry-or-moist, and
247  // above it are the non-water species a scheme may add -- both of those are
248  // real data whenever they were allocated, so a bounds check is the right
249  // test for them.
250  const int cons_comp = plot3d_conserved_component_index(name);
251  if (cons_comp >= 0) {
252  if ( (cons_comp >= RhoQ1_comp) &&
253  (cons_comp < RhoQ1_comp + caps.moist_state_size) ) {
254  return mi.has_comp(cons_comp);
255  }
256  return (cons_comp < caps.conserved_state_size);
257  }
258 
259  // Every moisture variable -- species, aggregates and moist diagnostics --
260  // is decided by the scheme's index map.
261  const auto moist_status = mi.query_var(name);
262  if (moist_status.governed) return moist_status.available;
263 
264  if (name == "u_t_avg" || name == "v_t_avg" || name == "w_t_avg" ||
265  name == "umag_t_avg") {
266  return caps.time_average_storage;
267  }
269  return caps.interval_mean_storage;
270  }
271  if (name == "qsrc_sw" || name == "qsrc_lw") {
272  return caps.radiation_heating_storage;
273  }
274  if (name == "nut" || name == "Kmv" || name == "Kmh" ||
275  name == "Khv" || name == "Khh" || name == "Lturb") {
276  return caps.eddy_diffusivity_storage;
277  }
278  if (name == "Rt" || name == "cmu" || name == "cmu_prime" || name == "cap_ratio") {
279  return caps.eddy_diffusivity_storage;
280  }
281  if (name == "diss") return caps.dissipation_storage;
282  if (name == "walldist") return caps.wall_distance_storage;
283 
285 }
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:66
int plot3d_conserved_component_index(const std::string &name)
Conserved-state component behind a raw state variable name ("density", "rhotheta",...
Definition: ERF_PlotfileSelection.H:146
bool plot3d_interval_mean_diagnostic(const std::string &name)
Whether a named 3D plot variable can be written by this run.
Definition: ERF_PlotfileSelection.H:214
bool plot3d_fixed_unconditional_diagnostic(const std::string &name)
Diagnostics that every run can write, moist or dry.
Definition: ERF_PlotfileSelection.H:176
bool available
the active scheme carries the data behind it
Definition: ERF_DataStruct.H:645
The moisture data carried by the active microphysics scheme.
Definition: ERF_DataStruct.H:251
bool has_comp(int comp) const
Test whether a conserved-state component holds one of the moisture variables this scheme carries.
Definition: ERF_DataStruct.H:566
VarAvailability query_var(const std::string &name) const
Classify an output variable name against this index map.
Definition: ERF_DataStruct.H:659

Referenced by ERF::canonicalizePlot3DVariables(), and ERF::setSubVolVariables().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plot3d_interval_mean_diagnostic()

bool erf_plotfile::plot3d_interval_mean_diagnostic ( const std::string &  name)
inline

Whether a named 3D plot variable can be written by this run.

The order of the tests below is the order of authority: raw state components answer from the state layout, moisture variables answer from the active scheme's index map, optional diagnostics answer from their storage flag, and anything left is an always-available diagnostic.

215 {
216  static constexpr const char* names[] = {
217  "u_mean", "v_mean", "w_mean", "theta_mean",
218  "uu_mean", "vv_mean", "ww_mean", "uw_mean", "vw_mean", "wtheta_mean",
219  "uu_fluct", "vv_fluct", "ww_fluct", "uw_fluct", "vw_fluct", "wtheta_fluct", "tke_resolved"
220  };
221 
222  for (const char* candidate : names) {
223  if (name == candidate) return true;
224  }
225  return false;
226 }

Referenced by plot3d_fixed_variable_available().

Here is the caller graph for this function:

◆ plot3d_needs_pressure()

bool erf_plotfile::plot3d_needs_pressure ( const amrex::Vector< std::string > &  names)
inline

Whether any requested variable needs the pressure field computed.

292 {
293  for (const auto& name : names) {
294  if (name == "pressure" || name == "pert_pres" ||
295  name == "dpdx" || name == "dpdy" || name == "dpdz" ||
296  name == "eq_pot_temp" || name == "VPD" || name == "qsat" ||
297  name == "rel_humidity") {
298  return true;
299  }
300  }
301  return false;
302 }

Referenced by ERF::FillPlot3DVars().

Here is the caller graph for this function:

◆ plot3d_q_conserved_component_index()

int erf_plotfile::plot3d_q_conserved_component_index ( const int  q)
inline

Conserved-state component holding the q-th moist variable, or -1 if q is outside the fixed RhoQ1..RhoQ11 layout.

110 {
111  if (q < 1 || q > 11) return -1;
112  return RhoQ1_comp + q - 1;
113 }

Referenced by plot3d_conserved_component_index().

Here is the caller graph for this function:

◆ plot3d_selected_particle_count_names()

amrex::Vector<std::string> erf_plotfile::plot3d_selected_particle_count_names ( const amrex::Vector< std::string > &  requested,
const amrex::Vector< std::string > &  configured 
)
inline
307 {
308  amrex::Vector<std::string> selected;
309  for (const auto& count_name : requested) {
310  constexpr std::size_t suffix_size = 6; // "_count"
311  if (count_name.size() > suffix_size &&
312  count_name.compare(count_name.size() - suffix_size, suffix_size, "_count") == 0) {
313  const std::string container = count_name.substr(0, count_name.size() - suffix_size);
314  if (std::find(configured.cbegin(), configured.cend(), container) == configured.cend() ||
315  std::find(selected.cbegin(), selected.cend(), container) != selected.cend()) {
316  continue;
317  }
318  selected.push_back(container);
319  }
320  }
321  return selected;
322 }

Referenced by ERF::canonicalizePlot3DVariables(), and ERF::FillPlot3DVars().

Here is the caller graph for this function:

◆ plot3d_selection_has_interval_mean_diagnostic()

bool erf_plotfile::plot3d_selection_has_interval_mean_diagnostic ( const amrex::Vector< std::string > &  names)
inline
231 {
232  return std::any_of(names.begin(), names.end(),
233  [] (const std::string& name) {
234  return plot3d_interval_mean_diagnostic(name);
235  });
236 }

Referenced by ERF::WriteAtFinalTime(), and ERF::WriteAtIntermediateTime().

Here is the caller graph for this function:

◆ plot3d_set_state_capabilities()

void erf_plotfile::plot3d_set_state_capabilities ( Plot3DSelectionCapabilities &  caps,
const MoistureComponentIndices &  mi,
const int  qstate_moist_size,
const int  qstate_size 
)
inline

Record the conserved-state layout of a run on its capabilities.

Every output path that selects raw state names must describe the state the same way, so the three fields are filled here rather than at each call site.

Parameters
capsCapabilities to fill in.
miThe active scheme's component/diagnostic map.
qstate_moist_sizeConserved components in the moist window (Microphysics::Get_Qstate_Moist_Size()).
qstate_sizeAll conserved components the microphysics adds, moist window plus non-water species (Microphysics::Get_Qstate_Size()).
88 {
89  caps.moisture_indices = mi;
90  caps.moist_state_size = qstate_moist_size;
91  caps.conserved_state_size = NDRY + NSCALARS + qstate_size;
92 }
#define NDRY
Definition: ERF_IndexDefines.H:15
#define NSCALARS
Definition: ERF_IndexDefines.H:26

Referenced by ERF::canonicalizePlot3DVariables(), and ERF::setSubVolVariables().

Here is the caller graph for this function:

◆ radiation_heating_storage_available()

bool erf_plotfile::radiation_heating_storage_available ( RadiationType  rad_model)
inline

Whether the SW/LW heating-rate storage (qsrc_sw, qsrc_lw) exists: every erf.radiation_model other than None (RRTMGP, Simple, TwoStream) allocates the same qheating_rates array.

23 {
24  return rad_model != RadiationType::None;
25 }
@ None
Definition: ERF_LSM_Types.H:6

Referenced by ERF::canonicalizePlot3DVariables().

Here is the caller graph for this function: