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 #include <cmath>
7 
8 #include <AMReX_ParmParse.H>
9 #include <AMReX_Print.H>
10 #include <AMReX_Gpu.H>
11 #include <AMReX_Geometry.H>
12 
13 #include "ERF_Constants.H"
14 #include "ERF_IndexDefines.H"
16 #include "ERF_AdvStruct.H"
17 #include "ERF_DampingStruct.H"
18 #include "ERF_DiffStruct.H"
19 #include "ERF_EBStruct.H"
20 #include "ERF_SpongeStruct.H"
21 #include "ERF_TurbStruct.H"
22 #include "ERF_TurbPertStruct.H"
23 #include "ERF_RadStruct.H"
25 #include "ERF_CanopyTurbStruct.H"
26 #include "ERF_MOSTUtils.H"
27 
28 /**
29  * Enum of possible plotfile types.
30  */
31 AMREX_ENUM(PlotFileType,
32  None, Amrex, Netcdf
33 );
34 
35 /**
36  * @brief Indices for map scale factors on mass and face grids.
37  */
38 enum MapFacType {
39 // This version assumes isotropic
40  m_x, u_x, v_x, num,
41  m_y = 0, u_y = 1, v_y = 2
42 // This version allows for non-isotropic
43 // m_x, u_x, v_x,
44 // m_y, u_y, v_y, num
45 };
46 
47 /**
48  * @brief Stress tensor component indices.
49  */
50 enum TauType {
52 };
53 
54 /**
55  * @brief Initial-condition source used to populate the ERF state.
56  */
57 AMREX_ENUM(InitType,
58  None, Input_Sounding, NCFile, WRFInput, Metgrid, Uniform, ConstantDensity, ConstantDensityLinearTheta,
59  Isentropic, MoistBaseState, HindCast
60 );
61 
62 /**
63  * @brief Interpretation of input sounding profiles.
64  */
65 AMREX_ENUM(SoundingType,
66  ConstantDensity, Ideal, Isentropic, DryIsentropic
67 );
68 
69 /**
70  * @brief Large-scale atmospheric boundary-layer driver type.
71  */
72 AMREX_ENUM(ABLDriverType,
73  None, PressureGradient, GeostrophicWind
74 );
75 
76 /**
77  * @brief Multilevel coupling strategy.
78  */
79 AMREX_ENUM(CouplingType,
80  OneWay, TwoWay
81 );
82 
83 /**
84  * @brief Values of the deprecated erf.substepping_type; read only to map them onto
85  * TimesteppingType.
86  */
87 AMREX_ENUM(SubsteppingType,
88  None, Implicit
89 );
90 
91 /**
92  * @brief Compressibility of the equations solved at a level.
93  *
94  * FullyCompressible solves the compressible equations with acoustic substepping.
95  * Anelastic holds the density at its base-state value and projects the velocity.
96  * PseudoIncompressible evolves the density and (rho theta) as FullyCompressible does, with the
97  * buoyancy -(rho - rho0) g, and projects the velocity to satisfy div(rho0 theta0 u) = 0 with a
98  * variable-coefficient solve; like Anelastic it never substeps acoustically.
99  */
100 AMREX_ENUM(CompressibilityType,
101  FullyCompressible, Anelastic, PseudoIncompressible
102 );
103 
104 /**
105  * @brief Horizontal pressure-gradient formulation with terrain-fitted coordinates.
106  *
107  * ChainRule: dp/dx along the coordinate surface minus the terrain slope times dp/dz
108  * HydrostaticHybrid: as ChainRule, but the hydrostatic part of p' is carried to the height
109  * of the face along dp'/dz = -g rho' and only the remainder
110  * dp'/dz + g rho' is differenced
111  */
112 AMREX_ENUM(GradpType,
113  ChainRule, HydrostaticHybrid
114 );
115 
116 /**
117  * @brief Values of the deprecated erf.anelastic_type; read only to map them onto
118  * TimesteppingType.
119  */
120 AMREX_ENUM(AnelasticType,
121  RK2, MidPoint
122 );
123 
124 /**
125  * @brief Time integrator used at a level.
126  *
127  * At a FullyCompressible level:
128  * RK3_ImplicitSubstep is the three-stage RK3 with implicit acoustic substepping;
129  * RK3_NoSubstepping is the three-stage SSP-RK3 with no acoustic substepping.
130  * At an Anelastic or PseudoIncompressible level (never any acoustic substepping):
131  * RK2 is the SSP (Heun) scheme: both stages advance a full timestep from the old
132  * state and the second averages the two slow sources;
133  * MidPoint advances only a half timestep in the first stage, which makes the
134  * vertical diffusion second order in time with an implicit solve in the first
135  * stage alone.
136  */
137 AMREX_ENUM(TimesteppingType,
138  RK3_ImplicitSubstep, RK3_NoSubstepping, RK2, MidPoint
139 );
140 
141 /**
142  * @brief Vertical mesh representation.
143  */
144 AMREX_ENUM(MeshType,
145  ConstantDz, StretchedDz, VariableDz
146 );
147 
148 /**
149  * @brief Linear solver for the anelastic or pseudo-incompressible projection on a terrain-fitted mesh.
150  *
151  * gmres_fft is GMRES with ERF's TerrainPoisson operator and an FFT preconditioner (needs the
152  * FFT build). mlmg and gmres_mlmg use amrex::MLTerrainPoisson (AMReX-Codes/amrex#6030), the
153  * same stencil with zero flux through the Neumann faces, solved by geometric multigrid
154  * alone or as the preconditioner of GMRES; they need no FFT.
155  */
156 AMREX_ENUM(TerrainPoissonSolver,
157  gmres_fft, mlmg, gmres_mlmg
158 );
159 
160 /**
161  * @brief Terrain and immersed-boundary representation.
162  */
163 AMREX_ENUM(TerrainType,
164  None, StaticFittedMesh, MovingFittedMesh, EB, ImmersedForcing
165 );
166 
167 /**
168  * @brief Building representation.
169  */
170 AMREX_ENUM(BuildingsType,
171  None, ImmersedForcing
172 );
173 
174 /**
175  * @brief Moisture transport representation.
176  */
177 AMREX_ENUM(MoistureModelType,
178  Eulerian, Lagrangian, Undefined
179 );
180 
181 /**
182  * @brief Moisture and microphysics model.
183  */
184 AMREX_ENUM(MoistureType,
185  SAM, SAM_NoIce, SAM_NoPrecip_NoIce, Kessler, Kessler_NoRain, SatAdj, Morrison, Morrison_NoIce, WSM6, WDM6, SuperDroplets, MoistNoCondensation, SBM, None
186 );
187 
188 /**
189  * @brief Wind-farm model.
190  */
191 AMREX_ENUM(WindFarmType,
193 );
194 
195 /**
196  * @brief Coordinate system used for wind-farm locations.
197  */
198 AMREX_ENUM(WindFarmLocType,
199  lat_lon, x_y, None
200 );
201 
202 /**
203  * @brief Land-surface model.
204  */
205 AMREX_ENUM(LandSurfaceType,
206  SLM, NOAHMP, None
207 );
208 
209 /**
210  * @brief Urban model.
211  */
212 AMREX_ENUM(UrbanType,
213  None
214 );
215 
216 /**
217  * @brief Radiation model.
218  */
219 AMREX_ENUM(RadiationType,
220  None, RRTMGP, Simple, TwoStream
221 );
222 
223 /**
224  * @brief Coordinate-axis selector.
225  */
226 enum struct Coord {
227  x, y, z
228 };
229 
230 // These are used as integers so must be enum not enum struct
231 /**
232  * @brief Rayleigh damping profile component indices.
233  */
234 enum Rayleigh {
236 };
237 
238 // These are used as integers so must be enum not enum struct
239 /**
240  * @brief Sponge reference-state component indices.
241  */
242 enum Sponge {
244 };
245 
246 static const std::string BoundaryFaceName[] = {"xlo", "ylo", "zlo", "xhi", "yhi", "zhi"};
247 
248 /**
249  * @brief The moisture data carried by the active microphysics scheme.
250  *
251  * This struct is the single source of truth for the question "which moisture
252  * quantities does this run actually have?". Everything downstream of the
253  * microphysics -- source terms, turbulence closures, and every output path
254  * (3D plotfiles, 2D plotfiles, subvolumes) -- answers that question by querying
255  * this struct instead of enumerating MoistureType values, so a newly added
256  * scheme only has to declare its layout once, in from_moisture_model() below.
257  *
258  * Two kinds of index live here:
259  *
260  * 1. Conserved-state components (qv ... nn). Absolute component indices into
261  * the conserved state array, i.e. one of RhoQ1_comp ... RhoQ11_comp. They
262  * name the *rho-weighted* species: state(i,j,k,qv) is rho*qv, so an output
263  * path must divide by Rho_comp to recover the mixing ratio.
264  *
265  * 2. qmoist diagnostic slots (rain_accum ... cond_rate). Indices into the
266  * per-level qmoist vector that is filled from
267  * Microphysics::Get_Qmoist_Ptr(lev,idx). Each scheme chooses that
268  * layout independently, so the slot numbers differ between schemes and are
269  * recorded per scheme below.
270  *
271  * In both cases the value is `absent` when the active scheme does not carry the
272  * quantity, so `index >= 0` is the criterion for "this exists and is meaningful
273  * to write". That is deliberately *not* the same test as "the storage is
274  * allocated": several schemes allocate a wider state than they integrate (the
275  * Morrison class always allocates eleven moist components, so Morrison_NoIce
276  * owns ice slots it never fills), and writing those slots to a plotfile would
277  * publish untouched memory as if it were data.
278  */
280 
281  // Sentinel values shared by both kinds of index above.
282  static constexpr int absent = -1; //!< not carried by the active scheme
283  static constexpr int computed_from_state = -2; //!< carried, but derived at output
284  //!< time from the conserved state
285  //!< rather than read from a qmoist slot
286 
287  // ---------------------------------------------------------------------
288  // Conserved-state components: mass mixing ratios (rho-weighted)
289  // ---------------------------------------------------------------------
290  int qv = absent; //!< water vapor
291  int qc = absent; //!< cloud liquid water
292  int qi = absent; //!< cloud ice
293  int qr = absent; //!< rain
294  int qs = absent; //!< snow
295  int qg = absent; //!< graupel
296 
297  // ---------------------------------------------------------------------
298  // Conserved-state components: number concentrations (rho-weighted)
299  // ---------------------------------------------------------------------
300  int nc = absent; //!< cloud liquid water number
301  int ni = absent; //!< cloud ice number
302  int nr = absent; //!< rain number
303  int ns = absent; //!< snow number
304  int ng = absent; //!< graupel number
305  // CCN / total aerosol number. Unlike every other number concentration above,
306  // this has no companion mass species: it is an aerosol reservoir that
307  // exchanges number with nc and nr through activation and evaporation rather
308  // than a hydrometeor count. Kept distinct from ni, which is cloud ice number,
309  // even though some schemes place the two in the same conserved-state slot.
310  int nn = absent; //!< CCN / total aerosol number
311 
312  // ---------------------------------------------------------------------
313  // qmoist diagnostic slots
314  //
315  // These are *not* conserved-state components; they index the qmoist vector
316  // handed out by the microphysics interface. Slot numbers are scheme
317  // specific, which is exactly why they belong in this per-scheme map.
318  // ---------------------------------------------------------------------
319  //
320  // The accumulations are what reached the ground, in mm of liquid water:
321  // rain, snow and graupel each hold that species alone, and precip_accum
322  // holds everything that fell out -- those three plus whatever cloud water
323  // and cloud ice the scheme sediments -- so it can exceed their sum.
324  int rain_accum = absent; //!< accumulated surface rain
325  int snow_accum = absent; //!< accumulated surface snow
326  int graupel_accum = absent; //!< accumulated surface graupel
327  int precip_accum = absent; //!< accumulated surface precipitation, all species
328  int rel_hum = absent; //!< relative humidity
329  int cond_rate = absent; //!< condensation rate
330 
331  /**
332  * @brief Construct the conserved-state component map.
333  *
334  * Prefer from_moisture_model() for production code: it fills in the qmoist
335  * diagnostic slots as well. This constructor exists for the callers -- unit
336  * tests and kernels exercised in isolation -- that only need the state map.
337  *
338  * @param qv_comp Water vapor component index.
339  * @param qc_comp Cloud liquid water component index.
340  * @param qi_comp Cloud ice component index.
341  * @param qr_comp Rain component index.
342  * @param qs_comp Snow component index.
343  * @param qg_comp Graupel component index.
344  * @param nc_comp Cloud liquid water number concentration component index.
345  * @param ni_comp Cloud ice number concentration component index.
346  * @param nr_comp Rain number concentration component index.
347  * @param ns_comp Snow number concentration component index.
348  * @param ng_comp Graupel number concentration component index.
349  * @param nn_comp CCN / total aerosol number concentration component index.
350  */
351  MoistureComponentIndices (int qv_comp, int qc_comp,
352  int qi_comp=absent,
353  int qr_comp=absent,
354  int qs_comp=absent,
355  int qg_comp=absent,
356  int nc_comp=absent,
357  int ni_comp=absent,
358  int nr_comp=absent,
359  int ns_comp=absent,
360  int ng_comp=absent,
361  int nn_comp=absent)
362  : qv(qv_comp), qc(qc_comp), qi(qi_comp), qr(qr_comp), qs(qs_comp), qg(qg_comp),
363  nc(nc_comp), ni(ni_comp), nr(nr_comp), ns(ns_comp), ng(ng_comp),
364  nn(nn_comp) {}
365 
366  /**
367  * @brief Construct an empty map, i.e. a dry run.
368  */
370 
371  /**
372  * @brief Build the complete index map -- conserved-state components and
373  * qmoist diagnostic slots -- for a moisture model.
374  *
375  * This is the one place a scheme declares what it carries. The conserved
376  * layout must match the component the scheme reads and writes in its
377  * Copy_State_to_Micro / Copy_Micro_to_State pair, and the qmoist slots must
378  * match the order the scheme installs in its MicVarMap. A slot that a
379  * scheme allocates but never fills is left `absent` on purpose: see the
380  * class comment for why allocation is not the criterion here.
381  *
382  * @param moisture_type Active moisture/microphysics model.
383  */
385  from_moisture_model (const MoistureType moisture_type)
386  {
388 
389  switch (moisture_type) {
390 
391  case MoistureType::None:
392  // Dry: no moisture data of any kind.
393  break;
394 
395  case MoistureType::MoistNoCondensation:
396  case MoistureType::SAM_NoPrecip_NoIce:
397  case MoistureType::Kessler_NoRain:
398  // Vapor plus suspended cloud water, no precipitation and no
399  // accumulation diagnostics.
400  mi.qv = RhoQ1_comp;
401  mi.qc = RhoQ2_comp;
402  break;
403 
404  case MoistureType::SatAdj:
405  // As above, but relative humidity is recovered from the state at
406  // output time rather than stored: SatAdj publishes no qmoist arrays.
407  mi.qv = RhoQ1_comp;
408  mi.qc = RhoQ2_comp;
410  break;
411 
412  case MoistureType::Kessler:
413  // Warm rain in three moist components; qmoist is {rain_accum}.
414  // Rain is the only species that falls, so the precipitation total
415  // is the rain accumulation itself.
416  mi.qv = RhoQ1_comp;
417  mi.qc = RhoQ2_comp;
418  mi.qr = RhoQ3_comp;
419  mi.rain_accum = 0;
420  mi.precip_accum = 0;
421  break;
422 
423  case MoistureType::SBM:
424  // SBM stores the distribution in an auxiliary state. These two
425  // compact liquid lanes are projections for host compatibility.
426  mi.qv = RhoQ1_comp;
427  mi.qc = RhoQ2_comp;
428  mi.qr = RhoQ3_comp;
429  break;
430 
431  case MoistureType::SAM_NoIce:
432  // The SAM class always allocates six moist components, so rain sits
433  // in the fourth slot even with the ice species switched off.
434  mi.qv = RhoQ1_comp;
435  mi.qc = RhoQ2_comp;
436  mi.qr = RhoQ4_comp;
437  mi.rain_accum = 0;
438  mi.precip_accum = 3;
439  break;
440 
441  case MoistureType::SAM:
442  case MoistureType::WSM6:
443  // Single-moment mixed phase; qmoist is
444  // {rain_accum, snow_accum, graupel_accum, precip_accum}.
445  mi.qv = RhoQ1_comp;
446  mi.qc = RhoQ2_comp;
447  mi.qi = RhoQ3_comp;
448  mi.qr = RhoQ4_comp;
449  mi.qs = RhoQ5_comp;
450  mi.qg = RhoQ6_comp;
451  mi.rain_accum = 0;
452  mi.snow_accum = 1;
453  mi.graupel_accum = 2;
454  mi.precip_accum = 3;
455  break;
456 
457  case MoistureType::Morrison:
458  // Two-moment mixed phase: six mass species followed by five number
459  // concentrations.
460  mi.qv = RhoQ1_comp;
461  mi.qc = RhoQ2_comp;
462  mi.qi = RhoQ3_comp;
463  mi.qr = RhoQ4_comp;
464  mi.qs = RhoQ5_comp;
465  mi.qg = RhoQ6_comp;
466  mi.nc = RhoQ7_comp;
467  mi.ni = RhoQ8_comp;
468  mi.nr = RhoQ9_comp;
469  mi.ns = RhoQ10_comp;
470  mi.ng = RhoQ11_comp;
471  mi.rain_accum = 0;
472  mi.snow_accum = 1;
473  mi.graupel_accum = 2;
474  mi.precip_accum = 3;
475  break;
476 
477  case MoistureType::Morrison_NoIce:
478  // Liquid-only Morrison: the class still allocates all eleven moist
479  // components, but only vapor, cloud water and rain -- and the cloud
480  // and rain numbers -- are integrated, so the frozen species and
481  // their numbers stay absent here.
482  mi.qv = RhoQ1_comp;
483  mi.qc = RhoQ2_comp;
484  mi.qr = RhoQ4_comp;
485  mi.nc = RhoQ7_comp;
486  mi.nr = RhoQ9_comp;
487  mi.rain_accum = 0;
488  mi.precip_accum = 3;
489  break;
490 
491  case MoistureType::WDM6:
492  // Double-moment warm phase on top of single-moment ice: nn is the
493  // aerosol reservoir and takes the slot Morrison uses for ice number,
494  // and there are no snow or graupel numbers.
495  mi.qv = RhoQ1_comp;
496  mi.qc = RhoQ2_comp;
497  mi.qi = RhoQ3_comp;
498  mi.qr = RhoQ4_comp;
499  mi.qs = RhoQ5_comp;
500  mi.qg = RhoQ6_comp;
501  mi.nc = RhoQ7_comp;
502  mi.nn = RhoQ8_comp;
503  mi.nr = RhoQ9_comp;
504  mi.rain_accum = 0;
505  mi.snow_accum = 1;
506  mi.graupel_accum = 2;
507  mi.precip_accum = 3;
508  break;
509 
510  case MoistureType::SuperDroplets:
511  // Lagrangian microphysics that still carries the six Eulerian mass
512  // species. Its qmoist layout is its own (see the MicVarMap in
513  // SuperDropletsMoist::Init): the graupel accumulation slot exists
514  // but is never filled, so it stays absent.
515  mi.qv = RhoQ1_comp;
516  mi.qc = RhoQ2_comp;
517  mi.qi = RhoQ3_comp;
518  mi.qr = RhoQ4_comp;
519  mi.qs = RhoQ5_comp;
520  mi.qg = RhoQ6_comp;
521  mi.cond_rate = 3;
522  mi.rel_hum = 7;
523  mi.rain_accum = 8;
524  mi.snow_accum = 10;
525  mi.precip_accum = 11;
526  break;
527 
528  default:
529  amrex::Abort("Unknown MoistureType in MoistureComponentIndices::from_moisture_model");
530  }
531 
532  return mi;
533  }
534 
535  /**
536  * @brief An ordered list of conserved-state components forming an aggregate
537  * moisture output variable (qt, qn, qp, moist_density).
538  *
539  * Only the species the active scheme carries are appended, so a consumer can
540  * sum the list without first asking which ones exist.
541  */
542  struct CompList {
543  static constexpr int max_size = 6; //!< qv, qc, qi, qr, qs, qg
545  int size = 0;
546 
547  //! Append a component, ignoring the ones the scheme does not carry.
548  void append (int c) {
549  if ( (c >= 0) && (size < max_size) ) { comp[size++] = c; }
550  }
551  [[nodiscard]] bool empty () const { return (size == 0); }
552  };
553 
554  /**
555  * @brief Components summed for total water, "qt": every mass mixing ratio.
556  *
557  * Number concentrations are excluded -- they are counts, not masses.
558  */
559  [[nodiscard]] CompList total_water_comps () const {
560  CompList list;
561  list.append(qv); list.append(qc); list.append(qi);
562  list.append(qr); list.append(qs); list.append(qg);
563  return list;
564  }
565 
566  /**
567  * @brief Components summed for non-precipitating water, "qn": vapor plus the
568  * suspended condensate. Also the moist part of "moist_density".
569  */
570  [[nodiscard]] CompList nonprecipitating_comps () const {
571  CompList list;
572  list.append(qv); list.append(qc); list.append(qi);
573  return list;
574  }
575 
576  /**
577  * @brief Components summed for precipitating water, "qp": the falling species.
578  */
579  [[nodiscard]] CompList precipitating_comps () const {
580  CompList list;
581  list.append(qr); list.append(qs); list.append(qg);
582  return list;
583  }
584 
585  /**
586  * @brief Test whether a conserved-state component holds one of the moisture
587  * variables this scheme carries.
588  *
589  * Use this rather than enumerating moisture models when deciding whether a
590  * "rhoQn" state component is meaningful for the active scheme.
591  *
592  * @param comp Absolute component index into the conserved state array.
593  */
594  [[nodiscard]] bool has_comp (int comp) const {
595  return ( (comp >= 0) &&
596  ( (comp == qv) || (comp == qc) || (comp == qi) ||
597  (comp == qr) || (comp == qs) || (comp == qg) ||
598  (comp == nc) || (comp == ni) || (comp == nr) ||
599  (comp == ns) || (comp == ng) || (comp == nn) ) );
600  }
601 
602  /**
603  * @brief Test whether the active scheme carries rain, snow and graupel in the
604  * RhoQ4/RhoQ5/RhoQ6 slots assumed by erf_derreflectivity and
605  * erf_dermaxreflectivity.
606  *
607  * Those kernels read the precipitating species by hardcoded component, so this
608  * checks the layout and not just the presence of the species.
609  */
610  [[nodiscard]] bool has_reflectivity_species () const {
611  return ( (qr == RhoQ4_comp) && (qs == RhoQ5_comp) && (qg == RhoQ6_comp) );
612  }
613 
614  /**
615  * @brief Test whether the active scheme carries any moisture at all.
616  *
617  * Every moist scheme allocates water vapor, so this is equivalent to testing
618  * moisture_type != MoistureType::None without needing the enum.
619  */
620  [[nodiscard]] bool has_moisture () const { return (qv >= 0); }
621 
622  /**
623  * @brief The conserved-state component behind a single-species output name,
624  * or `absent` if the name is not a single species or the scheme does
625  * not carry it.
626  *
627  * An output path can use this to copy a species without repeating the
628  * name-to-component mapping.
629  *
630  * @param name Derived or plot variable name.
631  */
632  [[nodiscard]] int comp_for_var (const std::string& name) const {
633  if (name == "qv") { return qv; }
634  if (name == "qc") { return qc; }
635  if (name == "qi") { return qi; }
636  if (name == "qrain") { return qr; }
637  if (name == "qsnow") { return qs; }
638  if (name == "qgraup") { return qg; }
639  if (name == "nc") { return nc; }
640  if (name == "ni") { return ni; }
641  if (name == "nr") { return nr; }
642  if (name == "ns") { return ns; }
643  if (name == "ng") { return ng; }
644  if (name == "nn") { return nn; }
645  return absent;
646  }
647 
648  /**
649  * @brief The qmoist slot behind a moist diagnostic output name.
650  *
651  * Returns `absent` when the scheme does not provide the diagnostic, and
652  * `computed_from_state` when it does provide it but not through a qmoist
653  * array -- in that case the caller must derive it from the conserved state.
654  *
655  * @param name Derived or plot variable name.
656  */
657  [[nodiscard]] int qmoist_index_for_var (const std::string& name) const {
658  if (name == "rain_accum") { return rain_accum; }
659  if (name == "snow_accum") { return snow_accum; }
660  if (name == "graupel_accum") { return graupel_accum; }
661  if (name == "precip_accum") { return precip_accum; }
662  if (name == "rel_humidity") { return rel_hum; }
663  if (name == "condensation_rate") { return cond_rate; }
664  return absent;
665  }
666 
667  /**
668  * @brief Whether this map decides a variable's availability, and if so
669  * whether the variable is available.
670  */
672  bool governed = false; //!< the name is a moisture output variable
673  bool available = false; //!< the active scheme carries the data behind it
674  };
675 
676  /**
677  * @brief Classify an output variable name against this index map.
678  *
679  * This is the one table pairing output names with the data behind them. It
680  * is driven off the scheme's index map rather than an enumerated list of
681  * moisture models, so it stays correct as schemes are added. Names with no
682  * moisture dependence come back not-governed, which lets a caller walk a
683  * mixed list of variable names and only defer to this map where it applies.
684  *
685  * @param name Derived or plot variable name.
686  */
687  [[nodiscard]] VarAvailability query_var (const std::string& name) const {
688 
689  // Single species, taken straight from the conserved state
690  if ( (name == "qv") || (name == "qc") || (name == "qi") ||
691  (name == "qrain") || (name == "qsnow") || (name == "qgraup") ||
692  (name == "nc") || (name == "ni") || (name == "nr") ||
693  (name == "ns") || (name == "ng") || (name == "nn") ) {
694  return {true, comp_for_var(name) >= 0};
695  }
696 
697  // Moist diagnostics, either from a qmoist array or derived at output time
698  if ( (name == "rain_accum") || (name == "snow_accum") ||
699  (name == "graupel_accum") || (name == "precip_accum") ||
700  (name == "rel_humidity") ||
701  (name == "condensation_rate") ) {
702  return {true, qmoist_index_for_var(name) != absent};
703  }
704 
705  // Aggregates over several species
706  if (name == "qt") { return {true, !total_water_comps().empty()}; }
707  if (name == "qp") { return {true, !precipitating_comps().empty()}; }
708 
709  // Non-precipitating water is vapor plus the suspended condensate, and
710  // moist density adds that same sum to the dry density
711  if ( (name == "qn") || (name == "moist_density") ) {
712  return {true, (qv >= 0) && (qc >= 0)};
713  }
714 
715  // Column and thermodynamic diagnostics that read vapor only
716  if ( (name == "qsat") || (name == "precipitable") ) {
717  return {true, has_moisture()};
718  }
719 
720  return {false, false};
721  }
722 
723  /**
724  * @brief Test whether the moist species behind a derived/plot variable name is
725  * carried by the active scheme.
726  *
727  * Names this map does not govern return true, so this can be used directly as
728  * a filter over a mixed list of variable names. Use query_var() instead when
729  * the caller needs to distinguish "not a moisture variable" from "available".
730  *
731  * @param name Derived or plot variable name.
732  */
733  [[nodiscard]] bool has_derived_var (const std::string& name) const {
734  const VarAvailability status = query_var(name);
735  return (!status.governed) || status.available;
736  }
737 };
738 
739 /**
740  * Container holding many of the algorithmic options and parameters
741  */
742 
743 struct SolverChoice {
744  public:
745  /**
746  * @brief Read solver-wide algorithmic options from the input parameter database.
747  * @param max_level Maximum AMR level configured for the run.
748  * @param pp_prefix ParmParse prefix for the ERF input namespace.
749  */
750  void init_params (int max_level, std::string pp_prefix)
751  {
752  amrex::ParmParse pp(pp_prefix);
753 
754  bool bogus_bool;
755  if (pp.query("use_terrain",bogus_bool) > 0) {
756  amrex::Error("The input use_terrain is deprecated. Set terrain_type instead.");
757  }
758 
759  if (pp.query("use_moist_background",bogus_bool) > 0) {
760  amrex::Error("The input use_moist_background is deprecated. Set init_type = MoistBaseState instead.");
761  }
762 
763  // Do we set map scale factors to myhalf instead of 1 for testing?
764  pp.queryAdd("test_mapfactor", test_mapfactor);
765 
766  // For testing: if nonzero, the map scale factors on level 0 vary smoothly in space,
767  // m = 1 + test_mapfactor_amp sin(2 pi x / Lx) cos(2 pi y / Ly), as if read from an init file
768  // there; finer levels take theirs from the coarser level, as a level without a file does
769  pp.queryAdd("test_mapfactor_amp", test_mapfactor_amp);
770  if (test_mapfactor && test_mapfactor_amp != amrex::Real(0)) {
771  amrex::Abort("erf.test_mapfactor and erf.test_mapfactor_amp cannot be used together");
772  }
773 
774  // Which horizontal pressure gradient formulation to use with terrain fitted coords?
775  // (see GradpType). HydrostaticHybrid always uses the perturbational pressure,
776  // regardless of the setting of use_pert_pres_gradient.
777  //
778  // The integer values this used to take are still accepted, with a warning:
779  // 0 -> ChainRule, 2 -> HydrostaticHybrid; 1 (Klemp 2011) has been removed
780  if (pp.contains("gradp_type")) {
781  std::string gradp_str;
782  pp.get("gradp_type", gradp_str);
783  if (gradp_str == "0" || gradp_str == "1" || gradp_str == "2") {
784  if (gradp_str == "1") {
785  amrex::Abort("erf.gradp_type = 1 has been removed; use erf.gradp_type = HydrostaticHybrid");
786  }
787  gradp_type = (gradp_str == "0") ? GradpType::ChainRule : GradpType::HydrostaticHybrid;
788  amrex::Print() << "WARNING: integer values of erf.gradp_type are deprecated; use erf.gradp_type = "
789  << amrex::getEnumNameString(gradp_type) << std::endl;
790  } else {
791  // Case-insensitive and ignoring underscores, so that e.g. hydrostatic_hybrid
792  // selects HydrostaticHybrid
793  try {
794  pp.query_enum_sloppy("gradp_type", gradp_type, "_");
795  } catch (...) {
796  amrex::Abort("erf.gradp_type must be ChainRule or HydrostaticHybrid, not '"
797  + gradp_str + "'");
798  }
799  }
800  }
801 
802  // With ChainRule, whether dp/dz at the bottom and top of the domain is the second-order
803  // one-sided difference through three cells rather than the first-order two-point one
804  pp.query("gradp_2nd_order_bndry", gradp_2nd_order_bndry);
805 
806  // For the lateral pressure gradient to be used in the momentum equation, should we
807  // take the x- and y-derivatives of the perturbational pressure or the full pressure?
808  pp.queryAdd("use_pert_pres_gradient", use_pert_pres_gradient);
809 
810  // What type of moisture model to use?
811  moisture_type = MoistureType::None; // Default
812  if (pp.query("moisture_type",moisture_type) > 0) {
813  amrex::Error("The input moisture_type is deprecated. Set moisture_model instead.");
814  }
815 
816  pp.query_enum_case_insensitive("moisture_model",moisture_type);
817 
818 #ifdef ERF_SBM_AMR_QUALIFICATION
819  pp.queryAdd("sbm_amr_qualification_test", sbm_amr_qualification_test);
820  pp.queryAdd("sbm_amr_qualification_expect_zero_flow",
822  pp.queryAdd("sbm_amr_qualification_expect_split",
824  pp.queryAdd("sbm_amr_qualification_expect_empty_fine_rank",
826  pp.queryAdd("sbm_amr_qualification_unique_profile",
828  pp.queryAdd("sbm_amr_qualification_parent_store_fault",
830  pp.queryAdd("sbm_amr_qualification_regrid",
832  pp.queryAdd("sbm_amr_qualification_regrid_reject_fault",
834  pp.queryAdd("sbm_amr_qualification_uniform_ratio",
836 #else
837  for (const char* name : {"sbm_amr_qualification_test",
838  "sbm_amr_qualification_expect_zero_flow",
839  "sbm_amr_qualification_expect_split",
840  "sbm_amr_qualification_expect_empty_fine_rank",
841  "sbm_amr_qualification_unique_profile",
842  "sbm_amr_qualification_parent_store_fault",
843  "sbm_amr_qualification_regrid",
844  "sbm_amr_qualification_regrid_reject_fault",
845  "sbm_amr_qualification_uniform_ratio"}) {
846  if (pp.contains(name)) {
847  amrex::Error(std::string("erf.") + name + " is available only in "
848  "the isolated ERF_ENABLE_SBM_AMR_QUALIFICATION build");
849  }
850  }
851 #endif
852 
853  // Test-only SBM failure injections. They remain disabled unless an
854  // integration test explicitly enables the corresponding option.
855  pp.queryAdd("sbm_test_native_qc_write_fault", sbm_test_native_qc_write_fault);
856  pp.queryAdd("sbm_test_donor_cfl_fault", sbm_test_donor_cfl_fault);
857  if (moisture_type != MoistureType::SBM &&
859  amrex::Error("SBM test fault-injection options require moisture_model=SBM");
860  }
861  pp.queryAdd("sbm_budget_check", sbm_budget_check);
862  if (moisture_type != MoistureType::SBM && sbm_budget_check) {
863  amrex::Error("erf.sbm_budget_check requires erf.moisture_model = SBM");
864  }
865 
866  // Register the moisture data this scheme carries: conserved-state
867  // components and qmoist diagnostic slots alike. MoistureComponentIndices
868  // is the one place that mapping lives, and every consumer -- source terms,
869  // turbulence closures, and the plotfile/subvolume writers -- queries it
870  // instead of testing moisture_type.
872 
873  if (moisture_type == MoistureType::SBM) {
874  if (pp.contains("sbm_zero_transport_fixture")) {
875  bool legacy_zero_transport = false;
876  pp.get("sbm_zero_transport_fixture", legacy_zero_transport);
877  if (legacy_zero_transport) {
878  amrex::Error("erf.sbm_zero_transport_fixture=true is obsolete; M3 advances the mapped spectral state, so remove this option");
879  }
880  }
881  pp.queryAdd("sbm_nbins", sbm_nbins);
882  pp.queryAdd("sbm_moment_mode", sbm_moment_mode);
883  pp.queryAdd("sbm_cloud_rain_split", sbm_cloud_rain_split);
884  pp.queryarr("sbm_edges", sbm_edges);
885  pp.queryarr("sbm_pivots", sbm_pivots);
886  pp.queryarr("sbm_fixture_initial_state", sbm_fixture_initial_state);
887  pp.queryarr("sbm_fixture_initial_state_xhi", sbm_fixture_initial_state_xhi);
888  pp.queryAdd("sbm_particle_mixing", sbm_particle_mixing);
889  pp.queryAdd("sbm_particle_mixing_kh", sbm_particle_mixing_kh);
890  pp.queryAdd("sbm_particle_mixing_kv", sbm_particle_mixing_kv);
891  pp.queryAdd("sbm_particle_mixing_terrain_qualification",
893 
894  if (sbm_nbins < 2 || (sbm_moment_mode != 1 && sbm_moment_mode != 2)) {
895  amrex::Error("SBM requires sbm_nbins >= 2 and sbm_moment_mode equal to 1 or 2");
896  }
897  if (sbm_edges.empty()) {
898  sbm_edges.resize(static_cast<std::size_t>(sbm_nbins + 1));
899  sbm_pivots.resize(static_cast<std::size_t>(sbm_nbins));
900  for (int b = 0; b <= sbm_nbins; ++b) {
901  const amrex::Real fraction = static_cast<amrex::Real>(b) /
902  static_cast<amrex::Real>(sbm_nbins);
903  sbm_edges[static_cast<std::size_t>(b)] =
904  std::pow(amrex::Real(10.0), amrex::Real(-18.0) + amrex::Real(6.0) * fraction);
905  }
906  for (int b = 0; b < sbm_nbins; ++b) {
907  sbm_pivots[static_cast<std::size_t>(b)] = std::sqrt(
908  sbm_edges[static_cast<std::size_t>(b)] * sbm_edges[static_cast<std::size_t>(b + 1)]);
909  }
910  } else {
911  sbm_nbins = static_cast<int>(sbm_edges.size()) - 1;
912  if (sbm_nbins < 2) amrex::Error("sbm_edges must define at least two bins");
913  if (sbm_pivots.empty()) {
914  sbm_pivots.resize(static_cast<std::size_t>(sbm_nbins));
915  for (int b = 0; b < sbm_nbins; ++b) {
916  sbm_pivots[static_cast<std::size_t>(b)] = std::sqrt(
917  sbm_edges[static_cast<std::size_t>(b)] * sbm_edges[static_cast<std::size_t>(b + 1)]);
918  }
919  }
920  }
921  if (sbm_pivots.size() != static_cast<amrex::Long>(sbm_nbins)) {
922  amrex::Error("sbm_pivots must contain one value per SBM bin");
923  }
925  if (sbm_cloud_rain_split <= 0 || sbm_cloud_rain_split >= sbm_nbins) {
926  amrex::Error("sbm_cloud_rain_split must be strictly inside the liquid bin range");
927  }
928  int expected_sbm_components = sbm_nbins * (sbm_moment_mode == 2 ? 2 : 1);
929 #ifdef ERF_SBM_AMR_QUALIFICATION
931  expected_sbm_components += sbm_nbins;
932  }
933 #endif
934  if (!sbm_fixture_initial_state.empty() &&
935  sbm_fixture_initial_state.size() != static_cast<amrex::Long>(expected_sbm_components)) {
936  amrex::Error("sbm_fixture_initial_state must match the full runtime SBM component count");
937  }
938  for (const amrex::Real value : sbm_fixture_initial_state) {
939  if (!std::isfinite(value) || value < amrex::Real(0.0)) {
940  amrex::Error("sbm_fixture_initial_state values must be finite and nonnegative");
941  }
942  }
943  if (!sbm_fixture_initial_state_xhi.empty() &&
945  amrex::Error("sbm_fixture_initial_state_xhi must have as many values as "
946  "sbm_fixture_initial_state");
947  }
948  for (const amrex::Real value : sbm_fixture_initial_state_xhi) {
949  if (!std::isfinite(value) || value < amrex::Real(0.0)) {
950  amrex::Error("sbm_fixture_initial_state_xhi values must be finite and nonnegative");
951  }
952  }
953  }
954 
955  // Set a default for both dry and moist
956  buoyancy_type.resize(max_level+1);
957  for (int i = 0; i <= max_level; ++i) {
958  buoyancy_type[i] = 1; // uses Rhoprime
959  }
960 
962  pp.queryAdd("moisture_tight_coupling",moisture_tight_coupling);
963  }
964 
965  // Which expression (1,2/3 or 4) to use for buoyancy
966  int default_buoyancy_type = buoyancy_type[0];
967  read_int_string(max_level, "buoyancy_type", buoyancy_type, default_buoyancy_type);
968 
969  // What type of land surface model to use
970  lsm_type = LandSurfaceType::None; // Default
971  pp.query_enum_case_insensitive("land_surface_model",lsm_type);
972 
973  // What type of urban model to use and whether it is active at the given level
975  pp.query_enum_case_insensitive("urban_model", urban_type);
976  read_int_string(max_level, "urban_lev_active", urban_enabled_lev, 1);
977  for (int lev = 0; lev <= max_level; ++lev) {
978  if (urban_enabled_lev[lev] != 0 && urban_enabled_lev[lev] != 1) {
979  amrex::Error("urban_lev_active should be 0 or 1");
980  }
981  }
982 
983  // Will an external ocean coupler supply SST for part or all of the water
984  // cells this run? The surface layer needs to know this it in time to select
985  // ThetaCalcType::SURFACE_TEMPERATURE, which is long before the first
986  // ApplyOceanSurfaceState call.
987  pp.queryAdd("use_coupled_sst", use_coupled_sst);
988 
989  // Will an external ocean coupler supply the surface current? The surface layer
990  // allocates the current with each level, before the first ApplyOceanSurfaceState
991  // call, and takes the wind relative to it.
992  pp.queryAdd("use_coupled_currents", use_coupled_currents);
993 
994  read_int_string(max_level, "is_land", is_land, 1);
995  for (int lev = 0; lev <= max_level; ++lev) {
996  if (is_land[lev] == 1) {
997  amrex::Print() << "Level " << lev << " is land" << std::endl;
998  } else if (is_land[lev] == 0) {
999  amrex::Print() << "Level " << lev << " is water" << std::endl;
1000  } else {
1001  amrex::Error("is_land should be 0 or 1");
1002  }
1003  }
1004 
1005  // What type of radiation model to use
1006  rad_type = RadiationType::None; // Default
1007  pp.query_enum_case_insensitive("radiation_model", rad_type);
1008 
1009  // Verify that radiation model cannot be RRTMGP if ERF was not compiled with RRTMGP
1010 #ifndef ERF_USE_RRTMGP
1011  if (rad_type == RadiationType::RRTMGP)
1012  {
1013  amrex::Error("ERF was not compiled with RRTMGP enabled!");
1014  }
1015 #endif
1016 
1017  // Is the terrain none, static or moving?
1018  std::string terrain_type_temp = "";
1019  pp.queryAdd("terrain_type", terrain_type_temp);
1020  if (terrain_type_temp == "Moving") {
1021  amrex::Error("erf.terrain_type = Moving is no longer supported; please replace Moving by MovingFittedMesh");
1022  } else if (terrain_type_temp == "Static") {
1023  amrex::Error("erf.terrain_type = Static is no longer supported; please replace Static by StaticFittedMesh");
1024  } else {
1025  pp.query_enum_case_insensitive("terrain_type",terrain_type);
1026  }
1027 
1028  // Whether the terrain is flat - this allows planar averages (lsf, nudging) with StaticFittedMesh
1029  pp.queryAdd("flat_terrain", flat_terrain);
1030 
1031  // Get buildings type
1032  std::string buildings_type_temp = "";
1033  pp.queryAdd("buildings_type", buildings_type_temp);
1034  if (buildings_type_temp == "ImmersedForcing") {
1035  buildings_type = BuildingsType::ImmersedForcing;
1036  }
1037  pp.queryAdd("buildings_fc_factories", buildings_fc_factories);
1038 
1039  //
1040  // Read the init_type here to make sure we correctly set the mesh and terrain types
1041  //
1042  std::string init_type_temp_string;
1043 
1044  int found = pp.queryAdd("init_type",init_type_temp_string);
1045 
1046  if ( (init_type_temp_string == "Real") || (init_type_temp_string == "real") ) {
1047  amrex::Error("erf.init_type = Real is deprecated; please replace Real by WRFInput");
1048  } else if ( (init_type_temp_string == "Ideal") || (init_type_temp_string == "ideal") ) {
1049  amrex::Error("erf.init_type = Ideal is deprecated; please replace Ideal by WRFInput");
1050  } else {
1051  pp.query_enum_case_insensitive("init_type",init_type);
1052  use_real_bcs = ( (init_type == InitType::WRFInput) || (init_type == InitType::Metgrid) );
1053  }
1054 
1055  if ( (init_type == InitType::WRFInput) || (init_type == InitType::Metgrid) ) {
1056  if (terrain_type != TerrainType::StaticFittedMesh) {
1057  amrex::Error("Only terrain_type = StaticFittedMesh are allowed with init_type = WRFInput or Metgrid");
1058  }
1059  }
1060 
1061  if (init_type == InitType::MoistBaseState) {
1063  amrex::Error("Makes no sense to have moist base state with no moisture model");
1064  }
1065  }
1066 
1067  if (init_type == InitType::WRFInput) {
1069  amrex::Error("Can't have moisture_type = None with init_type = WRFInput");
1070  }
1071 
1072  // NetCDF wrfbdy lateral boundary file
1073  std::string nc_bdy_file_temp_string;
1074  bool has_bdy = pp.queryAdd("nc_bdy_file", nc_bdy_file_temp_string);
1075  if (!has_bdy) use_real_bcs = false;
1076 
1077  bool use_real_bcs_temp = use_real_bcs;
1078  pp.queryAdd("use_real_bcs", use_real_bcs_temp);
1079  if (use_real_bcs && !use_real_bcs_temp) {
1080  use_real_bcs = false;
1081  }
1082  }
1083 
1084  if (found == 0 || init_type == InitType::None) {
1085  amrex::Print() << "init_type must now be set. The options are " << std::endl;
1086  amrex::Print() << " Input_Sounding, NCFile, WRFInput, Metgrid, Uniform, " << std::endl;
1087  amrex::Print() << " ConstantDensity, Isentropic, MoistBaseState, or HindCast " << std::endl;
1088  amrex::Error("Please add a string for init_type to your inputs file or command line");
1089  }
1090 
1091  // How to interpret input_sounding
1092  if (init_type == InitType::Input_Sounding) {
1093  pp.query_enum_case_insensitive("sounding_type",sounding_type);
1094  }
1095 
1096  if (terrain_type == TerrainType::StaticFittedMesh ||
1097  terrain_type == TerrainType::MovingFittedMesh) {
1098  mesh_type = MeshType::VariableDz;
1099  }
1100 
1101  if (flat_terrain && terrain_type != TerrainType::StaticFittedMesh) {
1102  amrex::Error("erf.flat_terrain requires terrain_type = StaticFittedMesh");
1103  }
1104 
1105  // Refined levels over moving terrain are not supported: erf_substep_MT does not take the
1106  // fluxes through coarse/fine faces from the coarse level (cf_flux_history_active)
1107  if (terrain_type == TerrainType::MovingFittedMesh && max_level > 0) {
1108  amrex::Error("erf.terrain_type = MovingFittedMesh requires amr.max_level = 0");
1109  }
1110 
1111  // Immersed-forcing buildings need the terrain blanking that init_zphys builds, and
1112  // init_zphys returns before building it when the terrain is EB
1113  if (terrain_type == TerrainType::EB && buildings_type == BuildingsType::ImmersedForcing) {
1114  amrex::Error("erf.buildings_type = ImmersedForcing is not supported with erf.terrain_type = EB");
1115  }
1116 
1117  // Each surface builds its own EB index space, and the factories use only the last one
1118  // (the buildings), so the terrain would be dropped without warning (#5188)
1119  if (terrain_type == TerrainType::ImmersedForcing && buildings_type == BuildingsType::ImmersedForcing) {
1120  amrex::Error("erf.terrain_type = ImmersedForcing and erf.buildings_type = ImmersedForcing "
1121  "cannot be used together");
1122  }
1123 
1124  if ( (moisture_type == MoistureType::SAM ||
1125  moisture_type == MoistureType::SAM_NoIce ||
1126  moisture_type == MoistureType::SAM_NoPrecip_NoIce ) &&
1127  (mesh_type == MeshType::VariableDz) )
1128  {
1129  amrex::Abort("SAM is not correct with variable dz -- choose another moisture model");
1130  }
1131 
1132  // queryAdd puts the default in the table, so ask whether the ratio was given first
1133  const bool have_stretching_ratio = pp.contains("grid_stretching_ratio");
1134  pp.queryAdd("grid_stretching_ratio", grid_stretching_ratio);
1135  if (grid_stretching_ratio != 0) {
1137  "The grid stretching ratio must be greater than 1");
1138  }
1139  // erf.initial_dz on its own asks for the stretching ratio to be solved for, so that
1140  // a first layer that thick stretches geometrically to close on prob_hi[2]. An
1141  // explicit erf.grid_stretching_ratio = 0 still means no stretching at all.
1142  const bool solve_stretching_ratio = !have_stretching_ratio && pp.contains("initial_dz");
1143  if (grid_stretching_ratio >= 1 || solve_stretching_ratio) {
1145  terrain_type = TerrainType::StaticFittedMesh;
1146  }
1147  if (mesh_type == MeshType::ConstantDz) {
1148  mesh_type = MeshType::StretchedDz;
1149  }
1150  pp.get("initial_dz", dz0);
1151  }
1152 
1153  // The stretched levels start at geometry.prob_lo[2]; erf.zsurface used to set the
1154  // bottom separately, and a flat surface did not follow it (#4442)
1155  if (pp.contains("zsurface")) {
1156  amrex::Abort("erf.zsurface is no longer supported: a stretched vertical grid now starts "
1157  "at geometry.prob_lo[2], so set the bottom of the domain there instead");
1158  }
1159 
1160  int n_zlevels = pp.countval("terrain_z_levels");
1161  if (n_zlevels > 0)
1162  {
1164  terrain_type = TerrainType::StaticFittedMesh;
1165  }
1166  if (mesh_type == MeshType::ConstantDz) {
1167  mesh_type = MeshType::StretchedDz;
1168  }
1169  }
1170 
1171  // Use lagged_delta_rt in the fast integrator?
1172  pp.queryAdd("use_lagged_delta_rt", use_lagged_delta_rt);
1173 
1174  // Average the input z-face heights onto the nodes, or reconstruct our own
1175  pp.queryAdd("avg_grid_faces_to_nodes",avg_grid_faces_to_nodes);
1176 
1177  // Build the ERF vertical grid from the file's own mean layer-thickness profile,
1178  // or from a single geometric stretch anchored on the file's first layer?
1179  pp.queryAdd("wrfinput_zlevels_from_file",wrfinput_zlevels_from_file);
1180 
1181  // Catch the old name for the flag above so the error says what to do
1182  // rather than silently ignoring the setting.
1183  if (pp.contains("use_wrf_height_grid")) {
1184  amrex::Abort("erf.use_wrf_height_grid has been renamed. "
1185  "Set erf.avg_grid_faces_to_nodes instead; it carries "
1186  "the same meaning (average the input z-face heights "
1187  "onto the nodes rather than reconstructing them).");
1188  }
1189 
1190  // Interpolate atmospheric state from coarse level instead of reading from wrfinput
1191  // when creating a finer level from coarse at a later time?
1192  pp.queryAdd("interp_atmos_from_coarse", interp_atmos_from_coarse);
1193 
1194  // Rebalance wrf state?
1195  pp.queryAdd("rebalance_wrf_input", rebalance_wrf_input);
1196 
1197  // Must rebalance if the nodal heights were reconstructed rather than averaged
1199  amrex::Print() << "Must rebalance when not averaging the input height grid. Setting rebalance_wrf_input to true \n";
1200  rebalance_wrf_input = true;
1201  }
1202 
1203  // These default to true but are used for unit testing
1204  pp.queryAdd("use_gravity", use_gravity);
1205 
1206  // Initializing from Metgrid or WRFInput without gravity makes no sense
1207  if ( !use_gravity && ( (init_type == InitType::WRFInput) || (init_type == InitType::Metgrid) ) ) {
1208  amrex::Print() << "Setting use_gravity to true due to init_type = WRFInput / Metgrid " << std::endl;
1209  use_gravity = true;
1210  }
1211 
1213 
1214  pp.queryAdd("c_p", c_p);
1215  rdOcp = R_d / c_p;
1216 
1217  // *******************************************************************************
1218  // Read compressibility_type etc and over-ride if necessary
1219  // *******************************************************************************
1220 
1221  compressibility_type.resize(max_level+1);
1222  for (int i = 0; i <= max_level; ++i) {
1223  compressibility_type[i] = CompressibilityType::FullyCompressible;
1224  }
1225  if (pp.contains("compressibility_type") && pp.contains("anelastic")) {
1226  amrex::Abort("Specify only one of erf.compressibility_type and erf.anelastic "
1227  "(erf.anelastic is deprecated)");
1228  }
1229  if (pp.contains("anelastic")) {
1230  amrex::Print() << "WARNING: erf.anelastic is deprecated; use erf.compressibility_type"
1231  << " = FullyCompressible, Anelastic or PseudoIncompressible" << std::endl;
1232  amrex::Vector<int> anelastic;
1233  read_int_string(max_level, "anelastic", anelastic, 0);
1234  for (int i = 0; i <= max_level; ++i) {
1235  if (anelastic[i] != 0 && anelastic[i] != 1) {
1236  amrex::Abort("erf.anelastic must be 0 or 1");
1237  }
1238  compressibility_type[i] = (anelastic[i] != 0) ? CompressibilityType::Anelastic
1239  : CompressibilityType::FullyCompressible;
1240  }
1241  } else {
1242  for (int i = 0; i <= max_level; ++i) {
1244  pp, "compressibility_type", compressibility_type[i], i, max_level);
1245  }
1246  }
1247  const bool fixed_density_given =
1248  read_int_string(max_level, "fixed_density", fixed_density, 0);
1249  read_int_string(max_level, "project_initial_velocity", project_initial_velocity, 0);
1250 
1251  // The anelastic equations hold the density at its base-state value, so
1252  // fixed_density is forced to 1 at every anelastic level. The pseudo-incompressible
1253  // equations evolve the density (continuity equation) with the density-departure
1254  // buoyancy -(rho - rho0) g, so fixed_density is forced to 0 and buoyancy_type to 1 there.
1255  // A user value that disagrees is ignored, and we say so rather than drop it silently.
1256  bool any_anelastic = false;
1257  bool any_compress = false;
1258  for (int i = 0; i <= max_level; ++i) {
1259  if (compressibility_type[i] == CompressibilityType::Anelastic) {
1260  if (fixed_density_given && fixed_density[i] == 0) {
1261  amrex::Print() << "WARNING: erf.fixed_density = 0 is ignored at level " << i
1262  << " because erf.compressibility_type is Anelastic there; the anelastic"
1263  << " equations always hold the density fixed in time." << std::endl;
1264  }
1265  project_initial_velocity[i] = 1;
1266  fixed_density[i] = 1; // Always fixed when anelastic
1267  buoyancy_type[i] = 3; // (This isn't actually used when anelastic is set)
1268  any_anelastic = true;
1269  } else if (compressibility_type[i] == CompressibilityType::PseudoIncompressible) {
1270  if (fixed_density_given && fixed_density[i] == 1) {
1271  amrex::Print() << "WARNING: erf.fixed_density = 1 is ignored at level " << i
1272  << " because erf.compressibility_type is PseudoIncompressible there; the"
1273  << " pseudo-incompressible equations evolve the density." << std::endl;
1274  }
1275  if (buoyancy_type[i] != 1) {
1276  amrex::Print() << "WARNING: erf.buoyancy_type = " << buoyancy_type[i] << " is replaced by 1 at level "
1277  << i << " because erf.compressibility_type is PseudoIncompressible there; the"
1278  << " pseudo-incompressible buoyancy is -(rho - rho0) g." << std::endl;
1279  }
1280  project_initial_velocity[i] = 1;
1281  fixed_density[i] = 0; // The density evolves
1282  buoyancy_type[i] = 1; // -(rho - rho0) g
1283  any_anelastic = true;
1284  } else {
1285  any_compress = true;
1286  }
1287  }
1288 
1289  // Want to have different immersed forcing defaults depending on anelastic / pseudo-incompressible
1290  // (any_anelastic is true for either) or fully compressible.
1291  // We should have different starting values because the stability of the method is dependent on dt.
1292  // dt is coarser when the pressure comes from the projection (no acoustic substeps)
1293  // --> need to loosen stiffness of immersed forcing.
1294  if (any_anelastic) {
1295  immersed_forcing_substep = false;
1296  if_Cd_momentum = amrex::Real(50.0);
1297  if_Cd_scalar = amrex::Real(5.0);
1298  } else {
1299  immersed_forcing_substep = true;
1300  if_Cd_momentum = amrex::Real(500.0);
1301  if_Cd_scalar = amrex::Real(50.0);
1302  }
1303 
1304  // *******************************************************************************
1305  // Read timestepping_type and allow for different values at each level. The default
1306  // depends on the level's compressibility: RK3_ImplicitSubstep at a FullyCompressible
1307  // level, MidPoint otherwise.
1308  // *******************************************************************************
1309  timestepping_type.resize(max_level+1);
1310  for (int i = 0; i <= max_level; i++) {
1311  timestepping_type[i] = (compressibility_type[i] == CompressibilityType::FullyCompressible)
1312  ? TimesteppingType::RK3_ImplicitSubstep : TimesteppingType::MidPoint;
1313  }
1314 
1315  const bool substepping_type_given = pp.contains("substepping_type");
1316  const bool anelastic_type_given = pp.contains("anelastic_type");
1317  if (pp.contains("timestepping_type")) {
1318  if (substepping_type_given || anelastic_type_given) {
1319  amrex::Abort("Specify erf.timestepping_type or the deprecated erf.substepping_type / "
1320  "erf.anelastic_type, not both");
1321  }
1322  for (int i = 0; i <= max_level; i++) {
1324  pp, "timestepping_type", timestepping_type[i], i, max_level);
1325  }
1326  } else {
1327  // The deprecated inputs: erf.substepping_type applied only at FullyCompressible
1328  // levels and erf.anelastic_type only at the others
1329  if (substepping_type_given) {
1330  amrex::Print() << "WARNING: erf.substepping_type is deprecated; use erf.timestepping_type"
1331  << " = RK3_ImplicitSubstep or RK3_NoSubstepping" << std::endl;
1332  for (int i = 0; i <= max_level; i++) {
1333  SubsteppingType sub = SubsteppingType::Implicit;
1334  query_one_or_per_level_enum_case_insensitive(pp, "substepping_type", sub, i, max_level);
1335  if (compressibility_type[i] == CompressibilityType::FullyCompressible) {
1337  ? TimesteppingType::RK3_NoSubstepping
1338  : TimesteppingType::RK3_ImplicitSubstep;
1339  }
1340  }
1341  }
1342  if (anelastic_type_given) {
1343  amrex::Print() << "WARNING: erf.anelastic_type is deprecated; use erf.timestepping_type"
1344  << " = RK2 or MidPoint" << std::endl;
1345  if (!any_anelastic) {
1346  amrex::Print() << "Ignoring erf.anelastic_type because every level is FullyCompressible"
1347  << std::endl;
1348  }
1349  for (int i = 0; i <= max_level; i++) {
1350  AnelasticType anelastic_scheme = AnelasticType::MidPoint;
1351  query_one_or_per_level_enum_case_insensitive(pp, "anelastic_type", anelastic_scheme, i, max_level);
1352  if (compressibility_type[i] != CompressibilityType::FullyCompressible) {
1353  timestepping_type[i] = (anelastic_scheme == AnelasticType::MidPoint)
1354  ? TimesteppingType::MidPoint : TimesteppingType::RK2;
1355  }
1356  }
1357  }
1358  }
1359 
1360  // RK3_* are the FullyCompressible integrators and RK2 / MidPoint the others
1361  for (int i = 0; i <= max_level; i++) {
1362  const bool fc = (compressibility_type[i] == CompressibilityType::FullyCompressible);
1363  const bool rk3 = (timestepping_type[i] == TimesteppingType::RK3_ImplicitSubstep ||
1364  timestepping_type[i] == TimesteppingType::RK3_NoSubstepping);
1365  if (fc != rk3) {
1366  amrex::Abort("erf.timestepping_type at level " + std::to_string(i) + " must be " +
1367  (fc ? "RK3_ImplicitSubstep or RK3_NoSubstepping because the level is "
1368  "FullyCompressible"
1369  : "RK2 or MidPoint because the level is not FullyCompressible"));
1370  }
1371  }
1372 
1373  // A moving mesh is advanced only by the RK3 integrators (erf_substep_MT with
1374  // RK3_ImplicitSubstep, the update without substeps with RK3_NoSubstepping), which by the
1375  // check above are those of a FullyCompressible level
1376  if (terrain_type == TerrainType::MovingFittedMesh) {
1377  for (int i = 0; i <= max_level; i++) {
1378  if (compressibility_type[i] != CompressibilityType::FullyCompressible) {
1379  amrex::Abort("erf.terrain_type = MovingFittedMesh requires erf.timestepping_type = "
1380  "RK3_ImplicitSubstep or RK3_NoSubstepping (a FullyCompressible level) "
1381  "at level " + std::to_string(i));
1382  }
1383  }
1384  }
1385 
1386  pp.queryAdd("substepping_diag", substepping_diag);
1387 
1388  pp.queryAdd("beta_s", beta_s);
1389 
1390  // Divergence damping coefficient for the forward projection of (rho theta)
1391  pp.queryAdd("beta_d", beta_d);
1392  if (!(beta_d >= amrex::Real(0.0) && beta_d <= amrex::Real(1.0))) {
1393  amrex::Abort("erf.beta_d must lie in [0, 1]; got " + std::to_string(beta_d));
1394  }
1395 
1396  // Number of steps between the synchronization of the two copies of a periodic face
1397  // velocity (0 = never)
1398  pp.query("face_sync_int", face_sync_int);
1399 
1400  // Spatially varying beta_s on the w-faces (implicit substepping only), set from the
1401  // terrain slope and the vertical acoustic Courant number (see make_fast_coeffs).
1402  // If it is not given, it is turned on during the run on a terrain-fitted mesh where
1403  // beta_s is below the stability limit min(sigma^2, 1) (ERF::CheckVariableBetaS);
1404  // an explicit false keeps the constant beta_s
1405  auto_variable_beta_s = !pp.contains("use_variable_beta_s");
1406  pp.queryAdd("use_variable_beta_s", use_variable_beta_s);
1407 
1408  // *******************************************************************************
1409  // Error check on deprecated input
1410  // *******************************************************************************
1411  int nvals_old = pp.countval("no_substepping");
1412  if (nvals_old > 0) {
1413  amrex::Error("The no_substepping flag is deprecated -- set erf.timestepping_type instead");
1414  }
1415 
1416  nvals_old = pp.countval("beta_s_min");
1417  if (nvals_old > 0) {
1418  amrex::Error("The beta_s_min flag is deprecated -- remove it from the inputs file");
1419  }
1420  nvals_old = pp.countval("beta_s_max");
1421  if (nvals_old > 0) {
1422  amrex::Error("The beta_s_max flag is deprecated -- remove it from the inputs file");
1423  }
1424 
1425  pp.queryAdd("ncorr", ncorr);
1426  // Wall distance on a terrain-fitted mesh (RANS): "poisson" (Tucker 2003
1427  // differential-equation distance) or "terrain_height" (height above the
1428  // local surface projected on its normal, no linear solve)
1429  pp.queryAdd("wall_dist_type", wall_dist_type);
1430  if (wall_dist_type != "poisson" && wall_dist_type != "terrain_height") {
1431  amrex::Error("erf.wall_dist_type must be poisson or terrain_height");
1432  }
1433  pp.queryAdd("poisson_abstol", poisson_abstol);
1434  pp.queryAdd("pi_drift_factor", pi_drift_factor);
1435  if (pi_drift_factor < zero) {
1436  amrex::Abort("erf.pi_drift_factor must be non-negative");
1437  }
1438  pp.queryAdd("poisson_reltol", poisson_reltol);
1439  // Solver for the projection on a terrain-fitted mesh: FFT-preconditioned GMRES (default),
1440  // or amrex::MLTerrainPoisson with multigrid, alone or under GMRES
1441  pp.query_enum_case_insensitive("terrain_poisson_solver", terrain_poisson_solver);
1442  if (pp.contains("terrain_poisson_solver") &&
1443  (mesh_type != MeshType::VariableDz || terrain_type == TerrainType::EB)) {
1444  amrex::Print() << "WARNING: erf.terrain_poisson_solver is ignored: it applies only to the "
1445  << "projection on a terrain-fitted mesh (erf.terrain_type = StaticFittedMesh "
1446  << "or MovingFittedMesh)" << std::endl;
1447  }
1448 #ifdef AMREX_USE_FLOAT
1449  poisson_abstol = amrex::max(poisson_abstol,amrex::Real(1e-6));
1450  poisson_reltol = amrex::max(poisson_reltol,amrex::Real(1e-6));
1451 #endif
1452  pp.queryAdd("force_stage1_single_substep", force_stage1_single_substep);
1453 
1454  // Include Coriolis forcing?
1455  pp.queryAdd("use_coriolis", use_coriolis);
1456  pp.queryAdd("variable_coriolis", variable_coriolis);
1457 
1458  // Include four stream radiation approximation
1459  pp.queryAdd("four_stream_radiation", four_stream_radiation);
1460 
1461  // flags for whether to apply other source terms in substep only
1462  pp.queryAdd("immersed_forcing_substep", immersed_forcing_substep); // apply immersed forcing source terms in substep only
1463  pp.queryAdd("forest_substep", forest_substep); // apply canopy-related source terms in substep only
1464 
1465  // Fixed-leaf-temperature canopy heat exchange
1466  pp.query("forest_biophysics", forest_biophysics);
1467  pp.query("forest_biophysics_heat", forest_biophysics_heat);
1468  pp.query("forest_leaf_theta_fixed", forest_leaf_theta_fixed);
1469 
1472  "forest_biophysics_heat requires forest_biophysics = true");
1476  "forest_biophysics_heat requires a positive forest_leaf_theta_fixed");
1479  "forest_leaf_theta_fixed requires forest_biophysics_heat = true");
1480 
1481  // Canopy terms of the k-eqn RANS model (erf.forest_canopy_*); the
1482  // checks that need the forest and the turbulence model are in
1483  // ERF::ReadParameters, once both are known
1485 
1486  // immersed forcing parameters
1487  pp.queryAdd("if_Cd_momentum", if_Cd_momentum);
1488  pp.queryAdd("if_Cd_scalar", if_Cd_scalar);
1489  pp.queryAdd("if_implicit_drag", if_implicit_drag); // flag for implicit vs. explicit drag formulation
1490  pp.queryAdd("if_z0", if_z0);
1491  pp.queryAdd("if_surf_temp_flux", if_surf_temp_flux);
1492  pp.queryAdd("if_init_surf_temp", if_init_surf_temp);
1493 
1494  pp.queryAdd("if_surf_heating_rate", if_surf_heating_rate);
1495 
1496  // Modify rate to be in units of K / s rather than K / hr
1497  if_surf_heating_rate /= amrex::Real(3600.0); // [K/s]
1498 
1499  pp.queryAdd("if_Olen", if_Olen_in);
1500  pp.queryAdd("if_surf_moist_flux", if_surf_moist_flux);
1501  pp.queryAdd("if_surf_moist", if_surf_moist);
1502  pp.queryAdd("if_use_most",if_use_most);
1503  pp.queryAdd("if_snap_partial_cells",if_snap_partial_cells);
1504  // The snapped staircase puts full-strength forcing on every wall face,
1505  // whose explicit relaxation rate (Cd / dx per substep) sits at the
1506  // stability limit and fails where faces stack at rims and corners; the
1507  // point-implicit form holds at any rate, so the snap uses it.
1509  amrex::Print() << "erf.if_snap_partial_cells: using the point-implicit drag (erf.if_implicit_drag = true)\n";
1510  if_implicit_drag = true;
1511  }
1512  pp.queryAdd("if_stability_correction",if_stability_correction);
1513 
1514  // Wall law of the terrain immersed forcing (erf-model/ERF#4134): "legacy" (the default)
1515  // relaxes the top partial cell toward the log law at fixed 0.5/1.5 dz;
1516  // "fraction_stress" applies the wall stress of ERF_ImmersedWallCell.H in the wall cell
1517  // and closes the wall face to diffusion (form 7 of the kynema-sgf immersed terrain)
1518  std::string if_wall_form_in = "legacy";
1519  pp.queryAdd("if_wall_form", if_wall_form_in);
1520  if (if_wall_form_in == "fraction_stress") {
1521  if_fraction_stress = true;
1522  } else if (if_wall_form_in != "legacy") {
1523  amrex::Abort("erf.if_wall_form must be legacy or fraction_stress, not " + if_wall_form_in);
1524  }
1525  // Spacing of the face above the wall cell (fraction_stress only): "log" (default) gives
1526  // that face the relative error of flat ground's first interior face for a log profile,
1527  // "physical" the centroid spacing, "grid" the cell height (ib_wall::face_above_factor)
1528  // (the keys below are accepted at their default values with the legacy law, so one deck
1529  // can run both laws; any other value belongs to fraction_stress)
1530  std::string if_wall_face_spacing_in = "log";
1531  pp.queryAdd("if_wall_face_spacing", if_wall_face_spacing_in);
1532  if (if_wall_face_spacing_in != "log" && !if_fraction_stress) {
1533  amrex::Abort("erf.if_wall_face_spacing belongs to erf.if_wall_form = fraction_stress");
1534  }
1535  if (if_wall_face_spacing_in == "grid") { if_wall_face_spacing = 0; }
1536  else if (if_wall_face_spacing_in == "physical") { if_wall_face_spacing = 1; }
1537  else if (if_wall_face_spacing_in == "log") { if_wall_face_spacing = 2; }
1538  else { amrex::Abort("erf.if_wall_face_spacing must be log, physical or grid"); }
1539  // Wall value of the k-eqn TKE in the fraction-stress wall cell, (u*^3 + kappa B d1)^(2/3)
1540  // / Cmu0^2 (the value erf.dirichlet_k holds over flat ground): with a time factor of 1
1541  // (the default) the wall cell is held at it after every stage and in the implicit TKE
1542  // solve, as flat ground is; a larger factor relaxes toward it as a source over that many
1543  // steps (the kynema-sgf form)
1544  pp.queryAdd("if_wall_tke", if_wall_tke);
1545  pp.queryAdd("if_wall_tke_time_factor", if_wall_tke_time_factor);
1547  amrex::Abort("erf.if_wall_tke = true and erf.if_wall_tke_time_factor != 1 belong to erf.if_wall_form = fraction_stress");
1548  }
1549  if (!(if_wall_tke_time_factor >= one)) {
1550  amrex::Abort("erf.if_wall_tke_time_factor must be >= 1 (steps over which the wall TKE is relaxed)");
1551  }
1552  // Partial wall cells of the fraction-stress law dissipate TKE with the length scale of flat
1553  // ground's first cell (kynema-sgf KLAxell.flat_wall_dissipation); on by default with it.
1554  // query, not queryAdd: the default depends on erf.if_wall_form, so storing it would make a
1555  // later init_params in the same process (the unit tests) see it as given (cf. #4940)
1557  pp.query("if_flat_wall_dissipation", if_flat_wall_dissipation);
1559  amrex::Abort("erf.if_flat_wall_dissipation = true belongs to erf.if_wall_form = fraction_stress");
1560  }
1561  if (if_fraction_stress) {
1562  if (terrain_type != TerrainType::ImmersedForcing) {
1563  amrex::Abort("erf.if_wall_form = fraction_stress needs erf.terrain_type = ImmersedForcing");
1564  }
1565  if (buildings_type == BuildingsType::ImmersedForcing) {
1566  amrex::Abort("erf.if_wall_form = fraction_stress is not available with erf.buildings_type = ImmersedForcing");
1567  }
1568  if (!if_use_most) {
1569  amrex::Abort("erf.if_wall_form = fraction_stress is a wall law: it needs erf.if_use_most = true");
1570  }
1571  if (mesh_type != MeshType::ConstantDz) {
1572  amrex::Abort("erf.if_wall_form = fraction_stress needs a constant-dz mesh");
1573  }
1574  // The wall heat flux and the wall TKE are written by the slow scalar source; the
1575  // compressible fast substep (erf.immersed_forcing_substep) does not carry them
1577  amrex::Abort("erf.if_wall_form = fraction_stress runs only where erf.compressibility_type is not FullyCompressible on "
1578  "every level; it does not support erf.immersed_forcing_substep = true");
1579  }
1580  // ... and the solid cells are held (rho, theta, the moisture species) by the update of an
1581  // anelastic or pseudo-incompressible level only
1582  for (int lev = 0; lev <= max_level; ++lev) {
1583  if (compressibility_type[lev] == CompressibilityType::FullyCompressible) {
1584  amrex::Abort("erf.if_wall_form = fraction_stress needs erf.compressibility_type not FullyCompressible on every level (level " +
1585  std::to_string(lev) + " is compressible)");
1586  }
1587  }
1588  // One surface condition (heat flux, surface temperature - optionally changing at
1589  // erf.if_surf_heating_rate - or Obukhov length; none is neutral, checked below); the
1590  // MOST stability functions always apply, as on the flat surface layer, so
1591  // erf.if_stability_correction (a legacy switch) must not be set
1593  amrex::Abort("erf.if_surf_heating_rate needs erf.if_init_surf_temp");
1594  }
1596  amrex::Abort("erf.if_wall_form = fraction_stress always applies the stability functions; "
1597  "erf.if_stability_correction is for the legacy wall law");
1598  }
1599  }
1600  // Surface moisture condition of the fraction-stress law: a given kinematic moisture flux or
1601  // a given surface mixing ratio (not both), as erf.most.surf_moist_flux / erf.most.surf_moist
1602  // on flat ground; it needs a moisture model that carries water vapor (the wall cell's qv
1603  // and the cell above's enter q* and the Obukhov length)
1604  {
1605  const bool moist_flux_set = (if_surf_moist_flux != zero);
1606  const bool moist_surf_set = (if_surf_moist >= zero);
1607  if (moist_flux_set || moist_surf_set) {
1608  if (!if_fraction_stress) {
1609  amrex::Abort("erf.if_surf_moist_flux and erf.if_surf_moist belong to erf.if_wall_form = fraction_stress");
1610  }
1611  if (moist_flux_set && moist_surf_set) {
1612  amrex::Abort("erf.if_surf_moist_flux and erf.if_surf_moist: give one surface moisture condition, not both");
1613  }
1615  amrex::Abort("erf.if_surf_moist_flux / erf.if_surf_moist need a moisture model that carries water vapour "
1616  "(erf.moisture_model)");
1617  }
1618  if (!(std::abs(if_surf_moist_flux) <= amrex::Real(0.01))) {
1619  amrex::Abort("erf.if_surf_moist_flux must be in [-0.01, 0.01] kg/kg m/s (a kinematic surface moisture flux; "
1620  "0.0001 is a strong evaporation)");
1621  }
1622  if (moist_surf_set && !(if_surf_moist <= amrex::Real(0.1))) {
1623  amrex::Abort("erf.if_surf_moist must be in [0, 0.1] kg/kg (a surface water vapour mixing ratio)");
1624  }
1625  }
1626  }
1627  // The wall laws that evaluate the stability functions (the legacy law with
1628  // erf.if_stability_correction, the fraction_stress law) take the surface layer's
1629  // similarity functions (the unqualified erf.most.stable_functions, erf.most.qnse_*);
1630  // read here because an immersed run need not have a surface-layer boundary
1632  most_sfuns = read_most_similarity_funs(pp, "Immersed wall law");
1633  }
1634  pp.queryAdd("if_ws_floor",if_ws_floor);
1635  pp.queryAdd("if_damp_alpha",if_damp_alpha);
1636  // Opt-in WRF-style bounds on the wall law (erf-model/ERF#4016): the wind floor behind the
1637  // friction velocity of its stability estimate, and the cap on psi_m in the momentum law as
1638  // a fraction of ln(z/z0); 0 and 1 (the defaults) turn them off
1639  pp.queryAdd("if_stability_wind_floor",if_stability_wind_floor);
1640  pp.queryAdd("if_psi_cap_factor",if_psi_cap_factor);
1641  if (!(if_stability_wind_floor >= zero)) {
1642  amrex::Abort("erf.if_stability_wind_floor must be >= 0 [m/s] (0 leaves the wind as it is)");
1643  }
1644  if (!(if_psi_cap_factor > zero && if_psi_cap_factor <= one)) {
1645  amrex::Abort("erf.if_psi_cap_factor must be in (0, 1] (1 caps psi at ln(z/z0))");
1646  }
1647  // The cell average down over immersed-forcing levels (erf-model/ERF#4918): the plain
1648  // average (the default), or one weighted by the fluid mass of the fine cells
1649  pp.queryAdd("if_average_down", if_average_down);
1650  if (if_average_down != "plain" && if_average_down != "fluid_mass") {
1651  amrex::Abort("erf.if_average_down must be plain or fluid_mass");
1652  }
1653  // (queryAdd puts the default into the table, so the test is on the value, not on contains)
1654  if (if_average_down == "fluid_mass" &&
1655  terrain_type != TerrainType::ImmersedForcing && buildings_type != BuildingsType::ImmersedForcing)
1656  {
1657  amrex::Abort("erf.if_average_down = fluid_mass needs erf.terrain_type = ImmersedForcing "
1658  "or erf.buildings_type = ImmersedForcing");
1659  }
1660  // Warn at start-up where a lateral coarse/fine boundary crosses the immersed surface so
1661  // that the levels disagree: spread of the fine solid fractions under a coarse edge cell
1662  // at least this (0 turns the check off)
1663  pp.queryAdd("if_cf_mismatch_warning", if_cf_mismatch_warning);
1665  amrex::Abort("erf.if_cf_mismatch_warning must be in [0, 1] (a spread of solid fractions; 0 turns it off)");
1666  }
1667  // Log-law share of the wall coarse face's flux among its fine sub-faces at the lateral
1668  // coarse/fine faces (erf-model/ERF#4920): the immersed surface or a surface-layer bottom
1669  // (checked in check_params); constant dz, not EB terrain. The roughness length defaults
1670  // to erf.if_z0 with immersed forcing and to the inputs' erf.most.z0 or erf.zlo.most.z0
1671  // (0.1 m when neither is given) otherwise.
1672  pp.queryAdd("cf_loglaw_fill", cf_loglaw_fill);
1673  const bool z0_given = pp.query("cf_loglaw_z0", cf_loglaw_z0);
1674  if (z0_given && !cf_loglaw_fill) {
1675  amrex::Abort("erf.cf_loglaw_z0 belongs to erf.cf_loglaw_fill = true");
1676  }
1677  if (cf_loglaw_fill) {
1678  if (mesh_type != MeshType::ConstantDz) {
1679  amrex::Abort("erf.cf_loglaw_fill needs a constant-dz mesh");
1680  }
1681  if (terrain_type == TerrainType::EB) {
1682  amrex::Abort("erf.cf_loglaw_fill is not implemented for erf.terrain_type = EB "
1683  "(its wall is not the bottom of the domain)");
1684  }
1685  if (!z0_given) {
1686  if (terrain_type == TerrainType::ImmersedForcing || buildings_type == BuildingsType::ImmersedForcing) {
1687  cf_loglaw_z0 = if_z0;
1688  } else {
1689  // the roughness given in the inputs for the bottom surface layer
1690  // (erf.most.z0, or erf.zlo.most.z0 when the faces are set one by one); a
1691  // roughness a land model supplies later is not seen here
1692  cf_loglaw_z0 = amrex::Real(0.1);
1693  pp.query("most.z0", cf_loglaw_z0);
1694  pp.query("zlo.most.z0", cf_loglaw_z0);
1695  }
1696  }
1697  if (!(cf_loglaw_z0 > zero)) {
1698  amrex::Abort("erf.cf_loglaw_z0 must be > 0 [m] (the roughness length of the log-law coarse/fine fill)");
1699  }
1700  }
1701  // Say so when a bound is set and the wall law's stability estimate is in use
1702  if ((terrain_type == TerrainType::ImmersedForcing || buildings_type == BuildingsType::ImmersedForcing) &&
1703  (if_use_most || if_surf_temp_flux != amrex::Real(1e-8) || if_Olen_in != amrex::Real(1e-8)) &&
1704  (if_psi_cap_factor < one || if_stability_wind_floor > zero))
1705  {
1706  amrex::Print() << "Immersed wall law: erf.if_psi_cap_factor = " << if_psi_cap_factor
1707  << ", erf.if_stability_wind_floor = " << if_stability_wind_floor
1708  << " m/s (WRF-style bounds; the defaults 1 and 0 turn them off)\n";
1709  }
1710 
1711  if ((if_init_surf_temp > zero && if_surf_temp_flux != amrex::Real(1e-8)) ||
1712  (if_init_surf_temp > zero && if_Olen_in != amrex::Real(1e-8)) ||
1713  (if_Olen_in != amrex::Real(1e-8) && if_surf_temp_flux != amrex::Real(1e-8)))
1714  {
1715  amrex::Error("Can only specify one of init_surf_temp, surf_temp_flux, or Olen");
1716  }
1717  if (if_Olen_in == zero &&
1718  (terrain_type == TerrainType::ImmersedForcing || buildings_type == BuildingsType::ImmersedForcing)) {
1719  amrex::Abort("erf.if_Olen = 0 is not an Obukhov length: give a nonzero length [m] (a large |L| is near neutral)");
1720  }
1721 
1722  // The immersed forcing's "almost fluid" threshold (erf-model/ERF#4226). It is recorded
1723  // under eb2.small_volfrac here, in ReadParameters, before ERF::initializeEB runs, so the
1724  // EB build (which covers cells below it), the blanking and the forcing kernels all use
1725  // the same value, and a deck without the key gets 0.005 rather than AMReX's 1e-14.
1726  if (terrain_type == TerrainType::ImmersedForcing || buildings_type == BuildingsType::ImmersedForcing) {
1727  amrex::ParmParse pp_eb2("eb2");
1728  pp_eb2.queryAdd("small_volfrac", if_small_volfrac);
1729  if (!(if_small_volfrac >= zero && if_small_volfrac < one)) {
1730  amrex::Abort("eb2.small_volfrac must be in [0, 1) with immersed forcing");
1731  }
1732  }
1733 
1734  // Implicit drag of the immersed forcing inside the projection (erf-model/ERF#4919
1735  // for terrain, #4887 for buildings): each face momentum becomes (m* - grad phi) / (1 + dt rate),
1736  // with rate the drag rate of the source term on that face, and the solid is not frozen
1737  // afterwards, so the projected field stays divergence free in the solid too
1738  pp.queryAdd("if_implicit_projection", if_implicit_projection);
1739  if (if_implicit_projection) {
1740  const bool if_terrain = (terrain_type == TerrainType::ImmersedForcing);
1741  const bool if_buildings = (buildings_type == BuildingsType::ImmersedForcing);
1742  if (!if_terrain && !if_buildings) {
1743  amrex::Abort("erf.if_implicit_projection needs erf.terrain_type = ImmersedForcing or "
1744  "erf.buildings_type = ImmersedForcing");
1745  }
1746  if (mesh_type == MeshType::VariableDz) {
1747  amrex::Abort("erf.if_implicit_projection needs a mesh without terrain-fitted coordinates "
1748  "(constant or stretched dz)");
1749  }
1750  // The drag is inside the projection on the levels that project; a FullyCompressible
1751  // level has no projection and keeps the drag in the momentum source (if_drag_in_projection)
1752  bool any_projecting_level = false;
1753  for (int lev = 0; lev <= max_level; ++lev) {
1754  if (compressibility_type[lev] != CompressibilityType::FullyCompressible) {
1755  any_projecting_level = true;
1756  }
1757  }
1758  if (!any_projecting_level) {
1759  amrex::Abort("erf.if_implicit_projection needs erf.compressibility_type not FullyCompressible on at least one level");
1760  }
1761  }
1762 
1763  // Flag to do MOST rotations with terrain
1764  pp.queryAdd("use_rotate_surface_flux",use_rotate_surface_flux);
1766  AMREX_ASSERT_WITH_MESSAGE(terrain_type != TerrainType::None,"MOST stress rotations are only valid with terrain!");
1767  }
1768 
1769  // Which external forcings?
1770  abl_driver_type = ABLDriverType::None; // Default: no ABL driver for simulating classical fluid dynamics problems
1771  pp.query_enum_case_insensitive("abl_driver_type",abl_driver_type);
1772  pp.queryAdd("const_massflux_u", const_massflux_u);
1773  pp.queryAdd("const_massflux_v", const_massflux_v);
1774  pp.queryAdd("const_massflux_tau", const_massflux_tau);
1775  // The control divides by tau; tau <= 0 gives no source or one that drives the flow
1776  // away from the target
1777  if (!(const_massflux_tau > amrex::Real(0))) {
1778  amrex::Abort("erf.const_massflux_tau must be > 0 (got " +
1779  std::to_string(const_massflux_tau) + ")");
1780  }
1781  pp.queryAdd("const_massflux_layer_lo", const_massflux_layer_lo);
1782  pp.queryAdd("const_massflux_layer_hi", const_massflux_layer_hi);
1783 
1784  // Which type of inflow turbulent generation
1785  // Real-data initialization uses parent controls unless explicitly overridden.
1786  perturbation_auto = (init_type == InitType::WRFInput || init_type == InitType::Metgrid);
1787  pp.queryAdd("perturbation_auto", perturbation_auto);
1788  pp.queryAdd("perturbation_auto_period", perturbation_auto_period);
1789  pp.queryAdd("perturbation_auto_pbl_fraction", perturbation_auto_pbl_fraction);
1790  if (perturbation_auto &&
1791  (!(perturbation_auto_period > zero) || !std::isfinite(perturbation_auto_period) ||
1793  amrex::Abort("Automatic perturbations require perturbation_auto_period > 0 and "
1794  "0 < perturbation_auto_pbl_fraction <= 1");
1795  }
1796  pert_type.resize(max_level+1);
1797  for (int lev = 0; lev <= max_level; ++lev) {
1798  pert_type[lev] = PerturbationType::None; // Default
1800  pp, "perturbation_type", pert_type[lev], lev, max_level);
1801  }
1802 
1803  amrex::Vector<amrex::Real> abl_pressure_grad_in = {zero, zero, zero};
1804  pp.queryarr("abl_pressure_grad",abl_pressure_grad_in);
1805  for(int i = 0; i < AMREX_SPACEDIM; ++i) abl_pressure_grad[i] = abl_pressure_grad_in[i];
1806 
1807  amrex::Vector<amrex::Real> abl_geo_forcing_in = {zero, zero, zero};
1808  if(pp.queryarr("abl_geo_forcing",abl_geo_forcing_in)) {
1809  amrex::Print() << "Specified abl_geo_forcing: (";
1810  for (int i = 0; i < AMREX_SPACEDIM; ++i) {
1811  abl_geo_forcing[i] = abl_geo_forcing_in[i];
1812  amrex::Print() << abl_geo_forcing[i] << " ";
1813  }
1814  amrex::Print() << ")" << std::endl;
1815  }
1816 
1817  if (use_coriolis)
1818  {
1820  }
1821 
1822  pp.queryAdd("add_custom_rhotheta_forcing", custom_rhotheta_forcing);
1823  pp.queryAdd("add_custom_moisture_forcing", custom_moisture_forcing);
1824  pp.queryAdd("add_custom_w_subsidence", custom_w_subsidence);
1825  pp.queryAdd("add_do_theta_advection", do_theta_advection); // If true, apply custom subsidence to (rho*theta) when add_custom_w_subsidence is used
1826  pp.queryAdd("add_do_mom_advection", do_mom_advection); // If true, apply custom subsidence to momentum when add_custom_w_subsidence is used
1827  pp.queryAdd("add_custom_geostrophic_profile", custom_geostrophic_profile);
1828  pp.queryAdd("custom_forcing_uses_primitive_vars", custom_forcing_prim_vars);
1829  pp.queryAdd("spatial_rhotheta_forcing", spatial_rhotheta_forcing);
1830  pp.queryAdd("spatial_moisture_forcing", spatial_moisture_forcing);
1831 
1832  pp.queryAdd("nudging_from_input_sounding", nudging_from_input_sounding);
1833 
1834  // Nudging towards observations at stations; the stations and the
1835  // parameters are read by the ObsNudging class, under erf.obs_nudging
1836  pp.queryAdd("nudging_from_observations", nudging_from_observations);
1837  if (nudging_from_observations && terrain_type == TerrainType::EB) {
1838  amrex::Abort("erf.nudging_from_observations does not support erf.terrain_type = EB; "
1839  "use a terrain-fitted mesh or immersed forcing");
1840  }
1841 
1842  int nudging_u_z1_set = pp.queryAdd("nudging_u_z1", nudging_u_z1);
1843  int nudging_u_z2_set = pp.queryAdd("nudging_u_z2", nudging_u_z2);
1844  pp.queryAdd("nudging_t_z1", nudging_t_z1);
1845  pp.queryAdd("nudging_t_z2", nudging_t_z2);
1846  pp.queryAdd("nudging_q_z1", nudging_q_z1);
1847  pp.queryAdd("nudging_q_z2", nudging_q_z2);
1848 
1850  "nudging_u_z1 must be less than or equal to nudging_u_z2");
1852  "nudging_t_z1 must be less than or equal to nudging_t_z2");
1854  "nudging_q_z1 must be less than or equal to nudging_q_z2");
1855 
1856  pp.queryAdd("nudging_u", nudging_u);
1857  pp.queryAdd("nudging_t", nudging_t);
1858  pp.queryAdd("nudging_q", nudging_q);
1859 
1860  pp.queryAdd("large_scale_forcing", large_scale_forcing);
1861 
1863  if (!nudging_u) {
1864  amrex::Print() << "WARNING: erf.nudging_u = false has no effect when erf.large_scale_forcing "
1865  "= true; momentum nudging is then controlled solely by large_scale_forcing.\n";
1866  }
1867  if (nudging_u_z1_set || nudging_u_z2_set) {
1868  amrex::Print() << "WARNING: erf.nudging_u_z1/erf.nudging_u_z2 are ignored when "
1869  "erf.large_scale_forcing = true; momentum nudging is then applied "
1870  "at all heights.\n";
1871  }
1872  }
1873 
1876  "Should not have both abl_geo_wind_table and custom_geostrophic_profile set.");
1877 
1878  pp.queryAdd("Ave_Plane", ave_plane);
1879 
1880  // Use numerical diffusion?
1881  // The 6th-order numerical diffusion is deactivated until its known issues are resolved;
1882  // a nonzero coefficient aborts rather than being silently ignored. To restore it, bring
1883  // back the [0, 1] range check, use_num_diff = (num_diff_coeff > 0) and the 2^-6 scaling
1884  // of num_diff_coeff that this block had before erf-model/ERF#5246.
1885  pp.queryAdd("num_diff_coeff",num_diff_coeff);
1887  "erf.num_diff_coeff must be 0: the 6th-order numerical diffusion is currently "
1888  "deactivated. Remove erf.num_diff_coeff or set it to 0.");
1889  use_num_diff = false;
1890 
1891  advChoice.init_params(pp_prefix);
1892  diffChoice.init_params(pp_prefix);
1893  dampingChoice.init_params(pp_prefix);
1894  spongeChoice.init_params(pp_prefix);
1895 
1896  // A level with thin immersed bodies is projected by project_velocity_tb, which has no
1897  // drag coefficient, while erf.if_implicit_projection takes the drag out of the momentum
1898  // source and leaves the solid faces unfrozen: the immersed solid would get no drag at all
1900  amrex::Abort("erf.if_implicit_projection is not supported with thin immersed bodies "
1901  "(erf.zero_xflux_faces, erf.zero_yflux_faces, erf.zero_zflux_faces): "
1902  "set erf.if_implicit_projection = false or remove the thin bodies");
1903  }
1904 
1905  // project_velocity_tb solves the constant-coefficient (anelastic) Poisson equation; it has
1906  // no beta = rho0 theta0 / rho, so it would not enforce the pseudo-incompressible constraint
1908  for (int lev = 0; lev <= max_level; ++lev) {
1909  if (compressibility_type[lev] == CompressibilityType::PseudoIncompressible) {
1910  amrex::Abort("Thin immersed bodies (erf.zero_xflux_faces, erf.zero_yflux_faces, "
1911  "erf.zero_zflux_faces) are not supported with "
1912  "erf.compressibility_type = PseudoIncompressible (level " +
1913  std::to_string(lev) + ")");
1914  }
1915  }
1916  }
1917 
1918  // EB advection (EBAdvectionSrcForScalars, EBAdvectionSrcForMom) has only the centered and
1919  // upwind schemes; with any other the fluxes are never set and, in a Release build, the
1920  // fields are not advected at all. The moist scalars default to WENO3, so they are checked
1921  // only when they are advected.
1922  bool any_projection = false;
1923  if (terrain_type == TerrainType::EB) {
1924  auto eb_supports = [] (AdvType t) {
1925  return (t == AdvType::Centered_2nd || t == AdvType::Upwind_3rd ||
1928  };
1929  auto check_eb_adv = [&] (const std::string& name, AdvType t) {
1930  if (!eb_supports(t)) {
1931  amrex::Abort("erf." + name + " = " + advChoice.adv_type_convert_int_to_string(t) +
1932  " is not supported with erf.terrain_type = EB; use Centered_2nd, "
1933  "Upwind_3rd, Centered_4th, Upwind_5th or Centered_6th");
1934  }
1935  };
1936  check_eb_adv("dycore_horiz_adv_type", advChoice.dycore_horiz_adv_type);
1937  check_eb_adv("dycore_vert_adv_type", advChoice.dycore_vert_adv_type);
1938  check_eb_adv("dryscal_horiz_adv_type", advChoice.dryscal_horiz_adv_type);
1939  check_eb_adv("dryscal_vert_adv_type", advChoice.dryscal_vert_adv_type);
1941  check_eb_adv("moistscal_horiz_adv_type", advChoice.moistscal_horiz_adv_type);
1942  check_eb_adv("moistscal_vert_adv_type", advChoice.moistscal_vert_adv_type);
1943  }
1944 
1945  // Covering zero-area faces is required if any level projects every step
1946  for (int lev = 0; lev <= max_level; ++lev) {
1947  any_projection |= (compressibility_type[lev] != CompressibilityType::FullyCompressible);
1948  }
1949  }
1950  ebChoice.init_params(pp_prefix, any_projection);
1951 
1952  // SlowImplicit damps w implicitly in the update of a level without acoustic substeps; a
1953  // level with substeps has FastImplicit for that
1955  for (int lev = 0; lev <= max_level; ++lev) {
1956  if (level_substeps(lev)) {
1957  amrex::Abort("erf.rayleigh_damping_type = SlowImplicit needs a level without acoustic"
1958  " substeps (anelastic, pseudo-incompressible or RK3_NoSubstepping); level " +
1959  std::to_string(lev) + " takes them: use FastImplicit");
1960  }
1961  }
1962  }
1963 
1964  // A level that takes no acoustic substeps applies these terms on the slow step instead
1965  // (level_substeps); say so when they were asked for
1966  for (int lev = 0; lev <= max_level; ++lev) {
1967  if (level_substeps(lev)) { continue; }
1970  amrex::Print() << "Level " << lev << " takes no acoustic substeps: Rayleigh damping is"
1971  << " applied on the slow step there" << std::endl;
1972  }
1973  if (forest_substep) {
1974  amrex::Print() << "Level " << lev << " takes no acoustic substeps: erf.forest_substep is"
1975  << " ignored there and canopy drag is applied on the slow step" << std::endl;
1976  }
1977  if (immersed_forcing_substep && pp.contains("immersed_forcing_substep")) {
1978  amrex::Print() << "Level " << lev << " takes no acoustic substeps: erf.immersed_forcing_substep"
1979  << " is ignored there and immersed forcing is applied on the slow step" << std::endl;
1980  }
1981  }
1982 
1983  turbChoice.resize(max_level+1);
1984  for (int lev = 0; lev <= max_level; lev++) {
1985  turbChoice[lev].init_params(lev,max_level,pp_prefix);
1986  // the moist TKE buoyancy of the k-eqn RANS reads the water vapor and its flux
1987  if (turbChoice[lev].rans_moist_buoyancy &&
1989  amrex::Abort("erf.rans_moist_buoyancy needs a moisture model that carries water vapour "
1990  "(erf.moisture_model; level " + std::to_string(lev) + ")");
1991  }
1992  // the log-consistent shear of the k-eqn RANS assumes the log law of the ground below
1993  // the cell: not with a cut-cell or immersed surface, nor with thin immersed bodies
1994  if (turbChoice[lev].rans_shear_stencil == RANSShearStencil::log_law) {
1995  if (terrain_type == TerrainType::EB || terrain_type == TerrainType::ImmersedForcing ||
1996  buildings_type == BuildingsType::ImmersedForcing) {
1997  amrex::Abort("erf.rans_shear_stencil = log_law is not available with erf.terrain_type = EB or "
1998  "ImmersedForcing or erf.buildings_type = ImmersedForcing");
1999  }
2000  // the wall distance is that of the initial mesh, the height differences move
2001  if (terrain_type == TerrainType::MovingFittedMesh) {
2002  amrex::Abort("erf.rans_shear_stencil = log_law is not available with erf.terrain_type = "
2003  "MovingFittedMesh");
2004  }
2006  amrex::Abort("erf.rans_shear_stencil = log_law is not available with thin immersed bodies "
2007  "(erf.zero_xflux_faces, erf.zero_yflux_faces, erf.zero_zflux_faces)");
2008  }
2009  }
2010  }
2011 
2012  if (perturbation_auto) {
2013  // Automatic forcing has a parent and a three-dimensional LES closure.
2014  // A horizontal Smagorinsky closure paired with a PBL scheme is mesoscale.
2015  for (int lev = 0; lev <= max_level; ++lev) {
2016  const auto& tc = turbChoice[lev];
2017  if (lev == 0 || tc.les_type == LESType::None || tc.smag2d ||
2018  tc.pbl_type != PBLType::None) {
2020  }
2021  }
2022  }
2023 
2024  // WRF's Smagorinsky-2D slope limiter divides K_h by the terrain slope factor of the
2025  // mesh, which is 1 everywhere without a terrain-fitted mesh; and the EB closure
2026  // (ComputeTurbulentViscosityLES_EB) applies neither limit.
2027  bool smag2d_requested = false;
2028  bool smag2d_somewhere = false;
2029  for (int lev = 0; lev <= max_level; lev++) {
2030  smag2d_requested = smag2d_requested || turbChoice[lev].smag2d_limits_requested;
2031  smag2d_somewhere = smag2d_somewhere || turbChoice[lev].smag2d;
2032  }
2033  if (smag2d_requested && !smag2d_somewhere) {
2034  amrex::Error("erf.smag2d_slope_limiter and erf.smag2d_kh_cap apply only to "
2035  "erf.les_type = Smagorinsky2D, which no level uses");
2036  }
2037  for (int lev = 0; lev <= max_level; lev++) {
2038  const bool fitted = (terrain_type == TerrainType::StaticFittedMesh ||
2039  terrain_type == TerrainType::MovingFittedMesh);
2040  if (turbChoice[lev].smag2d_slope_limiter && !fitted) {
2041  amrex::Error("erf.smag2d_slope_limiter requires erf.terrain_type = StaticFittedMesh "
2042  "or MovingFittedMesh");
2043  }
2044  if (turbChoice[lev].smag2d_kh_cap > zero && terrain_type == TerrainType::EB) {
2045  amrex::Error("erf.smag2d_kh_cap is not supported with erf.terrain_type = EB");
2046  }
2047  }
2048 
2049  // erf.radiation_model = TwoStream selects the two-stream model; its
2050  // erf.radiation.* sub-options are read only then.
2051  radChoice.init_params(rad_type == RadiationType::TwoStream, pp_prefix);
2052  if (rad_type == RadiationType::RRTMGP) {
2053  rrtmgpSolarChoice.read(pp_prefix);
2054  }
2056  if (topographicChoice.active()) {
2057  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(terrain_type == TerrainType::StaticFittedMesh,
2058  "Topographic radiation requires erf.terrain_type = StaticFittedMesh");
2059  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(rad_type == RadiationType::RRTMGP,
2060  "Topographic radiation currently requires erf.radiation_model = RRTMGP");
2061  }
2062 
2063  // Noah-MP integrates on the downwelling shortwave, downwelling longwave and solar
2064  // zenith angle a radiation model writes into it. Only RRTMGP and TwoStream register
2065  // those outputs with the land model (rad_feeds_lsm, ERF::init_stuff), so under any
2066  // other choice they are never written and Noah-MP runs with no radiative forcing at
2067  // all -- the inputs it reads fall back to zero. That is a legitimate thing to want
2068  // in a test, and rarely what anyone running a land model means, so say it at
2069  // start-up.
2070  if (lsm_type == LandSurfaceType::NOAHMP && !rad_feeds_lsm()) {
2071  amrex::Print() << "WARNING: erf.land_surface_model = NOAHMP with erf.radiation_model = "
2072  << amrex::getEnumNameString(rad_type)
2073  << ": only RRTMGP and TwoStream supply the downwelling shortwave, "
2074  "downwelling longwave and solar zenith angle Noah-MP needs. Noah-MP "
2075  "will run with no radiative forcing (zero SWDOWN, GLW and COSZEN).\n";
2076  }
2077 
2078  vert_implicit_fac.resize(max_level+1);
2079  for (int lev = 0; lev <= max_level; lev++) {
2080  vert_implicit_fac[lev].resize(3);
2081  vert_implicit_fac[lev][0] = one;
2082  vert_implicit_fac[lev][1] = one;
2083  vert_implicit_fac[lev][2] = zero;
2084  }
2085 
2086  // YSU PBL: use consistent coriolis frequency
2087  for (int lev = 0; lev <= max_level; lev++) {
2088  if (turbChoice[lev].pbl_ysu_use_consistent_coriolis) {
2089  if (use_coriolis) {
2090  turbChoice[lev].pbl_ysu_coriolis_freq = coriolis_factor * sinphi;
2091  if (lev == 0) {
2092  amrex::Print() << "YSU PBL using ERF coriolis frequency: " << turbChoice[lev].pbl_ysu_coriolis_freq << std::endl;
2093  }
2094  } else {
2095  amrex::Error("YSU cannot use ERF coriolis frequency if not using coriolis");
2096  }
2097  }
2098  }
2099  // MRF
2100  for (int lev = 0; lev <= max_level; lev++) {
2101  if (turbChoice[lev].pbl_ysu_use_consistent_coriolis) {
2102  if (use_coriolis) {
2103  turbChoice[lev].pbl_ysu_coriolis_freq = coriolis_factor * sinphi;
2104  if (lev == 0) {
2105  amrex::Print() << "MRF PBL using ERF coriolis frequency: " << turbChoice[lev].pbl_ysu_coriolis_freq << std::endl;
2106  }
2107  } else {
2108  amrex::Error("MRF cannot use ERF coriolis frequency if not using coriolis");
2109  }
2110  }
2111  }
2112 
2113  // What's the strength of the bdy nudging?
2114  pp.queryAdd("bdy_nudge_factor",bdy_nudge_factor);
2115 
2116  // Optionally use the dry-air density reconstructed from wrfbdy. It defaults to true only
2117  // when level 0 is FullyCompressible: an anelastic level holds rho at rho0, and a
2118  // pseudo-incompressible level ties rho theta to rho0 theta0, so neither can take the WRF
2119  // density. An explicit true there still aborts (ERF::ParameterSanityChecks).
2120  if (!compressibility_type.empty() &&
2121  compressibility_type[0] != CompressibilityType::FullyCompressible) {
2122  use_wrf_bdy_density = false;
2123  }
2124  pp.queryAdd("use_wrf_bdy_density", use_wrf_bdy_density);
2125 
2126  if (!use_real_bcs || init_type != InitType::WRFInput) {
2127  use_wrf_bdy_density = false;
2128  }
2129 
2130  pp.queryAdd("bdy_rho_nudge_factor", bdy_rho_nudge_factor);
2131 
2132  // Which approach to nudging the moist variables in the boundary region?
2133  pp.queryAdd("bdy_moist_nudge_type",bdy_moist_nudge_type);
2134  if (bdy_moist_nudge_type < 0 || bdy_moist_nudge_type > 2) {
2135  amrex::Error("erf.bdy_moist_nudge_type must be one of 0, 1, or 2");
2136  }
2137 
2138  // Are me transporting the scalar component?
2139  pp.queryAdd("transport_scalar",transport_scalar);
2140 
2141  for (int lev = 0; lev <= max_level; ++lev) {
2142  if (turbChoice[lev].uses_native_shoc()) {
2143  use_native_shoc = true;
2145  }
2146  }
2147 
2148  // Set up the vertical implicit diffusion solve
2149  int n_impfac = pp.countval("vert_implicit_fac");
2150  AMREX_ALWAYS_ASSERT(n_impfac == 0 || n_impfac == 1 || n_impfac==3);
2151  if (n_impfac == 1) {
2152  amrex::Real fac_in;
2153  pp.get("vert_implicit_fac", fac_in);
2154  for (int lev = 0; lev <= max_level; lev++) {
2155  for (int i=0; i<3; ++i) {
2156  vert_implicit_fac[lev][i] = fac_in;
2157  }
2158  }
2159  } else if (n_impfac == 3) {
2160  for (int lev = 0; lev <= max_level; lev++) {
2161  pp.getarr("vert_implicit_fac", vert_implicit_fac[lev]);
2162  }
2163  }
2164 
2165  // Record whether the user explicitly requested these
2166  const bool user_set_imp_thermal = pp.contains("implicit_thermal_diffusion");
2167  const bool user_set_imp_moisture = pp.contains("implicit_moisture_diffusion");
2168  const bool user_set_imp_ke = pp.contains("implicit_ke_diffusion");
2169  const bool user_set_imp_momentum = pp.contains("implicit_momentum_diffusion");
2170 
2171  // If true (default), include implicit contributions to vertical thermal diffusion
2172  pp.queryAdd("implicit_thermal_diffusion", implicit_thermal_diffusion);
2173 
2174  // If true (default), include implicit contributions to vertical moisture diffusion
2175  pp.queryAdd("implicit_moisture_diffusion", implicit_moisture_diffusion);
2176 
2177  // If true (default), include implicit contributions to vertical KE diffusion
2178  pp.queryAdd("implicit_ke_diffusion", implicit_ke_diffusion);
2179 
2180  // If true (default), include implicit contributions in tau13, tau23,
2181  pp.queryAdd("implicit_momentum_diffusion", implicit_momentum_diffusion);
2182 
2183  // If true (default false), also solve the compact terrain-metric part of the vertical
2184  // diffusion, K_h M d2/dz2 (ERF_TerrainImplicitMetric.H), implicitly (terrain-fitted
2185  // meshes only)
2186  pp.queryAdd("implicit_terrain_metric", implicit_terrain_metric);
2187 
2188  // The default is true (i.e. that it happens before the acoustic substepping).
2189  pp.queryAdd("implicit_before_substep", implicit_before_substep);
2190  for (int lev = 0; lev <= max_level; lev++) {
2191  if ( (timestepping_type[lev] != TimesteppingType::RK3_ImplicitSubstep) && !implicit_before_substep) {
2192  amrex::Print() << "implicit_before_substep cannot be false without substepping; setting to true." << "\n";
2193  implicit_before_substep = true;
2194  }
2195  }
2196 
2197  // Handle shoc case -- SHOC owns whatever vertical diffusion the host does not
2198  if (uses_shoc_family()) {
2199  const bool host_owns_scalars = host_owns_vertical_scalar_diffusion();
2200  const bool host_owns_momentum = host_owns_vertical_momentum_diffusion();
2201  if (!host_owns_scalars &&
2202  ( (user_set_imp_thermal && implicit_thermal_diffusion ) ||
2203  (user_set_imp_moisture && implicit_moisture_diffusion) ||
2204  (user_set_imp_ke && implicit_ke_diffusion ) ) ) {
2205  amrex::Print() << "Ignoring erf.implicit_{thermal,moisture,ke}_diffusion = true; "
2206  << "SHOC owns vertical scalar diffusion." << "\n";
2207  }
2208  if (!host_owns_momentum && user_set_imp_momentum && implicit_momentum_diffusion) {
2209  amrex::Print() << "Ignoring erf.implicit_momentum_diffusion = true; "
2210  << "SHOC owns vertical momentum diffusion." << "\n";
2211  }
2212 
2213  implicit_thermal_diffusion = (implicit_thermal_diffusion && host_owns_scalars);
2215  implicit_ke_diffusion = (implicit_ke_diffusion && host_owns_scalars);
2216  implicit_momentum_diffusion = (implicit_momentum_diffusion && host_owns_momentum);
2217 
2218  // Make the resulting configuration visible in the run log
2219  if (!host_owns_scalars && !host_owns_momentum) {
2220  amrex::Print() << "Turning off vertical implicit solve for all components since SHOC owns diffusion." << "\n";
2221  } else {
2222  amrex::Print() << "SHOC hands vertical diffusion of"
2223  << (host_owns_scalars ? " scalars" : "")
2224  << (host_owns_momentum ? " momentum" : "")
2225  << " to the host; keeping the vertical implicit solve on (theta = "
2227  << ", moisture = " << implicit_moisture_diffusion
2228  << ", tke = " << implicit_ke_diffusion
2229  << ", momenta = " << implicit_momentum_diffusion << ")." << "\n";
2230  }
2231  } // uses_shoc_family
2232 
2233  // Do not allow implicit vertical diff if user turns it off
2234  bool do_vert_implicit = true;
2235  pp.queryAdd("vert_implicit", do_vert_implicit);
2236  if (!do_vert_implicit) {
2237  for (int lev = 0; lev <= max_level; lev++) {
2238  amrex::Print() << "Turning off native vertical implicit solve from vert_implicit flag at level " << lev << std::endl;
2239  vert_implicit_fac[lev][0] = zero;
2240  vert_implicit_fac[lev][1] = zero;
2241  vert_implicit_fac[lev][2] = zero;
2242  }
2243  }
2244 
2245  // The implicit vertical diffusion is only second order at an anelastic or
2246  // pseudo-incompressible level (the RK2 / MidPoint integrators) when
2247  // the two stages are the midpoint method and the solve is done in the first stage
2248  // alone: S^* = S^n + (dt/2) F(S^*) and S^{n+1} = S^n + dt F(S^*) give
2249  // S^* = (S^n + S^{n+1})/2, i.e. the implicit midpoint rule. Solving again in the
2250  // second stage would reduce the pair to backward Euler, and with the RK2 (Heun)
2251  // stages there is no stage that plays the role of the midpoint at all.
2252  for (int lev = 0; lev <= max_level; lev++) {
2253  if (compressibility_type[lev] != CompressibilityType::FullyCompressible) {
2254  if (timestepping_type[lev] == TimesteppingType::RK2) {
2255  amrex::Print() << "Turning off native vertical implicit solve flag because anelastic at level " << lev
2256  << " with RK2 scheme." << std::endl;
2257  vert_implicit_fac[lev][0] = zero;
2258  vert_implicit_fac[lev][1] = zero;
2259  vert_implicit_fac[lev][2] = zero;
2260  } else if (timestepping_type[lev] == TimesteppingType::MidPoint) {
2261  if (do_vert_implicit && vert_implicit_fac[lev][0] != one) {
2262  amrex::Print() << "Forcing implicit factor 1 in first stage of MidPoint to ensure second-order accuracy." << std::endl;
2263  vert_implicit_fac[lev][0] = one;
2264  }
2265  if (vert_implicit_fac[lev][1] > zero) {
2266  amrex::Print() << "Turning off the second-stage vertical implicit solve at level " << lev
2267  << " because anelastic with MidPoint solves in the first stage only."
2268  << std::endl;
2269  }
2270  // The anelastic / pseudo-incompressible integrator only takes two stages, so [2] is never used
2271  vert_implicit_fac[lev][1] = zero;
2272  vert_implicit_fac[lev][2] = zero;
2273  }
2274  }
2275  }
2276 
2277  // Do not allow implicit vertical diff with EB
2278  if (terrain_type == TerrainType::EB) {
2279  for (int lev = 0; lev <= max_level; lev++) {
2280  if (do_vert_implicit) {
2281  amrex::Print() << "Implicit diffusion is not supported with EB; turning off at level " << lev << "\n";
2282  vert_implicit_fac[lev][0] = zero;
2283  vert_implicit_fac[lev][1] = zero;
2284  vert_implicit_fac[lev][2] = zero;
2285  }
2286  }
2287  }
2288 
2289  // The EB diffusion path adds no buoyancy, shear or dissipation source for
2290  // a prognostic TKE closure
2291  if (terrain_type == TerrainType::EB) {
2292  for (int lev = 0; lev <= max_level; lev++) {
2293  if (turbChoice[lev].use_keqn) {
2294  amrex::Error("erf.terrain_type = EB cannot be used with erf.les_type = Deardorff "
2295  "or erf.rans_type = kEqn: the EB diffusion path has no TKE sources");
2296  }
2297  }
2298  }
2299 
2300  // Do not allow implicit vertical diff when all the components are false
2305  amrex::Print() << "Thermal, moisture, KE, and momentum diffusion are all turned off; turning off vertical implicit solve." << std::endl;
2306  for (int lev = 0; lev <= max_level; lev++) {
2307  vert_implicit_fac[lev][0] = zero;
2308  vert_implicit_fac[lev][1] = zero;
2309  vert_implicit_fac[lev][2] = zero;
2310  }
2311  }
2312 
2313  // Which type of multilevel coupling
2314  coupling_type = CouplingType::TwoWay; // Default
2315  pp.query_enum_case_insensitive("coupling_type",coupling_type);
2316 
2317  // Test for hybrid (compressible + anelastic or pseudo-incompressible) -- in this case we must
2318  // use one-way coupling
2319  if (any_anelastic && any_compress) {
2320  coupling_type = CouplingType::OneWay;
2321  }
2322 
2323  // Which type of windfarm model
2324  windfarm_type = WindFarmType::None; // Default
2325  pp.query_enum_case_insensitive("windfarm_type",windfarm_type);
2326 
2328  pp.query_enum_case_insensitive("windfarm_loc_type",windfarm_loc_type);
2329 
2330  pp.queryAdd("windfarm_loc_table", windfarm_loc_table);
2331  pp.queryAdd("windfarm_spec_table", windfarm_spec_table);
2332  pp.queryAdd("windfarm_blade_table", windfarm_blade_table);
2333  pp.queryAdd("windfarm_airfoil_tables", windfarm_airfoil_tables);
2334  pp.queryAdd("windfarm_spec_table_extra", windfarm_spec_table_extra);
2335 
2336  // Sampling distance upstream of the turbine to find the
2337  // incoming free stream velocity as a factor of the diameter of the
2338  // turbine. ie. the sampling distance will be this number multiplied
2339  // by the diameter of the turbine
2340  pp.queryAdd("sampling_distance_by_D", sampling_distance_by_D);
2341  pp.queryAdd("turb_disk_angle_from_x", turb_disk_angle);
2342 
2343  pp.queryAdd("windfarm_x_shift",windfarm_x_shift);
2344  pp.queryAdd("windfarm_y_shift",windfarm_y_shift);
2345  // Test if time averaged data is to be output
2346  pp.queryAdd("time_avg_vel",time_avg_vel);
2347 
2348  // Interval means and resolved turbulent moments for plotfile output
2349  pp.queryAdd("compute_mean_vars", compute_mean_vars);
2350  pp.queryAdd("mean_vars_reset_mode", mean_vars_reset_mode);
2351  pp.queryAdd("mean_vars_reset_time", mean_vars_reset_time);
2352 
2353  if (compute_mean_vars &&
2354  mean_vars_reset_mode != "plotfile" && mean_vars_reset_mode != "time") {
2355  amrex::Error("erf.mean_vars_reset_mode must be either 'plotfile' or 'time'");
2356  }
2357  if (compute_mean_vars && mean_vars_reset_mode == "time" &&
2359  amrex::Error("erf.mean_vars_reset_time must be non-negative when "
2360  "erf.mean_vars_reset_mode = 'time'");
2361  }
2362 
2363  pp.queryAdd("hindcast_lateral_forcing", hindcast_lateral_forcing);
2364 
2365  // The hindcast latitude comes with the lateral-forcing data; without it, Coriolis
2366  // takes the variable or constant latitude instead, so say which
2367  if (init_type == InitType::HindCast && use_coriolis && !hindcast_lateral_forcing) {
2368  if (variable_coriolis) {
2369  amrex::Print() << "WARNING: erf.init_type = hindcast without erf.hindcast_lateral_forcing:"
2370  << " Coriolis uses the variable latitude (erf.variable_coriolis)" << std::endl;
2371  } else {
2372  amrex::Print() << "WARNING: erf.init_type = hindcast without erf.hindcast_lateral_forcing:"
2373  << " Coriolis uses the constant erf.latitude"
2374  << (pp.contains("latitude") ? "" : ", which is not set (default 90 degrees)")
2375  << std::endl;
2376  }
2377  }
2378 
2380  pp.queryAdd("hindcast_boundary_data_dir", hindcast_boundary_data_dir);
2381 
2382  if(hindcast_boundary_data_dir.empty()) {
2383  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_boundary_data_dir' for boundary data for lateral forcing");
2384  }
2385  pp.queryAdd("hindcast_data_interval_in_hrs", hindcast_data_interval_in_hrs);
2387  amrex::Error("ERROR: Input parameter 'erf.hindcast_data_interval_in_hrs' which is the time interval between the "
2388  "data files is either missing or set to less than zero");
2389  }
2390  pp.queryAdd("hindcast_lateral_sponge_strength", hindcast_lateral_sponge_strength);
2391  pp.queryAdd("hindcast_lateral_sponge_length", hindcast_lateral_sponge_length);
2392 
2393  pp.queryAdd("hindcast_zhi_sponge_length", hindcast_zhi_sponge_length);
2394  pp.queryAdd("hindcast_zhi_sponge_strength", hindcast_zhi_sponge_strength);
2395 
2396  pp.queryAdd("hindcast_zhi_sponge_damping", hindcast_zhi_sponge_damping);
2397 
2399  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_lateral_sponge_strength' or it is specified to be less than zero");
2400  }
2401 
2403  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_lateral_sponge_length' or it is specified to be less than zero");
2404  }
2405 
2407  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_zhi_sponge_length' or it is specified to be less than zero");
2408  }
2409 
2411  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_zhi_sponge_strength' or it is specified to be less than zero");
2412  }
2413  }
2414 
2415  pp.queryAdd("hindcast_surface_bcs", hindcast_surface_bcs);
2416  if(hindcast_surface_bcs) {
2417  pp.queryAdd("hindcast_surface_data_dir", hindcast_surface_data_dir);
2418  }
2419 
2420  pp.queryAdd("io_hurricane_eye_tracker", io_hurricane_eye_tracker);
2422  pp.queryAdd("hurricane_eye_latitude", hurricane_eye_latitude);
2423  pp.queryAdd("hurricane_eye_longitude", hurricane_eye_longitude);
2424  if(hurricane_eye_latitude == amrex::Real(-1e10) or hurricane_eye_longitude == amrex::Real(-1e10)) {
2425  amrex::Error("ERROR: You are using 'erf.io_hurricane_eye_tracker' to write out the files that track the eye of the hurricane"
2426  " but have not provided the initial location of the eye of the hurricane to be tracked. There has to be two"
2427  " options in the inputs - erf.hurricane_eye_latitude and erf.hurricane_eye_longitude that gives an approximate"
2428  " location of the eye in the initial condition");
2429  }
2430  // With init_type = hindcast the tracker takes latitude and longitude from the
2431  // forecast state, which exists only with lateral forcing
2432  if (init_type == InitType::HindCast && !hindcast_lateral_forcing) {
2433  amrex::Error("ERROR: 'erf.io_hurricane_eye_tracker' with erf.init_type = hindcast needs"
2434  " erf.hindcast_lateral_forcing = true: the tracker reads latitude and longitude"
2435  " from the forecast state, which only lateral forcing provides");
2436  }
2437  }
2438 
2439  pp.queryAdd("is_init_for_ensemble", is_init_for_ensemble);
2440  if(is_init_for_ensemble) {
2441  amrex::ParmParse pp_ens("ensemble");
2442  pp_ens.queryAdd("n_members", n_ensemble);
2443  if(n_ensemble < 2) {
2444  amrex::Abort("You are using an ensemble run. There needs to be at least 2 ensemble members. "
2445  "erf.n_ensemble must be >=2.");
2446  }
2447  pp_ens.queryAdd("coarse_bckgnd_data_file", coarse_bckgnd_data_file);
2448  if (coarse_bckgnd_data_file.empty()) {
2449  amrex::Abort("coarse_bckgnd_data_file is empty! For ensmeble simulations, there needs to be a coarse background file which "
2450  "contains the data which will be interpolated onto the fine mesh. There has to a entry ensemble.coarse_bckgnd_data_file "
2451  "which contains the filename in the inputs.");
2452  }
2453  pp_ens.queryAdd("ens_pert_amplitude", ens_pert_amplitude);
2454  if(ens_pert_amplitude <= 0.0) {
2455  amrex::Error("You are using initialization for ensemble simulations using the inputs option "
2456  "ensemble.is_init_for_ensemble=true. In this case, there has to be an option "
2457  "ensemble.ens_pert_amplitude which is the value of the amplitude of the perturbation "
2458  "to be added to the background state and has to be greater than 0.0");
2459  }
2460  pp_ens.queryAdd("ens_pert_correlated_radius", ens_pert_correlated_radius);
2461  if(ens_pert_correlated_radius <= 0.0) {
2462  amrex::Error("You are using initialization with spatially correlated perturbations using the inputs option "
2463  "ensemble.is_init_for_ensemble=true. In this case, there has to be an option "
2464  "ensemble.ens_pert_correlated_radius which is the value of the the spatial correlation radius, "
2465  "and has to be greater than 0.0");
2466  }
2467  }
2468  }
2469 
2470  /**
2471  * @brief Validate solver options after geometry and boundary conditions are known.
2472  * @param max_level Maximum AMR level configured for the run.
2473  * @param geom_vect Geometry for each AMR level.
2474  * @param phys_bc_type Physical boundary-condition types.
2475  */
2476  void check_params (int max_level, const amrex::Vector<amrex::Geometry>& geom_vect, amrex::GpuArray<ERF_BC, AMREX_SPACEDIM*2> phys_bc_type)
2477  {
2478  // The weighted average down acts only where covered coarse cells are averaged down
2479  if (if_average_down == "fluid_mass") {
2480  if (max_level > 0 && coupling_type == CouplingType::TwoWay) {
2481  amrex::Print() << "Immersed forcing: erf.if_average_down = fluid_mass (the cell average down "
2482  << "over refined levels is weighted by the fluid mass of the fine cells)\n";
2483  } else {
2484  amrex::Warning("erf.if_average_down = fluid_mass has no effect without refined levels "
2485  "(amr.max_level > 0) and erf.coupling_type = TwoWay");
2486  }
2487  }
2488  if (if_fraction_stress) {
2489  // The face-above spacing factor is bounded only while z0 < dz/4 (then d2 > d1 for
2490  // every solid fraction and the fluid centroid of a full wall cell sits above 2 z0)
2491  for (int lev = 0; lev <= max_level; ++lev) {
2492  const amrex::Real dz = geom_vect[lev].CellSize(2);
2493  if (!(if_z0 < amrex::Real(0.25) * dz)) {
2494  amrex::Abort("erf.if_wall_form = fraction_stress needs erf.if_z0 < dz/4 on every level (level " +
2495  std::to_string(lev) + ": z0 = " + std::to_string(if_z0) + " m, dz = " +
2496  std::to_string(dz) + " m)");
2497  }
2498  }
2499  }
2501  bool any_keqn = false;
2502  for (int lev = 0; lev <= max_level; ++lev) {
2503  any_keqn = any_keqn || (turbChoice[lev].rans_type == RANSType::kEqn);
2504  }
2505  if (!any_keqn) {
2506  amrex::Abort("erf.if_wall_tke and erf.if_flat_wall_dissipation act on the k-eqn RANS closure: "
2507  "set erf.rans_type = kEqn on a level, or turn them off (erf.if_flat_wall_dissipation = false)");
2508  }
2509  }
2510  if (if_fraction_stress) {
2511  amrex::Print() << "Immersed forcing: erf.if_wall_form = fraction_stress (wall stress in the wall cell, "
2512  << "the wall face closed to diffusion; face spacing "
2513  << ((if_wall_face_spacing == 2) ? "log" : (if_wall_face_spacing == 1) ? "physical" : "grid")
2514  << ", wall TKE " << (if_wall_tke ? "on" : "off")
2515  << ", flat-wall dissipation " << (if_flat_wall_dissipation ? "on" : "off") << ")\n";
2517  amrex::Print() << "Immersed forcing: the moisture species see a closed wall "
2518  << "(no diffusion through the wall face, held in the solid); surface moisture condition: ";
2519  if (if_surf_moist_flux != zero) {
2520  amrex::Print() << "flux erf.if_surf_moist_flux = " << if_surf_moist_flux << " kg/kg m/s (q* = -F_q/u*)";
2521  } else if (if_surf_moist >= zero) {
2522  amrex::Print() << "surface mixing ratio erf.if_surf_moist = " << if_surf_moist << " kg/kg";
2523  } else {
2524  amrex::Print() << "none (q* = 0)";
2525  }
2527  (if_surf_temp_flux != amrex::Real(1e-8) || if_init_surf_temp > zero || if_Olen_in != amrex::Real(1e-8) ||
2529  amrex::Print() << "; the Obukhov length uses theta_v and theta_v* = theta* (1 + epsv qv) + epsv theta q*";
2530  }
2531  amrex::Print() << "\n";
2532  }
2533  }
2534  // The log-law coarse/fine fill acts only on refined levels
2535  if (cf_loglaw_fill) {
2536  const bool immersed = (terrain_type == TerrainType::ImmersedForcing ||
2537  buildings_type == BuildingsType::ImmersedForcing);
2538  if (!immersed && phys_bc_type[amrex::Orientation(amrex::Direction::z, amrex::Orientation::low)] != ERF_BC::surface_layer) {
2539  amrex::Abort("erf.cf_loglaw_fill needs an immersed surface (erf.terrain_type or "
2540  "erf.buildings_type = ImmersedForcing) or zlo.type = surface_layer");
2541  }
2542  if (max_level > 0) {
2543  amrex::Print() << "Coarse/fine faces: erf.cf_loglaw_fill = true (the wall coarse face's flux is shared "
2544  << "among its fine sub-faces by the integral of ln(1 + z/z0), z0 = " << cf_loglaw_z0 << " m)\n";
2545  } else {
2546  amrex::Warning("erf.cf_loglaw_fill has no effect without refined levels (amr.max_level > 0)");
2547  }
2548  }
2550  (terrain_type == TerrainType::EB || terrain_type == TerrainType::ImmersedForcing)) {
2551  amrex::Abort("Automatic perturbations currently support flat, stretched, and fitted-terrain meshes; "
2552  "immersed/embedded terrain requires a ground-relative parent PBL-height conversion");
2553  }
2554 #if 0
2555  // Warn for PBL models and moisture - these may not yet be compatible
2556  for (int lev = 0; lev <= max_level; lev++) {
2557  if ((moisture_type != MoistureType::None) && (turbChoice[lev].pbl_type != PBLType::None)) {
2558  amrex::Warning("\n*** WARNING: Moisture may not yet be compatible with PBL models, \n proceed with caution ***");
2559  }
2560  }
2561 #endif
2562  //
2563  // Buoyancy type check
2564  //
2565  for (int lev = 0; lev <= max_level; lev++) {
2566  if (buoyancy_type[lev] != 1 && buoyancy_type[lev] != 2 && buoyancy_type[lev] != 3 && buoyancy_type[lev] != 4) {
2567  amrex::Error("buoyancy_type must be 1, 2, 3 or 4");
2568  }
2569  }
2570 
2571  if (!use_lagged_delta_rt && !(terrain_type == TerrainType::MovingFittedMesh)) {
2572  amrex::Error("Can't turn off lagged_delta_rt when terrain not moving");
2573  }
2574 
2575  //
2576  // Wind farm checks
2577  //
2578  if (windfarm_type==WindFarmType::SimpleAD and sampling_distance_by_D < zero) {
2579  amrex::Error("To use simplified actuator disks, you need to provide a variable"
2580  " erf.sampling_distance_by_D in the inputs which specifies the upstream"
2581  " distance as a factor of the turbine diameter at which the incoming free stream"
2582  " velocity will be computed at.");
2583  }
2584  if ( (windfarm_type==WindFarmType::SimpleAD ||
2585  windfarm_type==WindFarmType::GeneralAD ) && turb_disk_angle < zero) {
2586  amrex::Error("To use simplified actuator disks, you need to provide a variable"
2587  " erf.turb_disk_angle_from_x in the inputs which is the angle of the face of the"
2588  " turbine disk from the x-axis. A turbine facing an oncoming flow in the x-direction"
2589  " will have turb_disk_angle value of 90 deg.");
2590  }
2591 #ifdef ERF_USE_WINDFARM
2592  // Without a location type no turbine table is read, and the model would run on empty tables
2594  amrex::Error(std::string("erf.windfarm_type = ") + amrex::getEnumNameString(windfarm_type)
2595  + " needs erf.windfarm_loc_type, either lat_lon or x_y, with the turbine locations"
2596  " in erf.windfarm_loc_table and their specifications in erf.windfarm_spec_table.");
2597  }
2598 #endif
2599  if (windfarm_loc_type == WindFarmLocType::lat_lon and (windfarm_x_shift < zero or windfarm_y_shift < zero)) {
2600  amrex::Error("You are using windfarms with latitude-logitude option to position the turbines."
2601  " For this you should provide the inputs erf.windfarm_x_shift and"
2602  " erf.windfarm_y_shift which are the values by which the bounding box of the"
2603  " windfarm is shifted from the x and the y axes.");
2604  }
2605 
2606 
2607  if ( (const_massflux_u != 0) && !(geom_vect[0].isPeriodic(0)) ) {
2608  amrex::Error("Constant mass flux (in x) should be used with periodic boundaries");
2609  }
2610 
2611  if ( (const_massflux_v != 0) && !(geom_vect[0].isPeriodic(1)) ) {
2612  amrex::Error("Constant mass flux (in y) should be used with periodic boundaries");
2613  }
2614 
2615  // Mesoscale diffusion -- test if LES appropriate with this dx,dy
2616  for (int lev = 0; lev <= max_level; lev++) {
2617  if ((geom_vect[lev].CellSize(0) > amrex::Real(2000.)) || (geom_vect[lev].CellSize(1) > amrex::Real(2000.)))
2618  {
2619  if ( (turbChoice[lev].les_type == LESType::Smagorinsky) && !turbChoice[lev].smag2d ) {
2620  amrex::Warning("Should use 2-D Smagorinsky for mesoscale resolution");
2621  } else if (turbChoice[lev].les_type == LESType::Deardorff) {
2622  amrex::Warning("Should not use Deardorff LES for mesoscale resolution");
2623  }
2624  }
2625  }
2626 
2627  // Turn off implicit solve if we have no diffusion
2628  bool l_use_kturb = turbChoice[0].use_kturb;
2629  for (int lev = 1; lev <= max_level; lev++) {
2630  l_use_kturb = (l_use_kturb || turbChoice[lev].use_kturb);
2631  }
2632  bool l_use_diff = ( (diffChoice.molec_diff_type != MolecDiffType::None) || l_use_kturb );
2633 
2634  for (int lev = 0; lev <= max_level; lev++) {
2635  bool l_implicit_diff = (vert_implicit_fac[lev][0] > zero ||
2636  vert_implicit_fac[lev][1] > zero ||
2637  vert_implicit_fac[lev][2] > zero);
2638  if (l_implicit_diff && !l_use_diff) {
2639  amrex:: Print() << "No molecular or turbulent diffusion, turning off implicit solve at level " << lev << std::endl;
2640  vert_implicit_fac[lev][0] = zero;
2641  vert_implicit_fac[lev][1] = zero;
2642  vert_implicit_fac[lev][2] = zero;
2643  }
2644  }
2645 
2646  // Two-way coupling refluxes the diffusive fluxes of the slow scalars, but not on an EB mesh
2647  if (coupling_type == CouplingType::TwoWay && terrain_type == TerrainType::EB &&
2648  max_level > 0 && l_use_diff) {
2649  amrex::Warning("erf.coupling_type = TwoWay with erf.terrain_type = EB does not reflux the "
2650  "diffusive fluxes: diffusion does not conserve the scalars across "
2651  "coarse/fine boundaries");
2652  }
2653 
2654  // The implicit terrain metric is a change to the vertical implicit solves on a
2655  // terrain-fitted mesh; refuse it where it could not do anything. This comes after
2656  // every block that can turn the implicit solve off.
2658  if (mesh_type != MeshType::VariableDz) {
2659  amrex::Abort("erf.implicit_terrain_metric = true requires a terrain-fitted mesh with "
2660  "non-flat terrain (erf.terrain_type = StaticFittedMesh or MovingFittedMesh); "
2661  "on a flat or a purely stretched mesh there are no terrain-metric terms");
2662  }
2663  // In a stage without the implicit solve the whole averaged metric term is explicit
2664  // for that stage. On the steep ridge test the option gained little with 1 1 0
2665  // and ran worse than without it with anelastic MidPoint (measured before the exact
2666  // split: 15 s instead of 30 s), while 1 1 1 recovered the full time step. The rule
2667  // is measured, not derived: every stage must solve implicitly.
2668  for (int lev = 0; lev <= max_level; lev++) {
2669  for (int i = 0; i < 3; ++i) {
2670  if (vert_implicit_fac[lev][i] <= zero) {
2671  amrex::Abort("erf.implicit_terrain_metric = true needs the vertical implicit solve "
2672  "in every Runge-Kutta stage at every level, but erf.vert_implicit_fac "
2673  "is not positive in stage " + std::to_string(i+1) + " at level " +
2674  std::to_string(lev) + ". Set erf.vert_implicit_fac = 1 1 1; the "
2675  "option cannot be used where the implicit solve is turned off "
2676  "(erf.vert_implicit = false, every erf.implicit_*_diffusion = false, "
2677  "no molecular or turbulent diffusion, or anelastic, which solves in "
2678  "its first stage only or not at all)");
2679  }
2680  }
2681  }
2682  // The momentum solves carry most of the stiffness; with them explicit the option
2683  // treats only the scalar metric terms implicitly
2685  amrex::Print() << "WARNING: erf.implicit_terrain_metric = true with "
2686  << "erf.implicit_momentum_diffusion = false: the momentum terrain-metric "
2687  << "terms stay explicit; only the scalars are treated implicitly" << std::endl;
2688  }
2689  } else if (mesh_type == MeshType::VariableDz) {
2690  // On a terrain-fitted mesh the projected horizontal stresses carry K_h, and their
2691  // terrain-metric part K_h h^2 d2/dz2 is explicit in any stage without the implicit
2692  // solve. On steep slopes that limits the time step (steep test ridge: 45 s before
2693  // #4214 was fixed, 15 s after, at the default 1 1 0). Say so once at start-up.
2694  bool explicit_stage_with_kh = false;
2695  for (int lev = 0; lev <= max_level; lev++) {
2696  if (turbChoice[lev].les_type == LESType::None) { continue; }
2697  for (int i = 0; i < 3; ++i) {
2698  if (vert_implicit_fac[lev][i] <= zero) { explicit_stage_with_kh = true; }
2699  }
2700  }
2701  if (explicit_stage_with_kh) {
2702  amrex::Print() << "NOTE: terrain-fitted mesh with an LES closure (horizontal eddy "
2703  << "viscosity K_h) and an explicit vertical-diffusion stage "
2704  << "(erf.vert_implicit_fac has a zero): the terrain-metric term "
2705  << "K_h h^2 d2/dz2 stays explicit there and limits the time step on "
2706  << "steep slopes. To relax it, use erf.vert_implicit_fac = 1 1 1 with "
2707  << "erf.implicit_terrain_metric = true, or erf.smag2d_slope_limiter = true "
2708  << "for Smagorinsky2D; erf.diffusive_dt_check reports the limit."
2709  << std::endl;
2710  }
2711  }
2712 
2713  // Countergradient validation: ensure required implicit diffusion is enabled
2714  for (int lev = 0; lev <= max_level; lev++) {
2715  if (turbChoice[lev].enable_mrf_countergradient) {
2717  vert_implicit_fac[lev][0] > zero ||
2718  vert_implicit_fac[lev][1] > zero ||
2719  vert_implicit_fac[lev][2] > zero,
2720  "enable_mrf_countergradient requires vert_implicit_fac > 0");
2723  "enable_mrf_countergradient requires implicit_thermal_diffusion = true");
2727  "enable_mrf_countergradient with moisture requires implicit_moisture_diffusion = true");
2728  }
2729  }
2730  }
2731 
2732  for (int lev = 0; lev <= max_level; lev++) {
2733  turbChoice[lev].check_params(phys_bc_type);
2734  }
2735  }
2736 
2737  /**
2738  * @brief Print the configured solver, physics, and transport options.
2739  * @param max_level Maximum AMR level configured for the run.
2740  * @param pp_prefix ParmParse prefix used to display nested choices.
2741  */
2742  void display (int max_level, std::string pp_prefix)
2743  {
2744  amrex::Print() << "SOLVER CHOICE: " << std::endl;
2745  if (perturbation_auto) {
2746  amrex::Print() << "Automatic LES-nest perturbations: parent update period = "
2747  << perturbation_auto_period << " s, PBL height fraction = "
2748  << perturbation_auto_pbl_fraction << std::endl;
2749  }
2750  for (int lev = 0; lev <= max_level; lev++) {
2751  amrex::Print() << "At level " << lev << " : " << std::endl;
2752  if (compressibility_type[lev] != CompressibilityType::FullyCompressible) {
2753  amrex::Print() << ((compressibility_type[lev] == CompressibilityType::PseudoIncompressible)
2754  ? " pseudo-incompressible" : " anelastic")
2755  << " with no substepping, using the "
2756  << ((timestepping_type[lev] == TimesteppingType::MidPoint) ? "MidPoint" : "RK2")
2757  << " integrator" << std::endl;
2758  } else {
2759  if (timestepping_type[lev] == TimesteppingType::RK3_NoSubstepping) {
2760  amrex::Print() << " compressible with no substepping" << std::endl;
2761  } else if (timestepping_type[lev] == TimesteppingType::RK3_ImplicitSubstep) {
2762  amrex::Print() << " compressible with implicit substepping" << std::endl;
2763  }
2764  }
2765  if (fixed_density[lev]) {
2766  amrex::Print() << " and fixed density" << std::endl;
2767  }
2768  }
2769 
2770  for (int lev = 0; lev <= max_level; lev++) {
2771  amrex::Print() << "vert_implicit_fac at level " << lev << " : "
2772  << vert_implicit_fac[lev][0] << " "
2773  << vert_implicit_fac[lev][1] << " "
2774  << vert_implicit_fac[lev][2];
2775  if (vert_implicit_fac[lev][0] > zero ||
2776  vert_implicit_fac[lev][1] > zero ||
2777  vert_implicit_fac[lev][2] > zero)
2778  {
2779  amrex::Print() << " (theta = " << implicit_thermal_diffusion
2780  << ", moisture = " << implicit_moisture_diffusion
2781  << ", tke = " << implicit_ke_diffusion
2782  << ", momenta = " << implicit_momentum_diffusion;
2784  amrex::Print() << "; terrain metric implicit";
2785  }
2786  amrex::Print() << ")";
2787  }
2788  }
2789  amrex::Print() << std::endl;
2790  amrex::Print() << "use_coriolis : " << use_coriolis << std::endl;
2791  amrex::Print() << "use_gravity : " << use_gravity << std::endl;
2792 
2793  if (moisture_type == MoistureType::SAM) {
2794  amrex::Print() << "Moisture Model: SAM" << std::endl;
2795  } else if (moisture_type == MoistureType::SAM_NoIce) {
2796  amrex::Print() << "Moisture Model: SAM No Ice" << std::endl;
2797  } else if (moisture_type == MoistureType::SAM_NoPrecip_NoIce) {
2798  amrex::Print() << "Moisture Model: SAM No Precip No Ice" << std::endl;
2799  } else if (moisture_type == MoistureType::Morrison) {
2800  amrex::Print() << "Moisture Model: Morrison" << std::endl;
2801  } else if (moisture_type == MoistureType::Morrison_NoIce) {
2802  amrex::Print() << "Moisture Model: Morrison_NoIce" << std::endl;
2803  } else if (moisture_type == MoistureType::WSM6) {
2804  amrex::Print() << "Moisture Model: WSM6" << std::endl;
2805  } else if (moisture_type == MoistureType::WDM6) {
2806  amrex::Print() << "Moisture Model: WDM6" << std::endl;
2807  } else if (moisture_type == MoistureType::Kessler) {
2808  amrex::Print() << "Moisture Model: Kessler" << std::endl;
2809  } else if (moisture_type == MoistureType::Kessler_NoRain) {
2810  amrex::Print() << "Moisture Model: Kessler No Rain" << std::endl;
2811  } else if (moisture_type == MoistureType::SatAdj) {
2812  amrex::Print() << "Moisture Model: Saturation Adjustment" << std::endl;
2813  } else if (moisture_type == MoistureType::SuperDroplets) {
2814  amrex::Print() << "Moisture Model: SuperDroplets" << std::endl;
2815  } else if (moisture_type == MoistureType::MoistNoCondensation) {
2816  amrex::Print() << "Moisture Model: MoistNoCondensation" << std::endl;
2817  } else if (moisture_type == MoistureType::SBM) {
2818  amrex::Print() << "Moisture Model: SBM mapped spectral advection (M3)" << std::endl;
2819  } else {
2820  amrex::Print() << "Moisture Model: None" << std::endl;
2821  }
2822 
2823  if (terrain_type == TerrainType::StaticFittedMesh) {
2824  amrex::Print() << "Terrain Type: StaticFittedMesh" << std::endl;
2825  } else if (terrain_type == TerrainType::MovingFittedMesh) {
2826  amrex::Print() << "Terrain Type: MovingFittedMesh" << std::endl;
2827  } else if (terrain_type == TerrainType::EB) {
2828  amrex::Print() << "Terrain Type: EB" << std::endl;
2829  ebChoice.display();
2830  } else if (terrain_type == TerrainType::ImmersedForcing) {
2831  amrex::Print() << "Terrain Type: ImmersedForcing" << std::endl;
2832  } else {
2833  amrex::Print() << "Terrain Type: None" << std::endl;
2834  }
2835 
2836  amrex::Print() << "Flat fitted terrain: "
2837  << (flat_terrain ? "true" : "false") << std::endl;
2838 
2839  if (buildings_type == BuildingsType::ImmersedForcing) {
2840  amrex::Print() << "Buildings Type: ImmersedForcing" << std::endl;
2841  } else {
2842  amrex::Print() << "Buildings Type: None" << std::endl;
2843  }
2844 
2845  if (mesh_type == MeshType::ConstantDz) {
2846  amrex::Print() << " Mesh Type: ConstantDz" << std::endl;
2847  } else if (mesh_type == MeshType::StretchedDz) {
2848  amrex::Print() << " Mesh Type: StretchedDz" << std::endl;
2849  } else if (mesh_type == MeshType::VariableDz) {
2850  amrex::Print() << " Mesh Type: VariableDz" << std::endl;
2851  } else {
2852  amrex::Error("No mesh_type set!");
2853  }
2854 
2855  amrex::Print() << "ABL Driver Type: " << std::endl;
2857  amrex::Print() << " None" << std::endl;
2858  } else if (abl_driver_type == ABLDriverType::PressureGradient) {
2859  amrex::Print() << " Pressure Gradient "
2860  << amrex::RealVect(abl_pressure_grad[0],abl_pressure_grad[1],abl_pressure_grad[2])
2861  << std::endl;
2862  } else if (abl_driver_type == ABLDriverType::GeostrophicWind) {
2863  amrex::Print() << " Geostrophic Wind "
2864  << amrex::RealVect(abl_geo_forcing[0],abl_geo_forcing[1],abl_geo_forcing[2])
2865  << std::endl;
2866  }
2867 
2868  if (max_level > 0) {
2869  amrex::Print() << "Coupling Type: " << std::endl;
2870  if (coupling_type == CouplingType::TwoWay) {
2871  amrex::Print() << " Two-way" << std::endl;
2872  } else if (coupling_type == CouplingType::OneWay) {
2873  amrex::Print() << " One-way" << std::endl;
2874  }
2875  }
2876 
2877  if (rad_type == RadiationType::RRTMGP) {
2878  amrex::Print() << "Radiation Model: RRTMGP" << std::endl;
2879  } else if (rad_type == RadiationType::Simple) {
2880  amrex::Print() << "Radiation Model: Simple" << std::endl;
2881  } else if (rad_type == RadiationType::TwoStream) {
2882  amrex::Print() << "Radiation Model: TwoStream" << std::endl;
2883  } else {
2884  amrex::Print() << "Radiation Model: None" << std::endl;
2885  }
2886 
2887  amrex::Print() << "Gradp_type : " << amrex::getEnumNameString(gradp_type) << std::endl;
2888  amrex::Print() << "Gradp_2nd_order_bndry : " << gradp_2nd_order_bndry << std::endl;
2889 
2890  for (int lev = 0; lev <= max_level; lev++) {
2891  amrex::Print() << "Buoyancy_type at level " << lev << " : " << buoyancy_type[lev] << std::endl;
2892  }
2893 
2894  advChoice.display(pp_prefix);
2895  diffChoice.display();
2898 
2899  for (int lev = 0; lev <= max_level; lev++) {
2900  turbChoice[lev].display(lev);
2901  }
2902  }
2903 
2904  /**
2905  * @brief Build constant-latitude Coriolis forcing parameters.
2906  * @param pp_prefix ParmParse prefix for the ERF input namespace.
2907  */
2908  void build_coriolis_forcings_const_lat (std::string pp_prefix)
2909  {
2910  amrex::ParmParse pp(pp_prefix);
2911 
2912  // Read the rotational time period (in seconds)
2913  double rot_time_period = 86400.0;
2914  pp.queryAdd("rotational_time_period", rot_time_period);
2915 
2916  coriolis_factor = static_cast<amrex::Real>(4.0 * PI / rot_time_period);
2917 
2918  pp.queryAdd("coriolis_3d", coriolis_3d);
2919 
2920  // Convert to radians
2921  amrex::Real latitude_for_coriolis = amrex::Real(90.0);
2922  pp.queryAdd("latitude", latitude_for_coriolis);
2923  latitude_for_coriolis *= (PI/amrex::Real(180.));
2924  sinphi = std::sin(latitude_for_coriolis);
2925 
2926  // Note: cosphi defaults to 0
2927  if (coriolis_3d) {
2928  cosphi = std::cos(latitude_for_coriolis);
2929  }
2930 
2931  amrex::Print() << "Coriolis frequency, f = " << coriolis_factor * sinphi << " 1/s" << std::endl;
2932 
2933  if (abl_driver_type == ABLDriverType::GeostrophicWind) {
2934  // Read in the geostrophic wind -- we only use this to construct
2935  // the forcing term so no need to keep it
2936  amrex::Vector<amrex::Real> abl_geo_wind(3);
2937  pp.queryarr("abl_geo_wind",abl_geo_wind);
2938 
2939  if(!pp.queryAdd("abl_geo_wind_table",abl_geo_wind_table)) {
2940  abl_geo_forcing = {
2941  -coriolis_factor * (abl_geo_wind[1]*sinphi - abl_geo_wind[2]*cosphi),
2942  coriolis_factor * abl_geo_wind[0]*sinphi,
2943  -coriolis_factor * abl_geo_wind[0]*cosphi
2944  };
2945  } else {
2946  amrex::Print() << "NOTE: abl_geo_wind_table provided, ignoring input abl_geo_wind" << std::endl;
2947  }
2948  }
2949  }
2950 
2951  /**
2952  * @brief Read one integer value or one value per AMR level.
2953  * @param max_level Maximum AMR level configured for the run.
2954  * @param string_to_read ParmParse key to read.
2955  * @param vec_to_fill Destination vector with one entry per level.
2956  * @param default_int Default value used when the key is absent.
2957  * @return True if the key was present in the inputs.
2958  */
2959  bool read_int_string (int max_level, const char* string_to_read,
2960  amrex::Vector<int>& vec_to_fill, int default_int)
2961  {
2962  amrex::ParmParse pp("erf");
2963  int nvals = pp.countval(string_to_read);
2964  AMREX_ALWAYS_ASSERT(nvals == 0 || nvals == 1 || nvals >= max_level+1);
2965  amrex::Vector<int> temp; temp.resize(nvals);
2966  pp.queryarr(string_to_read,temp);
2967 
2968  if (vec_to_fill.size() < max_level+1) {
2969  vec_to_fill.resize(max_level+1);
2970  }
2971 
2972  if (nvals == 0) {
2973  for (int i = 0; i <= max_level; ++i) vec_to_fill[i] = default_int;
2974  } else if (nvals == 1) {
2975  for (int i = 0; i <= max_level; ++i) vec_to_fill[i] = temp[0];
2976  } else {
2977  for (int i = 0; i <= max_level; ++i) vec_to_fill[i] = temp[i];
2978  }
2979  return (nvals > 0);
2980  }
2981 
2982  inline static
2984 
2985  inline static
2986  SoundingType sounding_type = SoundingType::Ideal;
2987 
2988  inline static
2990 
2991  inline static
2992  bool flat_terrain = false;
2993 
2994  inline static
2996 
2997  inline static
2999 
3000  inline static
3001  bool use_real_bcs = false;
3002 
3003  inline static
3004  MeshType mesh_type = MeshType::ConstantDz;
3005 
3006  /**
3007  * @brief Override the globally selected mesh type.
3008  * @param new_mesh_type Mesh type to store.
3009  */
3010  static
3011  void set_mesh_type (MeshType new_mesh_type)
3012  {
3013  mesh_type = new_mesh_type;
3014  }
3015 
3020  amrex::Vector<TurbChoice> turbChoice;
3025 
3027 
3028  amrex::Vector<CompressibilityType> compressibility_type;
3029  amrex::Vector<TimesteppingType> timestepping_type;
3030  amrex::Vector<int> fixed_density;
3031  amrex::Vector<int> project_initial_velocity;
3032  amrex::Vector<int> buoyancy_type;
3033  amrex::Vector<int> is_land;
3034 
3035  // do some extra CFL diagnostics for compressible with substepping
3036  bool substepping_diag = false;
3037 
3038  // time off-centering coefficient, > 0 for forward weighting (i.e., bias
3039  // towards the future time step)
3040  amrex::Real beta_s = amrex::Real(0.1);
3041  int face_sync_int = 1;
3042 
3043  // if true, beta_s varies on the w-faces
3044  // and beta_s itself is not used (implicit substepping only)
3045  bool use_variable_beta_s = false;
3046  // true if erf.use_variable_beta_s is not given in the inputs, so that it may be turned on
3047  // where the constant beta_s is below the stability limit min(sigma^2, 1) of the terrain
3049 
3050  // divergence damping coefficient: how far (rho theta) is projected forward
3051  // in the horizontal momentum equations of the acoustic substepping
3052  amrex::Real beta_d = amrex::Real(0.1);
3053 
3054  // This controls the time-centering of the *vertical* differences in the diffusive term for
3055  // theta, u and v
3056  // 0: fully explicit
3057  // 1: fully implicit
3058  amrex::Vector<amrex::Vector<amrex::Real>> vert_implicit_fac; // one value per RK stage
3059 
3060  // if any vert_implicit_fac > 0, then the following apply:
3066  // On a terrain-fitted mesh, also treat the compact terrain-metric part of the vertical
3067  // diffusion (K_h M d2/dz2, ERF_TerrainImplicitMetric.H) implicitly, in every implicit solve
3069 
3070  int ncorr = 1;
3071  std::string wall_dist_type = "poisson";
3072  TerrainPoissonSolver terrain_poisson_solver = TerrainPoissonSolver::gmres_fft;
3073 #ifdef AMREX_USE_FLOAT
3074  amrex::Real poisson_abstol = amrex::Real(1e-6);
3075  amrex::Real poisson_reltol = amrex::Real(1e-6);
3076 #else
3077  amrex::Real poisson_abstol = amrex::Real(1e-8);
3078  amrex::Real poisson_reltol = amrex::Real(1e-8);
3079 #endif
3080 
3081  // Pseudo-incompressible: the constraint is div(rho0 theta0 u) = Q + c (rho theta - rho0 theta0) / dt,
3082  // with Q the non-advective tendency of (rho theta) and c this factor (0 for no drift correction)
3083  amrex::Real pi_drift_factor = myhalf;
3084 
3085  bool test_mapfactor = false;
3086  amrex::Real test_mapfactor_amp = amrex::Real(0);
3087 
3088  GradpType gradp_type = GradpType::ChainRule;
3089 
3091 
3093 
3094  // Specify what additional physics/forcing modules we use
3095  bool use_gravity = false;
3096  bool use_coriolis = false;
3097  bool coriolis_3d = true;
3098 
3100 
3101  // Specify whether to apply other various source terms on substep only
3103  bool forest_substep = false;
3104 
3105  // immersed forcing parameters
3106  amrex::Real if_Cd_momentum = amrex::Real(50.0);
3107  amrex::Real if_Cd_scalar = amrex::Real(10.0);
3108  // Use a point-implicit (linearly-implicit) formulation of the immersed-forcing
3109  // drag. Defaults to false (explicit forward-Euler source).
3110  bool if_implicit_drag = false;
3111  bool if_implicit_projection = false; // erf.if_implicit_projection: solid drag (terrain or buildings) inside the projection of an Anelastic or PseudoIncompressible level
3112  // immersed forcing MOST parameters.
3113  amrex::Real if_z0 = amrex::Real(0.1); // [m]
3114  amrex::Real if_surf_temp_flux = amrex::Real(1e-8); // [K m/s]
3115  amrex::Real if_init_surf_temp = zero; // [K]
3116  amrex::Real if_surf_heating_rate = zero; // [K/hr]
3117  amrex::Real if_Olen_in = amrex::Real(1e-8); // [m]
3118  // Surface moisture condition of the fraction-stress wall law: a given kinematic moisture flux
3119  // (erf.if_surf_moist_flux, 0 = none) or a given surface mixing ratio (erf.if_surf_moist, < 0 = none)
3120  amrex::Real if_surf_moist_flux = zero; // [kg/kg m/s]
3121  amrex::Real if_surf_moist = amrex::Real(-1.0); // [kg/kg]
3122  bool if_use_most = false;
3125  similarity_funs most_sfuns; // erf.most.stable_functions: the similarity functions of the immersed wall laws
3126  bool if_fraction_stress = false; // erf.if_wall_form = fraction_stress
3127  int if_wall_face_spacing = 2; // erf.if_wall_face_spacing: 0 grid, 1 physical, 2 log (default)
3128  bool if_wall_tke = false; // erf.if_wall_tke: wall value of the k-eqn TKE in the wall cell
3129  amrex::Real if_wall_tke_time_factor = amrex::Real(1.0); // erf.if_wall_tke_time_factor: 1 pins, > 1 relaxes over that many steps
3130  bool if_flat_wall_dissipation = false; // erf.if_flat_wall_dissipation (default: = if_fraction_stress)
3131  amrex::Real if_ws_floor = 0.001; // [m/s]
3132  amrex::Real if_damp_alpha = 0.5; // [-]
3133  amrex::Real if_stability_wind_floor = amrex::Real(0.0); // [m/s]
3134  amrex::Real if_psi_cap_factor = amrex::Real(1.0); // [-]
3135  amrex::Real if_small_volfrac = amrex::Real(0.005); // [-] eb2.small_volfrac
3136  std::string if_average_down = "plain"; // or fluid_mass
3137  amrex::Real if_cf_mismatch_warning = amrex::Real(0.75); // erf.if_cf_mismatch_warning: c/f surface mismatch threshold
3138  bool cf_loglaw_fill = false; // erf.cf_loglaw_fill: log-law share of the wall coarse face's flux
3139  amrex::Real cf_loglaw_z0 = amrex::Real(-1.0); // erf.cf_loglaw_z0 [m]; < 0: resolved from if_z0 / most.z0
3140 
3141  // This defaults to true but can be set to false for moving terrain cases only
3142  bool use_lagged_delta_rt = true;
3143 
3144  // Flag to rebalance states from wrfinput and wrfbdy
3145  bool rebalance_wrf_input = true;
3146 
3147  // Constants
3148  amrex::Real gravity;
3149  amrex::Real c_p = Cp_d; // specific heat at constant pressure for dry air [J/(kg-K)]
3150  amrex::Real rdOcp;
3151 
3152  // Staggered z levels for vertical grid stretching
3153  amrex::Real grid_stretching_ratio = 0;
3154  amrex::Real dz0 = zero;
3155 
3156  // Coriolis forcing
3157  amrex::Real coriolis_factor = zero;
3158  amrex::Real cosphi = zero;
3159  amrex::Real sinphi = zero;
3160 
3161  // User-specified forcings in problem definition
3164  bool custom_w_subsidence = false;
3165  bool do_theta_advection = true; // Apply custom vertical subsidence to (rho*theta) equation when using custom w subsidence
3166  bool do_mom_advection = true; // Apply custom vertical subsidence to momentum equations when using custom w subsidence
3171 
3172  // Do we use source terms to nudge the solution towards
3173  // the time-varying data provided in input sounding files?
3175 
3176  // Do we nudge the solution towards observations at stations (met masts,
3177  // lidars)? See ERF_ObsNudging.H.
3179 
3180  amrex::Real nudging_u_z1 = amrex::Real(-1.0e36);
3181  amrex::Real nudging_u_z2 = amrex::Real(1.0e36);
3182  amrex::Real nudging_t_z1 = zero;
3183  amrex::Real nudging_t_z2 = amrex::Real(10000.0);
3184  amrex::Real nudging_q_z1 = zero;
3185  amrex::Real nudging_q_z2 = amrex::Real(10000.0); // TODO: reasonable defaults here?
3186 
3187  bool nudging_u = true; // Nudge u,v when nudging_from_input_sounding is true
3188  bool nudging_t = true; // Nudge potential temperature when nudging_from_input_sounding is true
3189  bool nudging_q = true; // Nudge water vapor when nudging_from_input_sounding is true
3190 
3191  bool large_scale_forcing = false;
3192  std::string lsf_file = "";
3193  amrex::Real lsf_timescale = zero;
3194 
3195  // MOST stress rotations
3197 
3198  // Should we use SHOC?
3199  bool use_native_shoc = false;
3200 
3201  // Native shoc transport mode
3204 
3205  // Transport the passive scalar?
3206  bool transport_scalar = true;
3207 
3208  // User wishes to output time averaged velocity fields
3209  bool time_avg_vel = false;
3210 
3211  // User wishes to output interval means and resolved turbulent moments
3212  bool compute_mean_vars = false;
3213 
3214  // Reset interval means after each plotfile or once at a requested time
3215  std::string mean_vars_reset_mode = "plotfile";
3216  amrex::Real mean_vars_reset_time = -one;
3217 
3218  /**
3219  * True when the drag of the immersed solid is applied inside the projection on this
3220  * level (erf.if_implicit_projection on a level that is not FullyCompressible). A
3221  * FullyCompressible level has no projection, so it keeps the drag in the momentum source.
3222  */
3223  [[nodiscard]] bool if_drag_in_projection (int lev) const noexcept
3224  {
3225  return if_implicit_projection &&
3226  (compressibility_type[lev] != CompressibilityType::FullyCompressible);
3227  }
3228 
3229  // Building forcing and its landmask use the same horizontal resolution cutoff, with dx in
3230  // place of a dy over one cell, and the reverse.
3231  [[nodiscard]] bool use_building_immersed_forcing (const amrex::Geometry& geom) const noexcept
3232  {
3233  const auto len = LengthScaleCellSize(geom);
3234  return buildings_type == BuildingsType::ImmersedForcing &&
3235  std::sqrt(len[0] * len[1]) <=
3236  amrex::Real(50.0) * (one + amrex::Real(1.e-6));
3237  }
3238 
3239  // Whether a level takes acoustic substeps. Anelastic, pseudo-incompressible and
3240  // RK3_NoSubstepping levels do not, so a source term that is asked to be applied in
3241  // the substeps only is applied on the slow step there instead.
3242  [[nodiscard]] bool level_substeps (int lev) const noexcept
3243  {
3244  return timestepping_type[lev] == TimesteppingType::RK3_ImplicitSubstep;
3245  }
3246 
3247  // Rayleigh damping of u, v and (rho theta) in the substeps (FastExplicit, FastImplicit)
3248  [[nodiscard]] bool rayleigh_fast_uvT (int lev) const noexcept
3249  {
3250  return level_substeps(lev) &&
3253  }
3254 
3255  // Explicit Rayleigh damping of w in the substeps (FastExplicit only)
3256  [[nodiscard]] bool rayleigh_fast_w (int lev) const noexcept
3257  {
3258  return level_substeps(lev) &&
3260  }
3261 
3262  // Whether the vertical pressure gradient on level lev, in the slow and the fast terms, uses
3263  // the distance between the cell centers z_phys_cc rather than dz. Always on a mesh other
3264  // than ConstantDz; on a ConstantDz mesh only where the base state is nested
3265  // (ERF::build_nested_base_state sets zcc_vertical_metric_lev), since its cell centers are
3266  // then placed to hold the base state in balance and are no longer dz apart.
3267  [[nodiscard]] bool zcc_vertical_metric (int lev) const noexcept
3268  {
3269  if (mesh_type != MeshType::ConstantDz) { return true; }
3270  return lev >= 0 && lev < static_cast<int>(zcc_vertical_metric_lev.size()) &&
3271  zcc_vertical_metric_lev[lev] != 0;
3272  }
3273  amrex::Vector<int> zcc_vertical_metric_lev;
3274 
3275  // Implicit Rayleigh damping of w in the substeps (FastImplicit with erf.rayleigh_damp_W).
3276  // It replaces the explicit w damping, which is then applied on neither step.
3277  [[nodiscard]] bool rayleigh_implicit_w (int lev) const noexcept
3278  {
3279  return level_substeps(lev) && dampingChoice.rayleigh_damp_W &&
3281  }
3282 
3283  // Implicit Rayleigh damping of w on the slow step (with erf.rayleigh_damp_W), on a level without
3284  // acoustic substeps: with SlowImplicit, and by default (erf.rayleigh_damping_type not given) on
3285  // an anelastic or pseudo-incompressible level, whose dt is not limited by the sound speed. It
3286  // replaces the explicit w damping of SlowExplicit, which is unstable once
3287  // rayleigh_dampcoef * dt reaches 2 (RK2) or 2.5 (RK3).
3288  [[nodiscard]] bool rayleigh_slow_implicit_w (int lev) const noexcept
3289  {
3290  if (level_substeps(lev) || !dampingChoice.rayleigh_damp_W) { return false; }
3293  compressibility_type[lev] != CompressibilityType::FullyCompressible;
3294  }
3295 
3296  // Canopy drag in the substeps (erf.forest_substep)
3297  [[nodiscard]] bool forest_fast (int lev) const noexcept
3298  {
3299  return level_substeps(lev) && forest_substep;
3300  }
3301 
3302  // Immersed forcing in the substeps (erf.immersed_forcing_substep)
3303  [[nodiscard]] bool immersed_forcing_fast (int lev) const noexcept
3304  {
3306  }
3307 
3308  /**
3309  * @brief Query whether any turbulent perturbation mode is enabled on a level.
3310  * @param lev AMR level index.
3311  * @return True if source, direct, CPM, or CPM_W perturbations are enabled.
3312  */
3313  bool use_perturbation (int lev) const
3314  {
3315  return pert_type[lev] == PerturbationType::Source ||
3316  pert_type[lev] == PerturbationType::Direct ||
3317  pert_type[lev] == PerturbationType::CPM ||
3318  pert_type[lev] == PerturbationType::CPM_W;
3319  }
3320 
3321  /**
3322  * @brief Query whether direct turbulent perturbations are enabled on a level.
3323  * @param lev AMR level index.
3324  * @return True if direct, CPM, or CPM_W perturbations are enabled.
3325  */
3326  bool use_direct_perturbation (int lev) const
3327  {
3328  return pert_type[lev] == PerturbationType::Direct ||
3329  pert_type[lev] == PerturbationType::CPM ||
3330  pert_type[lev] == PerturbationType::CPM_W;
3331  }
3332 
3333  /**
3334  * @brief Query whether source-term turbulent perturbations are enabled on a level.
3335  * @param lev AMR level index.
3336  * @return True if source perturbations are enabled.
3337  */
3338  bool use_source_perturbation (int lev) const
3339  {
3340  return pert_type[lev] == PerturbationType::Source;
3341  }
3342 
3343  /**
3344  * @brief Query whether vertical-velocity CPM perturbations are enabled on a level.
3345  * @param lev AMR level index.
3346  * @return True if CPM_W perturbations are enabled.
3347  */
3348  bool use_wvel_perturbation (int lev) const
3349  {
3350  return pert_type[lev] == PerturbationType::CPM_W;
3351  }
3352 
3353  /**
3354  * @brief Query whether any SHOC-family PBL scheme is active.
3355  * @return True if native SHOC is active.
3356  */
3357  bool uses_shoc_family () const noexcept
3358  {
3359  return use_native_shoc;
3360  }
3361 
3362  /**
3363  * @brief Test whether the host owns momentum diffusion.
3364  * @return True if ERF dycore does vertical diffusion of momentum.
3365  */
3367  {
3368  if (!use_native_shoc) { return true; }
3370  }
3371 
3372  /**
3373  * @brief Test whether the host owns scalar diffusion.
3374  * @return True if ERF dycore does vertical diffusion of scalars.
3375  */
3377  {
3378  if (!use_native_shoc) { return true; }
3379  return false;
3380  }
3381 
3382  /**
3383  * @brief Query whether the active PBL scheme suppresses microphysics condensation.
3384  * @return True when the active PBL scheme owns condensation handling.
3385  */
3387  {
3388  return uses_shoc_family();
3389  }
3390 
3391  /**
3392  * @brief Query whether any level uses a turbulent perturbation mode.
3393  * @return True if at least one configured level has source, direct, CPM, or CPM_W perturbations.
3394  */
3395  bool any_perturbation () const
3396  {
3397  for (const auto& type : pert_type) {
3398  if (type == PerturbationType::Source ||
3399  type == PerturbationType::Direct ||
3400  type == PerturbationType::CPM ||
3401  type == PerturbationType::CPM_W) {
3402  return true;
3403  }
3404  }
3405  return false;
3406  }
3407 
3408  // Prefer a PBL scheme's height even when the immediate parent is LES.
3409  // An all-LES hierarchy instead uses the nearest LES surface-layer diagnostic.
3410  int perturbation_pblh_level (int lev) const
3411  {
3412  for (int source = lev-1; source >= 0; --source) {
3413  if (turbChoice[source].pbl_type != PBLType::None) { return source; }
3414  }
3415  for (int source = lev-1; source >= 0; --source) {
3416  const auto& tc = turbChoice[source];
3417  if (tc.les_type != LESType::None && !tc.smag2d) { return source; }
3418  }
3419  return -1;
3420  }
3421 
3422  // Type of perturbation
3423  amrex::Vector<PerturbationType> pert_type;
3424  bool perturbation_auto{false};
3425  amrex::Real perturbation_auto_period{amrex::Real(600.0)}; // seconds between parent-based updates
3426  amrex::Real perturbation_auto_pbl_fraction{amrex::Real(0.9)};
3427 
3428  // Numerical diffusion
3429  bool use_num_diff{false};
3430  amrex::Real num_diff_coeff{zero};
3431 
3432  CouplingType coupling_type;
3433  MoistureType moisture_type;
3434  int sbm_nbins{4};
3448  bool sbm_budget_check{false};
3449  amrex::Vector<amrex::Real> sbm_edges;
3450  amrex::Vector<amrex::Real> sbm_pivots;
3451  amrex::Vector<amrex::Real> sbm_fixture_initial_state;
3452  // The fixture state of cells whose center lies in the upper half of the x domain
3453  amrex::Vector<amrex::Real> sbm_fixture_initial_state_xhi;
3454  std::string sbm_particle_mixing{"None"};
3455  amrex::Real sbm_particle_mixing_kh{0};
3456  amrex::Real sbm_particle_mixing_kv{0};
3457  // Qualification only: particle mixing on a terrain-fitted mesh, which has
3458  // not passed its release gates.
3460  WindFarmType windfarm_type;
3461  WindFarmLocType windfarm_loc_type;
3462  LandSurfaceType lsm_type;
3463  UrbanType urban_type;
3464  amrex::Vector<int> urban_enabled_lev;
3465  RadiationType rad_type;
3466 
3467  /** @brief True for the models that run through the IRadiation interface
3468  * (RRTMGP, Simple); the two-stream model has its own class. */
3469  [[nodiscard]] bool rad_uses_interface () const {
3470  return (rad_type == RadiationType::RRTMGP) || (rad_type == RadiationType::Simple);
3471  }
3472 
3473  /** @brief True when the radiation model's outputs feed the land model
3474  * (downwelling shortwave, downwelling longwave, solar zenith angle). RRTMGP
3475  * writes them for any land model through lsm_output_ptrs; the two-stream
3476  * model writes the broadband three for Noah-MP only
3477  * (TwoStreamRadiation::write_land_forcing), since SLM wants the visible /
3478  * near-infrared direct / diffuse split it does not compute. Both register
3479  * the outputs in ERF::init_stuff and write them in ERF::advance_radiation;
3480  * every site that encodes that rule must use this predicate so wiring
3481  * another model in (e.g. Simple, which already runs through the interface)
3482  * is one edit. */
3483  [[nodiscard]] bool rad_feeds_lsm () const {
3484  return (rad_type == RadiationType::RRTMGP) ||
3485  (rad_type == RadiationType::TwoStream && lsm_type == LandSurfaceType::NOAHMP);
3486  }
3487 
3488  // Does an external ocean coupler supply SST? See the query in init_params.
3489  bool use_coupled_sst = false;
3490  // Does an external ocean coupler supply the surface current? See the query in init_params.
3491  bool use_coupled_currents = false;
3492 
3493  ABLDriverType abl_driver_type;
3494  amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> abl_pressure_grad;
3495  amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> abl_geo_forcing;
3496  std::string abl_geo_wind_table;
3498 
3499  bool variable_coriolis{false};
3500 
3501  int ave_plane {2};
3502 
3503  // Microphysics params
3505 
3507 
3510  amrex::Real sampling_distance_by_D = -one;
3511  amrex::Real turb_disk_angle = -one;
3512  amrex::Real windfarm_x_shift = -one;
3513  amrex::Real windfarm_y_shift = -one;
3514 
3515  // Nudging factor for bdy sponging : F1 = 1/(nudge_factor * dt)
3516  amrex::Real bdy_nudge_factor = amrex::Real(10.0);
3517 
3518  // Use density reconstructed from standard WRF lateral boundary data.
3519  bool use_wrf_bdy_density = true;
3520 
3521  // Density-specific Davies factor; non-positive means use bdy_nudge_factor.
3522  amrex::Real bdy_rho_nudge_factor = amrex::Real(-1.0);
3523 
3524  // Which approach to nudging the moist variables in the boundary region?
3526 
3527  // Average the input z-face heights onto the nodes rather than reconstructing them?
3529 
3530  // When the ERF mesh is reconstructed rather than taken from the file
3531  // (avg_grid_faces_to_nodes = false), build zlevels_stag from the domain-mean
3532  // layer-thickness profile of the wrfinput file. Set false to recover the older
3533  // construction: a single geometric stretch whose first layer is the thickest first
3534  // layer in the file and whose ratio is solved for so the column reaches z_top.
3536 
3537  // Interpolate atmospheric state from coarse when creating finer level at later time?
3539 
3540  // Use forest canopy model?
3541  bool do_forest_drag {false};
3542 
3543  // Fixed-leaf-temperature canopy heat exchange (disabled by default)
3544  bool forest_biophysics {false};
3547  // Canopy terms of the k-eqn RANS model (ERF_CanopyTurbStruct.H)
3549 
3550  // Enforce constant mass flux?
3551  amrex::Real const_massflux_u = zero;
3552  amrex::Real const_massflux_v = zero;
3553  amrex::Real const_massflux_tau = one;
3554  amrex::Real const_massflux_layer_lo = amrex::Real(-bogus_large_value);
3555  amrex::Real const_massflux_layer_hi = amrex::Real( bogus_large_value);
3556  int massflux_klo {0}; // these are updated in ERF.cpp
3557  int massflux_khi {0};
3558 
3562  bool hindcast_surface_bcs = false;
3566 
3568  amrex::Real hurricane_eye_latitude = -1e10, hurricane_eye_longitude = -1e10;
3569 
3570  bool is_init_for_ensemble = false;
3571  int n_ensemble = -1;
3572  amrex::Real ens_pert_correlated_radius = -1.0;
3573  amrex::Real ens_pert_amplitude = -1.0;
3575 };
3576 
3577 /**
3578  * @var SolverChoice::init_type
3579  * @brief Initial-condition source selected for the run.
3580  * @var SolverChoice::sounding_type
3581  * @brief Interpretation used for input sounding profiles.
3582  * @var SolverChoice::terrain_type
3583  * @brief Terrain or immersed-boundary representation.
3584  * @var SolverChoice::flat_terrain
3585  * @brief Permit fixed-index planar averages after validating a flat fitted mesh.
3586  * @var SolverChoice::buildings_type
3587  * @brief Building representation.
3588  * @var SolverChoice::buildings_fc_factories
3589  * @brief Use native face-centered EB factories for immersed buildings on a static fitted mesh.
3590  * @var SolverChoice::use_real_bcs
3591  * @brief Whether real-data lateral boundary conditions are used.
3592  * @var SolverChoice::mesh_type
3593  * @brief Vertical mesh representation.
3594  * @var SolverChoice::advChoice
3595  * @brief Advection-related options.
3596  * @var SolverChoice::diffChoice
3597  * @brief Diffusion-related options.
3598  * @var SolverChoice::dampingChoice
3599  * @brief Damping-related options.
3600  * @var SolverChoice::spongeChoice
3601  * @brief Sponge-layer options.
3602  * @var SolverChoice::turbChoice
3603  * @brief Turbulence options for each AMR level.
3604  * @var SolverChoice::ebChoice
3605  * @brief Embedded-boundary options.
3606  * @var SolverChoice::force_stage1_single_substep
3607  * @brief Flag forcing a single substep in the first RK stage.
3608  * @var SolverChoice::compressibility_type
3609  * @brief Per-level compressibility (FullyCompressible, Anelastic or PseudoIncompressible).
3610  * @var SolverChoice::timestepping_type
3611  * @brief Per-level time integrator (RK3_ImplicitSubstep, RK3_NoSubstepping, RK2 or MidPoint).
3612  * @var SolverChoice::fixed_density
3613  * @brief Per-level flag selecting fixed-density treatment; always 1 at an anelastic level and 0 at a pseudo-incompressible level.
3614  * @var SolverChoice::project_initial_velocity
3615  * @brief Per-level flag for projecting the initial velocity.
3616  * @var SolverChoice::buoyancy_type
3617  * @brief Per-level buoyancy formulation selector.
3618  * @var SolverChoice::is_land
3619  * @brief Per-level land/water selector.
3620  * @var SolverChoice::substepping_diag
3621  * @brief Whether to emit extra CFL diagnostics for compressible substepping.
3622  * @var SolverChoice::beta_s
3623  * @brief Time off-centering coefficient for forward weighting.
3624  * @var SolverChoice::use_variable_beta_s
3625  * @brief Whether beta_s varies on the w-faces with the terrain slope and acoustic Courant number.
3626  * @var SolverChoice::auto_variable_beta_s
3627  * @brief Whether erf.use_variable_beta_s may be turned on automatically (it is not set in the inputs).
3628  * @var SolverChoice::beta_d
3629  * @brief Divergence damping coefficient used in the acoustic substepping.
3630  * @var SolverChoice::vert_implicit_fac
3631  * @brief Per-level, per-stage implicit vertical diffusion factors.
3632  * @var SolverChoice::implicit_thermal_diffusion
3633  * @brief Whether implicit vertical thermal diffusion is included.
3634  * @var SolverChoice::implicit_moisture_diffusion
3635  * @brief Whether implicit vertical moisture diffusion is included.
3636  * @var SolverChoice::implicit_ke_diffusion
3637  * @brief Whether implicit vertical TKE diffusion is included.
3638  * @var SolverChoice::implicit_momentum_diffusion
3639  * @brief Whether implicit vertical momentum diffusion is included.
3640  * @var SolverChoice::implicit_before_substep
3641  * @brief Whether implicit diffusion is applied before acoustic substepping.
3642  * @var SolverChoice::implicit_terrain_metric
3643  * @brief Whether the compact terrain-metric part of the vertical diffusion is solved implicitly.
3644  * @var SolverChoice::ncorr
3645  * @brief Number of projection correction iterations.
3646  * @var SolverChoice::terrain_poisson_solver
3647  * @brief Projection solver on a terrain-fitted mesh: gmres_fft (default), mlmg or gmres_mlmg.
3648  * @var SolverChoice::poisson_abstol
3649  * @brief Absolute tolerance for the Poisson solve.
3650  * @var SolverChoice::poisson_reltol
3651  * @brief Relative tolerance for the Poisson solve.
3652  * @var SolverChoice::test_mapfactor
3653  * @brief Whether to use test map scale factors.
3654  * @var SolverChoice::test_mapfactor_amp
3655  * @brief Amplitude of the spatially varying test map scale factors on level 0 (0: not used).
3656  * @var SolverChoice::gradp_type
3657  * @brief Terrain-fitted horizontal pressure-gradient formulation.
3658  * @var SolverChoice::gradp_2nd_order_bndry
3659  * @brief Whether ChainRule takes dp/dz at the bottom and top from a second-order one-sided difference.
3660  * @var SolverChoice::use_pert_pres_gradient
3661  * @brief Whether momentum equations use perturbational pressure gradients.
3662  * @var SolverChoice::use_gravity
3663  * @brief Whether gravitational forcing is enabled.
3664  * @var SolverChoice::use_coriolis
3665  * @brief Whether Coriolis forcing is enabled.
3666  * @var SolverChoice::coriolis_3d
3667  * @brief Whether the three-dimensional Coriolis terms are included.
3668  * @var SolverChoice::four_stream_radiation
3669  * @brief Whether the four-stream radiation approximation is enabled.
3670  * @var SolverChoice::immersed_forcing_substep
3671  * @brief Whether immersed-forcing source terms are applied only during substeps.
3672  * @var SolverChoice::forest_substep
3673  * @brief Whether canopy source terms are applied only during substeps.
3674  * @var SolverChoice::if_Cd_momentum
3675  * @brief Immersed-forcing drag coefficient for momentum.
3676  * @var SolverChoice::if_Cd_scalar
3677  * @brief Immersed-forcing drag coefficient for scalars.
3678  * @var SolverChoice::if_z0
3679  * @brief Immersed-forcing roughness length [m].
3680  * @var SolverChoice::if_surf_temp_flux
3681  * @brief Immersed-forcing surface temperature flux [K m/s].
3682  * @var SolverChoice::if_init_surf_temp
3683  * @brief Initial immersed-forcing surface temperature [K].
3684  * @var SolverChoice::if_fraction_stress
3685  * @brief erf.if_wall_form = fraction_stress: the wall stress of ERF_ImmersedWallCell.H in the wall
3686  * cell of each column, with the wall face closed to diffusion; false is the legacy MOST
3687  * relaxation at fixed 0.5/1.5 dz (the default, unchanged).
3688  * @var SolverChoice::if_wall_face_spacing
3689  * @brief Spacing the face above the fraction-stress wall cell differences over: 0 the cell
3690  * height, 1 the centroid spacing, 2 (default) the log spacing (ib_wall::face_above_factor).
3691  * @var SolverChoice::if_wall_tke
3692  * @brief Hold the k-eqn TKE of the fraction-stress wall cell at its flat-ground wall value
3693  * (ib_wall::wall_tke), as erf.dirichlet_k does over flat ground.
3694  * @var SolverChoice::if_wall_tke_time_factor
3695  * @brief 1 (the default) pins the wall cell after every stage and in the implicit TKE solve;
3696  * a larger value relaxes toward the wall value as a source over that many steps.
3697  * @var SolverChoice::if_flat_wall_dissipation
3698  * @brief Partial fraction-stress wall cells dissipate TKE with the length scale of flat ground's
3699  * first cell; on by default with the fraction-stress law.
3700  * @var SolverChoice::if_surf_heating_rate
3701  * @brief Immersed-forcing surface heating rate [K/hr].
3702  * @var SolverChoice::if_Olen_in
3703  * @brief Input Obukhov length for immersed-forcing MOST [m].
3704  * @var SolverChoice::if_use_most
3705  * @brief Whether immersed-forcing MOST is enabled.
3706  * @var SolverChoice::if_average_down
3707  * @brief Cell average down over immersed-forcing levels: "plain" (the default, the plain cell
3708  * average) or "fluid_mass" (the fine cells weighted by their fluid mass, coarse cells solid
3709  * on their own level kept; see if_average_down in ERF_Utils.H).
3710  * @var SolverChoice::if_cf_mismatch_warning
3711  * @brief Spread of the fine solid fractions under a coarse cell along a lateral coarse/fine face
3712  * at or above which the start-up warning counts the cell (the levels describe the surface
3713  * differently there); 0 turns the check off.
3714  * @var SolverChoice::cf_loglaw_fill
3715  * @brief Share the flux of the first coarse face above a wall among its fine sub-faces at the
3716  * lateral coarse/fine faces by ln(1 + z/z0) at their heights above the wall, instead of the
3717  * linear interpolation; the immersed surface or a surface-layer bottom, constant dz.
3718  * @var SolverChoice::cf_loglaw_z0
3719  * @brief Roughness length [m] of that share; by default erf.if_z0 with immersed forcing, else
3720  * the inputs' erf.most.z0 or erf.zlo.most.z0 (0.1 m when neither is given).
3721  * @var SolverChoice::if_small_volfrac
3722  * @brief Immersed-forcing solid fraction below which a cell or face counts as fluid; read from
3723  * eb2.small_volfrac (default 0.005), the same value the EB build uses.
3724  * @var SolverChoice::if_snap_partial_cells
3725  * When true, the immersed forcing reads the blanking snapped to solid (1) or
3726  * fluid (0) at half, so a building from a height map becomes the same
3727  * staircase of whole cells an exact box is: the wall law (and the thermal
3728  * conditions) sit on the boundary solid cells, roofs included, the drag on
3729  * the interior cells, and nothing on the sliver cells of the reader's
3730  * one-cell ramp (1-20 percent solid at the corners), on which the raw
3731  * fractions make the wall law and the drag disagree and grow a vertical
3732  * checkerboard over hours. The staircase puts full-strength forcing on every
3733  * wall face, so the switch also selects the point-implicit drag form
3734  * (if_implicit_drag), without which the explicit rate at rims and corners
3735  * drives the density negative within seconds. The momentum kernels take the
3736  * blanking of a face from the two cells it joins (solid if either is), so
3737  * the staircase is the same with and without the face-centered blanking of
3738  * the build; a face between a solid and a fluid cell is wall-normal and gets
3739  * the interior drag toward zero (no penetration) whichever row it lies in,
3740  * and a face between two solid cells the roof or wall law of its row (with
3741  * the full log-law target; the partial-cell weight of the target is not
3742  * applied) or the interior drag. Buildings only (erf.buildings_type = ImmersedForcing): the
3743  * terrain kernels keep the raw fractions, whose wall law is weighted by the
3744  * fluid fraction of the face. Default false, the raw fractions, for backward
3745  * compatibility (on an exact box a boundary cell then carries the wall law
3746  * and the interior drag together, and the roof only the drag); set it for
3747  * height-map buildings.
3748  * @var SolverChoice::if_stability_correction
3749  * @brief Whether the immersed-forcing wall law applies the MOST similarity functions, in the momentum and the
3750  * temperature kernels alike (off: the log law; a prescribed flux or Obukhov length still sets theta*).
3751  * @var SolverChoice::if_ws_floor
3752  * @brief Wind-speed floor [m/s] in the per-step change limit of the building wall-law forcing.
3753  * @var SolverChoice::if_damp_alpha
3754  * @brief Immersed-forcing damping coefficient.
3755  * @var SolverChoice::if_stability_wind_floor
3756  * @brief Wind-speed floor [m/s] behind the friction velocity of the wall law's stability estimate (0: none).
3757  * @var SolverChoice::if_psi_cap_factor
3758  * @brief Cap on psi_m in the immersed momentum wall law as a fraction of ln(z/z0) (1: none).
3759  * @var SolverChoice::use_lagged_delta_rt
3760  * @brief Whether to use lagged delta terms for moving terrain.
3761  * @var SolverChoice::rebalance_wrf_input
3762  * @brief Whether to rebalance states from wrfinput and wrfbdy data.
3763  * @var SolverChoice::gravity
3764  * @brief Effective gravitational acceleration.
3765  * @var SolverChoice::c_p
3766  * @brief Specific heat at constant pressure for dry air [J/(kg-K)].
3767  * @var SolverChoice::rdOcp
3768  * @brief Ratio of dry-air gas constant to c_p.
3769  * @var SolverChoice::grid_stretching_ratio
3770  * @brief Vertical grid stretching ratio.
3771  * @var SolverChoice::dz0
3772  * @brief Initial vertical grid spacing for stretched-grid setup.
3773  * @var SolverChoice::coriolis_factor
3774  * @brief Twice the planetary rotation rate used for Coriolis forcing.
3775  * @var SolverChoice::cosphi
3776  * @brief Cosine of the latitude used for Coriolis forcing.
3777  * @var SolverChoice::sinphi
3778  * @brief Sine of the latitude used for Coriolis forcing.
3779  * @var SolverChoice::custom_rhotheta_forcing
3780  * @brief Whether custom rho-theta forcing is enabled.
3781  * @var SolverChoice::custom_moisture_forcing
3782  * @brief Whether custom moisture forcing is enabled.
3783  * @var SolverChoice::custom_w_subsidence
3784  * @brief Whether custom vertical subsidence is enabled.
3785  * @var SolverChoice::do_theta_advection
3786  * @brief Whether custom vertical subsidence is applied to rho-theta.
3787  * @var SolverChoice::do_mom_advection
3788  * @brief Whether custom vertical subsidence is applied to momentum.
3789  * @var SolverChoice::custom_geostrophic_profile
3790  * @brief Whether a custom geostrophic wind profile is used.
3791  * @var SolverChoice::custom_forcing_prim_vars
3792  * @brief Whether custom forcing operates on primitive variables.
3793  * @var SolverChoice::spatial_rhotheta_forcing
3794  * @brief Whether spatially varying rho-theta forcing is enabled.
3795  * @var SolverChoice::spatial_moisture_forcing
3796  * @brief Whether spatially varying moisture forcing is enabled.
3797  * @var SolverChoice::nudging_from_input_sounding
3798  * @brief Whether solution fields are nudged toward input sounding data.
3799  * @var SolverChoice::nudging_from_observations
3800  * @brief Whether solution fields are nudged toward observations at stations.
3801  * @var SolverChoice::use_rotate_surface_flux
3802  * @brief Whether MOST surface fluxes are rotated with terrain.
3803  * @var SolverChoice::use_native_shoc
3804  * @brief Whether any level uses the native SHOC PBL scheme.
3805  * @var SolverChoice::transport_scalar
3806  * @brief Whether the passive scalar component is transported.
3807  * @var SolverChoice::time_avg_vel
3808  * @brief Whether time-averaged velocity fields are output.
3809  * @var SolverChoice::pert_type
3810  * @brief Turbulent perturbation type for each AMR level.
3811  * @var SolverChoice::perturbation_auto
3812  * @brief Select LES nests, using parent winds and a PBL ancestor's height,
3813  * or the nearest LES ancestor's diagnostic when no PBL scheme is present.
3814  * Defaults to true for WRFInput and Metgrid initialization, false otherwise.
3815  * @var SolverChoice::perturbation_auto_period
3816  * @brief Seconds between automatic parent-wind and PBL-height updates.
3817  * @var SolverChoice::perturbation_auto_pbl_fraction
3818  * @brief Fraction of the selected ancestor's PBL height occupied by perturbations.
3819  * @var SolverChoice::use_num_diff
3820  * @brief Whether sixth-order numerical diffusion is enabled.
3821  * @var SolverChoice::num_diff_coeff
3822  * @brief Numerical diffusion coefficient after input scaling.
3823  * @var SolverChoice::coupling_type
3824  * @brief Multilevel coupling strategy.
3825  * @var SolverChoice::moisture_type
3826  * @brief Moisture or microphysics model.
3827  * @var SolverChoice::windfarm_type
3828  * @brief Wind-farm model.
3829  * @var SolverChoice::windfarm_loc_type
3830  * @brief Coordinate system for wind-farm turbine locations.
3831  * @var SolverChoice::lsm_type
3832  * @brief Land-surface model.
3833  * @var SolverChoice::rad_type
3834  * @brief Radiation model.
3835  * @var SolverChoice::abl_driver_type
3836  * @brief Atmospheric boundary-layer driver type.
3837  * @var SolverChoice::abl_pressure_grad
3838  * @brief Applied ABL pressure-gradient forcing vector.
3839  * @var SolverChoice::abl_geo_forcing
3840  * @brief Applied geostrophic-wind forcing vector.
3841  * @var SolverChoice::abl_geo_wind_table
3842  * @brief Path to a time-varying geostrophic wind table.
3843  * @var SolverChoice::have_geo_wind_profile
3844  * @brief Whether a geostrophic wind profile has been configured.
3845  * @var SolverChoice::variable_coriolis
3846  * @brief Whether spatially varying Coriolis forcing is enabled.
3847  * @var SolverChoice::ave_plane
3848  * @brief Averaging plane index used by diagnostics.
3849  * @var SolverChoice::moisture_indices
3850  * @brief Index map of the moisture data carried by the active scheme: conserved-state
3851  * components for the species and qmoist slots for the moist diagnostics.
3852  * @var SolverChoice::moisture_tight_coupling
3853  * @brief Whether moisture updates use tight coupling.
3854  * @var SolverChoice::windfarm_loc_table
3855  * @brief Wind-farm location table path.
3856  * @var SolverChoice::windfarm_spec_table
3857  * @brief Wind-farm turbine specification table path.
3858  * @var SolverChoice::windfarm_spec_table_extra
3859  * @brief Additional wind-farm turbine specification table path.
3860  * @var SolverChoice::windfarm_blade_table
3861  * @brief Wind-farm blade table path.
3862  * @var SolverChoice::windfarm_airfoil_tables
3863  * @brief Wind-farm airfoil table paths.
3864  * @var SolverChoice::sampling_distance_by_D
3865  * @brief Turbine inflow sampling distance normalized by rotor diameter.
3866  * @var SolverChoice::turb_disk_angle
3867  * @brief Turbine disk angle from the x axis [deg].
3868  * @var SolverChoice::windfarm_x_shift
3869  * @brief Wind-farm x-coordinate shift.
3870  * @var SolverChoice::windfarm_y_shift
3871  * @brief Wind-farm y-coordinate shift.
3872  * @var SolverChoice::bdy_nudge_factor
3873  * @brief Boundary sponge nudging factor.
3874  * @var SolverChoice::bdy_moist_nudge_type
3875  * @brief Moist-variable nudging strategy in boundary regions.
3876  * @var SolverChoice::do_forest_drag
3877  * @brief Whether forest canopy drag is enabled.
3878  * @var SolverChoice::const_massflux_u
3879  * @brief Target constant mass flux in the x direction.
3880  * @var SolverChoice::const_massflux_v
3881  * @brief Target constant mass flux in the y direction.
3882  * @var SolverChoice::const_massflux_tau
3883  * @brief Relaxation time scale for constant-mass-flux forcing.
3884  * @var SolverChoice::const_massflux_layer_lo
3885  * @brief Lower height of the constant-mass-flux forcing layer.
3886  * @var SolverChoice::const_massflux_layer_hi
3887  * @brief Upper height of the constant-mass-flux forcing layer.
3888  * @var SolverChoice::massflux_klo
3889  * @brief Lower vertical index for constant-mass-flux forcing.
3890  * @var SolverChoice::massflux_khi
3891  * @brief Upper vertical index for constant-mass-flux forcing.
3892  * @var SolverChoice::hindcast_boundary_data_dir
3893  * @brief Directory containing hindcast lateral boundary data.
3894  * @var SolverChoice::hindcast_surface_data_dir
3895  * @brief Directory containing hindcast surface boundary data.
3896  * @var SolverChoice::hindcast_data_interval_in_hrs
3897  * @brief Time interval between hindcast data files [hr].
3898  * @var SolverChoice::hindcast_lateral_forcing
3899  * @brief Whether hindcast lateral forcing is enabled.
3900  * @var SolverChoice::hindcast_surface_bcs
3901  * @brief Whether hindcast surface boundary conditions are enabled.
3902  * @var SolverChoice::hindcast_lateral_sponge_strength
3903  * @brief Strength of the hindcast lateral sponge layer.
3904  * @var SolverChoice::hindcast_lateral_sponge_length
3905  * @brief Length of the hindcast lateral sponge layer.
3906  * @var SolverChoice::hindcast_zhi_sponge_strength
3907  * @brief Strength of the upper hindcast sponge layer.
3908  * @var SolverChoice::hindcast_zhi_sponge_length
3909  * @brief Length of the upper hindcast sponge layer.
3910  * @var SolverChoice::hindcast_zhi_sponge_damping
3911  * @brief Whether upper-boundary hindcast sponge damping is enabled.
3912  * @var SolverChoice::io_hurricane_eye_tracker
3913  * @brief Whether hurricane-eye tracking output is enabled.
3914  * @var SolverChoice::hurricane_eye_latitude
3915  * @brief Initial hurricane-eye latitude.
3916  * @var SolverChoice::hurricane_eye_longitude
3917  * @brief Initial hurricane-eye longitude.
3918  * @var SolverChoice::is_init_for_ensemble
3919  * @brief Whether initialization is for an ensemble simulation.
3920  * @var SolverChoice::n_ensemble
3921  * @brief Number of ensemble members.
3922  * @var SolverChoice::ens_pert_correlated_radius
3923  * @brief Spatial correlation radius for ensemble perturbations.
3924  * @var SolverChoice::ens_pert_amplitude
3925  * @brief Amplitude of ensemble initialization perturbations.
3926  * @var SolverChoice::coarse_bckgnd_data_file
3927  * @brief Coarse background data file used for ensemble initialization.
3928  */
3929 #endif
constexpr amrex::Real Cp_d
Definition: ERF_Constants.H:51
constexpr amrex::Real bogus_large_value
Definition: ERF_Constants.H:19
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:72
constexpr amrex::Real R_d
Definition: ERF_Constants.H:49
static const std::string BoundaryFaceName[]
Definition: ERF_DataStruct.H:246
TauType
Stress tensor component indices.
Definition: ERF_DataStruct.H:50
@ tau12
Definition: ERF_DataStruct.H:51
@ tau23
Definition: ERF_DataStruct.H:51
@ tau33
Definition: ERF_DataStruct.H:51
@ tau22
Definition: ERF_DataStruct.H:51
@ tau11
Definition: ERF_DataStruct.H:51
@ tau32
Definition: ERF_DataStruct.H:51
@ tau31
Definition: ERF_DataStruct.H:51
@ tau21
Definition: ERF_DataStruct.H:51
@ tau13
Definition: ERF_DataStruct.H:51
Rayleigh
Rayleigh damping profile component indices.
Definition: ERF_DataStruct.H:234
@ ubar
Definition: ERF_DataStruct.H:235
@ wbar
Definition: ERF_DataStruct.H:235
@ nvars
Definition: ERF_DataStruct.H:235
@ vbar
Definition: ERF_DataStruct.H:235
@ thetabar
Definition: ERF_DataStruct.H:235
Sponge
Sponge reference-state component indices.
Definition: ERF_DataStruct.H:242
@ nvars_sponge
Definition: ERF_DataStruct.H:243
@ vbar_sponge
Definition: ERF_DataStruct.H:243
@ ubar_sponge
Definition: ERF_DataStruct.H:243
MapFacType
Indices for map scale factors on mass and face grids.
Definition: ERF_DataStruct.H:38
@ v_x
Definition: ERF_DataStruct.H:40
@ num
Definition: ERF_DataStruct.H:40
@ u_y
Definition: ERF_DataStruct.H:41
@ v_y
Definition: ERF_DataStruct.H:41
@ m_y
Definition: ERF_DataStruct.H:41
@ u_x
Definition: ERF_DataStruct.H:40
@ m_x
Definition: ERF_DataStruct.H:40
Coord
Coordinate-axis selector.
Definition: ERF_DataStruct.H:226
AMREX_ENUM(PlotFileType, None, Amrex, Netcdf)
#define RhoQ4_comp
Definition: ERF_IndexDefines.H:81
#define RhoQ2_comp
Definition: ERF_IndexDefines.H:79
#define RhoQ3_comp
Definition: ERF_IndexDefines.H:80
#define RhoQ11_comp
Definition: ERF_IndexDefines.H:88
#define RhoQ9_comp
Definition: ERF_IndexDefines.H:86
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:78
#define RhoQ6_comp
Definition: ERF_IndexDefines.H:83
#define RhoQ8_comp
Definition: ERF_IndexDefines.H:85
#define RhoQ5_comp
Definition: ERF_IndexDefines.H:82
#define RhoQ7_comp
Definition: ERF_IndexDefines.H:84
AdvType
Definition: ERF_IndexDefines.H:329
@ Centered_4th
@ Centered_6th
@ Centered_2nd
@ surface_layer
#define RhoQ10_comp
Definition: ERF_IndexDefines.H:87
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
ParmParse pp("prob")
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > LengthScaleCellSize(const amrex::Geometry &geom)
Definition: ERF_LengthScaleCellSize.H:28
similarity_funs read_most_similarity_funs(amrex::ParmParse &pp, const std::string &who="Surface layer")
Definition: ERF_MOSTUtils.H:379
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46
std::string name
Definition: ERF_Plotfile2DCatalog.cpp:139
Radiation model type and control parameters.
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:95
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:124
Definition: ERF_NOAHMP.H:57
Definition: ERF_SAM.H:57
Definition: ERF_SLM.H:187
Definition: ERF_SatAdj.H:47
Definition: ERF_SimpleAD.H:8
Definition: ERF_WDM6.H:115
Definition: ERF_WSM6.H:128
@ None
Definition: ERF_LSM_Types.H:6
@ fc
Definition: ERF_AdvanceMorrison.cpp:141
@ dz
Definition: ERF_AdvanceWDM6.cpp:273
@ t
Definition: ERF_WSM6.H:295
Definition: ERF_AdvStruct.H:19
void display(std::string &pp_prefix)
Print the configured advection choices.
Definition: ERF_AdvStruct.H:240
void init_params(std::string pp_prefix)
Read advection options from the input parameter database.
Definition: ERF_AdvStruct.H:25
bool have_zero_flux_faces
Whether any zero-flux thin immersed-body faces were specified.
Definition: ERF_AdvStruct.H:424
AdvType dycore_vert_adv_type
Vertical advection scheme for dynamical-core variables.
Definition: ERF_AdvStruct.H:404
AdvType moistscal_vert_adv_type
Vertical advection scheme for moist scalar variables.
Definition: ERF_AdvStruct.H:408
AdvType dryscal_horiz_adv_type
Horizontal advection scheme for dry scalar variables.
Definition: ERF_AdvStruct.H:405
AdvType dycore_horiz_adv_type
Horizontal advection scheme for dynamical-core variables.
Definition: ERF_AdvStruct.H:403
AdvType moistscal_horiz_adv_type
Horizontal advection scheme for moist scalar variables.
Definition: ERF_AdvStruct.H:407
std::string adv_type_convert_int_to_string(AdvType adv_int)
Convert an advection type enum to the corresponding input string.
Definition: ERF_AdvStruct.H:329
AdvType dryscal_vert_adv_type
Vertical advection scheme for dry scalar variables.
Definition: ERF_AdvStruct.H:406
Definition: ERF_CanopyTurbStruct.H:16
void init_params(amrex::ParmParse &pp)
Definition: ERF_CanopyTurbStruct.H:32
Definition: ERF_DampingStruct.H:22
RayleighDampingType rayleigh_damping_type
Selected Rayleigh damping time-integration treatment.
Definition: ERF_DampingStruct.H:116
void init_params(std::string pp_prefix)
Read damping options from the input parameter database.
Definition: ERF_DampingStruct.H:28
bool rayleigh_damp_W
Whether Rayleigh damping is applied to vertical momentum.
Definition: ERF_DampingStruct.H:101
bool rayleigh_damping_type_given
Definition: ERF_DampingStruct.H:117
void display()
Print the configured damping options.
Definition: ERF_DampingStruct.H:76
Definition: ERF_DiffStruct.H:25
MolecDiffType molec_diff_type
Selected molecular transport model.
Definition: ERF_DiffStruct.H:97
void init_params(std::string pp_prefix)
Read diffusion options from the input parameter database.
Definition: ERF_DiffStruct.H:31
void display()
Print the configured diffusion options.
Definition: ERF_DiffStruct.H:80
Definition: ERF_EBStruct.H:36
void display()
Print the configured embedded-boundary options.
Definition: ERF_EBStruct.H:74
void init_params(std::string pp_prefix, bool requires_cover)
Read embedded-boundary options from the input parameter database.
Definition: ERF_EBStruct.H:44
An ordered list of conserved-state components forming an aggregate moisture output variable (qt,...
Definition: ERF_DataStruct.H:542
int comp[max_size]
Definition: ERF_DataStruct.H:544
int size
Definition: ERF_DataStruct.H:545
bool empty() const
Definition: ERF_DataStruct.H:551
void append(int c)
Append a component, ignoring the ones the scheme does not carry.
Definition: ERF_DataStruct.H:548
static constexpr int max_size
qv, qc, qi, qr, qs, qg
Definition: ERF_DataStruct.H:543
Whether this map decides a variable's availability, and if so whether the variable is available.
Definition: ERF_DataStruct.H:671
bool available
the active scheme carries the data behind it
Definition: ERF_DataStruct.H:673
bool governed
the name is a moisture output variable
Definition: ERF_DataStruct.H:672
The moisture data carried by the active microphysics scheme.
Definition: ERF_DataStruct.H:279
int nc
cloud liquid water number
Definition: ERF_DataStruct.H:300
int qs
snow
Definition: ERF_DataStruct.H:294
int cond_rate
condensation rate
Definition: ERF_DataStruct.H:329
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:632
int nn
CCN / total aerosol number.
Definition: ERF_DataStruct.H:310
int qr
rain
Definition: ERF_DataStruct.H:293
static constexpr int absent
not carried by the active scheme
Definition: ERF_DataStruct.H:282
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:594
int precip_accum
accumulated surface precipitation, all species
Definition: ERF_DataStruct.H:327
MoistureComponentIndices()=default
Construct an empty map, i.e. a dry run.
int qi
cloud ice
Definition: ERF_DataStruct.H:292
int rel_hum
relative humidity
Definition: ERF_DataStruct.H:328
int graupel_accum
accumulated surface graupel
Definition: ERF_DataStruct.H:326
static constexpr int computed_from_state
Definition: ERF_DataStruct.H:283
int ni
cloud ice number
Definition: ERF_DataStruct.H:301
int qv
water vapor
Definition: ERF_DataStruct.H:290
int rain_accum
accumulated surface rain
Definition: ERF_DataStruct.H:324
CompList nonprecipitating_comps() const
Components summed for non-precipitating water, "qn": vapor plus the suspended condensate....
Definition: ERF_DataStruct.H:570
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:610
int snow_accum
accumulated surface snow
Definition: ERF_DataStruct.H:325
CompList total_water_comps() const
Components summed for total water, "qt": every mass mixing ratio.
Definition: ERF_DataStruct.H:559
int nr
rain number
Definition: ERF_DataStruct.H:302
int qc
cloud liquid water
Definition: ERF_DataStruct.H:291
int ng
graupel number
Definition: ERF_DataStruct.H:304
CompList precipitating_comps() const
Components summed for precipitating water, "qp": the falling species.
Definition: ERF_DataStruct.H:579
int qg
graupel
Definition: ERF_DataStruct.H:295
bool has_moisture() const
Test whether the active scheme carries any moisture at all.
Definition: ERF_DataStruct.H:620
int ns
snow number
Definition: ERF_DataStruct.H:303
VarAvailability query_var(const std::string &name) const
Classify an output variable name against this index map.
Definition: ERF_DataStruct.H:687
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:733
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:385
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:351
int qmoist_index_for_var(const std::string &name) const
The qmoist slot behind a moist diagnostic output name.
Definition: ERF_DataStruct.H:657
Definition: ERF_RadStruct.H:83
void read(const std::string &prefix)
Definition: ERF_RadStruct.H:89
Container holding radiation-related choices and parameters.
Definition: ERF_RadStruct.H:142
void init_params(bool two_stream_selected, std::string pp_prefix)
Definition: ERF_RadStruct.H:1064
Definition: ERF_DataStruct.H:743
bool use_coupled_sst
Definition: ERF_DataStruct.H:3489
int sbm_moment_mode
Definition: ERF_DataStruct.H:3435
bool custom_geostrophic_profile
Whether a custom geostrophic wind profile is used.
Definition: ERF_DataStruct.H:3167
int n_ensemble
Number of ensemble members.
Definition: ERF_DataStruct.H:3571
WindFarmLocType windfarm_loc_type
Coordinate system for wind-farm turbine locations.
Definition: ERF_DataStruct.H:3461
bool implicit_before_substep
Whether implicit diffusion is applied before acoustic substepping.
Definition: ERF_DataStruct.H:3065
amrex::Real const_massflux_v
Target constant mass flux in the y direction.
Definition: ERF_DataStruct.H:3552
std::string hindcast_boundary_data_dir
Directory containing hindcast lateral boundary data.
Definition: ERF_DataStruct.H:3559
amrex::Real if_psi_cap_factor
Cap on psi_m in the immersed momentum wall law as a fraction of ln(z/z0) (1: none).
Definition: ERF_DataStruct.H:3134
amrex::Real ens_pert_correlated_radius
Spatial correlation radius for ensemble perturbations.
Definition: ERF_DataStruct.H:3572
amrex::Real forest_leaf_theta_fixed
Definition: ERF_DataStruct.H:3546
static InitType init_type
Initial-condition source selected for the run.
Definition: ERF_DataStruct.H:2983
amrex::Real coriolis_factor
Twice the planetary rotation rate used for Coriolis forcing.
Definition: ERF_DataStruct.H:3157
bool if_drag_in_projection(int lev) const noexcept
Definition: ERF_DataStruct.H:3223
int perturbation_pblh_level(int lev) const
Definition: ERF_DataStruct.H:3410
bool io_hurricane_eye_tracker
Whether hurricane-eye tracking output is enabled.
Definition: ERF_DataStruct.H:3567
static bool flat_terrain
Permit fixed-index planar averages after validating a flat fitted mesh.
Definition: ERF_DataStruct.H:2992
std::string abl_geo_wind_table
Path to a time-varying geostrophic wind table.
Definition: ERF_DataStruct.H:3496
amrex::Vector< int > fixed_density
Per-level flag selecting fixed-density treatment; always 1 at an anelastic level and 0 at a pseudo-in...
Definition: ERF_DataStruct.H:3030
amrex::Vector< TurbChoice > turbChoice
Turbulence options for each AMR level.
Definition: ERF_DataStruct.H:3020
amrex::Real const_massflux_layer_lo
Lower height of the constant-mass-flux forcing layer.
Definition: ERF_DataStruct.H:3554
amrex::Vector< TimesteppingType > timestepping_type
Per-level time integrator (RK3_ImplicitSubstep, RK3_NoSubstepping, RK2 or MidPoint).
Definition: ERF_DataStruct.H:3029
amrex::Real hindcast_zhi_sponge_length
Length of the upper hindcast sponge layer.
Definition: ERF_DataStruct.H:3564
TopographicShadingChoice topographicChoice
Definition: ERF_DataStruct.H:3024
bool if_fraction_stress
erf.if_wall_form = fraction_stress: the wall stress of ERF_ImmersedWallCell.H in the wall cell of eac...
Definition: ERF_DataStruct.H:3126
amrex::Real gravity
Effective gravitational acceleration.
Definition: ERF_DataStruct.H:3148
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:2476
bool pbl_suppresses_microphysics_condensation() const noexcept
Query whether the active PBL scheme suppresses microphysics condensation.
Definition: ERF_DataStruct.H:3386
bool rayleigh_fast_uvT(int lev) const noexcept
Definition: ERF_DataStruct.H:3248
amrex::Real perturbation_auto_period
Seconds between automatic parent-wind and PBL-height updates.
Definition: ERF_DataStruct.H:3425
bool variable_coriolis
Whether spatially varying Coriolis forcing is enabled.
Definition: ERF_DataStruct.H:3499
bool implicit_moisture_diffusion
Whether implicit vertical moisture diffusion is included.
Definition: ERF_DataStruct.H:3062
MoistureType moisture_type
Moisture or microphysics model.
Definition: ERF_DataStruct.H:3433
void display(int max_level, std::string pp_prefix)
Print the configured solver, physics, and transport options.
Definition: ERF_DataStruct.H:2742
amrex::Real poisson_abstol
Absolute tolerance for the Poisson solve.
Definition: ERF_DataStruct.H:3077
amrex::Real if_Cd_momentum
Immersed-forcing drag coefficient for momentum.
Definition: ERF_DataStruct.H:3106
bool nudging_t
Definition: ERF_DataStruct.H:3188
amrex::Real if_Olen_in
Input Obukhov length for immersed-forcing MOST [m].
Definition: ERF_DataStruct.H:3117
amrex::Vector< int > buoyancy_type
Per-level buoyancy formulation selector.
Definition: ERF_DataStruct.H:3032
bool forest_biophysics
Definition: ERF_DataStruct.H:3544
void build_coriolis_forcings_const_lat(std::string pp_prefix)
Build constant-latitude Coriolis forcing parameters.
Definition: ERF_DataStruct.H:2908
CouplingType coupling_type
Multilevel coupling strategy.
Definition: ERF_DataStruct.H:3432
bool use_pert_pres_gradient
Whether momentum equations use perturbational pressure gradients.
Definition: ERF_DataStruct.H:3092
bool sbm_particle_mixing_terrain_qualification
Definition: ERF_DataStruct.H:3459
bool sbm_test_native_qc_write_fault
Definition: ERF_DataStruct.H:3446
amrex::Vector< int > project_initial_velocity
Per-level flag for projecting the initial velocity.
Definition: ERF_DataStruct.H:3031
int ave_plane
Averaging plane index used by diagnostics.
Definition: ERF_DataStruct.H:3501
amrex::Real const_massflux_u
Target constant mass flux in the x direction.
Definition: ERF_DataStruct.H:3551
bool nudging_q
Definition: ERF_DataStruct.H:3189
int ncorr
Number of projection correction iterations.
Definition: ERF_DataStruct.H:3070
amrex::Real if_small_volfrac
Immersed-forcing solid fraction below which a cell or face counts as fluid; read from eb2....
Definition: ERF_DataStruct.H:3135
bool forest_fast(int lev) const noexcept
Definition: ERF_DataStruct.H:3297
static bool buildings_fc_factories
Use native face-centered EB factories for immersed buildings on a static fitted mesh.
Definition: ERF_DataStruct.H:2998
amrex::Real sampling_distance_by_D
Turbine inflow sampling distance normalized by rotor diameter.
Definition: ERF_DataStruct.H:3510
std::string sbm_particle_mixing
Definition: ERF_DataStruct.H:3454
amrex::Real windfarm_y_shift
Wind-farm y-coordinate shift.
Definition: ERF_DataStruct.H:3513
bool use_rotate_surface_flux
Whether MOST surface fluxes are rotated with terrain.
Definition: ERF_DataStruct.H:3196
bool use_building_immersed_forcing(const amrex::Geometry &geom) const noexcept
Definition: ERF_DataStruct.H:3231
bool auto_variable_beta_s
Whether erf.use_variable_beta_s may be turned on automatically (it is not set in the inputs).
Definition: ERF_DataStruct.H:3048
bool moisture_tight_coupling
Whether moisture updates use tight coupling.
Definition: ERF_DataStruct.H:3506
EBChoice ebChoice
Embedded-boundary options.
Definition: ERF_DataStruct.H:3021
bool compute_mean_vars
Definition: ERF_DataStruct.H:3212
amrex::Real test_mapfactor_amp
Amplitude of the spatially varying test map scale factors on level 0 (0: not used).
Definition: ERF_DataStruct.H:3086
amrex::Real beta_s
Time off-centering coefficient for forward weighting.
Definition: ERF_DataStruct.H:3040
amrex::Real pi_drift_factor
Definition: ERF_DataStruct.H:3083
bool rayleigh_implicit_w(int lev) const noexcept
Definition: ERF_DataStruct.H:3277
amrex::Vector< amrex::Real > sbm_fixture_initial_state_xhi
Definition: ERF_DataStruct.H:3453
bool implicit_ke_diffusion
Whether implicit vertical TKE diffusion is included.
Definition: ERF_DataStruct.H:3063
bool interp_atmos_from_coarse
Definition: ERF_DataStruct.H:3538
bool any_perturbation() const
Query whether any level uses a turbulent perturbation mode.
Definition: ERF_DataStruct.H:3395
amrex::Real if_z0
Immersed-forcing roughness length [m].
Definition: ERF_DataStruct.H:3113
bool forest_substep
Whether canopy source terms are applied only during substeps.
Definition: ERF_DataStruct.H:3103
bool use_wrf_bdy_density
Definition: ERF_DataStruct.H:3519
bool implicit_thermal_diffusion
Whether implicit vertical thermal diffusion is included.
Definition: ERF_DataStruct.H:3061
bool if_implicit_projection
Definition: ERF_DataStruct.H:3111
std::string mean_vars_reset_mode
Definition: ERF_DataStruct.H:3215
bool use_gravity
Whether gravitational forcing is enabled.
Definition: ERF_DataStruct.H:3095
amrex::Real num_diff_coeff
Numerical diffusion coefficient after input scaling.
Definition: ERF_DataStruct.H:3430
amrex::Real if_wall_tke_time_factor
1 (the default) pins the wall cell after every stage and in the implicit TKE solve; a larger value re...
Definition: ERF_DataStruct.H:3129
similarity_funs most_sfuns
Definition: ERF_DataStruct.H:3125
amrex::Real bdy_nudge_factor
Boundary sponge nudging factor.
Definition: ERF_DataStruct.H:3516
int sbm_cloud_rain_split
Definition: ERF_DataStruct.H:3436
amrex::Real rdOcp
Ratio of dry-air gas constant to c_p.
Definition: ERF_DataStruct.H:3150
bool use_wvel_perturbation(int lev) const
Query whether vertical-velocity CPM perturbations are enabled on a level.
Definition: ERF_DataStruct.H:3348
bool hindcast_lateral_forcing
Whether hindcast lateral forcing is enabled.
Definition: ERF_DataStruct.H:3561
bool do_theta_advection
Whether custom vertical subsidence is applied to rho-theta.
Definition: ERF_DataStruct.H:3165
bool sbm_amr_qualification_regrid
Definition: ERF_DataStruct.H:3443
bool use_native_shoc
Whether any level uses the native SHOC PBL scheme.
Definition: ERF_DataStruct.H:3199
amrex::Real nudging_q_z2
Definition: ERF_DataStruct.H:3185
static bool use_real_bcs
Whether real-data lateral boundary conditions are used.
Definition: ERF_DataStruct.H:3001
bool spatial_moisture_forcing
Whether spatially varying moisture forcing is enabled.
Definition: ERF_DataStruct.H:3170
bool perturbation_auto
Select LES nests, using parent winds and a PBL ancestor's height, or the nearest LES ancestor's diagn...
Definition: ERF_DataStruct.H:3424
RRTMGPSolarChoice rrtmgpSolarChoice
Definition: ERF_DataStruct.H:3023
amrex::Real nudging_u_z2
Definition: ERF_DataStruct.H:3181
bool use_perturbation(int lev) const
Query whether any turbulent perturbation mode is enabled on a level.
Definition: ERF_DataStruct.H:3313
static SoundingType sounding_type
Interpretation used for input sounding profiles.
Definition: ERF_DataStruct.H:2986
int bdy_moist_nudge_type
Moist-variable nudging strategy in boundary regions.
Definition: ERF_DataStruct.H:3525
amrex::Real poisson_reltol
Relative tolerance for the Poisson solve.
Definition: ERF_DataStruct.H:3078
bool use_coriolis
Whether Coriolis forcing is enabled.
Definition: ERF_DataStruct.H:3096
amrex::Vector< PerturbationType > pert_type
Turbulent perturbation type for each AMR level.
Definition: ERF_DataStruct.H:3423
static MeshType mesh_type
Vertical mesh representation.
Definition: ERF_DataStruct.H:3004
AdvChoice advChoice
Advection-related options.
Definition: ERF_DataStruct.H:3016
amrex::Vector< CompressibilityType > compressibility_type
Per-level compressibility (FullyCompressible, Anelastic or PseudoIncompressible).
Definition: ERF_DataStruct.H:3028
UrbanType urban_type
Definition: ERF_DataStruct.H:3463
SpongeChoice spongeChoice
Sponge-layer options.
Definition: ERF_DataStruct.H:3019
void init_params(int max_level, std::string pp_prefix)
Read solver-wide algorithmic options from the input parameter database.
Definition: ERF_DataStruct.H:750
bool time_avg_vel
Whether time-averaged velocity fields are output.
Definition: ERF_DataStruct.H:3209
bool use_direct_perturbation(int lev) const
Query whether direct turbulent perturbations are enabled on a level.
Definition: ERF_DataStruct.H:3326
bool have_geo_wind_profile
Whether a geostrophic wind profile has been configured.
Definition: ERF_DataStruct.H:3497
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_pressure_grad
Applied ABL pressure-gradient forcing vector.
Definition: ERF_DataStruct.H:3494
RadChoice radChoice
Definition: ERF_DataStruct.H:3022
bool four_stream_radiation
Whether the four-stream radiation approximation is enabled.
Definition: ERF_DataStruct.H:3099
amrex::Real perturbation_auto_pbl_fraction
Fraction of the selected ancestor's PBL height occupied by perturbations.
Definition: ERF_DataStruct.H:3426
GradpType gradp_type
Terrain-fitted horizontal pressure-gradient formulation.
Definition: ERF_DataStruct.H:3088
amrex::Real if_surf_moist
Definition: ERF_DataStruct.H:3121
amrex::Real if_surf_moist_flux
Definition: ERF_DataStruct.H:3120
DampingChoice dampingChoice
Damping-related options.
Definition: ERF_DataStruct.H:3018
amrex::Real if_damp_alpha
Immersed-forcing damping coefficient.
Definition: ERF_DataStruct.H:3132
bool rebalance_wrf_input
Whether to rebalance states from wrfinput and wrfbdy data.
Definition: ERF_DataStruct.H:3145
bool gradp_2nd_order_bndry
Whether ChainRule takes dp/dz at the bottom and top from a second-order one-sided difference.
Definition: ERF_DataStruct.H:3090
bool sbm_amr_qualification_expect_zero_flow
Definition: ERF_DataStruct.H:3438
amrex::Real sbm_particle_mixing_kv
Definition: ERF_DataStruct.H:3456
bool wrfinput_zlevels_from_file
Definition: ERF_DataStruct.H:3535
amrex::Vector< amrex::Real > sbm_edges
Definition: ERF_DataStruct.H:3449
amrex::Real turb_disk_angle
Turbine disk angle from the x axis [deg].
Definition: ERF_DataStruct.H:3511
amrex::Real hindcast_data_interval_in_hrs
Time interval between hindcast data files [hr].
Definition: ERF_DataStruct.H:3560
amrex::Real const_massflux_layer_hi
Upper height of the constant-mass-flux forcing layer.
Definition: ERF_DataStruct.H:3555
bool sbm_amr_qualification_test
Definition: ERF_DataStruct.H:3437
std::string wall_dist_type
Definition: ERF_DataStruct.H:3071
bool avg_grid_faces_to_nodes
Definition: ERF_DataStruct.H:3528
amrex::Real cf_loglaw_z0
Roughness length [m] of that share; by default erf.if_z0 with immersed forcing, else the inputs' erf....
Definition: ERF_DataStruct.H:3139
std::string windfarm_spec_table_extra
Additional wind-farm turbine specification table path.
Definition: ERF_DataStruct.H:3508
amrex::Real if_ws_floor
Wind-speed floor [m/s] in the per-step change limit of the building wall-law forcing.
Definition: ERF_DataStruct.H:3131
amrex::Real lsf_timescale
Definition: ERF_DataStruct.H:3193
bool is_init_for_ensemble
Whether initialization is for an ensemble simulation.
Definition: ERF_DataStruct.H:3570
bool uses_shoc_family() const noexcept
Query whether any SHOC-family PBL scheme is active.
Definition: ERF_DataStruct.H:3357
bool sbm_amr_qualification_expect_empty_fine_rank
Definition: ERF_DataStruct.H:3440
bool test_mapfactor
Whether to use test map scale factors.
Definition: ERF_DataStruct.H:3085
amrex::Real nudging_u_z1
Definition: ERF_DataStruct.H:3180
bool if_snap_partial_cells
Definition: ERF_DataStruct.H:3123
amrex::Vector< amrex::Real > sbm_pivots
Definition: ERF_DataStruct.H:3450
std::string coarse_bckgnd_data_file
Coarse background data file used for ensemble initialization.
Definition: ERF_DataStruct.H:3574
amrex::Real sbm_particle_mixing_kh
Definition: ERF_DataStruct.H:3455
bool do_forest_drag
Whether forest canopy drag is enabled.
Definition: ERF_DataStruct.H:3541
bool sbm_amr_qualification_regrid_reject_fault
Definition: ERF_DataStruct.H:3444
amrex::Real dz0
Initial vertical grid spacing for stretched-grid setup.
Definition: ERF_DataStruct.H:3154
amrex::Real windfarm_x_shift
Wind-farm x-coordinate shift.
Definition: ERF_DataStruct.H:3512
bool use_lagged_delta_rt
Whether to use lagged delta terms for moving terrain.
Definition: ERF_DataStruct.H:3142
bool sbm_amr_qualification_unique_profile
Definition: ERF_DataStruct.H:3441
amrex::Real ens_pert_amplitude
Amplitude of ensemble initialization perturbations.
Definition: ERF_DataStruct.H:3573
std::string windfarm_airfoil_tables
Wind-farm airfoil table paths.
Definition: ERF_DataStruct.H:3509
amrex::Real bdy_rho_nudge_factor
Definition: ERF_DataStruct.H:3522
amrex::Real nudging_q_z1
Definition: ERF_DataStruct.H:3184
amrex::Vector< amrex::Vector< amrex::Real > > vert_implicit_fac
Per-level, per-stage implicit vertical diffusion factors.
Definition: ERF_DataStruct.H:3058
bool transport_scalar
Whether the passive scalar component is transported.
Definition: ERF_DataStruct.H:3206
bool cf_loglaw_fill
Share the flux of the first coarse face above a wall among its fine sub-faces at the lateral coarse/f...
Definition: ERF_DataStruct.H:3138
TerrainPoissonSolver terrain_poisson_solver
Projection solver on a terrain-fitted mesh: gmres_fft (default), mlmg or gmres_mlmg.
Definition: ERF_DataStruct.H:3072
bool hindcast_zhi_sponge_damping
Whether upper-boundary hindcast sponge damping is enabled.
Definition: ERF_DataStruct.H:3565
amrex::Real hurricane_eye_longitude
Initial hurricane-eye longitude.
Definition: ERF_DataStruct.H:3568
bool nudging_from_observations
Whether solution fields are nudged toward observations at stations.
Definition: ERF_DataStruct.H:3178
LandSurfaceType lsm_type
Land-surface model.
Definition: ERF_DataStruct.H:3462
int massflux_khi
Upper vertical index for constant-mass-flux forcing.
Definition: ERF_DataStruct.H:3557
bool large_scale_forcing
Definition: ERF_DataStruct.H:3191
bool implicit_terrain_metric
Whether the compact terrain-metric part of the vertical diffusion is solved implicitly.
Definition: ERF_DataStruct.H:3068
bool if_wall_tke
Hold the k-eqn TKE of the fraction-stress wall cell at its flat-ground wall value (ib_wall::wall_tke)...
Definition: ERF_DataStruct.H:3128
bool substepping_diag
Whether to emit extra CFL diagnostics for compressible substepping.
Definition: ERF_DataStruct.H:3036
static TerrainType terrain_type
Terrain or immersed-boundary representation.
Definition: ERF_DataStruct.H:2989
amrex::Real mean_vars_reset_time
Definition: ERF_DataStruct.H:3216
std::string windfarm_blade_table
Wind-farm blade table path.
Definition: ERF_DataStruct.H:3509
bool if_flat_wall_dissipation
Partial fraction-stress wall cells dissipate TKE with the length scale of flat ground's first cell; o...
Definition: ERF_DataStruct.H:3130
CanopyTurbulence canopyTurb
Definition: ERF_DataStruct.H:3548
amrex::Vector< int > is_land
Per-level land/water selector.
Definition: ERF_DataStruct.H:3033
amrex::Real hindcast_lateral_sponge_strength
Strength of the hindcast lateral sponge layer.
Definition: ERF_DataStruct.H:3563
bool forest_biophysics_heat
Definition: ERF_DataStruct.H:3545
std::string if_average_down
Cell average down over immersed-forcing levels: "plain" (the default, the plain cell average) or "flu...
Definition: ERF_DataStruct.H:3136
ShocTransportMode shoc_transport_mode
Definition: ERF_DataStruct.H:3202
amrex::Real hurricane_eye_latitude
Initial hurricane-eye latitude.
Definition: ERF_DataStruct.H:3568
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:3469
amrex::Real cosphi
Cosine of the latitude used for Coriolis forcing.
Definition: ERF_DataStruct.H:3158
bool sbm_amr_qualification_uniform_ratio
Definition: ERF_DataStruct.H:3445
amrex::Real if_Cd_scalar
Immersed-forcing drag coefficient for scalars.
Definition: ERF_DataStruct.H:3107
bool immersed_forcing_fast(int lev) const noexcept
Definition: ERF_DataStruct.H:3303
bool sbm_amr_qualification_parent_store_fault
Definition: ERF_DataStruct.H:3442
amrex::Real if_cf_mismatch_warning
Spread of the fine solid fractions under a coarse cell along a lateral coarse/fine face at or above w...
Definition: ERF_DataStruct.H:3137
static BuildingsType buildings_type
Building representation.
Definition: ERF_DataStruct.H:2995
std::string windfarm_loc_table
Wind-farm location table path.
Definition: ERF_DataStruct.H:3508
std::string hindcast_surface_data_dir
Directory containing hindcast surface boundary data.
Definition: ERF_DataStruct.H:3559
int if_wall_face_spacing
Spacing the face above the fraction-stress wall cell differences over: 0 the cell height,...
Definition: ERF_DataStruct.H:3127
bool rayleigh_fast_w(int lev) const noexcept
Definition: ERF_DataStruct.H:3256
ShocMomentumTransport shoc_momentum_transport
Definition: ERF_DataStruct.H:3203
bool custom_rhotheta_forcing
Whether custom rho-theta forcing is enabled.
Definition: ERF_DataStruct.H:3162
amrex::Real beta_d
Divergence damping coefficient used in the acoustic substepping.
Definition: ERF_DataStruct.H:3052
bool sbm_test_donor_cfl_fault
Definition: ERF_DataStruct.H:3447
bool level_substeps(int lev) const noexcept
Definition: ERF_DataStruct.H:3242
amrex::Real if_init_surf_temp
Initial immersed-forcing surface temperature [K].
Definition: ERF_DataStruct.H:3115
amrex::Real nudging_t_z2
Definition: ERF_DataStruct.H:3183
int face_sync_int
Definition: ERF_DataStruct.H:3041
int massflux_klo
Lower vertical index for constant-mass-flux forcing.
Definition: ERF_DataStruct.H:3556
std::string lsf_file
Definition: ERF_DataStruct.H:3192
std::string windfarm_spec_table
Wind-farm turbine specification table path.
Definition: ERF_DataStruct.H:3508
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_geo_forcing
Applied geostrophic-wind forcing vector.
Definition: ERF_DataStruct.H:3495
bool sbm_amr_qualification_expect_split
Definition: ERF_DataStruct.H:3439
bool 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:2959
ABLDriverType abl_driver_type
Atmospheric boundary-layer driver type.
Definition: ERF_DataStruct.H:3493
DiffChoice diffChoice
Diffusion-related options.
Definition: ERF_DataStruct.H:3017
amrex::Real if_surf_temp_flux
Immersed-forcing surface temperature flux [K m/s].
Definition: ERF_DataStruct.H:3114
bool spatial_rhotheta_forcing
Whether spatially varying rho-theta forcing is enabled.
Definition: ERF_DataStruct.H:3169
amrex::Vector< int > urban_enabled_lev
Definition: ERF_DataStruct.H:3464
WindFarmType windfarm_type
Wind-farm model.
Definition: ERF_DataStruct.H:3460
bool use_variable_beta_s
Whether beta_s varies on the w-faces with the terrain slope and acoustic Courant number.
Definition: ERF_DataStruct.H:3045
bool use_source_perturbation(int lev) const
Query whether source-term turbulent perturbations are enabled on a level.
Definition: ERF_DataStruct.H:3338
bool custom_w_subsidence
Whether custom vertical subsidence is enabled.
Definition: ERF_DataStruct.H:3164
bool rad_feeds_lsm() const
True when the radiation model's outputs feed the land model (downwelling shortwave,...
Definition: ERF_DataStruct.H:3483
bool custom_moisture_forcing
Whether custom moisture forcing is enabled.
Definition: ERF_DataStruct.H:3163
amrex::Real if_surf_heating_rate
Immersed-forcing surface heating rate [K/hr].
Definition: ERF_DataStruct.H:3116
int sbm_nbins
Definition: ERF_DataStruct.H:3434
MoistureComponentIndices moisture_indices
Index map of the moisture data carried by the active scheme: conserved-state components for the speci...
Definition: ERF_DataStruct.H:3504
RadiationType rad_type
Radiation model.
Definition: ERF_DataStruct.H:3465
amrex::Real grid_stretching_ratio
Vertical grid stretching ratio.
Definition: ERF_DataStruct.H:3153
bool hindcast_surface_bcs
Whether hindcast surface boundary conditions are enabled.
Definition: ERF_DataStruct.H:3562
bool rayleigh_slow_implicit_w(int lev) const noexcept
Definition: ERF_DataStruct.H:3288
bool host_owns_vertical_scalar_diffusion() const noexcept
Test whether the host owns scalar diffusion.
Definition: ERF_DataStruct.H:3376
bool immersed_forcing_substep
Whether immersed-forcing source terms are applied only during substeps.
Definition: ERF_DataStruct.H:3102
bool if_use_most
Whether immersed-forcing MOST is enabled.
Definition: ERF_DataStruct.H:3122
amrex::Real const_massflux_tau
Relaxation time scale for constant-mass-flux forcing.
Definition: ERF_DataStruct.H:3553
bool zcc_vertical_metric(int lev) const noexcept
Definition: ERF_DataStruct.H:3267
amrex::Real hindcast_lateral_sponge_length
Length of the hindcast lateral sponge layer.
Definition: ERF_DataStruct.H:3563
amrex::Real sinphi
Sine of the latitude used for Coriolis forcing.
Definition: ERF_DataStruct.H:3159
bool host_owns_vertical_momentum_diffusion() const noexcept
Test whether the host owns momentum diffusion.
Definition: ERF_DataStruct.H:3366
amrex::Real hindcast_zhi_sponge_strength
Strength of the upper hindcast sponge layer.
Definition: ERF_DataStruct.H:3564
bool coriolis_3d
Whether the three-dimensional Coriolis terms are included.
Definition: ERF_DataStruct.H:3097
int force_stage1_single_substep
Flag forcing a single substep in the first RK stage.
Definition: ERF_DataStruct.H:3026
amrex::Real c_p
Specific heat at constant pressure for dry air [J/(kg-K)].
Definition: ERF_DataStruct.H:3149
bool if_implicit_drag
Definition: ERF_DataStruct.H:3110
bool implicit_momentum_diffusion
Whether implicit vertical momentum diffusion is included.
Definition: ERF_DataStruct.H:3064
bool do_mom_advection
Whether custom vertical subsidence is applied to momentum.
Definition: ERF_DataStruct.H:3166
bool if_stability_correction
Whether the immersed-forcing wall law applies the MOST similarity functions, in the momentum and the ...
Definition: ERF_DataStruct.H:3124
amrex::Real nudging_t_z1
Definition: ERF_DataStruct.H:3182
amrex::Vector< amrex::Real > sbm_fixture_initial_state
Definition: ERF_DataStruct.H:3451
bool custom_forcing_prim_vars
Whether custom forcing operates on primitive variables.
Definition: ERF_DataStruct.H:3168
amrex::Real if_stability_wind_floor
Wind-speed floor [m/s] behind the friction velocity of the wall law's stability estimate (0: none).
Definition: ERF_DataStruct.H:3133
amrex::Vector< int > zcc_vertical_metric_lev
Definition: ERF_DataStruct.H:3273
bool use_coupled_currents
Definition: ERF_DataStruct.H:3491
bool nudging_u
Definition: ERF_DataStruct.H:3187
bool nudging_from_input_sounding
Whether solution fields are nudged toward input sounding data.
Definition: ERF_DataStruct.H:3174
static void set_mesh_type(MeshType new_mesh_type)
Override the globally selected mesh type.
Definition: ERF_DataStruct.H:3011
bool use_num_diff
Whether sixth-order numerical diffusion is enabled.
Definition: ERF_DataStruct.H:3429
bool sbm_budget_check
Definition: ERF_DataStruct.H:3448
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
Definition: ERF_RadStruct.H:113
void read(const std::string &prefix, const RRTMGPSolarChoice &solar)
Definition: ERF_TopographicShading.cpp:40
bool active() const
Definition: ERF_RadStruct.H:123
Definition: ERF_MOSTUtils.H:84