ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_DataStruct.H
Go to the documentation of this file.
1 #ifndef ERF_DATA_STRUCT_H_
2 #define ERF_DATA_STRUCT_H_
3 
4 #include <string>
5 #include <iostream>
6 
7 #include <AMReX_ParmParse.H>
8 #include <AMReX_Print.H>
9 #include <AMReX_Gpu.H>
10 #include <AMReX_Geometry.H>
11 
12 #include "ERF_Constants.H"
13 #include "ERF_IndexDefines.H"
14 #include "ERF_AdvStruct.H"
15 #include "ERF_DampingStruct.H"
16 #include "ERF_DiffStruct.H"
17 #include "ERF_EBStruct.H"
18 #include "ERF_SpongeStruct.H"
19 #include "ERF_TurbStruct.H"
20 #include "ERF_TurbPertStruct.H"
21 #include "ERF_RadStruct.H"
23 
24 /**
25  * @brief Indices for map scale factors on mass and face grids.
26  */
27 enum MapFacType {
28 // This version assumes isotropic
29  m_x, u_x, v_x, num,
30  m_y = 0, u_y = 1, v_y = 2
31 // This version allows for non-isotropic
32 // m_x, u_x, v_x,
33 // m_y, u_y, v_y, num
34 };
35 
36 /**
37  * @brief Stress tensor component indices.
38  */
39 enum TauType {
41 };
42 
43 /**
44  * @brief Initial-condition source used to populate the ERF state.
45  */
46 AMREX_ENUM(InitType,
47  None, Input_Sounding, NCFile, WRFInput, Metgrid, Uniform, ConstantDensity, ConstantDensityLinearTheta,
48  Isentropic, MoistBaseState, HindCast
49 );
50 
51 /**
52  * @brief Interpretation of input sounding profiles.
53  */
54 AMREX_ENUM(SoundingType,
55  ConstantDensity, Ideal, Isentropic, DryIsentropic
56 );
57 
58 /**
59  * @brief Large-scale atmospheric boundary-layer driver type.
60  */
61 AMREX_ENUM(ABLDriverType,
62  None, PressureGradient, GeostrophicWind
63 );
64 
65 /**
66  * @brief Multilevel coupling strategy.
67  */
68 AMREX_ENUM(CouplingType,
69  OneWay, TwoWay
70 );
71 
72 /**
73  * @brief Acoustic substepping strategy.
74  */
75 AMREX_ENUM(SubsteppingType,
76  None, Implicit
77 );
78 
79 /**
80  * @brief Two-stage scheme used by the anelastic time integrator.
81  *
82  * RK2 is the SSP (Heun) scheme: both stages advance a full timestep from the old
83  * state and the second averages the two slow sources. MidPoint advances only a
84  * half timestep in the first stage, which makes the vertical diffusion second
85  * order in time with an implicit solve in the first stage alone.
86  */
87 AMREX_ENUM(AnelasticType,
88  RK2, MidPoint
89 );
90 
91 /**
92  * @brief Vertical mesh representation.
93  */
94 AMREX_ENUM(MeshType,
95  ConstantDz, StretchedDz, VariableDz
96 );
97 
98 /**
99  * @brief Terrain and immersed-boundary representation.
100  */
101 AMREX_ENUM(TerrainType,
102  None, StaticFittedMesh, MovingFittedMesh, EB, ImmersedForcing
103 );
104 
105 /**
106  * @brief Building representation.
107  */
108 AMREX_ENUM(BuildingsType,
109  None, ImmersedForcing
110 );
111 
112 /**
113  * @brief Moisture transport representation.
114  */
115 AMREX_ENUM(MoistureModelType,
116  Eulerian, Lagrangian, Undefined
117 );
118 
119 /**
120  * @brief Moisture and microphysics model.
121  */
122 AMREX_ENUM(MoistureType,
123  SAM, SAM_NoIce, SAM_NoPrecip_NoIce, Kessler, Kessler_NoRain, SatAdj, Morrison, Morrison_NoIce, WSM6, WDM6, SuperDroplets, MoistNoCondensation, None
124 );
125 
126 /**
127  * @brief Whether an anelastic SuperDroplets configuration is unsupported.
128  *
129  * The current SuperDroplets implementation diagnoses thermodynamics through
130  * the compressible equation of state and has no BaseState pressure input.
131  */
133  const MoistureType moisture_type,
134  const bool any_anelastic) noexcept
135 {
136  return any_anelastic && moisture_type == MoistureType::SuperDroplets;
137 }
138 
139 /**
140  * @brief Wind-farm model.
141  */
142 AMREX_ENUM(WindFarmType,
143  Fitch, EWP, SimpleAD, GeneralAD, None
144 );
145 
146 /**
147  * @brief Coordinate system used for wind-farm locations.
148  */
149 AMREX_ENUM(WindFarmLocType,
150  lat_lon, x_y, None
151 );
152 
153 /**
154  * @brief Land-surface model.
155  */
156 AMREX_ENUM(LandSurfaceType,
157  SLM, NOAHMP, None
158 );
159 
160 /**
161  * @brief Radiation model.
162  */
163 AMREX_ENUM(RadiationType,
164  None, RRTMGP, Simple, TwoStream
165 );
166 
167 /**
168  * @brief Coordinate-axis selector.
169  */
170 enum struct Coord {
171  x, y, z
172 };
173 
174 // These are used as integers so must be enum not enum struct
175 /**
176  * @brief Rayleigh damping profile component indices.
177  */
178 enum Rayleigh {
180 };
181 
182 // These are used as integers so must be enum not enum struct
183 /**
184  * @brief Sponge reference-state component indices.
185  */
186 enum Sponge {
188 };
189 
190 static const std::string BoundaryFaceName[] = {"xlo", "ylo", "zlo", "xhi", "yhi", "zhi"};
191 
192 /**
193  * @brief The moisture data carried by the active microphysics scheme.
194  *
195  * This struct is the single source of truth for the question "which moisture
196  * quantities does this run actually have?". Everything downstream of the
197  * microphysics -- source terms, turbulence closures, and every output path
198  * (3D plotfiles, 2D plotfiles, subvolumes) -- answers that question by querying
199  * this struct instead of enumerating MoistureType values, so a newly added
200  * scheme only has to declare its layout once, in from_moisture_model() below.
201  *
202  * Two kinds of index live here:
203  *
204  * 1. Conserved-state components (qv ... nn). Absolute component indices into
205  * the conserved state array, i.e. one of RhoQ1_comp ... RhoQ11_comp. They
206  * name the *rho-weighted* species: state(i,j,k,qv) is rho*qv, so an output
207  * path must divide by Rho_comp to recover the mixing ratio.
208  *
209  * 2. qmoist diagnostic slots (rain_accum ... cond_rate). Indices into the
210  * per-level qmoist vector that is filled from
211  * Microphysics::Get_Qmoist_Ptr(lev,idx). Each scheme chooses that
212  * layout independently, so the slot numbers differ between schemes and are
213  * recorded per scheme below.
214  *
215  * In both cases the value is `absent` when the active scheme does not carry the
216  * quantity, so `index >= 0` is the criterion for "this exists and is meaningful
217  * to write". That is deliberately *not* the same test as "the storage is
218  * allocated": several schemes allocate a wider state than they integrate (the
219  * Morrison class always allocates eleven moist components, so Morrison_NoIce
220  * owns ice slots it never fills), and writing those slots to a plotfile would
221  * publish untouched memory as if it were data.
222  */
224 
225  // Sentinel values shared by both kinds of index above.
226  static constexpr int absent = -1; //!< not carried by the active scheme
227  static constexpr int computed_from_state = -2; //!< carried, but derived at output
228  //!< time from the conserved state
229  //!< rather than read from a qmoist slot
230 
231  // ---------------------------------------------------------------------
232  // Conserved-state components: mass mixing ratios (rho-weighted)
233  // ---------------------------------------------------------------------
234  int qv = absent; //!< water vapor
235  int qc = absent; //!< cloud liquid water
236  int qi = absent; //!< cloud ice
237  int qr = absent; //!< rain
238  int qs = absent; //!< snow
239  int qg = absent; //!< graupel
240 
241  // ---------------------------------------------------------------------
242  // Conserved-state components: number concentrations (rho-weighted)
243  // ---------------------------------------------------------------------
244  int nc = absent; //!< cloud liquid water number
245  int ni = absent; //!< cloud ice number
246  int nr = absent; //!< rain number
247  int ns = absent; //!< snow number
248  int ng = absent; //!< graupel number
249  // CCN / total aerosol number. Unlike every other number concentration above,
250  // this has no companion mass species: it is an aerosol reservoir that
251  // exchanges number with nc and nr through activation and evaporation rather
252  // than a hydrometeor count. Kept distinct from ni, which is cloud ice number,
253  // even though some schemes place the two in the same conserved-state slot.
254  int nn = absent; //!< CCN / total aerosol number
255 
256  // ---------------------------------------------------------------------
257  // qmoist diagnostic slots
258  //
259  // These are *not* conserved-state components; they index the qmoist vector
260  // handed out by the microphysics interface. Slot numbers are scheme
261  // specific, which is exactly why they belong in this per-scheme map.
262  // ---------------------------------------------------------------------
263  int rain_accum = absent; //!< accumulated surface rain
264  int snow_accum = absent; //!< accumulated surface snow
265  int graup_accum = absent; //!< accumulated surface graupel
266  int rel_hum = absent; //!< relative humidity
267  int cond_rate = absent; //!< condensation rate
268 
269  /**
270  * @brief Construct the conserved-state component map.
271  *
272  * Prefer from_moisture_model() for production code: it fills in the qmoist
273  * diagnostic slots as well. This constructor exists for the callers -- unit
274  * tests and kernels exercised in isolation -- that only need the state map.
275  *
276  * @param qv_comp Water vapor component index.
277  * @param qc_comp Cloud liquid water component index.
278  * @param qi_comp Cloud ice component index.
279  * @param qr_comp Rain component index.
280  * @param qs_comp Snow component index.
281  * @param qg_comp Graupel component index.
282  * @param nc_comp Cloud liquid water number concentration component index.
283  * @param ni_comp Cloud ice number concentration component index.
284  * @param nr_comp Rain number concentration component index.
285  * @param ns_comp Snow number concentration component index.
286  * @param ng_comp Graupel number concentration component index.
287  * @param nn_comp CCN / total aerosol number concentration component index.
288  */
289  MoistureComponentIndices (int qv_comp, int qc_comp,
290  int qi_comp=absent,
291  int qr_comp=absent,
292  int qs_comp=absent,
293  int qg_comp=absent,
294  int nc_comp=absent,
295  int ni_comp=absent,
296  int nr_comp=absent,
297  int ns_comp=absent,
298  int ng_comp=absent,
299  int nn_comp=absent)
300  : qv(qv_comp), qc(qc_comp), qi(qi_comp), qr(qr_comp), qs(qs_comp), qg(qg_comp),
301  nc(nc_comp), ni(ni_comp), nr(nr_comp), ns(ns_comp), ng(ng_comp),
302  nn(nn_comp) {}
303 
304  /**
305  * @brief Construct an empty map, i.e. a dry run.
306  */
308 
309  /**
310  * @brief Build the complete index map -- conserved-state components and
311  * qmoist diagnostic slots -- for a moisture model.
312  *
313  * This is the one place a scheme declares what it carries. The conserved
314  * layout must match the component the scheme reads and writes in its
315  * Copy_State_to_Micro / Copy_Micro_to_State pair, and the qmoist slots must
316  * match the order the scheme installs in its MicVarMap. A slot that a
317  * scheme allocates but never fills is left `absent` on purpose: see the
318  * class comment for why allocation is not the criterion here.
319  *
320  * @param moisture_type Active moisture/microphysics model.
321  */
323  from_moisture_model (const MoistureType moisture_type)
324  {
326 
327  switch (moisture_type) {
328 
329  case MoistureType::None:
330  // Dry: no moisture data of any kind.
331  break;
332 
333  case MoistureType::MoistNoCondensation:
334  case MoistureType::SAM_NoPrecip_NoIce:
335  case MoistureType::Kessler_NoRain:
336  // Vapor plus suspended cloud water, no precipitation and no
337  // accumulation diagnostics.
338  mi.qv = RhoQ1_comp;
339  mi.qc = RhoQ2_comp;
340  break;
341 
342  case MoistureType::SatAdj:
343  // As above, but relative humidity is recovered from the state at
344  // output time rather than stored: SatAdj publishes no qmoist arrays.
345  mi.qv = RhoQ1_comp;
346  mi.qc = RhoQ2_comp;
348  break;
349 
350  case MoistureType::Kessler:
351  // Warm rain in three moist components; qmoist is {rain_accum}.
352  mi.qv = RhoQ1_comp;
353  mi.qc = RhoQ2_comp;
354  mi.qr = RhoQ3_comp;
355  mi.rain_accum = 0;
356  break;
357 
358  case MoistureType::SAM_NoIce:
359  // The SAM class always allocates six moist components, so rain sits
360  // in the fourth slot even with the ice species switched off.
361  mi.qv = RhoQ1_comp;
362  mi.qc = RhoQ2_comp;
363  mi.qr = RhoQ4_comp;
364  mi.rain_accum = 0;
365  break;
366 
367  case MoistureType::SAM:
368  case MoistureType::WSM6:
369  // Single-moment mixed phase; qmoist is
370  // {rain_accum, snow_accum, graup_accum}.
371  mi.qv = RhoQ1_comp;
372  mi.qc = RhoQ2_comp;
373  mi.qi = RhoQ3_comp;
374  mi.qr = RhoQ4_comp;
375  mi.qs = RhoQ5_comp;
376  mi.qg = RhoQ6_comp;
377  mi.rain_accum = 0;
378  mi.snow_accum = 1;
379  mi.graup_accum = 2;
380  break;
381 
382  case MoistureType::Morrison:
383  // Two-moment mixed phase: six mass species followed by five number
384  // concentrations.
385  mi.qv = RhoQ1_comp;
386  mi.qc = RhoQ2_comp;
387  mi.qi = RhoQ3_comp;
388  mi.qr = RhoQ4_comp;
389  mi.qs = RhoQ5_comp;
390  mi.qg = RhoQ6_comp;
391  mi.nc = RhoQ7_comp;
392  mi.ni = RhoQ8_comp;
393  mi.nr = RhoQ9_comp;
394  mi.ns = RhoQ10_comp;
395  mi.ng = RhoQ11_comp;
396  mi.rain_accum = 0;
397  mi.snow_accum = 1;
398  mi.graup_accum = 2;
399  break;
400 
401  case MoistureType::Morrison_NoIce:
402  // Liquid-only Morrison: the class still allocates all eleven moist
403  // components, but only vapor, cloud water and rain -- and the cloud
404  // and rain numbers -- are integrated, so the frozen species and
405  // their numbers stay absent here.
406  mi.qv = RhoQ1_comp;
407  mi.qc = RhoQ2_comp;
408  mi.qr = RhoQ4_comp;
409  mi.nc = RhoQ7_comp;
410  mi.nr = RhoQ9_comp;
411  mi.rain_accum = 0;
412  break;
413 
414  case MoistureType::WDM6:
415  // Double-moment warm phase on top of single-moment ice: nn is the
416  // aerosol reservoir and takes the slot Morrison uses for ice number,
417  // and there are no snow or graupel numbers.
418  mi.qv = RhoQ1_comp;
419  mi.qc = RhoQ2_comp;
420  mi.qi = RhoQ3_comp;
421  mi.qr = RhoQ4_comp;
422  mi.qs = RhoQ5_comp;
423  mi.qg = RhoQ6_comp;
424  mi.nc = RhoQ7_comp;
425  mi.nn = RhoQ8_comp;
426  mi.nr = RhoQ9_comp;
427  mi.rain_accum = 0;
428  mi.snow_accum = 1;
429  mi.graup_accum = 2;
430  break;
431 
432  case MoistureType::SuperDroplets:
433  // Lagrangian microphysics that still carries the six Eulerian mass
434  // species. Its qmoist layout is its own (see the MicVarMap in
435  // SuperDropletsMoist::Init): the graupel accumulation slot exists
436  // but is never filled, so it stays absent.
437  mi.qv = RhoQ1_comp;
438  mi.qc = RhoQ2_comp;
439  mi.qi = RhoQ3_comp;
440  mi.qr = RhoQ4_comp;
441  mi.qs = RhoQ5_comp;
442  mi.qg = RhoQ6_comp;
443  mi.cond_rate = 3;
444  mi.rel_hum = 7;
445  mi.rain_accum = 8;
446  mi.snow_accum = 10;
447  break;
448 
449  default:
450  amrex::Abort("Unknown MoistureType in MoistureComponentIndices::from_moisture_model");
451  }
452 
453  return mi;
454  }
455 
456  /**
457  * @brief An ordered list of conserved-state components forming an aggregate
458  * moisture output variable (qt, qn, qp, moist_density).
459  *
460  * Only the species the active scheme carries are appended, so a consumer can
461  * sum the list without first asking which ones exist.
462  */
463  struct CompList {
464  static constexpr int max_size = 6; //!< qv, qc, qi, qr, qs, qg
466  int size = 0;
467 
468  //! Append a component, ignoring the ones the scheme does not carry.
469  void append (int c) {
470  if ( (c >= 0) && (size < max_size) ) { comp[size++] = c; }
471  }
472  [[nodiscard]] bool empty () const { return (size == 0); }
473  };
474 
475  /**
476  * @brief Components summed for total water, "qt": every mass mixing ratio.
477  *
478  * Number concentrations are excluded -- they are counts, not masses.
479  */
480  [[nodiscard]] CompList total_water_comps () const {
481  CompList list;
482  list.append(qv); list.append(qc); list.append(qi);
483  list.append(qr); list.append(qs); list.append(qg);
484  return list;
485  }
486 
487  /**
488  * @brief Components summed for non-precipitating water, "qn": vapor plus the
489  * suspended condensate. Also the moist part of "moist_density".
490  */
491  [[nodiscard]] CompList nonprecipitating_comps () const {
492  CompList list;
493  list.append(qv); list.append(qc); list.append(qi);
494  return list;
495  }
496 
497  /**
498  * @brief Components summed for precipitating water, "qp": the falling species.
499  */
500  [[nodiscard]] CompList precipitating_comps () const {
501  CompList list;
502  list.append(qr); list.append(qs); list.append(qg);
503  return list;
504  }
505 
506  /**
507  * @brief Test whether a conserved-state component holds one of the moisture
508  * variables this scheme carries.
509  *
510  * Use this rather than enumerating moisture models when deciding whether a
511  * "rhoQn" state component is meaningful for the active scheme.
512  *
513  * @param comp Absolute component index into the conserved state array.
514  */
515  [[nodiscard]] bool has_comp (int comp) const {
516  return ( (comp >= 0) &&
517  ( (comp == qv) || (comp == qc) || (comp == qi) ||
518  (comp == qr) || (comp == qs) || (comp == qg) ||
519  (comp == nc) || (comp == ni) || (comp == nr) ||
520  (comp == ns) || (comp == ng) || (comp == nn) ) );
521  }
522 
523  /**
524  * @brief Test whether the active scheme carries rain, snow and graupel in the
525  * RhoQ4/RhoQ5/RhoQ6 slots assumed by erf_derreflectivity and
526  * erf_dermaxreflectivity.
527  *
528  * Those kernels read the precipitating species by hardcoded component, so this
529  * checks the layout and not just the presence of the species.
530  */
531  [[nodiscard]] bool has_reflectivity_species () const {
532  return ( (qr == RhoQ4_comp) && (qs == RhoQ5_comp) && (qg == RhoQ6_comp) );
533  }
534 
535  /**
536  * @brief Test whether the active scheme carries any moisture at all.
537  *
538  * Every moist scheme allocates water vapor, so this is equivalent to testing
539  * moisture_type != MoistureType::None without needing the enum.
540  */
541  [[nodiscard]] bool has_moisture () const { return (qv >= 0); }
542 
543  /**
544  * @brief The conserved-state component behind a single-species output name,
545  * or `absent` if the name is not a single species or the scheme does
546  * not carry it.
547  *
548  * An output path can use this to copy a species without repeating the
549  * name-to-component mapping.
550  *
551  * @param name Derived or plot variable name.
552  */
553  [[nodiscard]] int comp_for_var (const std::string& name) const {
554  if (name == "qv") { return qv; }
555  if (name == "qc") { return qc; }
556  if (name == "qi") { return qi; }
557  if (name == "qrain") { return qr; }
558  if (name == "qsnow") { return qs; }
559  if (name == "qgraup") { return qg; }
560  if (name == "nc") { return nc; }
561  if (name == "ni") { return ni; }
562  if (name == "nr") { return nr; }
563  if (name == "ns") { return ns; }
564  if (name == "ng") { return ng; }
565  if (name == "nn") { return nn; }
566  return absent;
567  }
568 
569  /**
570  * @brief The qmoist slot behind a moist diagnostic output name.
571  *
572  * Returns `absent` when the scheme does not provide the diagnostic, and
573  * `computed_from_state` when it does provide it but not through a qmoist
574  * array -- in that case the caller must derive it from the conserved state.
575  *
576  * @param name Derived or plot variable name.
577  */
578  [[nodiscard]] int qmoist_index_for_var (const std::string& name) const {
579  if (name == "rain_accum") { return rain_accum; }
580  if (name == "snow_accum") { return snow_accum; }
581  if (name == "graup_accum") { return graup_accum; }
582  if (name == "rel_humidity") { return rel_hum; }
583  if (name == "condensation_rate") { return cond_rate; }
584  return absent;
585  }
586 
587  /**
588  * @brief Whether this map decides a variable's availability, and if so
589  * whether the variable is available.
590  */
592  bool governed = false; //!< the name is a moisture output variable
593  bool available = false; //!< the active scheme carries the data behind it
594  };
595 
596  /**
597  * @brief Classify an output variable name against this index map.
598  *
599  * This is the one table pairing output names with the data behind them. It
600  * is driven off the scheme's index map rather than an enumerated list of
601  * moisture models, so it stays correct as schemes are added. Names with no
602  * moisture dependence come back not-governed, which lets a caller walk a
603  * mixed list of variable names and only defer to this map where it applies.
604  *
605  * @param name Derived or plot variable name.
606  */
607  [[nodiscard]] VarAvailability query_var (const std::string& name) const {
608 
609  // Single species, taken straight from the conserved state
610  if ( (name == "qv") || (name == "qc") || (name == "qi") ||
611  (name == "qrain") || (name == "qsnow") || (name == "qgraup") ||
612  (name == "nc") || (name == "ni") || (name == "nr") ||
613  (name == "ns") || (name == "ng") || (name == "nn") ) {
614  return {true, comp_for_var(name) >= 0};
615  }
616 
617  // Moist diagnostics, either from a qmoist array or derived at output time
618  if ( (name == "rain_accum") || (name == "snow_accum") ||
619  (name == "graup_accum") || (name == "rel_humidity") ||
620  (name == "condensation_rate") ) {
621  return {true, qmoist_index_for_var(name) != absent};
622  }
623 
624  // Aggregates over several species
625  if (name == "qt") { return {true, !total_water_comps().empty()}; }
626  if (name == "qp") { return {true, !precipitating_comps().empty()}; }
627 
628  // Non-precipitating water is vapor plus the suspended condensate, and
629  // moist density adds that same sum to the dry density
630  if ( (name == "qn") || (name == "moist_density") ) {
631  return {true, (qv >= 0) && (qc >= 0)};
632  }
633 
634  // Column and thermodynamic diagnostics that read vapor only
635  if ( (name == "qsat") || (name == "precipitable") ) {
636  return {true, has_moisture()};
637  }
638 
639  return {false, false};
640  }
641 
642  /**
643  * @brief Test whether the moist species behind a derived/plot variable name is
644  * carried by the active scheme.
645  *
646  * Names this map does not govern return true, so this can be used directly as
647  * a filter over a mixed list of variable names. Use query_var() instead when
648  * the caller needs to distinguish "not a moisture variable" from "available".
649  *
650  * @param name Derived or plot variable name.
651  */
652  [[nodiscard]] bool has_derived_var (const std::string& name) const {
653  const VarAvailability status = query_var(name);
654  return (!status.governed) || status.available;
655  }
656 };
657 
658 /**
659  * Container holding many of the algorithmic options and parameters
660  */
661 
662 struct SolverChoice {
663  public:
664  /**
665  * @brief Read solver-wide algorithmic options from the input parameter database.
666  * @param max_level Maximum AMR level configured for the run.
667  * @param pp_prefix ParmParse prefix for the ERF input namespace.
668  */
669  void init_params (int max_level, std::string pp_prefix)
670  {
671  amrex::ParmParse pp(pp_prefix);
672 
673  bool bogus_bool;
674  if (pp.query("use_terrain",bogus_bool) > 0) {
675  amrex::Error("The input use_terrain is deprecated. Set terrain_type instead.");
676  }
677 
678  if (pp.query("use_moist_background",bogus_bool) > 0) {
679  amrex::Error("The input use_moist_background is deprecated. Set init_type = MoistBaseState instead.");
680  }
681 
682  // Do we set map scale factors to myhalf instead of 1 for testing?
683  pp.queryAdd("test_mapfactor", test_mapfactor);
684 
685  // Which horizontal pressure gradient formulation to use with terrain fitted coords?
686  // 0: dp/dx with dp/dz correction (default)
687  // 1: gradient of vertically interpolated p, see Klemp 2011
688  pp.queryAdd("gradp_type", gradp_type);
690 
691  // For the lateral pressure gradient to be used in the momentum equation, should we
692  // take the x- and y-derivatives of the perturbational pressure or the full pressure?
693  pp.queryAdd("use_pert_pres_gradient", use_pert_pres_gradient);
694 
695  // What type of moisture model to use?
696  moisture_type = MoistureType::None; // Default
697  if (pp.query("moisture_type",moisture_type) > 0) {
698  amrex::Error("The input moisture_type is deprecated. Set moisture_model instead.");
699  }
700 
701  pp.query_enum_case_insensitive("moisture_model",moisture_type);
702 
703  // Register the moisture data this scheme carries: conserved-state
704  // components and qmoist diagnostic slots alike. MoistureComponentIndices
705  // is the one place that mapping lives, and every consumer -- source terms,
706  // turbulence closures, and the plotfile/subvolume writers -- queries it
707  // instead of testing moisture_type.
709 
710  // Set a default for both dry and moist
711  buoyancy_type.resize(max_level+1);
712  for (int i = 0; i <= max_level; ++i) {
713  buoyancy_type[i] = 1; // uses Rhoprime
714  }
715 
716  if (moisture_type != MoistureType::None) {
717  pp.queryAdd("moisture_tight_coupling",moisture_tight_coupling);
718  }
719 
720  // Which expression (1,2/3 or 4) to use for buoyancy
721  int default_buoyancy_type = buoyancy_type[0];
722  read_int_string(max_level, "buoyancy_type", buoyancy_type, default_buoyancy_type);
723 
724  // What type of land surface model to use
725  lsm_type = LandSurfaceType::None; // Default
726  pp.query_enum_case_insensitive("land_surface_model",lsm_type);
727 
728  // Will an external ocean coupler supply SST for part or all of the water
729  // cells this run? The surface layer needs to know this it in time to select
730  // ThetaCalcType::SURFACE_TEMPERATURE, which is long before the first
731  // ApplyOceanSurfaceState call.
732  pp.queryAdd("use_coupled_sst", use_coupled_sst);
733 
734  read_int_string(max_level, "is_land", is_land, 1);
735  for (int lev = 0; lev <= max_level; ++lev) {
736  if (is_land[lev] == 1) {
737  amrex::Print() << "Level " << lev << " is land" << std::endl;
738  } else if (is_land[lev] == 0) {
739  amrex::Print() << "Level " << lev << " is water" << std::endl;
740  } else {
741  amrex::Error("is_land should be 0 or 1");
742  }
743  }
744 
745  // What type of radiation model to use
746  rad_type = RadiationType::None; // Default
747  pp.query_enum_case_insensitive("radiation_model", rad_type);
748 
749  // Verify that radiation model cannot be RRTMGP if ERF was not compiled with RRTMGP
750 #ifndef ERF_USE_RRTMGP
751  if (rad_type == RadiationType::RRTMGP)
752  {
753  amrex::Error("ERF was not compiled with RRTMGP enabled!");
754  }
755 #endif
756 
757  // Is the terrain none, static or moving?
758  std::string terrain_type_temp = "";
759  pp.queryAdd("terrain_type", terrain_type_temp);
760  if (terrain_type_temp == "Moving") {
761  amrex::Warning("erf.terrain_type = Moving is deprecated; please replace Moving by MovingFittedMesh");
762  terrain_type = TerrainType::MovingFittedMesh;
763  } else if (terrain_type_temp == "Static") {
764  amrex::Warning("erf.terrain_type = Static is deprecated; please replace Static by StaticFittedMesh");
765  terrain_type = TerrainType::StaticFittedMesh;
766  } else {
767  pp.query_enum_case_insensitive("terrain_type",terrain_type);
768  }
769 
770  // Get buildings type
771  std::string buildings_type_temp = "";
772  pp.queryAdd("buildings_type", buildings_type_temp);
773  if (buildings_type_temp == "ImmersedForcing") {
774  buildings_type = BuildingsType::ImmersedForcing;
775  }
776 
777  //
778  // Read the init_type here to make sure we correctly set the mesh and terrain types
779  //
780  std::string init_type_temp_string;
781 
782  int found = pp.queryAdd("init_type",init_type_temp_string);
783 
784  if ( (init_type_temp_string == "Real") || (init_type_temp_string == "real") ) {
785  amrex::Error("erf.init_type = Real is deprecated; please replace Real by WRFInput");
786  } else if ( (init_type_temp_string == "Ideal") || (init_type_temp_string == "ideal") ) {
787  amrex::Error("erf.init_type = Ideal is deprecated; please replace Ideal by WRFInput");
788  } else {
789  pp.query_enum_case_insensitive("init_type",init_type);
790  use_real_bcs = ( (init_type == InitType::WRFInput) || (init_type == InitType::Metgrid) );
791  }
792 
793  if ( (init_type == InitType::WRFInput) || (init_type == InitType::Metgrid) ) {
794  if (terrain_type != TerrainType::StaticFittedMesh) {
795  amrex::Error("Only terrain_type = StaticFittedMesh are allowed with init_type = WRFInput or Metgrid");
796  }
797  }
798 
799  if (init_type == InitType::MoistBaseState) {
800  if (moisture_type == MoistureType::None) {
801  amrex::Error("Makes no sense to have moist base state with no moisture model");
802  }
803  }
804 
805  if (init_type == InitType::WRFInput) {
806  if (moisture_type == MoistureType::None) {
807  amrex::Error("Can't have moisture_type = None with init_type = WRFInput");
808  }
809 
810  // NetCDF wrfbdy lateral boundary file
811  std::string nc_bdy_file_temp_string;
812  bool has_bdy = pp.queryAdd("nc_bdy_file", nc_bdy_file_temp_string);
813  if (!has_bdy) use_real_bcs = false;
814 
815  bool use_real_bcs_temp = use_real_bcs;
816  pp.queryAdd("use_real_bcs", use_real_bcs_temp);
817  if (use_real_bcs && !use_real_bcs_temp) {
818  use_real_bcs = false;
819  }
820  }
821 
822  if (found == 0 || init_type == InitType::None) {
823  amrex::Print() << "init_type must now be set. The options are " << std::endl;
824  amrex::Print() << " Input_Sounding, NCFile, WRFInput, Metgrid, Uniform, " << std::endl;
825  amrex::Print() << " ConstantDensity, Isentropic, MoistBaseState, or HindCast " << std::endl;
826  amrex::Error("Please add a string for init_type to your inputs file or command line");
827  }
828 
829  // How to interpret input_sounding
830  if (init_type == InitType::Input_Sounding) {
831  pp.query_enum_case_insensitive("sounding_type",sounding_type);
832  }
833 
834  if (terrain_type == TerrainType::StaticFittedMesh ||
835  terrain_type == TerrainType::MovingFittedMesh) {
836  mesh_type = MeshType::VariableDz;
837  }
838 
839  if ( (moisture_type == MoistureType::SAM ||
840  moisture_type == MoistureType::SAM_NoIce ||
841  moisture_type == MoistureType::SAM_NoPrecip_NoIce ) &&
842  (mesh_type == MeshType::VariableDz) )
843  {
844  amrex::Abort("SAM is not correct with variable dz -- choose another moisture model");
845  }
846 
847  pp.queryAdd("grid_stretching_ratio", grid_stretching_ratio);
848  if (grid_stretching_ratio != 0) {
850  "The grid stretching ratio must be greater than 1");
851  }
852  if (grid_stretching_ratio >= 1) {
853  if (terrain_type == TerrainType::None) {
854  terrain_type = TerrainType::StaticFittedMesh;
855  }
856  if (mesh_type == MeshType::ConstantDz) {
857  mesh_type = MeshType::StretchedDz;
858  }
859  pp.queryAdd("zsurface", zsurf);
860  if (zsurf != zero) {
861  amrex::Print() << "Nominal zsurface height != 0, may result in unexpected behavior"
862  << std::endl;
863  }
864  pp.get("initial_dz", dz0);
865  }
866 
867  int n_zlevels = pp.countval("terrain_z_levels");
868  if (n_zlevels > 0)
869  {
870  if (terrain_type == TerrainType::None) {
871  terrain_type = TerrainType::StaticFittedMesh;
872  }
873  if (mesh_type == MeshType::ConstantDz) {
874  mesh_type = MeshType::StretchedDz;
875  }
876  }
877 
878  // Use lagged_delta_rt in the fast integrator?
879  pp.queryAdd("use_lagged_delta_rt", use_lagged_delta_rt);
880 
881  // Average the input z-face heights onto the nodes, or reconstruct our own
882  pp.queryAdd("avg_grid_faces_to_nodes",avg_grid_faces_to_nodes);
883 
884  // Catch the old name for the flag above so the error says what to do
885  // rather than silently ignoring the setting.
886  if (pp.contains("use_wrf_height_grid")) {
887  amrex::Abort("erf.use_wrf_height_grid has been renamed. "
888  "Set erf.avg_grid_faces_to_nodes instead; it carries "
889  "the same meaning (average the input z-face heights "
890  "onto the nodes rather than reconstructing them).");
891  }
892 
893  // Interpolate atmospheric state from coarse level instead of reading from wrfinput
894  // when creating a finer level from coarse at a later time?
895  pp.queryAdd("interp_atmos_from_coarse", interp_atmos_from_coarse);
896 
897  // Rebalance wrf state?
898  pp.queryAdd("rebalance_wrf_input", rebalance_wrf_input);
899 
900  // Must rebalance if the nodal heights were reconstructed rather than averaged
902  amrex::Print() << "Must rebalance when not averaging the input height grid. Setting rebalance_wrf_input to true \n";
903  rebalance_wrf_input = true;
904  }
905 
906  // These default to true but are used for unit testing
907  pp.queryAdd("use_gravity", use_gravity);
908 
909  // Initializing from Metgrid or WRFInput without gravity makes no sense
910  if ( !use_gravity && ( (init_type == InitType::WRFInput) || (init_type == InitType::Metgrid) ) ) {
911  amrex::Print() << "Setting use_gravity to true due to init_type = WRFInput / Metgrid " << std::endl;
912  use_gravity = true;
913  }
914 
916 
917  pp.queryAdd("c_p", c_p);
918  rdOcp = R_d / c_p;
919 
920  // *******************************************************************************
921  // Read anelastic etc and over-ride if necessary
922  // *******************************************************************************
923 
924  read_int_string(max_level, "anelastic", anelastic, 0);
925  read_int_string(max_level, "fixed_density", fixed_density, 0);
926  read_int_string(max_level, "project_initial_velocity", project_initial_velocity, 0);
927 
928  bool any_anelastic = false;
929  bool any_compress = false;
930  for (int i = 0; i <= max_level; ++i) {
931  if (anelastic[i] == 1) {
933  fixed_density[i] = 1; // We default to true but are allowed to override below
934  buoyancy_type[i] = 3; // (This isn't actually used when anelastic is set)
935  any_anelastic = true;
936  } else {
937  any_compress = true;
938  }
939  }
940 
942  amrex::Error("erf.moisture_model = SuperDroplets is not supported with "
943  "erf.anelastic = 1: the Super-Droplet path currently uses "
944  "the compressible equation of state. Use compressible "
945  "dynamics or a supported Eulerian moisture model.");
946  }
947 
948  // Want to have different immersed forcing defaults depending on anelastic or fully compressible.
949  // We should have different starting values because the stability of the method is dependent on dt.
950  // dt is coarser for anelastic --> need to loosen stiffness of immersed forcing.
951  if (any_anelastic) {
952  immersed_forcing_substep = false;
953  if_Cd_momentum = amrex::Real(50.0);
954  if_Cd_scalar = amrex::Real(5.0);
955  } else {
957  if_Cd_momentum = amrex::Real(500.0);
958  if_Cd_scalar = amrex::Real(50.0);
959  }
960 
961  // *******************************************************************************
962  // Read anelastic_type and allow for different values at each level
963  // *******************************************************************************
964  anelastic_type.resize(max_level+1);
965 
966  for (int i = 0; i <= max_level; i++) {
967  anelastic_type[i] = AnelasticType::RK2;
968  }
969 
970  for (int i = 0; i <= max_level; i++) {
972  pp, "anelastic_type", anelastic_type[i], i, max_level);
973  }
974 
975  if (pp.contains("anelastic_type") && !any_anelastic) {
976  amrex::Print() << "Ignoring erf.anelastic_type because no level is anelastic" << std::endl;
977  for (int i = 0; i <= max_level; i++) { anelastic_type[i] = AnelasticType::RK2; }
978  }
979 
980  // *******************************************************************************
981  // Read substepping_type and allow for different values at each level
982  // *******************************************************************************
983  substepping_type.resize(max_level+1);
984 
985  for (int i = 0; i <= max_level; i++) {
986  substepping_type[i] = SubsteppingType::Implicit;
987  }
988 
989  for (int i = 0; i <= max_level; i++) {
991  pp, "substepping_type", substepping_type[i], i, max_level);
992  }
993 
994  pp.queryAdd("substepping_diag", substepping_diag);
995 
996  pp.queryAdd("beta_s", beta_s);
997 
998  // *******************************************************************************
999  // Error check on deprecated input
1000  // *******************************************************************************
1001  int nvals_old = pp.countval("no_substepping");
1002  if (nvals_old > 0) {
1003  amrex::Error("The no_substepping flag is deprecated -- set substepping_type instead");
1004  }
1005 
1006  pp.queryAdd("ncorr", ncorr);
1007  // Wall distance on a terrain-fitted mesh (RANS): "poisson" (Tucker 2003
1008  // differential-equation distance) or "terrain_height" (height above the
1009  // local surface projected on its normal, no linear solve)
1010  pp.queryAdd("wall_dist_type", wall_dist_type);
1011  if (wall_dist_type != "poisson" && wall_dist_type != "terrain_height") {
1012  amrex::Error("erf.wall_dist_type must be poisson or terrain_height");
1013  }
1014  pp.queryAdd("poisson_abstol", poisson_abstol);
1015  pp.queryAdd("poisson_reltol", poisson_reltol);
1016 #ifdef AMREX_USE_FLOAT
1017  poisson_abstol = amrex::max(poisson_abstol,amrex::Real(1e-6));
1018  poisson_reltol = amrex::max(poisson_reltol,amrex::Real(1e-6));
1019 #endif
1020  for (int lev = 0; lev <= max_level; lev++) {
1021  if (anelastic[lev] != 0)
1022  {
1023  substepping_type[lev] = SubsteppingType::None;
1024  }
1025  }
1026 
1027  pp.queryAdd("force_stage1_single_substep", force_stage1_single_substep);
1028 
1029  // Include Coriolis forcing?
1030  pp.queryAdd("use_coriolis", use_coriolis);
1031  pp.queryAdd("variable_coriolis", variable_coriolis);
1032 
1033  // Include four stream radiation approximation
1034  pp.queryAdd("four_stream_radiation", four_stream_radiation);
1035 
1036  // flags for whether to apply other source terms in substep only
1037  pp.queryAdd("immersed_forcing_substep", immersed_forcing_substep); // apply immersed forcing source terms in substep only
1038  pp.queryAdd("forest_substep", forest_substep); // apply canopy-related source terms in substep only
1039 
1040  // Fixed-leaf-temperature canopy heat exchange
1041  pp.query("forest_biophysics", forest_biophysics);
1042  pp.query("forest_biophysics_heat", forest_biophysics_heat);
1043  pp.query("forest_leaf_theta_fixed", forest_leaf_theta_fixed);
1044 
1047  "forest_biophysics_heat requires forest_biophysics = true");
1051  "forest_biophysics_heat requires a positive forest_leaf_theta_fixed");
1054  "forest_leaf_theta_fixed requires forest_biophysics_heat = true");
1055 
1056  // immersed forcing parameters
1057  pp.queryAdd("if_Cd_momentum", if_Cd_momentum);
1058  pp.queryAdd("if_Cd_scalar", if_Cd_scalar);
1059  pp.queryAdd("if_implicit_drag", if_implicit_drag); // flag for implicit vs. explicit drag formulation
1060  pp.queryAdd("if_z0", if_z0);
1061  pp.queryAdd("if_surf_temp_flux", if_surf_temp_flux);
1062  pp.queryAdd("if_init_surf_temp", if_init_surf_temp);
1063 
1064  pp.queryAdd("if_surf_heating_rate", if_surf_heating_rate);
1065 
1066  // Modify rate to be in units of K / s rather than K / hr
1067  if_surf_heating_rate /= amrex::Real(3600.0); // [K/s]
1068 
1069  pp.queryAdd("if_Olen", if_Olen_in);
1070  pp.queryAdd("if_use_most",if_use_most);
1071  pp.queryAdd("if_snap_partial_cells",if_snap_partial_cells);
1072  // The snapped staircase puts full-strength forcing on every wall face,
1073  // whose explicit relaxation rate (Cd / dx per substep) sits at the
1074  // stability limit and fails where faces stack at rims and corners; the
1075  // point-implicit form holds at any rate, so the snap uses it.
1077  amrex::Print() << "erf.if_snap_partial_cells: using the point-implicit drag (erf.if_implicit_drag = true)\n";
1078  if_implicit_drag = true;
1079  }
1080  pp.queryAdd("if_stability_correction",if_stability_correction);
1081  pp.queryAdd("if_ws_floor",if_ws_floor);
1082  pp.queryAdd("if_damp_alpha",if_damp_alpha);
1083 
1084  if ((if_init_surf_temp > zero && if_surf_temp_flux != amrex::Real(1e-8)) ||
1085  (if_init_surf_temp > zero && if_Olen_in != amrex::Real(1e-8)) ||
1086  (if_Olen_in != amrex::Real(1e-8) && if_surf_temp_flux != amrex::Real(1e-8)))
1087  {
1088  amrex::Error("Can only specify one of init_surf_temp, surf_temp_flux, or Olen");
1089  }
1090 
1091  // Flag to do MOST rotations with terrain
1092  pp.queryAdd("use_rotate_surface_flux",use_rotate_surface_flux);
1094  AMREX_ASSERT_WITH_MESSAGE(terrain_type != TerrainType::None,"MOST stress rotations are only valid with terrain!");
1095  }
1096 
1097  // Which external forcings?
1098  abl_driver_type = ABLDriverType::None; // Default: no ABL driver for simulating classical fluid dynamics problems
1099  pp.query_enum_case_insensitive("abl_driver_type",abl_driver_type);
1100  pp.queryAdd("const_massflux_u", const_massflux_u);
1101  pp.queryAdd("const_massflux_v", const_massflux_v);
1102  pp.queryAdd("const_massflux_tau", const_massflux_tau);
1103  pp.queryAdd("const_massflux_layer_lo", const_massflux_layer_lo);
1104  pp.queryAdd("const_massflux_layer_hi", const_massflux_layer_hi);
1105 
1106  // Which type of inflow turbulent generation
1107  pert_type.resize(max_level+1);
1108  for (int lev = 0; lev <= max_level; ++lev) {
1109  pert_type[lev] = PerturbationType::None; // Default
1111  pp, "perturbation_type", pert_type[lev], lev, max_level);
1112  }
1113 
1114  amrex::Vector<amrex::Real> abl_pressure_grad_in = {zero, zero, zero};
1115  pp.queryarr("abl_pressure_grad",abl_pressure_grad_in);
1116  for(int i = 0; i < AMREX_SPACEDIM; ++i) abl_pressure_grad[i] = abl_pressure_grad_in[i];
1117 
1118  amrex::Vector<amrex::Real> abl_geo_forcing_in = {zero, zero, zero};
1119  if(pp.queryarr("abl_geo_forcing",abl_geo_forcing_in)) {
1120  amrex::Print() << "Specified abl_geo_forcing: (";
1121  for (int i = 0; i < AMREX_SPACEDIM; ++i) {
1122  abl_geo_forcing[i] = abl_geo_forcing_in[i];
1123  amrex::Print() << abl_geo_forcing[i] << " ";
1124  }
1125  amrex::Print() << ")" << std::endl;
1126  }
1127 
1128  if (use_coriolis)
1129  {
1131  }
1132 
1133  pp.queryAdd("add_custom_rhotheta_forcing", custom_rhotheta_forcing);
1134  pp.queryAdd("add_custom_moisture_forcing", custom_moisture_forcing);
1135  pp.queryAdd("add_custom_w_subsidence", custom_w_subsidence);
1136  pp.queryAdd("add_do_theta_advection", do_theta_advection); // If true, apply custom subsidence to (rho*theta) when add_custom_w_subsidence is used
1137  pp.queryAdd("add_do_mom_advection", do_mom_advection); // If true, apply custom subsidence to momentum when add_custom_w_subsidence is used
1138  pp.queryAdd("add_custom_geostrophic_profile", custom_geostrophic_profile);
1139  pp.queryAdd("custom_forcing_uses_primitive_vars", custom_forcing_prim_vars);
1140  pp.queryAdd("spatial_rhotheta_forcing", spatial_rhotheta_forcing);
1141  pp.queryAdd("spatial_moisture_forcing", spatial_moisture_forcing);
1142 
1143  pp.queryAdd("nudging_from_input_sounding", nudging_from_input_sounding);
1144 
1145  int nudging_u_z1_set = pp.queryAdd("nudging_u_z1", nudging_u_z1);
1146  int nudging_u_z2_set = pp.queryAdd("nudging_u_z2", nudging_u_z2);
1147  pp.queryAdd("nudging_t_z1", nudging_t_z1);
1148  pp.queryAdd("nudging_t_z2", nudging_t_z2);
1149  pp.queryAdd("nudging_q_z1", nudging_q_z1);
1150  pp.queryAdd("nudging_q_z2", nudging_q_z2);
1151 
1153  "nudging_u_z1 must be less than or equal to nudging_u_z2");
1155  "nudging_t_z1 must be less than or equal to nudging_t_z2");
1157  "nudging_q_z1 must be less than or equal to nudging_q_z2");
1158 
1159  pp.queryAdd("nudging_u", nudging_u);
1160  pp.queryAdd("nudging_t", nudging_t);
1161  pp.queryAdd("nudging_q", nudging_q);
1162 
1163  pp.queryAdd("large_scale_forcing", large_scale_forcing);
1164 
1166  if (!nudging_u) {
1167  amrex::Print() << "WARNING: erf.nudging_u = false has no effect when erf.large_scale_forcing "
1168  "= true; momentum nudging is then controlled solely by large_scale_forcing.\n";
1169  }
1170  if (nudging_u_z1_set || nudging_u_z2_set) {
1171  amrex::Print() << "WARNING: erf.nudging_u_z1/erf.nudging_u_z2 are ignored when "
1172  "erf.large_scale_forcing = true; momentum nudging is then applied "
1173  "at all heights.\n";
1174  }
1175  }
1176 
1179  "Should not have both abl_geo_wind_table and custom_geostrophic_profile set.");
1180 
1181  pp.queryAdd("Ave_Plane", ave_plane);
1182 
1183  // Use numerical diffusion?
1184  pp.queryAdd("num_diff_coeff",num_diff_coeff);
1186  "Numerical diffusion coefficient must be between 0 & one");
1187  use_num_diff = (num_diff_coeff > 0);
1188  if (use_num_diff) {
1189  amrex::Print() << "6th-order numerical diffusion turned on with coefficient = "
1190  << num_diff_coeff << std::endl;
1191  num_diff_coeff *= amrex::Math::powi<-6>(two);
1192  }
1193 
1194  advChoice.init_params(pp_prefix);
1195  diffChoice.init_params(pp_prefix);
1196  dampingChoice.init_params(pp_prefix);
1197  spongeChoice.init_params(pp_prefix);
1198  ebChoice.init_params(pp_prefix);
1199 
1200  turbChoice.resize(max_level+1);
1201  for (int lev = 0; lev <= max_level; lev++) {
1202  turbChoice[lev].init_params(lev,max_level,pp_prefix);
1203  }
1204 
1205  // erf.radiation_model = TwoStream selects the two-stream model; its
1206  // erf.radiation.* sub-options are read only then.
1207  radChoice.init_params(rad_type == RadiationType::TwoStream, max_level, pp_prefix);
1208 
1209  vert_implicit_fac.resize(max_level+1);
1210  for (int lev = 0; lev <= max_level; lev++) {
1211  vert_implicit_fac[lev].resize(3);
1212  vert_implicit_fac[lev][0] = one;
1213  vert_implicit_fac[lev][1] = one;
1214  vert_implicit_fac[lev][2] = zero;
1215  }
1216 
1217  // YSU PBL: use consistent coriolis frequency
1218  for (int lev = 0; lev <= max_level; lev++) {
1219  if (turbChoice[lev].pbl_ysu_use_consistent_coriolis) {
1220  if (use_coriolis) {
1221  turbChoice[lev].pbl_ysu_coriolis_freq = coriolis_factor * sinphi;
1222  if (lev == 0) {
1223  amrex::Print() << "YSU PBL using ERF coriolis frequency: " << turbChoice[lev].pbl_ysu_coriolis_freq << std::endl;
1224  }
1225  } else {
1226  amrex::Error("YSU cannot use ERF coriolis frequency if not using coriolis");
1227  }
1228  }
1229  }
1230  // MRF
1231  for (int lev = 0; lev <= max_level; lev++) {
1232  if (turbChoice[lev].pbl_ysu_use_consistent_coriolis) {
1233  if (use_coriolis) {
1234  turbChoice[lev].pbl_ysu_coriolis_freq = coriolis_factor * sinphi;
1235  if (lev == 0) {
1236  amrex::Print() << "MRF PBL using ERF coriolis frequency: " << turbChoice[lev].pbl_ysu_coriolis_freq << std::endl;
1237  }
1238  } else {
1239  amrex::Error("MRF cannot use ERF coriolis frequency if not using coriolis");
1240  }
1241  }
1242  }
1243 
1244  // What's the strength of the bdy nudging?
1245  pp.queryAdd("bdy_nudge_factor",bdy_nudge_factor);
1246 
1247  // Optionally use the dry-air density reconstructed from wrfbdy.
1248  pp.queryAdd("use_wrf_bdy_density", use_wrf_bdy_density);
1249 
1250  // Optionally ingest cloud water and cloud ice from wrfinput/wrfbdy.
1251  pp.queryAdd("use_wrf_bdy_qc_qi", use_wrf_bdy_qc_qi);
1252 
1253  if (!use_real_bcs || init_type != InitType::WRFInput) {
1254  use_wrf_bdy_density = false;
1255  }
1256 
1257  pp.queryAdd("bdy_rho_nudge_factor", bdy_rho_nudge_factor);
1258 
1259  // Which approach to nudging the moist variables in the boundary region?
1260  pp.queryAdd("bdy_moist_nudge_type",bdy_moist_nudge_type);
1261  if (bdy_moist_nudge_type < 0 || bdy_moist_nudge_type > 3) {
1262  amrex::Error("erf.bdy_moist_nudge_type must be one of 0, 1, 2, or 3");
1263  }
1264  if (bdy_moist_nudge_type == 3 && !use_wrf_bdy_qc_qi) {
1265  amrex::Error("erf.bdy_moist_nudge_type = 3 requires erf.use_wrf_bdy_qc_qi = true");
1266  }
1267  if (use_wrf_bdy_qc_qi) {
1268  if (moisture_type == MoistureType::None) {
1269  amrex::Error("erf.use_wrf_bdy_qc_qi requires an active moisture model");
1270  }
1271  if (!use_real_bcs || init_type != InitType::WRFInput) {
1272  amrex::Error("erf.use_wrf_bdy_qc_qi requires WRFInput real boundary conditions");
1273  }
1276  amrex::Error("erf.use_wrf_bdy_qc_qi requires active qv and qc component indices");
1277  }
1278  const int optional_moisture_comps[] = {moisture_indices.qi,
1282  for (const int comp : optional_moisture_comps) {
1283  if (comp != -1 && (comp < RhoQ1_comp || comp > RhoQ11_comp)) {
1284  amrex::Error("erf.use_wrf_bdy_qc_qi found an invalid active moisture component index");
1285  }
1286  }
1287  }
1288 
1289  // Are me transporting the scalar component?
1290  pp.queryAdd("transport_scalar",transport_scalar);
1291 
1292  for (int lev = 0; lev <= max_level; ++lev) {
1293  if (turbChoice[lev].uses_eamxx_shoc()) {
1294  use_eamxx_shoc = true;
1295  }
1296  if (turbChoice[lev].uses_native_shoc()) {
1297  use_native_shoc = true;
1299  }
1300  }
1301 
1302  // Set up the vertical implicit diffusion solve
1303  int n_impfac = pp.countval("vert_implicit_fac");
1304  AMREX_ALWAYS_ASSERT(n_impfac == 0 || n_impfac == 1 || n_impfac==3);
1305  if (n_impfac == 1) {
1306  amrex::Real fac_in;
1307  pp.get("vert_implicit_fac", fac_in);
1308  for (int lev = 0; lev <= max_level; lev++) {
1309  for (int i=0; i<3; ++i) {
1310  vert_implicit_fac[lev][i] = fac_in;
1311  }
1312  }
1313  } else if (n_impfac == 3) {
1314  for (int lev = 0; lev <= max_level; lev++) {
1315  pp.getarr("vert_implicit_fac", vert_implicit_fac[lev]);
1316  }
1317  }
1318 
1319  // Record whether the user explicitly requested these
1320  const bool user_set_imp_thermal = pp.contains("implicit_thermal_diffusion");
1321  const bool user_set_imp_moisture = pp.contains("implicit_moisture_diffusion");
1322  const bool user_set_imp_ke = pp.contains("implicit_ke_diffusion");
1323  const bool user_set_imp_momentum = pp.contains("implicit_momentum_diffusion");
1324 
1325  // If true (default), include implicit contributions to vertical thermal diffusion
1326  pp.queryAdd("implicit_thermal_diffusion", implicit_thermal_diffusion);
1327 
1328  // If true (default), include implicit contributions to vertical moisture diffusion
1329  pp.queryAdd("implicit_moisture_diffusion", implicit_moisture_diffusion);
1330 
1331  // If true (default), include implicit contributions to vertical KE diffusion
1332  pp.queryAdd("implicit_ke_diffusion", implicit_ke_diffusion);
1333 
1334  // If true (default), include implicit contributions in tau13, tau23,
1335  pp.queryAdd("implicit_momentum_diffusion", implicit_momentum_diffusion);
1336 
1337  // The default is true (i.e. that it happens before the acoustic substepping).
1338  pp.queryAdd("implicit_before_substep", implicit_before_substep);
1339  for (int lev = 0; lev <= max_level; lev++) {
1340  if ( (substepping_type[lev] == SubsteppingType::None) && !implicit_before_substep) {
1341  amrex::Print() << "implicit_before_substep cannot be false without substepping; setting to true." << "\n";
1342  implicit_before_substep = true;
1343  }
1344  }
1345 
1346  // Handle shoc case -- SHOC owns whatever vertical diffusion the host does not
1347  if (uses_shoc_family()) {
1348  const bool host_owns_scalars = host_owns_vertical_scalar_diffusion();
1349  const bool host_owns_momentum = host_owns_vertical_momentum_diffusion();
1350  if (!host_owns_scalars &&
1351  ( (user_set_imp_thermal && implicit_thermal_diffusion ) ||
1352  (user_set_imp_moisture && implicit_moisture_diffusion) ||
1353  (user_set_imp_ke && implicit_ke_diffusion ) ) ) {
1354  amrex::Print() << "Ignoring erf.implicit_{thermal,moisture,ke}_diffusion = true; "
1355  << "SHOC owns vertical scalar diffusion." << "\n";
1356  }
1357  if (!host_owns_momentum && user_set_imp_momentum && implicit_momentum_diffusion) {
1358  amrex::Print() << "Ignoring erf.implicit_momentum_diffusion = true; "
1359  << "SHOC owns vertical momentum diffusion." << "\n";
1360  }
1361 
1362  implicit_thermal_diffusion = (implicit_thermal_diffusion && host_owns_scalars);
1364  implicit_ke_diffusion = (implicit_ke_diffusion && host_owns_scalars);
1365  implicit_momentum_diffusion = (implicit_momentum_diffusion && host_owns_momentum);
1366 
1367  // Make the resulting configuration visible in the run log
1368  if (!host_owns_scalars && !host_owns_momentum) {
1369  amrex::Print() << "Turning off vertical implicit solve for all components since SHOC owns diffusion." << "\n";
1370  } else {
1371  amrex::Print() << "SHOC hands vertical diffusion of"
1372  << (host_owns_scalars ? " scalars" : "")
1373  << (host_owns_momentum ? " momentum" : "")
1374  << " to the host; keeping the vertical implicit solve on (theta = "
1376  << ", moisture = " << implicit_moisture_diffusion
1377  << ", tke = " << implicit_ke_diffusion
1378  << ", momenta = " << implicit_momentum_diffusion << ")." << "\n";
1379  }
1380  } // uses_shoc_family
1381 
1382  // Do not allow implicit vertical diff if user turns it off
1383  bool do_vert_implicit = true;
1384  pp.queryAdd("vert_implicit", do_vert_implicit);
1385  if (!do_vert_implicit) {
1386  for (int lev = 0; lev <= max_level; lev++) {
1387  amrex::Print() << "Turning off native vertical implicit solve from vert_implicit flag at level " << lev << std::endl;
1388  vert_implicit_fac[lev][0] = zero;
1389  vert_implicit_fac[lev][1] = zero;
1390  vert_implicit_fac[lev][2] = zero;
1391  }
1392  }
1393 
1394  // The implicit vertical diffusion is only second order in an anelastic run when
1395  // the two stages are the midpoint method and the solve is done in the first stage
1396  // alone: S^* = S^n + (dt/2) F(S^*) and S^{n+1} = S^n + dt F(S^*) give
1397  // S^* = (S^n + S^{n+1})/2, i.e. the implicit midpoint rule. Solving again in the
1398  // second stage would reduce the pair to backward Euler, and with the RK2 (Heun)
1399  // stages there is no stage that plays the role of the midpoint at all.
1400  for (int lev = 0; lev <= max_level; lev++) {
1401  if (anelastic[lev]) {
1402  if (anelastic_type[lev] == AnelasticType::RK2) {
1403  amrex::Print() << "Turning off native vertical implicit solve flag because anelastic at level " << lev
1404  << " with RK2 scheme." << std::endl;
1405  vert_implicit_fac[lev][0] = zero;
1406  vert_implicit_fac[lev][1] = zero;
1407  vert_implicit_fac[lev][2] = zero;
1408  } else if (anelastic_type[lev] == AnelasticType::MidPoint) {
1409  if (do_vert_implicit && vert_implicit_fac[lev][0] != one) {
1410  amrex::Print() << "Forcing implicit factor 1 in first stage of MidPoint to ensure second-order accuracy." << std::endl;
1411  vert_implicit_fac[lev][0] = one;
1412  }
1413  if (vert_implicit_fac[lev][1] > zero) {
1414  amrex::Print() << "Turning off the second-stage vertical implicit solve at level " << lev
1415  << " because anelastic with MidPoint solves in the first stage only."
1416  << std::endl;
1417  }
1418  // The anelastic integrator only takes two stages, so [2] is never used
1419  vert_implicit_fac[lev][1] = zero;
1420  vert_implicit_fac[lev][2] = zero;
1421  }
1422  }
1423  }
1424 
1425  // Do not allow implicit vertical diff with EB
1426  if (terrain_type == TerrainType::EB) {
1427  for (int lev = 0; lev <= max_level; lev++) {
1428  if (do_vert_implicit) {
1429  amrex::Print() << "Implicit diffusion is not supported with EB; turning off at level " << lev << "\n";
1430  vert_implicit_fac[lev][0] = zero;
1431  vert_implicit_fac[lev][1] = zero;
1432  vert_implicit_fac[lev][2] = zero;
1433  }
1434  }
1435  }
1436 
1437  // The EB diffusion path adds no buoyancy, shear or dissipation source for
1438  // a prognostic TKE closure
1439  if (terrain_type == TerrainType::EB) {
1440  for (int lev = 0; lev <= max_level; lev++) {
1441  if (turbChoice[lev].use_keqn) {
1442  amrex::Error("erf.terrain_type = EB cannot be used with erf.les_type = Deardorff "
1443  "or erf.rans_type = kEqn: the EB diffusion path has no TKE sources");
1444  }
1445  }
1446  }
1447 
1448  // Do not allow implicit vertical diff when all the components are false
1453  amrex::Print() << "Thermal, moisture, KE, and momentum diffusion are all turned off; turning off vertical implicit solve." << std::endl;
1454  for (int lev = 0; lev <= max_level; lev++) {
1455  vert_implicit_fac[lev][0] = zero;
1456  vert_implicit_fac[lev][1] = zero;
1457  vert_implicit_fac[lev][2] = zero;
1458  }
1459  }
1460 
1461  // Which type of multilevel coupling
1462  coupling_type = CouplingType::TwoWay; // Default
1463  pp.query_enum_case_insensitive("coupling_type",coupling_type);
1464 
1465  // Test for hybrid (compressible + anelastic) -- in this case we must use one-way coupling
1466  if (any_anelastic && any_compress) {
1467  coupling_type = CouplingType::OneWay;
1468  }
1469 
1470  // Which type of windfarm model
1471  windfarm_type = WindFarmType::None; // Default
1472  pp.query_enum_case_insensitive("windfarm_type",windfarm_type);
1473 
1474  windfarm_loc_type = WindFarmLocType::None;
1475  pp.query_enum_case_insensitive("windfarm_loc_type",windfarm_loc_type);
1476 
1477  pp.queryAdd("windfarm_loc_table", windfarm_loc_table);
1478  pp.queryAdd("windfarm_spec_table", windfarm_spec_table);
1479  pp.queryAdd("windfarm_blade_table", windfarm_blade_table);
1480  pp.queryAdd("windfarm_airfoil_tables", windfarm_airfoil_tables);
1481  pp.queryAdd("windfarm_spec_table_extra", windfarm_spec_table_extra);
1482 
1483  // Sampling distance upstream of the turbine to find the
1484  // incoming free stream velocity as a factor of the diameter of the
1485  // turbine. ie. the sampling distance will be this number multiplied
1486  // by the diameter of the turbine
1487  pp.queryAdd("sampling_distance_by_D", sampling_distance_by_D);
1488  pp.queryAdd("turb_disk_angle_from_x", turb_disk_angle);
1489 
1490  pp.queryAdd("windfarm_x_shift",windfarm_x_shift);
1491  pp.queryAdd("windfarm_y_shift",windfarm_y_shift);
1492  // Test if time averaged data is to be output
1493  pp.queryAdd("time_avg_vel",time_avg_vel);
1494 
1495  // Interval means and resolved turbulent moments for plotfile output
1496  pp.queryAdd("compute_mean_vars", compute_mean_vars);
1497  pp.queryAdd("mean_vars_reset_mode", mean_vars_reset_mode);
1498  pp.queryAdd("mean_vars_reset_time", mean_vars_reset_time);
1499 
1500  if (compute_mean_vars &&
1501  mean_vars_reset_mode != "plotfile" && mean_vars_reset_mode != "time") {
1502  amrex::Error("erf.mean_vars_reset_mode must be either 'plotfile' or 'time'");
1503  }
1504  if (compute_mean_vars && mean_vars_reset_mode == "time" &&
1506  amrex::Error("erf.mean_vars_reset_time must be non-negative when "
1507  "erf.mean_vars_reset_mode = 'time'");
1508  }
1509 
1510  pp.queryAdd("hindcast_lateral_forcing", hindcast_lateral_forcing);
1511 
1513  pp.queryAdd("hindcast_boundary_data_dir", hindcast_boundary_data_dir);
1514 
1515  if(hindcast_boundary_data_dir.empty()) {
1516  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_boundary_data_dir' for boundary data for lateral forcing");
1517  }
1518  pp.queryAdd("hindcast_data_interval_in_hrs", hindcast_data_interval_in_hrs);
1520  amrex::Error("ERROR: Input parameter 'erf.hindcast_data_interval_in_hrs' which is the time interval between the "
1521  "data files is either missing or set to less than zero");
1522  }
1523  pp.queryAdd("hindcast_lateral_sponge_strength", hindcast_lateral_sponge_strength);
1524  pp.queryAdd("hindcast_lateral_sponge_length", hindcast_lateral_sponge_length);
1525 
1526  pp.queryAdd("hindcast_zhi_sponge_length", hindcast_zhi_sponge_length);
1527  pp.queryAdd("hindcast_zhi_sponge_strength", hindcast_zhi_sponge_strength);
1528 
1529  pp.queryAdd("hindcast_zhi_sponge_damping", hindcast_zhi_sponge_damping);
1530 
1532  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_lateral_sponge_strength' or it is specified to be less than zero");
1533  }
1534 
1536  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_lateral_sponge_length' or it is specified to be less than zero");
1537  }
1538 
1540  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_zhi_sponge_length' or it is specified to be less than zero");
1541  }
1542 
1544  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_zhi_sponge_strength' or it is specified to be less than zero");
1545  }
1546  }
1547 
1548  pp.queryAdd("hindcast_surface_bcs", hindcast_surface_bcs);
1549  if(hindcast_surface_bcs) {
1550  pp.queryAdd("hindcast_surface_data_dir", hindcast_surface_data_dir);
1551  }
1552 
1553  pp.queryAdd("io_hurricane_eye_tracker", io_hurricane_eye_tracker);
1555  pp.queryAdd("hurricane_eye_latitude", hurricane_eye_latitude);
1556  pp.queryAdd("hurricane_eye_longitude", hurricane_eye_longitude);
1558  amrex::Error("ERROR: You are using 'erf.io_hurricane_eye_tracker' to write out the files that track the eye of the hurricane"
1559  " but have not provided the initial location of the eye of the hurricane to be tracked. There has to be two"
1560  " options in the inputs - erf.hurricane_eye_latitude and erf.hurricane_eye_longitude that gives an approximate"
1561  " location of the eye in the initial condition");
1562  }
1563  }
1564 
1565  pp.queryAdd("is_init_for_ensemble", is_init_for_ensemble);
1566  if(is_init_for_ensemble) {
1567  amrex::ParmParse pp_ens("ensemble");
1568  pp_ens.queryAdd("n_members", n_ensemble);
1569  if(n_ensemble < 2) {
1570  amrex::Abort("You are using an ensemble run. There needs to be at least 2 ensemble members. "
1571  "erf.n_ensemble must be >=2.");
1572  }
1573  pp_ens.queryAdd("coarse_bckgnd_data_file", coarse_bckgnd_data_file);
1574  if (coarse_bckgnd_data_file.empty()) {
1575  amrex::Abort("coarse_bckgnd_data_file is empty! For ensmeble simulations, there needs to be a coarse background file which "
1576  "contains the data which will be interpolated onto the fine mesh. There has to a entry ensemble.coarse_bckgnd_data_file "
1577  "which contains the filename in the inputs.");
1578  }
1579  pp_ens.queryAdd("ens_pert_amplitude", ens_pert_amplitude);
1580  if(ens_pert_amplitude <= 0.0) {
1581  amrex::Error("You are using initialization for ensemble simulations using the inputs option "
1582  "ensemble.is_init_for_ensemble=true. In this case, there has to be an option "
1583  "ensemble.ens_pert_amplitude which is the value of the amplitude of the perturbation "
1584  "to be added to the background state and has to be greater than 0.0");
1585  }
1586  pp_ens.queryAdd("ens_pert_correlated_radius", ens_pert_correlated_radius);
1587  if(ens_pert_correlated_radius <= 0.0) {
1588  amrex::Error("You are using initialization with spatially correlated perturbations using the inputs option "
1589  "ensemble.is_init_for_ensemble=true. In this case, there has to be an option "
1590  "ensemble.ens_pert_correlated_radius which is the value of the the spatial correlation radius, "
1591  "and has to be greater than 0.0");
1592  }
1593  }
1594  }
1595 
1596  /**
1597  * @brief Validate solver options after geometry and boundary conditions are known.
1598  * @param max_level Maximum AMR level configured for the run.
1599  * @param geom_vect Geometry for each AMR level.
1600  * @param phys_bc_type Physical boundary-condition types.
1601  */
1602  void check_params (int max_level, const amrex::Vector<amrex::Geometry>& geom_vect, amrex::GpuArray<ERF_BC, AMREX_SPACEDIM*2> phys_bc_type)
1603  {
1604 #if 0
1605  // Warn for PBL models and moisture - these may not yet be compatible
1606  for (int lev = 0; lev <= max_level; lev++) {
1607  if ((moisture_type != MoistureType::None) && (turbChoice[lev].pbl_type != PBLType::None)) {
1608  amrex::Warning("\n*** WARNING: Moisture may not yet be compatible with PBL models, \n proceed with caution ***");
1609  }
1610  }
1611 #endif
1612  //
1613  // Buoyancy type check
1614  //
1615  for (int lev = 0; lev <= max_level; lev++) {
1616  if (buoyancy_type[lev] != 1 && buoyancy_type[lev] != 2 && buoyancy_type[lev] != 3 && buoyancy_type[lev] != 4) {
1617  amrex::Error("buoyancy_type must be 1, 2, 3 or 4");
1618  }
1619  }
1620 
1621  if (!use_lagged_delta_rt && !(terrain_type == TerrainType::MovingFittedMesh)) {
1622  amrex::Error("Can't turn off lagged_delta_rt when terrain not moving");
1623  }
1624 
1625  //
1626  // Wind farm checks
1627  //
1628  if (windfarm_type==WindFarmType::SimpleAD and sampling_distance_by_D < zero) {
1629  amrex::Error("To use simplified actuator disks, you need to provide a variable"
1630  " erf.sampling_distance_by_D in the inputs which specifies the upstream"
1631  " distance as a factor of the turbine diameter at which the incoming free stream"
1632  " velocity will be computed at.");
1633  }
1634  if ( (windfarm_type==WindFarmType::SimpleAD ||
1635  windfarm_type==WindFarmType::GeneralAD ) && turb_disk_angle < zero) {
1636  amrex::Error("To use simplified actuator disks, you need to provide a variable"
1637  " erf.turb_disk_angle_from_x in the inputs which is the angle of the face of the"
1638  " turbine disk from the x-axis. A turbine facing an oncoming flow in the x-direction"
1639  " will have turb_disk_angle value of 90 deg.");
1640  }
1641  if (windfarm_loc_type == WindFarmLocType::lat_lon and (windfarm_x_shift < zero or windfarm_y_shift < zero)) {
1642  amrex::Error("You are using windfarms with latitude-logitude option to position the turbines."
1643  " For this you should provide the inputs erf.windfarm_x_shift and"
1644  " erf.windfarm_y_shift which are the values by which the bounding box of the"
1645  " windfarm is shifted from the x and the y axes.");
1646  }
1647 
1648 
1649  if ( (const_massflux_u != 0) && !(geom_vect[0].isPeriodic(0)) ) {
1650  amrex::Error("Constant mass flux (in x) should be used with periodic boundaries");
1651  }
1652 
1653  if ( (const_massflux_v != 0) && !(geom_vect[0].isPeriodic(1)) ) {
1654  amrex::Error("Constant mass flux (in y) should be used with periodic boundaries");
1655  }
1656 
1657  // Mesoscale diffusion -- test if LES appropriate with this dx,dy
1658  for (int lev = 0; lev <= max_level; lev++) {
1659  if ((geom_vect[lev].CellSize(0) > amrex::Real(2000.)) || (geom_vect[lev].CellSize(1) > amrex::Real(2000.)))
1660  {
1661  if ( (turbChoice[lev].les_type == LESType::Smagorinsky) && !turbChoice[lev].smag2d ) {
1662  amrex::Warning("Should use 2-D Smagorinsky for mesoscale resolution");
1663  } else if (turbChoice[lev].les_type == LESType::Deardorff) {
1664  amrex::Warning("Should not use Deardorff LES for mesoscale resolution");
1665  }
1666  }
1667  }
1668 
1669  // Turn off implicit solve if we have no diffusion
1670  bool l_use_kturb = turbChoice[0].use_kturb;
1671  for (int lev = 1; lev <= max_level; lev++) {
1672  l_use_kturb = (l_use_kturb || turbChoice[lev].use_kturb);
1673  }
1674  bool l_use_diff = ( (diffChoice.molec_diff_type != MolecDiffType::None) || l_use_kturb );
1675 
1676  for (int lev = 0; lev <= max_level; lev++) {
1677  bool l_implicit_diff = (vert_implicit_fac[lev][0] > zero ||
1678  vert_implicit_fac[lev][1] > zero ||
1679  vert_implicit_fac[lev][2] > zero);
1680  if (l_implicit_diff && !l_use_diff) {
1681  amrex:: Print() << "No molecular or turbulent diffusion, turning off implicit solve at level " << lev << std::endl;
1682  vert_implicit_fac[lev][0] = zero;
1683  vert_implicit_fac[lev][1] = zero;
1684  vert_implicit_fac[lev][2] = zero;
1685  }
1686  }
1687 
1688  // Countergradient validation: ensure required implicit diffusion is enabled
1689  for (int lev = 0; lev <= max_level; lev++) {
1690  if (turbChoice[lev].enable_mrf_countergradient) {
1692  vert_implicit_fac[lev][0] > zero ||
1693  vert_implicit_fac[lev][1] > zero ||
1694  vert_implicit_fac[lev][2] > zero,
1695  "enable_mrf_countergradient requires vert_implicit_fac > 0");
1698  "enable_mrf_countergradient requires implicit_thermal_diffusion = true");
1699  if (moisture_type != MoistureType::None) {
1702  "enable_mrf_countergradient with moisture requires implicit_moisture_diffusion = true");
1703  }
1704  }
1705  }
1706 
1707  for (int lev = 0; lev <= max_level; lev++) {
1708  turbChoice[lev].check_params(phys_bc_type);
1709  }
1710  }
1711 
1712  /**
1713  * @brief Print the configured solver, physics, and transport options.
1714  * @param max_level Maximum AMR level configured for the run.
1715  * @param pp_prefix ParmParse prefix used to display nested choices.
1716  */
1717  void display (int max_level, std::string pp_prefix)
1718  {
1719  amrex::Print() << "SOLVER CHOICE: " << std::endl;
1720  for (int lev = 0; lev <= max_level; lev++) {
1721  amrex::Print() << "At level " << lev << " : " << std::endl;
1722  if (anelastic[lev]) {
1723  amrex::Print() << " anelastic with no substepping, using the "
1724  << ((anelastic_type[lev] == AnelasticType::MidPoint) ? "MidPoint" : "RK2")
1725  << " integrator" << std::endl;
1726  } else {
1727  if (substepping_type[lev] == SubsteppingType::None) {
1728  amrex::Print() << " compressible with no substepping" << std::endl;
1729  } else if (substepping_type[lev] == SubsteppingType::Implicit) {
1730  amrex::Print() << " compressible with implicit substepping" << std::endl;
1731  }
1732  }
1733  if (fixed_density[lev]) {
1734  amrex::Print() << " and fixed density" << std::endl;
1735  }
1736  }
1737 
1738  for (int lev = 0; lev <= max_level; lev++) {
1739  amrex::Print() << "vert_implicit_fac at level " << lev << " : "
1740  << vert_implicit_fac[lev][0] << " "
1741  << vert_implicit_fac[lev][1] << " "
1742  << vert_implicit_fac[lev][2];
1743  if (vert_implicit_fac[lev][0] > zero ||
1744  vert_implicit_fac[lev][1] > zero ||
1745  vert_implicit_fac[lev][2] > zero)
1746  {
1747  amrex::Print() << " (theta = " << implicit_thermal_diffusion
1748  << ", moisture = " << implicit_moisture_diffusion
1749  << ", tke = " << implicit_ke_diffusion
1750  << ", momenta = " << implicit_momentum_diffusion;
1751 #ifdef ERF_IMPLICIT_W
1752  amrex::Print() << ", including w";
1753 #endif
1754  amrex::Print() << ")";
1755  }
1756  }
1757  amrex::Print() << std::endl;
1758  amrex::Print() << "use_coriolis : " << use_coriolis << std::endl;
1759  amrex::Print() << "use_gravity : " << use_gravity << std::endl;
1760 
1761  if (moisture_type == MoistureType::SAM) {
1762  amrex::Print() << "Moisture Model: SAM" << std::endl;
1763  } else if (moisture_type == MoistureType::SAM_NoIce) {
1764  amrex::Print() << "Moisture Model: SAM No Ice" << std::endl;
1765  } else if (moisture_type == MoistureType::SAM_NoPrecip_NoIce) {
1766  amrex::Print() << "Moisture Model: SAM No Precip No Ice" << std::endl;
1767  } else if (moisture_type == MoistureType::Morrison) {
1768  amrex::Print() << "Moisture Model: Morrison" << std::endl;
1769  } else if (moisture_type == MoistureType::Morrison_NoIce) {
1770  amrex::Print() << "Moisture Model: Morrison_NoIce" << std::endl;
1771  } else if (moisture_type == MoistureType::WSM6) {
1772  amrex::Print() << "Moisture Model: WSM6" << std::endl;
1773  } else if (moisture_type == MoistureType::WDM6) {
1774  amrex::Print() << "Moisture Model: WDM6" << std::endl;
1775  } else if (moisture_type == MoistureType::Kessler) {
1776  amrex::Print() << "Moisture Model: Kessler" << std::endl;
1777  } else if (moisture_type == MoistureType::Kessler_NoRain) {
1778  amrex::Print() << "Moisture Model: Kessler No Rain" << std::endl;
1779  } else if (moisture_type == MoistureType::SatAdj) {
1780  amrex::Print() << "Moisture Model: Saturation Adjustment" << std::endl;
1781  } else if (moisture_type == MoistureType::SuperDroplets) {
1782  amrex::Print() << "Moisture Model: SuperDroplets" << std::endl;
1783  } else if (moisture_type == MoistureType::MoistNoCondensation) {
1784  amrex::Print() << "Moisture Model: MoistNoCondensation" << std::endl;
1785  } else {
1786  amrex::Print() << "Moisture Model: None" << std::endl;
1787  }
1788 
1789  if (terrain_type == TerrainType::StaticFittedMesh) {
1790  amrex::Print() << "Terrain Type: StaticFittedMesh" << std::endl;
1791  } else if (terrain_type == TerrainType::MovingFittedMesh) {
1792  amrex::Print() << "Terrain Type: MovingFittedMesh" << std::endl;
1793  } else if (terrain_type == TerrainType::EB) {
1794  amrex::Print() << "Terrain Type: EB" << std::endl;
1795  ebChoice.display();
1796  } else if (terrain_type == TerrainType::ImmersedForcing) {
1797  amrex::Print() << "Terrain Type: ImmersedForcing" << std::endl;
1798  } else {
1799  amrex::Print() << "Terrain Type: None" << std::endl;
1800  }
1801 
1802  if (buildings_type == BuildingsType::ImmersedForcing) {
1803  amrex::Print() << "Buildings Type: ImmersedForcing" << std::endl;
1804  } else {
1805  amrex::Print() << "Buildings Type: None" << std::endl;
1806  }
1807 
1808  if (mesh_type == MeshType::ConstantDz) {
1809  amrex::Print() << " Mesh Type: ConstantDz" << std::endl;
1810  } else if (mesh_type == MeshType::StretchedDz) {
1811  amrex::Print() << " Mesh Type: StretchedDz" << std::endl;
1812  } else if (mesh_type == MeshType::VariableDz) {
1813  amrex::Print() << " Mesh Type: VariableDz" << std::endl;
1814  } else {
1815  amrex::Error("No mesh_type set!");
1816  }
1817 
1818  amrex::Print() << "ABL Driver Type: " << std::endl;
1819  if (abl_driver_type == ABLDriverType::None) {
1820  amrex::Print() << " None" << std::endl;
1821  } else if (abl_driver_type == ABLDriverType::PressureGradient) {
1822  amrex::Print() << " Pressure Gradient "
1823  << amrex::RealVect(abl_pressure_grad[0],abl_pressure_grad[1],abl_pressure_grad[2])
1824  << std::endl;
1825  } else if (abl_driver_type == ABLDriverType::GeostrophicWind) {
1826  amrex::Print() << " Geostrophic Wind "
1827  << amrex::RealVect(abl_geo_forcing[0],abl_geo_forcing[1],abl_geo_forcing[2])
1828  << std::endl;
1829  }
1830 
1831  if (max_level > 0) {
1832  amrex::Print() << "Coupling Type: " << std::endl;
1833  if (coupling_type == CouplingType::TwoWay) {
1834  amrex::Print() << " Two-way" << std::endl;
1835  } else if (coupling_type == CouplingType::OneWay) {
1836  amrex::Print() << " One-way" << std::endl;
1837  }
1838  }
1839 
1840  if (rad_type == RadiationType::RRTMGP) {
1841  amrex::Print() << "Radiation Model: RRTMGP" << std::endl;
1842  } else if (rad_type == RadiationType::Simple) {
1843  amrex::Print() << "Radiation Model: Simple" << std::endl;
1844  } else if (rad_type == RadiationType::TwoStream) {
1845  amrex::Print() << "Radiation Model: TwoStream" << std::endl;
1846  } else {
1847  amrex::Print() << "Radiation Model: None" << std::endl;
1848  }
1849 
1850  amrex::Print() << "Gradp_type : " << gradp_type << std::endl;
1851 
1852  for (int lev = 0; lev <= max_level; lev++) {
1853  amrex::Print() << "Buoyancy_type at level " << lev << " : " << buoyancy_type[lev] << std::endl;
1854  }
1855 
1856  advChoice.display(pp_prefix);
1857  diffChoice.display();
1860 
1861  for (int lev = 0; lev <= max_level; lev++) {
1862  turbChoice[lev].display(lev);
1863  }
1864  }
1865 
1866  /**
1867  * @brief Build constant-latitude Coriolis forcing parameters.
1868  * @param pp_prefix ParmParse prefix for the ERF input namespace.
1869  */
1870  void build_coriolis_forcings_const_lat (std::string pp_prefix)
1871  {
1872  amrex::ParmParse pp(pp_prefix);
1873 
1874  // Read the rotational time period (in seconds)
1875  double rot_time_period = 86400.0;
1876  pp.queryAdd("rotational_time_period", rot_time_period);
1877 
1878  coriolis_factor = static_cast<amrex::Real>(4.0 * PI / rot_time_period);
1879 
1880  pp.queryAdd("coriolis_3d", coriolis_3d);
1881 
1882  // Convert to radians
1883  amrex::Real latitude_for_coriolis = amrex::Real(90.0);
1884  pp.queryAdd("latitude", latitude_for_coriolis);
1885  latitude_for_coriolis *= (PI/amrex::Real(180.));
1886  sinphi = std::sin(latitude_for_coriolis);
1887 
1888  // Note: cosphi defaults to 0
1889  if (coriolis_3d) {
1890  cosphi = std::cos(latitude_for_coriolis);
1891  }
1892 
1893  amrex::Print() << "Coriolis frequency, f = " << coriolis_factor * sinphi << " 1/s" << std::endl;
1894 
1895  if (abl_driver_type == ABLDriverType::GeostrophicWind) {
1896  // Read in the geostrophic wind -- we only use this to construct
1897  // the forcing term so no need to keep it
1898  amrex::Vector<amrex::Real> abl_geo_wind(3);
1899  pp.queryarr("abl_geo_wind",abl_geo_wind);
1900 
1901  if(!pp.queryAdd("abl_geo_wind_table",abl_geo_wind_table)) {
1902  abl_geo_forcing = {
1903  -coriolis_factor * (abl_geo_wind[1]*sinphi - abl_geo_wind[2]*cosphi),
1904  coriolis_factor * abl_geo_wind[0]*sinphi,
1905  -coriolis_factor * abl_geo_wind[0]*cosphi
1906  };
1907  } else {
1908  amrex::Print() << "NOTE: abl_geo_wind_table provided, ignoring input abl_geo_wind" << std::endl;
1909  }
1910  }
1911  }
1912 
1913  /**
1914  * @brief Read one integer value or one value per AMR level.
1915  * @param max_level Maximum AMR level configured for the run.
1916  * @param string_to_read ParmParse key to read.
1917  * @param vec_to_fill Destination vector with one entry per level.
1918  * @param default_int Default value used when the key is absent.
1919  */
1920  void read_int_string (int max_level, const char* string_to_read,
1921  amrex::Vector<int>& vec_to_fill, int default_int)
1922  {
1923  amrex::ParmParse pp("erf");
1924  int nvals = pp.countval(string_to_read);
1925  AMREX_ALWAYS_ASSERT(nvals == 0 || nvals == 1 || nvals >= max_level+1);
1926  amrex::Vector<int> temp; temp.resize(nvals);
1927  pp.queryarr(string_to_read,temp);
1928 
1929  if (vec_to_fill.size() < max_level+1) {
1930  vec_to_fill.resize(max_level+1);
1931  }
1932 
1933  if (nvals == 0) {
1934  for (int i = 0; i <= max_level; ++i) vec_to_fill[i] = default_int;
1935  } else if (nvals == 1) {
1936  for (int i = 0; i <= max_level; ++i) vec_to_fill[i] = temp[0];
1937  } else {
1938  for (int i = 0; i <= max_level; ++i) vec_to_fill[i] = temp[i];
1939  }
1940  }
1941 
1942  inline static
1943  InitType init_type = InitType::None;
1944 
1945  inline static
1946  SoundingType sounding_type = SoundingType::Ideal;
1947 
1948  inline static
1949  TerrainType terrain_type = TerrainType::None;
1950 
1951  inline static
1952  BuildingsType buildings_type = BuildingsType::None;
1953 
1954  inline static
1955  bool use_real_bcs = false;
1956 
1957  inline static
1958  MeshType mesh_type = MeshType::ConstantDz;
1959 
1960  /**
1961  * @brief Override the globally selected mesh type.
1962  * @param new_mesh_type Mesh type to store.
1963  */
1964  static
1965  void set_mesh_type (MeshType new_mesh_type)
1966  {
1967  mesh_type = new_mesh_type;
1968  }
1969 
1974  amrex::Vector<TurbChoice> turbChoice;
1977 
1979 
1980  amrex::Vector<SubsteppingType> substepping_type;
1981  amrex::Vector<int> anelastic;
1982  amrex::Vector<AnelasticType> anelastic_type;
1983  amrex::Vector<int> fixed_density;
1984  amrex::Vector<int> project_initial_velocity;
1985  amrex::Vector<int> buoyancy_type;
1986  amrex::Vector<int> is_land;
1987 
1988  // do some extra CFL diagnostics for compressible with substepping
1989  bool substepping_diag = false;
1990 
1991  // time off-centering coefficient, > 0 for forward weighting (i.e., bias
1992  // towards the future time step)
1994 
1995  // This controls the time-centering of the *vertical* differences in the diffusive term for
1996  // theta, u, v (and w if ERF_IMPLICIT_W is set)
1997  // 0: fully explicit
1998  // 1: fully implicit
1999  amrex::Vector<amrex::Vector<amrex::Real>> vert_implicit_fac; // one value per RK stage
2000 
2001  // if any vert_implicit_fac > 0, then the following apply:
2007 
2008  int ncorr = 1;
2009  std::string wall_dist_type = "poisson";
2010 #ifdef AMREX_USE_FLOAT
2013 #else
2016 #endif
2017 
2018  bool test_mapfactor = false;
2019 
2020  int gradp_type = 0;
2021 
2023 
2024  // Specify what additional physics/forcing modules we use
2025  bool use_gravity = false;
2026  bool use_coriolis = false;
2027  bool coriolis_3d = true;
2028 
2030 
2031  // Specify whether to apply other various source terms on substep only
2033  bool forest_substep = false;
2034 
2035  // immersed forcing parameters
2038  // Use a point-implicit (linearly-implicit) formulation of the immersed-forcing
2039  // drag. Defaults to false (explicit forward-Euler source).
2040  bool if_implicit_drag = false;
2041  // immersed forcing MOST parameters.
2047  bool if_use_most = false;
2050  amrex::Real if_ws_floor = 0.001; // [m/s]
2052 
2053  // This defaults to true but can be set to false for moving terrain cases only
2054  bool use_lagged_delta_rt = true;
2055 
2056  // Flag to rebalance states from wrfinput and wrfbdy
2057  bool rebalance_wrf_input = true;
2058 
2059  // Constants
2061  amrex::Real c_p = Cp_d; // specific heat at constant pressure for dry air [J/(kg-K)]
2063 
2064  // Staggered z levels for vertical grid stretching
2068 
2069  // Coriolis forcing
2073 
2074  // User-specified forcings in problem definition
2077  bool custom_w_subsidence = false;
2078  bool do_theta_advection = true; // Apply custom vertical subsidence to (rho*theta) equation when using custom w subsidence
2079  bool do_mom_advection = true; // Apply custom vertical subsidence to momentum equations when using custom w subsidence
2084 
2085  // Do we use source terms to nudge the solution towards
2086  // the time-varying data provided in input sounding files?
2088 
2094  amrex::Real nudging_q_z2 = amrex::Real(10000.0); // TODO: reasonable defaults here?
2095 
2096  bool nudging_u = true; // Nudge u,v when nudging_from_input_sounding is true
2097  bool nudging_t = true; // Nudge potential temperature when nudging_from_input_sounding is true
2098  bool nudging_q = true; // Nudge water vapor when nudging_from_input_sounding is true
2099 
2100  bool large_scale_forcing = false;
2101  std::string lsf_file = "";
2103 
2104  // MOST stress rotations
2106 
2107  // Should we use SHOC?
2108  bool use_eamxx_shoc = false;
2109  bool use_native_shoc = false;
2110 
2111  // Native shoc transport mode
2114 
2115  // Transport the passive scalar?
2116  bool transport_scalar = true;
2117 
2118  // User wishes to output time averaged velocity fields
2119  bool time_avg_vel = false;
2120 
2121  // User wishes to output interval means and resolved turbulent moments
2122  bool compute_mean_vars = false;
2123 
2124  // Reset interval means after each plotfile or once at a requested time
2125  std::string mean_vars_reset_mode = "plotfile";
2127 
2128  /**
2129  * @brief Query whether any turbulent perturbation mode is enabled on a level.
2130  * @param lev AMR level index.
2131  * @return True if source, direct, CPM, or CPM_W perturbations are enabled.
2132  */
2133  bool use_perturbation (int lev) const
2134  {
2135  return pert_type[lev] == PerturbationType::Source ||
2136  pert_type[lev] == PerturbationType::Direct ||
2137  pert_type[lev] == PerturbationType::CPM ||
2138  pert_type[lev] == PerturbationType::CPM_W;
2139  }
2140 
2141  /**
2142  * @brief Query whether direct turbulent perturbations are enabled on a level.
2143  * @param lev AMR level index.
2144  * @return True if direct, CPM, or CPM_W perturbations are enabled.
2145  */
2146  bool use_direct_perturbation (int lev) const
2147  {
2148  return pert_type[lev] == PerturbationType::Direct ||
2149  pert_type[lev] == PerturbationType::CPM ||
2150  pert_type[lev] == PerturbationType::CPM_W;
2151  }
2152 
2153  /**
2154  * @brief Query whether source-term turbulent perturbations are enabled on a level.
2155  * @param lev AMR level index.
2156  * @return True if source perturbations are enabled.
2157  */
2158  bool use_source_perturbation (int lev) const
2159  {
2160  return pert_type[lev] == PerturbationType::Source;
2161  }
2162 
2163  /**
2164  * @brief Query whether vertical-velocity CPM perturbations are enabled on a level.
2165  * @param lev AMR level index.
2166  * @return True if CPM_W perturbations are enabled.
2167  */
2168  bool use_wvel_perturbation (int lev) const
2169  {
2170  return pert_type[lev] == PerturbationType::CPM_W;
2171  }
2172 
2173  /**
2174  * @brief Query whether any SHOC-family PBL scheme is active.
2175  * @return True if native or EAMxx SHOC is active.
2176  */
2177  bool uses_shoc_family () const noexcept
2178  {
2179  return (use_eamxx_shoc || use_native_shoc);
2180  }
2181 
2182  /**
2183  * @brief Test whether the host owns momentum diffusion.
2184  * @return True if ERF dycore does vertical diffusion of momentum.
2185  */
2187  {
2188  if (use_eamxx_shoc) { return false; }
2189  if (!use_native_shoc) { return true; }
2191  }
2192 
2193  /**
2194  * @brief Test whether the host owns scalar diffusion.
2195  * @return True if ERF dycore does vertical diffusion of scalars.
2196  */
2198  {
2199  if (use_eamxx_shoc) { return false; }
2200  if (!use_native_shoc) { return true; }
2201  return false;
2202  }
2203 
2204  /**
2205  * @brief Query whether the active PBL scheme suppresses microphysics condensation.
2206  * @return True when the active PBL scheme owns condensation handling.
2207  */
2209  {
2210  return uses_shoc_family();
2211  }
2212 
2213  /**
2214  * @brief Query whether any level uses a turbulent perturbation mode.
2215  * @return True if at least one configured level has source, direct, or CPM perturbations.
2216  */
2217  bool any_perturbation () const
2218  {
2219  for (const auto& type : pert_type) {
2220  if (type == PerturbationType::Source ||
2221  type == PerturbationType::Direct ||
2222  type == PerturbationType::CPM) {
2223  return true;
2224  }
2225  }
2226  return false;
2227  }
2228 
2229  // Type of perturbation
2230  amrex::Vector<PerturbationType> pert_type;
2231 
2232  // Numerical diffusion
2233  bool use_num_diff{false};
2235 
2236  CouplingType coupling_type;
2237  MoistureType moisture_type;
2238  WindFarmType windfarm_type;
2239  WindFarmLocType windfarm_loc_type;
2240  LandSurfaceType lsm_type;
2241  RadiationType rad_type;
2242 
2243  /** @brief True for the models that run through the IRadiation interface
2244  * (RRTMGP, Simple); the two-stream model has its own class. */
2245  [[nodiscard]] bool rad_uses_interface () const {
2246  return (rad_type == RadiationType::RRTMGP) || (rad_type == RadiationType::Simple);
2247  }
2248 
2249  // Does an external ocean coupler supply SST? See the query in init_params.
2250  bool use_coupled_sst = false;
2251 
2252  ABLDriverType abl_driver_type;
2253  amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> abl_pressure_grad;
2254  amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> abl_geo_forcing;
2255  std::string abl_geo_wind_table;
2257 
2258  bool variable_coriolis{false};
2259 
2260  int ave_plane {2};
2261 
2262  // Microphysics params
2264 
2266 
2273 
2274  // Nudging factor for bdy sponging : F1 = 1/(nudge_factor * dt)
2276 
2277  // Use density reconstructed from standard WRF lateral boundary data.
2278  bool use_wrf_bdy_density = true;
2279 
2280  // Ingest WRF cloud water and active cloud ice at initialization and lateral boundaries.
2281  bool use_wrf_bdy_qc_qi = false;
2282 
2283  // Density-specific Davies factor; non-positive means use bdy_nudge_factor.
2285 
2286  // Which approach to nudging the moist variables in the boundary region?
2288 
2289  // Average the input z-face heights onto the nodes rather than reconstructing them?
2291 
2292  // Interpolate atmospheric state from coarse when creating finer level at later time?
2294 
2295  // Use forest canopy model?
2296  bool do_forest_drag {false};
2297 
2298  // Fixed-leaf-temperature canopy heat exchange (disabled by default)
2299  bool forest_biophysics {false};
2302 
2303  // Enforce constant mass flux?
2309  int massflux_klo {0}; // these are updated in ERF.cpp
2310  int massflux_khi {0};
2311 
2315  bool hindcast_surface_bcs = false;
2319 
2322 
2323  bool is_init_for_ensemble = false;
2324  int n_ensemble = -1;
2328 };
2329 
2330 /**
2331  * @var SolverChoice::init_type
2332  * @brief Initial-condition source selected for the run.
2333  * @var SolverChoice::sounding_type
2334  * @brief Interpretation used for input sounding profiles.
2335  * @var SolverChoice::terrain_type
2336  * @brief Terrain or immersed-boundary representation.
2337  * @var SolverChoice::buildings_type
2338  * @brief Building representation.
2339  * @var SolverChoice::use_real_bcs
2340  * @brief Whether real-data lateral boundary conditions are used.
2341  * @var SolverChoice::mesh_type
2342  * @brief Vertical mesh representation.
2343  * @var SolverChoice::advChoice
2344  * @brief Advection-related options.
2345  * @var SolverChoice::diffChoice
2346  * @brief Diffusion-related options.
2347  * @var SolverChoice::dampingChoice
2348  * @brief Damping-related options.
2349  * @var SolverChoice::spongeChoice
2350  * @brief Sponge-layer options.
2351  * @var SolverChoice::turbChoice
2352  * @brief Turbulence options for each AMR level.
2353  * @var SolverChoice::ebChoice
2354  * @brief Embedded-boundary options.
2355  * @var SolverChoice::force_stage1_single_substep
2356  * @brief Flag forcing a single substep in the first RK stage.
2357  * @var SolverChoice::substepping_type
2358  * @brief Acoustic substepping type for each AMR level.
2359  * @var SolverChoice::anelastic
2360  * @brief Per-level flag selecting anelastic dynamics.
2361  * @var SolverChoice::anelastic_type
2362  * @brief Per-level two-stage scheme used by the anelastic integrator.
2363  * @var SolverChoice::fixed_density
2364  * @brief Per-level flag selecting fixed-density treatment.
2365  * @var SolverChoice::project_initial_velocity
2366  * @brief Per-level flag for projecting the initial velocity.
2367  * @var SolverChoice::buoyancy_type
2368  * @brief Per-level buoyancy formulation selector.
2369  * @var SolverChoice::is_land
2370  * @brief Per-level land/water selector.
2371  * @var SolverChoice::substepping_diag
2372  * @brief Whether to emit extra CFL diagnostics for compressible substepping.
2373  * @var SolverChoice::beta_s
2374  * @brief Time off-centering coefficient for forward weighting.
2375  * @var SolverChoice::vert_implicit_fac
2376  * @brief Per-level, per-stage implicit vertical diffusion factors.
2377  * @var SolverChoice::implicit_thermal_diffusion
2378  * @brief Whether implicit vertical thermal diffusion is included.
2379  * @var SolverChoice::implicit_moisture_diffusion
2380  * @brief Whether implicit vertical moisture diffusion is included.
2381  * @var SolverChoice::implicit_ke_diffusion
2382  * @brief Whether implicit vertical TKE diffusion is included.
2383  * @var SolverChoice::implicit_momentum_diffusion
2384  * @brief Whether implicit vertical momentum diffusion is included.
2385  * @var SolverChoice::implicit_before_substep
2386  * @brief Whether implicit diffusion is applied before acoustic substepping.
2387  * @var SolverChoice::ncorr
2388  * @brief Number of projection correction iterations.
2389  * @var SolverChoice::poisson_abstol
2390  * @brief Absolute tolerance for the Poisson solve.
2391  * @var SolverChoice::poisson_reltol
2392  * @brief Relative tolerance for the Poisson solve.
2393  * @var SolverChoice::test_mapfactor
2394  * @brief Whether to use test map scale factors.
2395  * @var SolverChoice::gradp_type
2396  * @brief Terrain-fitted horizontal pressure-gradient formulation.
2397  * @var SolverChoice::use_pert_pres_gradient
2398  * @brief Whether momentum equations use perturbational pressure gradients.
2399  * @var SolverChoice::use_gravity
2400  * @brief Whether gravitational forcing is enabled.
2401  * @var SolverChoice::use_coriolis
2402  * @brief Whether Coriolis forcing is enabled.
2403  * @var SolverChoice::coriolis_3d
2404  * @brief Whether the three-dimensional Coriolis terms are included.
2405  * @var SolverChoice::four_stream_radiation
2406  * @brief Whether the four-stream radiation approximation is enabled.
2407  * @var SolverChoice::immersed_forcing_substep
2408  * @brief Whether immersed-forcing source terms are applied only during substeps.
2409  * @var SolverChoice::forest_substep
2410  * @brief Whether canopy source terms are applied only during substeps.
2411  * @var SolverChoice::if_Cd_momentum
2412  * @brief Immersed-forcing drag coefficient for momentum.
2413  * @var SolverChoice::if_Cd_scalar
2414  * @brief Immersed-forcing drag coefficient for scalars.
2415  * @var SolverChoice::if_z0
2416  * @brief Immersed-forcing roughness length [m].
2417  * @var SolverChoice::if_surf_temp_flux
2418  * @brief Immersed-forcing surface temperature flux [K m/s].
2419  * @var SolverChoice::if_init_surf_temp
2420  * @brief Initial immersed-forcing surface temperature [K].
2421  * @var SolverChoice::if_surf_heating_rate
2422  * @brief Immersed-forcing surface heating rate [K/hr].
2423  * @var SolverChoice::if_Olen_in
2424  * @brief Input Obukhov length for immersed-forcing MOST [m].
2425  * @var SolverChoice::if_use_most
2426  * @brief Whether immersed-forcing MOST is enabled.
2427  * @var SolverChoice::if_snap_partial_cells
2428  * When true, the immersed forcing reads the blanking snapped to solid (1) or
2429  * fluid (0) at half, so a building from a height map becomes the same
2430  * staircase of whole cells an exact box is: the wall law (and the thermal
2431  * conditions) sit on the boundary solid cells, roofs included, the drag on
2432  * the interior cells, and nothing on the sliver cells of the reader's
2433  * one-cell ramp (1-20 percent solid at the corners), on which the raw
2434  * fractions make the wall law and the drag disagree and grow a vertical
2435  * checkerboard over hours. The staircase puts full-strength forcing on every
2436  * wall face, so the switch also selects the point-implicit drag form
2437  * (if_implicit_drag), without which the explicit rate at rims and corners
2438  * drives the density negative within seconds. The momentum kernels take the
2439  * blanking of a face from the two cells it joins (solid if either is), so
2440  * the staircase is the same with and without the face-centred blanking of
2441  * the build; a face between a solid and a fluid cell is wall-normal and gets
2442  * the interior drag toward zero (no penetration) whichever row it lies in,
2443  * and a face between two solid cells the roof or wall law of its row (with
2444  * the full log-law target; the partial-cell weight of the target is not
2445  * applied) or the interior drag. Buildings only (erf.buildings_type = ImmersedForcing): the
2446  * terrain kernels keep the raw fractions, whose wall law is weighted by the
2447  * fluid fraction of the face. Default false, the raw fractions, for backward
2448  * compatibility (on an exact box a boundary cell then carries the wall law
2449  * and the interior drag together, and the roof only the drag); set it for
2450  * height-map buildings.
2451  * @var SolverChoice::if_stability_correction
2452  * @brief Whether immersed-forcing stability corrections are enabled.
2453  * @var SolverChoice::if_ws_floor
2454  * @brief Wind-speed floor for immersed-forcing MOST [m/s].
2455  * @var SolverChoice::if_damp_alpha
2456  * @brief Immersed-forcing damping coefficient.
2457  * @var SolverChoice::use_lagged_delta_rt
2458  * @brief Whether to use lagged delta terms for moving terrain.
2459  * @var SolverChoice::rebalance_wrf_input
2460  * @brief Whether to rebalance states from wrfinput and wrfbdy data.
2461  * @var SolverChoice::gravity
2462  * @brief Effective gravitational acceleration.
2463  * @var SolverChoice::c_p
2464  * @brief Specific heat at constant pressure for dry air [J/(kg-K)].
2465  * @var SolverChoice::rdOcp
2466  * @brief Ratio of dry-air gas constant to c_p.
2467  * @var SolverChoice::grid_stretching_ratio
2468  * @brief Vertical grid stretching ratio.
2469  * @var SolverChoice::zsurf
2470  * @brief Nominal surface height for stretched-grid setup.
2471  * @var SolverChoice::dz0
2472  * @brief Initial vertical grid spacing for stretched-grid setup.
2473  * @var SolverChoice::coriolis_factor
2474  * @brief Twice the planetary rotation rate used for Coriolis forcing.
2475  * @var SolverChoice::cosphi
2476  * @brief Cosine of the latitude used for Coriolis forcing.
2477  * @var SolverChoice::sinphi
2478  * @brief Sine of the latitude used for Coriolis forcing.
2479  * @var SolverChoice::custom_rhotheta_forcing
2480  * @brief Whether custom rho-theta forcing is enabled.
2481  * @var SolverChoice::custom_moisture_forcing
2482  * @brief Whether custom moisture forcing is enabled.
2483  * @var SolverChoice::custom_w_subsidence
2484  * @brief Whether custom vertical subsidence is enabled.
2485  * @var SolverChoice::do_theta_advection
2486  * @brief Whether custom vertical subsidence is applied to rho-theta.
2487  * @var SolverChoice::do_mom_advection
2488  * @brief Whether custom vertical subsidence is applied to momentum.
2489  * @var SolverChoice::custom_geostrophic_profile
2490  * @brief Whether a custom geostrophic wind profile is used.
2491  * @var SolverChoice::custom_forcing_prim_vars
2492  * @brief Whether custom forcing operates on primitive variables.
2493  * @var SolverChoice::spatial_rhotheta_forcing
2494  * @brief Whether spatially varying rho-theta forcing is enabled.
2495  * @var SolverChoice::spatial_moisture_forcing
2496  * @brief Whether spatially varying moisture forcing is enabled.
2497  * @var SolverChoice::nudging_from_input_sounding
2498  * @brief Whether solution fields are nudged toward input sounding data.
2499  * @var SolverChoice::use_rotate_surface_flux
2500  * @brief Whether MOST surface fluxes are rotated with terrain.
2501  * @var SolverChoice::use_eamxx_shoc
2502  * @brief Whether any level uses the EAMxx SHOC PBL scheme.
2503  * @var SolverChoice::use_native_shoc
2504  * @brief Whether any level uses the native SHOC PBL scheme.
2505  * @var SolverChoice::transport_scalar
2506  * @brief Whether the passive scalar component is transported.
2507  * @var SolverChoice::time_avg_vel
2508  * @brief Whether time-averaged velocity fields are output.
2509  * @var SolverChoice::pert_type
2510  * @brief Turbulent perturbation type for each AMR level.
2511  * @var SolverChoice::use_num_diff
2512  * @brief Whether sixth-order numerical diffusion is enabled.
2513  * @var SolverChoice::num_diff_coeff
2514  * @brief Numerical diffusion coefficient after input scaling.
2515  * @var SolverChoice::coupling_type
2516  * @brief Multilevel coupling strategy.
2517  * @var SolverChoice::moisture_type
2518  * @brief Moisture or microphysics model.
2519  * @var SolverChoice::windfarm_type
2520  * @brief Wind-farm model.
2521  * @var SolverChoice::windfarm_loc_type
2522  * @brief Coordinate system for wind-farm turbine locations.
2523  * @var SolverChoice::lsm_type
2524  * @brief Land-surface model.
2525  * @var SolverChoice::rad_type
2526  * @brief Radiation model.
2527  * @var SolverChoice::abl_driver_type
2528  * @brief Atmospheric boundary-layer driver type.
2529  * @var SolverChoice::abl_pressure_grad
2530  * @brief Applied ABL pressure-gradient forcing vector.
2531  * @var SolverChoice::abl_geo_forcing
2532  * @brief Applied geostrophic-wind forcing vector.
2533  * @var SolverChoice::abl_geo_wind_table
2534  * @brief Path to a time-varying geostrophic wind table.
2535  * @var SolverChoice::have_geo_wind_profile
2536  * @brief Whether a geostrophic wind profile has been configured.
2537  * @var SolverChoice::variable_coriolis
2538  * @brief Whether spatially varying Coriolis forcing is enabled.
2539  * @var SolverChoice::ave_plane
2540  * @brief Averaging plane index used by diagnostics.
2541  * @var SolverChoice::moisture_indices
2542  * @brief Index map of the moisture data carried by the active scheme: conserved-state
2543  * components for the species and qmoist slots for the moist diagnostics.
2544  * @var SolverChoice::moisture_tight_coupling
2545  * @brief Whether moisture updates use tight coupling.
2546  * @var SolverChoice::windfarm_loc_table
2547  * @brief Wind-farm location table path.
2548  * @var SolverChoice::windfarm_spec_table
2549  * @brief Wind-farm turbine specification table path.
2550  * @var SolverChoice::windfarm_spec_table_extra
2551  * @brief Additional wind-farm turbine specification table path.
2552  * @var SolverChoice::windfarm_blade_table
2553  * @brief Wind-farm blade table path.
2554  * @var SolverChoice::windfarm_airfoil_tables
2555  * @brief Wind-farm airfoil table paths.
2556  * @var SolverChoice::sampling_distance_by_D
2557  * @brief Turbine inflow sampling distance normalized by rotor diameter.
2558  * @var SolverChoice::turb_disk_angle
2559  * @brief Turbine disk angle from the x axis [deg].
2560  * @var SolverChoice::windfarm_x_shift
2561  * @brief Wind-farm x-coordinate shift.
2562  * @var SolverChoice::windfarm_y_shift
2563  * @brief Wind-farm y-coordinate shift.
2564  * @var SolverChoice::bdy_nudge_factor
2565  * @brief Boundary sponge nudging factor.
2566  * @var SolverChoice::use_wrf_bdy_qc_qi
2567  * @brief Whether WRF cloud water and active cloud ice are ingested at real boundaries.
2568  * @var SolverChoice::bdy_moist_nudge_type
2569  * @brief Moist-variable nudging strategy in boundary regions.
2570  * @var SolverChoice::do_forest_drag
2571  * @brief Whether forest canopy drag is enabled.
2572  * @var SolverChoice::const_massflux_u
2573  * @brief Target constant mass flux in the x direction.
2574  * @var SolverChoice::const_massflux_v
2575  * @brief Target constant mass flux in the y direction.
2576  * @var SolverChoice::const_massflux_tau
2577  * @brief Relaxation time scale for constant-mass-flux forcing.
2578  * @var SolverChoice::const_massflux_layer_lo
2579  * @brief Lower height of the constant-mass-flux forcing layer.
2580  * @var SolverChoice::const_massflux_layer_hi
2581  * @brief Upper height of the constant-mass-flux forcing layer.
2582  * @var SolverChoice::massflux_klo
2583  * @brief Lower vertical index for constant-mass-flux forcing.
2584  * @var SolverChoice::massflux_khi
2585  * @brief Upper vertical index for constant-mass-flux forcing.
2586  * @var SolverChoice::hindcast_boundary_data_dir
2587  * @brief Directory containing hindcast lateral boundary data.
2588  * @var SolverChoice::hindcast_surface_data_dir
2589  * @brief Directory containing hindcast surface boundary data.
2590  * @var SolverChoice::hindcast_data_interval_in_hrs
2591  * @brief Time interval between hindcast data files [hr].
2592  * @var SolverChoice::hindcast_lateral_forcing
2593  * @brief Whether hindcast lateral forcing is enabled.
2594  * @var SolverChoice::hindcast_surface_bcs
2595  * @brief Whether hindcast surface boundary conditions are enabled.
2596  * @var SolverChoice::hindcast_lateral_sponge_strength
2597  * @brief Strength of the hindcast lateral sponge layer.
2598  * @var SolverChoice::hindcast_lateral_sponge_length
2599  * @brief Length of the hindcast lateral sponge layer.
2600  * @var SolverChoice::hindcast_zhi_sponge_strength
2601  * @brief Strength of the upper hindcast sponge layer.
2602  * @var SolverChoice::hindcast_zhi_sponge_length
2603  * @brief Length of the upper hindcast sponge layer.
2604  * @var SolverChoice::hindcast_zhi_sponge_damping
2605  * @brief Whether upper-boundary hindcast sponge damping is enabled.
2606  * @var SolverChoice::io_hurricane_eye_tracker
2607  * @brief Whether hurricane-eye tracking output is enabled.
2608  * @var SolverChoice::hurricane_eye_latitude
2609  * @brief Initial hurricane-eye latitude.
2610  * @var SolverChoice::hurricane_eye_longitude
2611  * @brief Initial hurricane-eye longitude.
2612  * @var SolverChoice::is_init_for_ensemble
2613  * @brief Whether initialization is for an ensemble simulation.
2614  * @var SolverChoice::n_ensemble
2615  * @brief Number of ensemble members.
2616  * @var SolverChoice::ens_pert_correlated_radius
2617  * @brief Spatial correlation radius for ensemble perturbations.
2618  * @var SolverChoice::ens_pert_amplitude
2619  * @brief Amplitude of ensemble initialization perturbations.
2620  * @var SolverChoice::coarse_bckgnd_data_file
2621  * @brief Coarse background data file used for ensemble initialization.
2622  */
2623 #endif
constexpr amrex::Real Cp_d
Definition: ERF_Constants.H:36
constexpr amrex::Real bogus_large_value
Definition: ERF_Constants.H:17
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:56
constexpr amrex::Real R_d
Definition: ERF_Constants.H:34
static const std::string BoundaryFaceName[]
Definition: ERF_DataStruct.H:190
TauType
Stress tensor component indices.
Definition: ERF_DataStruct.H:39
@ tau12
Definition: ERF_DataStruct.H:40
@ tau23
Definition: ERF_DataStruct.H:40
@ tau33
Definition: ERF_DataStruct.H:40
@ tau22
Definition: ERF_DataStruct.H:40
@ tau11
Definition: ERF_DataStruct.H:40
@ tau32
Definition: ERF_DataStruct.H:40
@ tau31
Definition: ERF_DataStruct.H:40
@ tau21
Definition: ERF_DataStruct.H:40
@ tau13
Definition: ERF_DataStruct.H:40
bool anelastic_superdroplets_configuration_invalid(const MoistureType moisture_type, const bool any_anelastic) noexcept
Whether an anelastic SuperDroplets configuration is unsupported.
Definition: ERF_DataStruct.H:132
AMREX_ENUM(InitType, None, Input_Sounding, NCFile, WRFInput, Metgrid, Uniform, ConstantDensity, ConstantDensityLinearTheta, Isentropic, MoistBaseState, HindCast)
Initial-condition source used to populate the ERF state.
Rayleigh
Rayleigh damping profile component indices.
Definition: ERF_DataStruct.H:178
@ ubar
Definition: ERF_DataStruct.H:179
@ wbar
Definition: ERF_DataStruct.H:179
@ nvars
Definition: ERF_DataStruct.H:179
@ vbar
Definition: ERF_DataStruct.H:179
@ thetabar
Definition: ERF_DataStruct.H:179
Sponge
Sponge reference-state component indices.
Definition: ERF_DataStruct.H:186
@ nvars_sponge
Definition: ERF_DataStruct.H:187
@ vbar_sponge
Definition: ERF_DataStruct.H:187
@ ubar_sponge
Definition: ERF_DataStruct.H:187
MapFacType
Indices for map scale factors on mass and face grids.
Definition: ERF_DataStruct.H:27
@ v_x
Definition: ERF_DataStruct.H:29
@ num
Definition: ERF_DataStruct.H:29
@ u_y
Definition: ERF_DataStruct.H:30
@ v_y
Definition: ERF_DataStruct.H:30
@ m_y
Definition: ERF_DataStruct.H:30
@ u_x
Definition: ERF_DataStruct.H:29
@ m_x
Definition: ERF_DataStruct.H:29
Coord
Coordinate-axis selector.
Definition: ERF_DataStruct.H:170
#define RhoQ4_comp
Definition: ERF_IndexDefines.H:48
#define RhoQ2_comp
Definition: ERF_IndexDefines.H:46
#define RhoQ3_comp
Definition: ERF_IndexDefines.H:47
#define RhoQ11_comp
Definition: ERF_IndexDefines.H:55
#define RhoQ9_comp
Definition: ERF_IndexDefines.H:53
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:45
#define RhoQ6_comp
Definition: ERF_IndexDefines.H:50
#define RhoQ8_comp
Definition: ERF_IndexDefines.H:52
#define RhoQ5_comp
Definition: ERF_IndexDefines.H:49
#define RhoQ7_comp
Definition: ERF_IndexDefines.H:51
#define RhoQ10_comp
Definition: ERF_IndexDefines.H:54
ParmParse pp("prob")
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_cloud_chamber_config.active, "Cloud Chamber: initializer reached without a parsed configuration")
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:31
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:30
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:29
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:39
std::string name
Definition: ERF_Plotfile2DCatalog.cpp:101
Radiation model type and control parameters.
amrex::Real Real
Definition: ERF_ShocInterface.H:19
ShocMomentumTransport
Definition: ERF_ShocTransportStruct.H:16
bool shoc_disables_momentum_transport(ShocMomentumTransport mode)
Definition: ERF_ShocTransportStruct.H:47
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:118
ShocTransportMode
Definition: ERF_ShocTransportStruct.H:11
int query_one_or_per_level_enum_case_insensitive(const amrex::ParmParse &pp, const char *query_string, T &query_var, const int lev, const int maxlev)
Query a scalar or per-level enum input value using case-insensitive matching.
Definition: ERF_TurbStruct.H:81
AMREX_ASSERT_WITH_MESSAGE(wbar_cutoff_min > wbar_cutoff_max, "ERROR: wbar_cutoff_min < wbar_cutoff_max")
Definition: ERF_EWP.H:9
Definition: ERF_Fitch.H:9
Definition: ERF_GeneralAD.H:8
Definition: ERF_Kessler.H:78
Definition: ERF_MoistNoCondensation.H:13
Definition: ERF_Morrison.H:105
Definition: ERF_NOAHMP.H:57
Definition: ERF_SAM.H:56
Definition: ERF_SLM.H:25
Definition: ERF_SatAdj.H:47
Definition: ERF_SimpleAD.H:8
Definition: ERF_WDM6.H:108
Definition: ERF_WSM6.H:121
Definition: ERF_AdvStruct.H:19
void display(std::string &pp_prefix)
Print the configured advection choices.
Definition: ERF_AdvStruct.H:243
void init_params(std::string pp_prefix)
Read advection options from the input parameter database.
Definition: ERF_AdvStruct.H:25
Definition: ERF_DampingStruct.H:22
void init_params(std::string pp_prefix)
Read damping options from the input parameter database.
Definition: ERF_DampingStruct.H:28
void display()
Print the configured damping options.
Definition: ERF_DampingStruct.H:71
Definition: ERF_DiffStruct.H:22
MolecDiffType molec_diff_type
Selected molecular transport model.
Definition: ERF_DiffStruct.H:94
void init_params(std::string pp_prefix)
Read diffusion options from the input parameter database.
Definition: ERF_DiffStruct.H:28
void display()
Print the configured diffusion options.
Definition: ERF_DiffStruct.H:77
Definition: ERF_EBStruct.H:36
void init_params(std::string pp_prefix)
Read embedded-boundary options from the input parameter database.
Definition: ERF_EBStruct.H:42
void display()
Print the configured embedded-boundary options.
Definition: ERF_EBStruct.H:63
An ordered list of conserved-state components forming an aggregate moisture output variable (qt,...
Definition: ERF_DataStruct.H:463
int comp[max_size]
Definition: ERF_DataStruct.H:465
int size
Definition: ERF_DataStruct.H:466
bool empty() const
Definition: ERF_DataStruct.H:472
void append(int c)
Append a component, ignoring the ones the scheme does not carry.
Definition: ERF_DataStruct.H:469
static constexpr int max_size
qv, qc, qi, qr, qs, qg
Definition: ERF_DataStruct.H:464
Whether this map decides a variable's availability, and if so whether the variable is available.
Definition: ERF_DataStruct.H:591
bool available
the active scheme carries the data behind it
Definition: ERF_DataStruct.H:593
bool governed
the name is a moisture output variable
Definition: ERF_DataStruct.H:592
The moisture data carried by the active microphysics scheme.
Definition: ERF_DataStruct.H:223
int nc
cloud liquid water number
Definition: ERF_DataStruct.H:244
int qs
snow
Definition: ERF_DataStruct.H:238
int cond_rate
condensation rate
Definition: ERF_DataStruct.H:267
int comp_for_var(const std::string &name) const
The conserved-state component behind a single-species output name, or absent if the name is not a sin...
Definition: ERF_DataStruct.H:553
int nn
CCN / total aerosol number.
Definition: ERF_DataStruct.H:254
int qr
rain
Definition: ERF_DataStruct.H:237
static constexpr int absent
not carried by the active scheme
Definition: ERF_DataStruct.H:226
int graup_accum
accumulated surface graupel
Definition: ERF_DataStruct.H:265
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:515
MoistureComponentIndices()=default
Construct an empty map, i.e. a dry run.
int qi
cloud ice
Definition: ERF_DataStruct.H:236
int rel_hum
relative humidity
Definition: ERF_DataStruct.H:266
static constexpr int computed_from_state
Definition: ERF_DataStruct.H:227
int ni
cloud ice number
Definition: ERF_DataStruct.H:245
int qv
water vapor
Definition: ERF_DataStruct.H:234
int rain_accum
accumulated surface rain
Definition: ERF_DataStruct.H:263
CompList nonprecipitating_comps() const
Components summed for non-precipitating water, "qn": vapor plus the suspended condensate....
Definition: ERF_DataStruct.H:491
bool has_reflectivity_species() const
Test whether the active scheme carries rain, snow and graupel in the RhoQ4/RhoQ5/RhoQ6 slots assumed ...
Definition: ERF_DataStruct.H:531
int snow_accum
accumulated surface snow
Definition: ERF_DataStruct.H:264
CompList total_water_comps() const
Components summed for total water, "qt": every mass mixing ratio.
Definition: ERF_DataStruct.H:480
int nr
rain number
Definition: ERF_DataStruct.H:246
int qc
cloud liquid water
Definition: ERF_DataStruct.H:235
int ng
graupel number
Definition: ERF_DataStruct.H:248
CompList precipitating_comps() const
Components summed for precipitating water, "qp": the falling species.
Definition: ERF_DataStruct.H:500
int qg
graupel
Definition: ERF_DataStruct.H:239
bool has_moisture() const
Test whether the active scheme carries any moisture at all.
Definition: ERF_DataStruct.H:541
int ns
snow number
Definition: ERF_DataStruct.H:247
VarAvailability query_var(const std::string &name) const
Classify an output variable name against this index map.
Definition: ERF_DataStruct.H:607
bool has_derived_var(const std::string &name) const
Test whether the moist species behind a derived/plot variable name is carried by the active scheme.
Definition: ERF_DataStruct.H:652
static MoistureComponentIndices from_moisture_model(const MoistureType moisture_type)
Build the complete index map – conserved-state components and qmoist diagnostic slots – for a moistur...
Definition: ERF_DataStruct.H:323
MoistureComponentIndices(int qv_comp, int qc_comp, int qi_comp=absent, int qr_comp=absent, int qs_comp=absent, int qg_comp=absent, int nc_comp=absent, int ni_comp=absent, int nr_comp=absent, int ns_comp=absent, int ng_comp=absent, int nn_comp=absent)
Construct the conserved-state component map.
Definition: ERF_DataStruct.H:289
int qmoist_index_for_var(const std::string &name) const
The qmoist slot behind a moist diagnostic output name.
Definition: ERF_DataStruct.H:578
Container holding radiation-related choices and parameters.
Definition: ERF_RadStruct.H:70
void init_params(bool two_stream_selected, int max_level, std::string pp_prefix)
Definition: ERF_RadStruct.H:727
Definition: ERF_DataStruct.H:662
bool use_coupled_sst
Definition: ERF_DataStruct.H:2250
bool custom_geostrophic_profile
Whether a custom geostrophic wind profile is used.
Definition: ERF_DataStruct.H:2080
int n_ensemble
Number of ensemble members.
Definition: ERF_DataStruct.H:2324
WindFarmLocType windfarm_loc_type
Coordinate system for wind-farm turbine locations.
Definition: ERF_DataStruct.H:2239
bool implicit_before_substep
Whether implicit diffusion is applied before acoustic substepping.
Definition: ERF_DataStruct.H:2006
amrex::Real const_massflux_v
Target constant mass flux in the y direction.
Definition: ERF_DataStruct.H:2305
std::string hindcast_boundary_data_dir
Directory containing hindcast lateral boundary data.
Definition: ERF_DataStruct.H:2312
amrex::Real ens_pert_correlated_radius
Spatial correlation radius for ensemble perturbations.
Definition: ERF_DataStruct.H:2325
amrex::Real forest_leaf_theta_fixed
Definition: ERF_DataStruct.H:2301
static InitType init_type
Initial-condition source selected for the run.
Definition: ERF_DataStruct.H:1943
amrex::Real coriolis_factor
Twice the planetary rotation rate used for Coriolis forcing.
Definition: ERF_DataStruct.H:2070
bool io_hurricane_eye_tracker
Whether hurricane-eye tracking output is enabled.
Definition: ERF_DataStruct.H:2320
std::string abl_geo_wind_table
Path to a time-varying geostrophic wind table.
Definition: ERF_DataStruct.H:2255
amrex::Vector< int > fixed_density
Per-level flag selecting fixed-density treatment.
Definition: ERF_DataStruct.H:1983
amrex::Vector< TurbChoice > turbChoice
Turbulence options for each AMR level.
Definition: ERF_DataStruct.H:1974
amrex::Real const_massflux_layer_lo
Lower height of the constant-mass-flux forcing layer.
Definition: ERF_DataStruct.H:2307
amrex::Real hindcast_zhi_sponge_length
Length of the upper hindcast sponge layer.
Definition: ERF_DataStruct.H:2317
amrex::Real gravity
Effective gravitational acceleration.
Definition: ERF_DataStruct.H:2060
void check_params(int max_level, const amrex::Vector< amrex::Geometry > &geom_vect, amrex::GpuArray< ERF_BC, AMREX_SPACEDIM *2 > phys_bc_type)
Validate solver options after geometry and boundary conditions are known.
Definition: ERF_DataStruct.H:1602
bool pbl_suppresses_microphysics_condensation() const noexcept
Query whether the active PBL scheme suppresses microphysics condensation.
Definition: ERF_DataStruct.H:2208
bool variable_coriolis
Whether spatially varying Coriolis forcing is enabled.
Definition: ERF_DataStruct.H:2258
bool implicit_moisture_diffusion
Whether implicit vertical moisture diffusion is included.
Definition: ERF_DataStruct.H:2003
MoistureType moisture_type
Moisture or microphysics model.
Definition: ERF_DataStruct.H:2237
void display(int max_level, std::string pp_prefix)
Print the configured solver, physics, and transport options.
Definition: ERF_DataStruct.H:1717
amrex::Real poisson_abstol
Absolute tolerance for the Poisson solve.
Definition: ERF_DataStruct.H:2014
amrex::Real if_Cd_momentum
Immersed-forcing drag coefficient for momentum.
Definition: ERF_DataStruct.H:2036
bool nudging_t
Definition: ERF_DataStruct.H:2097
amrex::Real if_Olen_in
Input Obukhov length for immersed-forcing MOST [m].
Definition: ERF_DataStruct.H:2046
amrex::Vector< int > buoyancy_type
Per-level buoyancy formulation selector.
Definition: ERF_DataStruct.H:1985
bool forest_biophysics
Definition: ERF_DataStruct.H:2299
void build_coriolis_forcings_const_lat(std::string pp_prefix)
Build constant-latitude Coriolis forcing parameters.
Definition: ERF_DataStruct.H:1870
CouplingType coupling_type
Multilevel coupling strategy.
Definition: ERF_DataStruct.H:2236
bool use_pert_pres_gradient
Whether momentum equations use perturbational pressure gradients.
Definition: ERF_DataStruct.H:2022
amrex::Vector< int > project_initial_velocity
Per-level flag for projecting the initial velocity.
Definition: ERF_DataStruct.H:1984
int ave_plane
Averaging plane index used by diagnostics.
Definition: ERF_DataStruct.H:2260
amrex::Real const_massflux_u
Target constant mass flux in the x direction.
Definition: ERF_DataStruct.H:2304
void read_int_string(int max_level, const char *string_to_read, amrex::Vector< int > &vec_to_fill, int default_int)
Read one integer value or one value per AMR level.
Definition: ERF_DataStruct.H:1920
bool nudging_q
Definition: ERF_DataStruct.H:2098
int ncorr
Number of projection correction iterations.
Definition: ERF_DataStruct.H:2008
amrex::Real sampling_distance_by_D
Turbine inflow sampling distance normalized by rotor diameter.
Definition: ERF_DataStruct.H:2269
amrex::Real windfarm_y_shift
Wind-farm y-coordinate shift.
Definition: ERF_DataStruct.H:2272
bool use_rotate_surface_flux
Whether MOST surface fluxes are rotated with terrain.
Definition: ERF_DataStruct.H:2105
bool moisture_tight_coupling
Whether moisture updates use tight coupling.
Definition: ERF_DataStruct.H:2265
EBChoice ebChoice
Embedded-boundary options.
Definition: ERF_DataStruct.H:1975
bool compute_mean_vars
Definition: ERF_DataStruct.H:2122
amrex::Real beta_s
Time off-centering coefficient for forward weighting.
Definition: ERF_DataStruct.H:1993
bool implicit_ke_diffusion
Whether implicit vertical TKE diffusion is included.
Definition: ERF_DataStruct.H:2004
bool interp_atmos_from_coarse
Definition: ERF_DataStruct.H:2293
bool any_perturbation() const
Query whether any level uses a turbulent perturbation mode.
Definition: ERF_DataStruct.H:2217
amrex::Real if_z0
Immersed-forcing roughness length [m].
Definition: ERF_DataStruct.H:2042
bool forest_substep
Whether canopy source terms are applied only during substeps.
Definition: ERF_DataStruct.H:2033
bool use_wrf_bdy_density
Definition: ERF_DataStruct.H:2278
bool implicit_thermal_diffusion
Whether implicit vertical thermal diffusion is included.
Definition: ERF_DataStruct.H:2002
std::string mean_vars_reset_mode
Definition: ERF_DataStruct.H:2125
bool use_gravity
Whether gravitational forcing is enabled.
Definition: ERF_DataStruct.H:2025
amrex::Real num_diff_coeff
Numerical diffusion coefficient after input scaling.
Definition: ERF_DataStruct.H:2234
amrex::Real bdy_nudge_factor
Boundary sponge nudging factor.
Definition: ERF_DataStruct.H:2275
amrex::Real rdOcp
Ratio of dry-air gas constant to c_p.
Definition: ERF_DataStruct.H:2062
bool use_wvel_perturbation(int lev) const
Query whether vertical-velocity CPM perturbations are enabled on a level.
Definition: ERF_DataStruct.H:2168
bool hindcast_lateral_forcing
Whether hindcast lateral forcing is enabled.
Definition: ERF_DataStruct.H:2314
bool do_theta_advection
Whether custom vertical subsidence is applied to rho-theta.
Definition: ERF_DataStruct.H:2078
bool use_native_shoc
Whether any level uses the native SHOC PBL scheme.
Definition: ERF_DataStruct.H:2109
amrex::Real nudging_q_z2
Definition: ERF_DataStruct.H:2094
static bool use_real_bcs
Whether real-data lateral boundary conditions are used.
Definition: ERF_DataStruct.H:1955
bool spatial_moisture_forcing
Whether spatially varying moisture forcing is enabled.
Definition: ERF_DataStruct.H:2083
amrex::Vector< SubsteppingType > substepping_type
Acoustic substepping type for each AMR level.
Definition: ERF_DataStruct.H:1980
amrex::Real nudging_u_z2
Definition: ERF_DataStruct.H:2090
bool use_perturbation(int lev) const
Query whether any turbulent perturbation mode is enabled on a level.
Definition: ERF_DataStruct.H:2133
static SoundingType sounding_type
Interpretation used for input sounding profiles.
Definition: ERF_DataStruct.H:1946
int bdy_moist_nudge_type
Moist-variable nudging strategy in boundary regions.
Definition: ERF_DataStruct.H:2287
amrex::Real poisson_reltol
Relative tolerance for the Poisson solve.
Definition: ERF_DataStruct.H:2015
bool use_coriolis
Whether Coriolis forcing is enabled.
Definition: ERF_DataStruct.H:2026
amrex::Vector< PerturbationType > pert_type
Turbulent perturbation type for each AMR level.
Definition: ERF_DataStruct.H:2230
static MeshType mesh_type
Vertical mesh representation.
Definition: ERF_DataStruct.H:1958
AdvChoice advChoice
Advection-related options.
Definition: ERF_DataStruct.H:1970
SpongeChoice spongeChoice
Sponge-layer options.
Definition: ERF_DataStruct.H:1973
void init_params(int max_level, std::string pp_prefix)
Read solver-wide algorithmic options from the input parameter database.
Definition: ERF_DataStruct.H:669
bool time_avg_vel
Whether time-averaged velocity fields are output.
Definition: ERF_DataStruct.H:2119
bool use_direct_perturbation(int lev) const
Query whether direct turbulent perturbations are enabled on a level.
Definition: ERF_DataStruct.H:2146
bool have_geo_wind_profile
Whether a geostrophic wind profile has been configured.
Definition: ERF_DataStruct.H:2256
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_pressure_grad
Applied ABL pressure-gradient forcing vector.
Definition: ERF_DataStruct.H:2253
RadChoice radChoice
Definition: ERF_DataStruct.H:1976
amrex::Vector< int > anelastic
Per-level flag selecting anelastic dynamics.
Definition: ERF_DataStruct.H:1981
bool four_stream_radiation
Whether the four-stream radiation approximation is enabled.
Definition: ERF_DataStruct.H:2029
int gradp_type
Terrain-fitted horizontal pressure-gradient formulation.
Definition: ERF_DataStruct.H:2020
DampingChoice dampingChoice
Damping-related options.
Definition: ERF_DataStruct.H:1972
amrex::Real if_damp_alpha
Immersed-forcing damping coefficient.
Definition: ERF_DataStruct.H:2051
bool rebalance_wrf_input
Whether to rebalance states from wrfinput and wrfbdy data.
Definition: ERF_DataStruct.H:2057
amrex::Real turb_disk_angle
Turbine disk angle from the x axis [deg].
Definition: ERF_DataStruct.H:2270
amrex::Real hindcast_data_interval_in_hrs
Time interval between hindcast data files [hr].
Definition: ERF_DataStruct.H:2313
amrex::Real const_massflux_layer_hi
Upper height of the constant-mass-flux forcing layer.
Definition: ERF_DataStruct.H:2308
std::string wall_dist_type
Definition: ERF_DataStruct.H:2009
bool avg_grid_faces_to_nodes
Definition: ERF_DataStruct.H:2290
std::string windfarm_spec_table_extra
Additional wind-farm turbine specification table path.
Definition: ERF_DataStruct.H:2267
amrex::Real if_ws_floor
Wind-speed floor for immersed-forcing MOST [m/s].
Definition: ERF_DataStruct.H:2050
amrex::Real lsf_timescale
Definition: ERF_DataStruct.H:2102
bool is_init_for_ensemble
Whether initialization is for an ensemble simulation.
Definition: ERF_DataStruct.H:2323
bool uses_shoc_family() const noexcept
Query whether any SHOC-family PBL scheme is active.
Definition: ERF_DataStruct.H:2177
bool test_mapfactor
Whether to use test map scale factors.
Definition: ERF_DataStruct.H:2018
amrex::Real nudging_u_z1
Definition: ERF_DataStruct.H:2089
bool if_snap_partial_cells
Definition: ERF_DataStruct.H:2048
std::string coarse_bckgnd_data_file
Coarse background data file used for ensemble initialization.
Definition: ERF_DataStruct.H:2327
bool do_forest_drag
Whether forest canopy drag is enabled.
Definition: ERF_DataStruct.H:2296
amrex::Real dz0
Initial vertical grid spacing for stretched-grid setup.
Definition: ERF_DataStruct.H:2067
amrex::Real windfarm_x_shift
Wind-farm x-coordinate shift.
Definition: ERF_DataStruct.H:2271
bool use_lagged_delta_rt
Whether to use lagged delta terms for moving terrain.
Definition: ERF_DataStruct.H:2054
amrex::Real ens_pert_amplitude
Amplitude of ensemble initialization perturbations.
Definition: ERF_DataStruct.H:2326
std::string windfarm_airfoil_tables
Wind-farm airfoil table paths.
Definition: ERF_DataStruct.H:2268
amrex::Vector< AnelasticType > anelastic_type
Per-level two-stage scheme used by the anelastic integrator.
Definition: ERF_DataStruct.H:1982
amrex::Real bdy_rho_nudge_factor
Definition: ERF_DataStruct.H:2284
amrex::Real nudging_q_z1
Definition: ERF_DataStruct.H:2093
amrex::Vector< amrex::Vector< amrex::Real > > vert_implicit_fac
Per-level, per-stage implicit vertical diffusion factors.
Definition: ERF_DataStruct.H:1999
bool transport_scalar
Whether the passive scalar component is transported.
Definition: ERF_DataStruct.H:2116
bool hindcast_zhi_sponge_damping
Whether upper-boundary hindcast sponge damping is enabled.
Definition: ERF_DataStruct.H:2318
amrex::Real hurricane_eye_longitude
Initial hurricane-eye longitude.
Definition: ERF_DataStruct.H:2321
LandSurfaceType lsm_type
Land-surface model.
Definition: ERF_DataStruct.H:2240
int massflux_khi
Upper vertical index for constant-mass-flux forcing.
Definition: ERF_DataStruct.H:2310
bool large_scale_forcing
Definition: ERF_DataStruct.H:2100
bool substepping_diag
Whether to emit extra CFL diagnostics for compressible substepping.
Definition: ERF_DataStruct.H:1989
static TerrainType terrain_type
Terrain or immersed-boundary representation.
Definition: ERF_DataStruct.H:1949
amrex::Real mean_vars_reset_time
Definition: ERF_DataStruct.H:2126
std::string windfarm_blade_table
Wind-farm blade table path.
Definition: ERF_DataStruct.H:2268
amrex::Vector< int > is_land
Per-level land/water selector.
Definition: ERF_DataStruct.H:1986
amrex::Real hindcast_lateral_sponge_strength
Strength of the hindcast lateral sponge layer.
Definition: ERF_DataStruct.H:2316
bool forest_biophysics_heat
Definition: ERF_DataStruct.H:2300
ShocTransportMode shoc_transport_mode
Definition: ERF_DataStruct.H:2112
amrex::Real hurricane_eye_latitude
Initial hurricane-eye latitude.
Definition: ERF_DataStruct.H:2321
bool rad_uses_interface() const
True for the models that run through the IRadiation interface (RRTMGP, Simple); the two-stream model ...
Definition: ERF_DataStruct.H:2245
amrex::Real cosphi
Cosine of the latitude used for Coriolis forcing.
Definition: ERF_DataStruct.H:2071
amrex::Real if_Cd_scalar
Immersed-forcing drag coefficient for scalars.
Definition: ERF_DataStruct.H:2037
static BuildingsType buildings_type
Building representation.
Definition: ERF_DataStruct.H:1952
std::string windfarm_loc_table
Wind-farm location table path.
Definition: ERF_DataStruct.H:2267
std::string hindcast_surface_data_dir
Directory containing hindcast surface boundary data.
Definition: ERF_DataStruct.H:2312
ShocMomentumTransport shoc_momentum_transport
Definition: ERF_DataStruct.H:2113
bool custom_rhotheta_forcing
Whether custom rho-theta forcing is enabled.
Definition: ERF_DataStruct.H:2075
amrex::Real zsurf
Nominal surface height for stretched-grid setup.
Definition: ERF_DataStruct.H:2066
amrex::Real if_init_surf_temp
Initial immersed-forcing surface temperature [K].
Definition: ERF_DataStruct.H:2044
amrex::Real nudging_t_z2
Definition: ERF_DataStruct.H:2092
int massflux_klo
Lower vertical index for constant-mass-flux forcing.
Definition: ERF_DataStruct.H:2309
std::string lsf_file
Definition: ERF_DataStruct.H:2101
std::string windfarm_spec_table
Wind-farm turbine specification table path.
Definition: ERF_DataStruct.H:2267
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_geo_forcing
Applied geostrophic-wind forcing vector.
Definition: ERF_DataStruct.H:2254
ABLDriverType abl_driver_type
Atmospheric boundary-layer driver type.
Definition: ERF_DataStruct.H:2252
DiffChoice diffChoice
Diffusion-related options.
Definition: ERF_DataStruct.H:1971
amrex::Real if_surf_temp_flux
Immersed-forcing surface temperature flux [K m/s].
Definition: ERF_DataStruct.H:2043
bool spatial_rhotheta_forcing
Whether spatially varying rho-theta forcing is enabled.
Definition: ERF_DataStruct.H:2082
WindFarmType windfarm_type
Wind-farm model.
Definition: ERF_DataStruct.H:2238
bool use_source_perturbation(int lev) const
Query whether source-term turbulent perturbations are enabled on a level.
Definition: ERF_DataStruct.H:2158
bool custom_w_subsidence
Whether custom vertical subsidence is enabled.
Definition: ERF_DataStruct.H:2077
bool custom_moisture_forcing
Whether custom moisture forcing is enabled.
Definition: ERF_DataStruct.H:2076
amrex::Real if_surf_heating_rate
Immersed-forcing surface heating rate [K/hr].
Definition: ERF_DataStruct.H:2045
MoistureComponentIndices moisture_indices
Index map of the moisture data carried by the active scheme: conserved-state components for the speci...
Definition: ERF_DataStruct.H:2263
RadiationType rad_type
Radiation model.
Definition: ERF_DataStruct.H:2241
amrex::Real grid_stretching_ratio
Vertical grid stretching ratio.
Definition: ERF_DataStruct.H:2065
bool hindcast_surface_bcs
Whether hindcast surface boundary conditions are enabled.
Definition: ERF_DataStruct.H:2315
bool host_owns_vertical_scalar_diffusion() const noexcept
Test whether the host owns scalar diffusion.
Definition: ERF_DataStruct.H:2197
bool immersed_forcing_substep
Whether immersed-forcing source terms are applied only during substeps.
Definition: ERF_DataStruct.H:2032
bool if_use_most
Whether immersed-forcing MOST is enabled.
Definition: ERF_DataStruct.H:2047
amrex::Real const_massflux_tau
Relaxation time scale for constant-mass-flux forcing.
Definition: ERF_DataStruct.H:2306
amrex::Real hindcast_lateral_sponge_length
Length of the hindcast lateral sponge layer.
Definition: ERF_DataStruct.H:2316
bool use_eamxx_shoc
Whether any level uses the EAMxx SHOC PBL scheme.
Definition: ERF_DataStruct.H:2108
amrex::Real sinphi
Sine of the latitude used for Coriolis forcing.
Definition: ERF_DataStruct.H:2072
bool host_owns_vertical_momentum_diffusion() const noexcept
Test whether the host owns momentum diffusion.
Definition: ERF_DataStruct.H:2186
amrex::Real hindcast_zhi_sponge_strength
Strength of the upper hindcast sponge layer.
Definition: ERF_DataStruct.H:2317
bool coriolis_3d
Whether the three-dimensional Coriolis terms are included.
Definition: ERF_DataStruct.H:2027
int force_stage1_single_substep
Flag forcing a single substep in the first RK stage.
Definition: ERF_DataStruct.H:1978
amrex::Real c_p
Specific heat at constant pressure for dry air [J/(kg-K)].
Definition: ERF_DataStruct.H:2061
bool if_implicit_drag
Definition: ERF_DataStruct.H:2040
bool implicit_momentum_diffusion
Whether implicit vertical momentum diffusion is included.
Definition: ERF_DataStruct.H:2005
bool do_mom_advection
Whether custom vertical subsidence is applied to momentum.
Definition: ERF_DataStruct.H:2079
bool if_stability_correction
Whether immersed-forcing stability corrections are enabled.
Definition: ERF_DataStruct.H:2049
amrex::Real nudging_t_z1
Definition: ERF_DataStruct.H:2091
bool custom_forcing_prim_vars
Whether custom forcing operates on primitive variables.
Definition: ERF_DataStruct.H:2081
bool nudging_u
Definition: ERF_DataStruct.H:2096
bool nudging_from_input_sounding
Whether solution fields are nudged toward input sounding data.
Definition: ERF_DataStruct.H:2087
static void set_mesh_type(MeshType new_mesh_type)
Override the globally selected mesh type.
Definition: ERF_DataStruct.H:1965
bool use_num_diff
Whether sixth-order numerical diffusion is enabled.
Definition: ERF_DataStruct.H:2233
bool use_wrf_bdy_qc_qi
Whether WRF cloud water and active cloud ice are ingested at real boundaries.
Definition: ERF_DataStruct.H:2281
Definition: ERF_SpongeStruct.H:22
void display()
Print the configured sponge-layer options.
Definition: ERF_SpongeStruct.H:85
void init_params(std::string pp_prefix)
Read sponge-layer options from the input parameter database.
Definition: ERF_SpongeStruct.H:28