ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_DataStruct.H
Go to the documentation of this file.
1 #ifndef ERF_DATA_STRUCT_H_
2 #define ERF_DATA_STRUCT_H_
3 
4 #include <string>
5 #include <iostream>
6 
7 #include <AMReX_ParmParse.H>
8 #include <AMReX_Print.H>
9 #include <AMReX_Gpu.H>
10 #include <AMReX_Geometry.H>
11 
12 #include <ERF_Constants.H>
13 #include <ERF_IndexDefines.H>
14 #include <ERF_AdvStruct.H>
15 #include <ERF_DampingStruct.H>
16 #include <ERF_DiffStruct.H>
17 #include <ERF_EBStruct.H>
18 #include <ERF_SpongeStruct.H>
19 #include <ERF_TurbStruct.H>
20 #include <ERF_TurbPertStruct.H>
21 
22 enum MapFacType {
23 // This version assumes isotropic
24  m_x, u_x, v_x, num,
25  m_y = 0, u_y = 1, v_y = 2
26 // This version allows for non-isotropic
27 // m_x, u_x, v_x,
28 // m_y, u_y, v_y, num
29 };
30 
31 enum TauType {
33 };
34 
35 AMREX_ENUM(InitType,
36  None, Input_Sounding, NCFile, WRFInput, Metgrid, Uniform, ConstantDensity, ConstantDensityLinearTheta,
37  Isentropic, MoistBaseState, HindCast
38 );
39 
40 AMREX_ENUM(SoundingType,
41  ConstantDensity, Ideal, Isentropic, DryIsentropic
42 );
43 
44 AMREX_ENUM(ABLDriverType,
45  None, PressureGradient, GeostrophicWind
46 );
47 
48 AMREX_ENUM(CouplingType,
49  OneWay, TwoWay
50 );
51 
52 AMREX_ENUM(SubsteppingType,
53  None, Implicit
54 );
55 
56 AMREX_ENUM(MeshType,
57  ConstantDz, StretchedDz, VariableDz
58 );
59 
60 AMREX_ENUM(TerrainType,
61  None, StaticFittedMesh, MovingFittedMesh, EB, ImmersedForcing
62 );
63 
64 AMREX_ENUM(BuildingsType,
65  None, ImmersedForcing
66 );
67 
68 AMREX_ENUM(MoistureModelType,
69  Eulerian, Lagrangian, Undefined
70 );
71 
72 AMREX_ENUM(MoistureType,
73  SAM, SAM_NoIce, SAM_NoPrecip_NoIce, Kessler, Kessler_NoRain, SatAdj, Morrison, Morrison_NoIce, WSM6, SuperDroplets, MoistNoCondensation, None
74 );
75 
76 AMREX_ENUM(WindFarmType,
77  Fitch, EWP, SimpleAD, GeneralAD, None
78 );
79 
80 AMREX_ENUM(WindFarmLocType,
81  lat_lon, x_y, None
82 );
83 
84 AMREX_ENUM(LandSurfaceType,
85  SLM, MM5, NOAHMP, OceanSurf, None
86 );
87 
88 AMREX_ENUM(RadiationType,
89  None, RRTMGP
90 );
91 
92 enum struct Coord {
93  x, y, z
94 };
95 
96 // These are used as integers so must be enum not enum struct
97 enum Rayleigh {
99 };
100 
101 // These are used as integers so must be enum not enum struct
102 enum Sponge {
104 };
105 
107  int qv = -1; // Water vapor
108  int qc = -1; // Cloud liquid water
109  int qi = -1; // Cloud ice
110  int qr = -1; // Rain
111  int qs = -1; // Snow
112  int qg = -1; // Graupel
113  int nc = -1; // number concentration for cloud liquid water
114  int ni = -1; // number concentration for cloud ice
115  int nr = -1; // number concentration for rain
116  int ns = -1; // number concentration for snow
117  int ng = -1; // number concentration for graupel
118 
119  // Constructor for easy initialization
120  MoistureComponentIndices (int qv_comp, int qc_comp,
121  int qi_comp=-1,
122  int qr_comp=-1,
123  int qs_comp=-1,
124  int qg_comp=-1,
125  int nc_comp=-1,
126  int ni_comp=-1,
127  int nr_comp=-1,
128  int ns_comp=-1,
129  int ng_comp=-1)
130  : qv(qv_comp), qc(qc_comp), qi(qi_comp), qr(qr_comp), qs(qs_comp), qg(qg_comp),
131  nc(nc_comp), ni(ni_comp), nr(nr_comp), ns(ns_comp), ng(ng_comp) {}
132 
133  // Default constructor
135 };
136 
137 /**
138  * Container holding many of the algorithmic options and parameters
139  */
140 
141 struct SolverChoice {
142  public:
143  void init_params (int max_level, std::string pp_prefix)
144  {
145  amrex::ParmParse pp(pp_prefix);
146 
147  bool bogus_bool;
148  if (pp.query("use_terrain",bogus_bool) > 0) {
149  amrex::Error("The input use_terrain is deprecated. Set terrain_type instead.");
150  }
151 
152  if (pp.query("use_moist_background",bogus_bool) > 0) {
153  amrex::Error("The input use_moist_background is deprecated. Set init_type = MoistBaseState instead.");
154  }
155 
156  // Do we set map scale factors to myhalf instead of 1 for testing?
157  pp.query("test_mapfactor", test_mapfactor);
158 
159  // Which horizontal pressure gradient formulation to use with terrain fitted coords?
160  // 0: dp/dx with dp/dz correction (default)
161  // 1: gradient of vertically interpolated p, see Klemp 2011
162  pp.query("gradp_type", gradp_type);
164 
165  // For the lateral pressure gradient to be used in the momentum equation, should we
166  // take the x- and y-derivatives of the perturbational pressure or the full pressure?
167  pp.query("use_pert_pres_gradient", use_pert_pres_gradient);
168 
169  // What type of moisture model to use?
170  moisture_type = MoistureType::None; // Default
171  if (pp.query("moisture_type",moisture_type) > 0) {
172  amrex::Error("The input moisture_type is deprecated. Set moisture_model instead.");
173  }
174 
175  pp.query_enum_case_insensitive("moisture_model",moisture_type);
176  if (moisture_type == MoistureType::Morrison) {
178  RhoQ1_comp, // water vapor
179  RhoQ2_comp, // cloud water
180  RhoQ3_comp, // cloud ice
181  RhoQ4_comp, // rain
182  RhoQ5_comp, // snow
183  RhoQ6_comp, // graupel
184  RhoQ7_comp, // number concentration of cloud water
185  RhoQ8_comp, // number concentration of cloud ice
186  RhoQ9_comp, // number concentration of rain
187  RhoQ10_comp, // number concentration of snow
188  RhoQ11_comp // number concentration of graupel
189  );
190  } else if ( (moisture_type == MoistureType::WSM6) ||
191  (moisture_type == MoistureType::SAM) ) {
193  RhoQ1_comp, // water vapor
194  RhoQ2_comp, // cloud water
195  RhoQ3_comp, // cloud ice
196  RhoQ4_comp, // rain
197  RhoQ5_comp, // snow
198  RhoQ6_comp // graupel
199  );
200  } else if ( (moisture_type == MoistureType::Morrison_NoIce) ||
201  (moisture_type == MoistureType::SAM_NoIce) ) {
203  RhoQ1_comp, // water vapor
204  RhoQ2_comp, // cloud water
205  -1, // cloud ice
206  RhoQ4_comp // rain
207  );
208  } else if ( (moisture_type == MoistureType::SAM_NoPrecip_NoIce) ||
209  (moisture_type == MoistureType::Kessler_NoRain) ||
210  (moisture_type == MoistureType::SatAdj) ||
211  (moisture_type == MoistureType::MoistNoCondensation) ) {
213  RhoQ1_comp, // water vapor
214  RhoQ2_comp // cloud water
215  );
216  } else if (moisture_type == MoistureType::Kessler) {
218  RhoQ1_comp, // water vapor
219  RhoQ2_comp, // cloud water
220  -1, // cloud ice
221  RhoQ3_comp // rain
222  );
223  } else if (moisture_type == MoistureType::SuperDroplets) {
225  RhoQ1_comp, // water vapor
226  RhoQ2_comp, // cloud water
227  -1, // cloud ice
228  RhoQ3_comp // rain
229  );
230  }
231 
232  // Set a default for dry
233  buoyancy_type.resize(max_level+1);
234  for (int i = 0; i <= max_level; ++i) {
235  buoyancy_type[i] = 1; // uses Rhoprime
236  }
237 
238  // Set a default for moist
239  if (moisture_type != MoistureType::None) {
240  if ( !(moisture_type == MoistureType::Kessler_NoRain ||
241  moisture_type == MoistureType::SAM ||
242  moisture_type == MoistureType::SAM_NoIce ||
243  moisture_type == MoistureType::SAM_NoPrecip_NoIce ||
244  moisture_type == MoistureType::Morrison ||
245  moisture_type == MoistureType::Morrison_NoIce ||
246  moisture_type == MoistureType::WSM6 ||
247  moisture_type == MoistureType::SatAdj) )
248  {
249  for (int i = 0; i <= max_level; ++i) {
250  buoyancy_type[i] = 2; // uses Tprime
251  }
252  }
253 
254  pp.query("moisture_tight_coupling",moisture_tight_coupling);
255  }
256 
257  // Which expression (1,2/3 or 4) to use for buoyancy
258  int default_buoyancy_type = buoyancy_type[0];
259  read_int_string(max_level, "buoyancy_type", buoyancy_type, default_buoyancy_type);
260 
261  // What type of land surface model to use
262  lsm_type = LandSurfaceType::None; // Default
263  pp.query_enum_case_insensitive("land_surface_model",lsm_type);
264 
265  read_int_string(max_level, "is_land", is_land, 1);
266  for (int lev = 0; lev <= max_level; ++lev) {
267  if (is_land[lev] == 1) {
268  amrex::Print() << "Level " << lev << " is land" << std::endl;
269  } else if (is_land[lev] == 0) {
270  amrex::Print() << "Level " << lev << " is water" << std::endl;
271  } else {
272  amrex::Error("is_land should be 0 or 1");
273  }
274  }
275 
276  // What type of radiation model to use
277  rad_type = RadiationType::None; // Default
278  pp.query_enum_case_insensitive("radiation_model", rad_type);
279 
280  // Verify that radiation model cannot be RRTMGP if ERF was not compiled with RRTMGP
281 #ifndef ERF_USE_RRTMGP
282  if (rad_type == RadiationType::RRTMGP)
283  {
284  amrex::Error("ERF was not compiled with RRTMGP enabled!");
285  }
286 #endif
287 
288  // Is the terrain none, static or moving?
289  std::string terrain_type_temp = "";
290  pp.query("terrain_type", terrain_type_temp);
291  if (terrain_type_temp == "Moving") {
292  amrex::Warning("erf.terrain_type = Moving is deprecated; please replace Moving by MovingFittedMesh");
293  terrain_type = TerrainType::MovingFittedMesh;
294  } else if (terrain_type_temp == "Static") {
295  amrex::Warning("erf.terrain_type = Static is deprecated; please replace Static by StaticFittedMesh");
296  terrain_type = TerrainType::StaticFittedMesh;
297  } else {
298  pp.query_enum_case_insensitive("terrain_type",terrain_type);
299  }
300 
301  // Get buildings type
302  std::string buildings_type_temp = "";
303  pp.query("buildings_type", buildings_type_temp);
304  if (buildings_type_temp == "ImmersedForcing") {
305  buildings_type = BuildingsType::ImmersedForcing;
306  }
307 
308  //
309  // Read the init_type here to make sure we correctly set the mesh and terrain types
310  //
311  std::string init_type_temp_string;
312 
313  int found = pp.query("init_type",init_type_temp_string);
314 
315  if ( (init_type_temp_string == "Real") || (init_type_temp_string == "real") ) {
316  amrex::Error("erf.init_type = Real is deprecated; please replace Real by WRFInput");
317  } else if ( (init_type_temp_string == "Ideal") || (init_type_temp_string == "ideal") ) {
318  amrex::Error("erf.init_type = Ideal is deprecated; please replace Ideal by WRFInput");
319  } else {
320  pp.query_enum_case_insensitive("init_type",init_type);
321  use_real_bcs = ( (init_type == InitType::WRFInput) || (init_type == InitType::Metgrid) );
322  }
323 
324  if ( (init_type == InitType::WRFInput) || (init_type == InitType::Metgrid) ) {
325  if (terrain_type != TerrainType::StaticFittedMesh) {
326  amrex::Error("Only terrain_type = StaticFittedMesh are allowed with init_type = WRFInput or Metgrid");
327  }
328  }
329 
330  if (init_type == InitType::MoistBaseState) {
331  if (moisture_type == MoistureType::None) {
332  amrex::Error("Makes no sense to have moist base state with no moisture model");
333  }
334  }
335 
336  if (init_type == InitType::WRFInput) {
337  if (moisture_type == MoistureType::None) {
338  amrex::Error("Can't have moisture_type = None with init_type = WRFInput");
339  }
340 
341  // NetCDF wrfbdy lateral boundary file
342  std::string nc_bdy_file_temp_string;
343  bool has_bdy = pp.query("nc_bdy_file", nc_bdy_file_temp_string);
344  if (!has_bdy) use_real_bcs = false;
345 
346  bool use_real_bcs_temp = use_real_bcs;
347  pp.query("use_real_bcs", use_real_bcs_temp);
348  if (use_real_bcs && !use_real_bcs_temp) {
349  use_real_bcs = false;
350  }
351  }
352 
353  if (found == 0 || init_type == InitType::None) {
354  amrex::Print() << "init_type must now be set. The options are " << std::endl;
355  amrex::Print() << " Input_Sounding, NCFile, WRFInput, Metgrid, Uniform, " << std::endl;
356  amrex::Print() << " ConstantDensity, Isentropic, MoistBaseState, or HindCast " << std::endl;
357  amrex::Error("Please add a string for init_type to your inputs file or command line");
358  }
359 
360  // How to interpret input_sounding
361  if (init_type == InitType::Input_Sounding) {
362  pp.query_enum_case_insensitive("sounding_type",sounding_type);
363  }
364 
365  if (terrain_type == TerrainType::StaticFittedMesh ||
366  terrain_type == TerrainType::MovingFittedMesh) {
367  mesh_type = MeshType::VariableDz;
368  }
369 
370  if ( (moisture_type == MoistureType::SAM ||
371  moisture_type == MoistureType::SAM_NoIce ||
372  moisture_type == MoistureType::SAM_NoPrecip_NoIce ) &&
373  (mesh_type == MeshType::VariableDz) )
374  {
375  amrex::Abort("SAM is not correct with variable dz -- choose another moisture model");
376  }
377 
378  pp.query("grid_stretching_ratio", grid_stretching_ratio);
379  if (grid_stretching_ratio != 0) {
381  "The grid stretching ratio must be greater than 1");
382  }
383  if (grid_stretching_ratio >= 1) {
384  if (terrain_type == TerrainType::None) {
385  terrain_type = TerrainType::StaticFittedMesh;
386  }
387  if (mesh_type == MeshType::ConstantDz) {
388  mesh_type = MeshType::StretchedDz;
389  }
390  pp.query("zsurface", zsurf);
391  if (zsurf != zero) {
392  amrex::Print() << "Nominal zsurface height != 0, may result in unexpected behavior"
393  << std::endl;
394  }
395  pp.get("initial_dz", dz0);
396  }
397 
398  int n_zlevels = pp.countval("terrain_z_levels");
399  if (n_zlevels > 0)
400  {
401  if (terrain_type == TerrainType::None) {
402  terrain_type = TerrainType::StaticFittedMesh;
403  }
404  if (mesh_type == MeshType::ConstantDz) {
405  mesh_type = MeshType::StretchedDz;
406  }
407  }
408 
409  // Use lagged_delta_rt in the fast integrator?
410  pp.query("use_lagged_delta_rt", use_lagged_delta_rt);
411 
412  // Rebalance wrf state?
413  pp.query("rebalance_wrf_input", rebalance_wrf_input);
414 
415  // These default to true but are used for unit testing
416  pp.query("use_gravity", use_gravity);
418 
419  pp.query("c_p", c_p);
420  rdOcp = R_d / c_p;
421 
422  // *******************************************************************************
423  // Read anelastic etc and over-ride if necessary
424  // *******************************************************************************
425 
426  read_int_string(max_level, "anelastic", anelastic, 0);
427  read_int_string(max_level, "fixed_density", fixed_density, 0);
428  read_int_string(max_level, "project_initial_velocity", project_initial_velocity, 0);
429 
430  for (int i = 0; i <= max_level; ++i) {
431  if (anelastic[i] == 1) {
433  fixed_density[i] = 1; // We default to true but are allowed to override below
434  buoyancy_type[i] = 3; // (This isn't actually used when anelastic is set)
435  }
436  }
437 
438 
439  // *******************************************************************************
440  // Read substepping_type and allow for different values at each level
441  // *******************************************************************************
442  substepping_type.resize(max_level+1);
443 
444  for (int i = 0; i <= max_level; i++) {
445  substepping_type[i] = SubsteppingType::Implicit;
446  }
447 
448  for (int i = 0; i <= max_level; i++) {
450  pp, "substepping_type", substepping_type[i], i, max_level);
451  }
452 
453  pp.query("substepping_diag", substepping_diag);
454 
455  pp.query("beta_s", beta_s);
456 
457 
458 
459  // *******************************************************************************
460  // Error check on deprecated input
461  // *******************************************************************************
462  int nvals_old = pp.countval("no_substepping");
463  if (nvals_old > 0) {
464  amrex::Error("The no_substepping flag is deprecated -- set substepping_type instead");
465  }
466 
467  // *******************************************************************************
468 
469  pp.query("ncorr", ncorr);
470  pp.query("poisson_abstol", poisson_abstol);
471  pp.query("poisson_reltol", poisson_reltol);
472 #ifdef AMREX_USE_FLOAT
473  poisson_abstol = amrex::max(poisson_abstol,amrex::Real(1e-6));
474  poisson_reltol = amrex::max(poisson_reltol,amrex::Real(1e-6));
475 #endif
476  for (int lev = 0; lev <= max_level; lev++) {
477  if (anelastic[lev] != 0)
478  {
479  substepping_type[lev] = SubsteppingType::None;
480  }
481  }
482 
483  pp.query("force_stage1_single_substep", force_stage1_single_substep);
484 
485  // Include Coriolis forcing?
486  pp.query("use_coriolis", use_coriolis);
487  pp.query("variable_coriolis", variable_coriolis);
488 
489  // Include four stream radiation approximation
490  pp.query("four_stream_radiation", four_stream_radiation);
491 
492  // flags for whether to apply other source terms in substep only
493  pp.query("immersed_forcing_substep", immersed_forcing_substep); // apply immersed forcing source terms in substep only
494  pp.query("forest_substep", forest_substep); // apply canopy-related source terms in substep only
495 
496  // immersed forcing parameters
497  pp.query("if_Cd_scalar", if_Cd_scalar);
498  pp.query("if_Cd_momentum", if_Cd_momentum);
499  pp.query("if_z0", if_z0);
500  pp.query("if_surf_temp_flux", if_surf_temp_flux);
501  pp.query("if_init_surf_temp", if_init_surf_temp);
502 
503  pp.query("if_surf_heating_rate", if_surf_heating_rate);
504 
505  // Modify rate to be in units of K / s rather than K / hr
506  if_surf_heating_rate /= amrex::Real(3600.0); // [K/s]
507 
508  pp.query("if_Olen", if_Olen_in);
509  pp.query("if_use_most",if_use_most);
510 
511  if ((if_init_surf_temp > zero && if_surf_temp_flux != amrex::Real(1e-8)) ||
512  (if_init_surf_temp > zero && if_Olen_in != amrex::Real(1e-8)) ||
513  (if_Olen_in != amrex::Real(1e-8) && if_surf_temp_flux != amrex::Real(1e-8)))
514  {
515  amrex::Error("Can only specify one of init_surf_temp, surf_temp_flux, or Olen");
516  }
517 
518  if (if_use_most && buildings_type == BuildingsType::ImmersedForcing)
519  {
520  amrex::Error("MOST wall-model with immersed forcing for buildings is not currently supported");
521  }
522 
523  if (if_surf_temp_flux != amrex::Real(1e-8) && buildings_type == BuildingsType::ImmersedForcing)
524  {
525  amrex::Error("Specifying surf_temp_flux with immersed forcing for buildings is not currently supported");
526  }
527 
528  if (if_Olen_in != amrex::Real(1e-8) && buildings_type == BuildingsType::ImmersedForcing)
529  {
530  amrex::Error("Specifying Olen with immersed forcing for buildings is not currently supported");
531  }
532 
533  // Flag to do MOST rotations with terrain
534  pp.query("use_rotate_surface_flux",use_rotate_surface_flux);
536  AMREX_ASSERT_WITH_MESSAGE(terrain_type != TerrainType::None,"MOST stress rotations are only valid with terrain!");
537  }
538 
539  // Which external forcings?
540  abl_driver_type = ABLDriverType::None; // Default: no ABL driver for simulating classical fluid dynamics problems
541  pp.query_enum_case_insensitive("abl_driver_type",abl_driver_type);
542  pp.query("const_massflux_u", const_massflux_u);
543  pp.query("const_massflux_v", const_massflux_v);
544  pp.query("const_massflux_tau", const_massflux_tau);
545  pp.query("const_massflux_layer_lo", const_massflux_layer_lo);
546  pp.query("const_massflux_layer_hi", const_massflux_layer_hi);
547 
548  // Which type of inflow turbulent generation
549  pert_type.resize(max_level+1);
550  for (int lev = 0; lev <= max_level; ++lev) {
551  pert_type[lev] = PerturbationType::None; // Default
553  pp, "perturbation_type", pert_type[lev], lev, max_level);
554  }
555 
556  amrex::Vector<amrex::Real> abl_pressure_grad_in = {zero, zero, zero};
557  pp.queryarr("abl_pressure_grad",abl_pressure_grad_in);
558  for(int i = 0; i < AMREX_SPACEDIM; ++i) abl_pressure_grad[i] = abl_pressure_grad_in[i];
559 
560  amrex::Vector<amrex::Real> abl_geo_forcing_in = {zero, zero, zero};
561  if(pp.queryarr("abl_geo_forcing",abl_geo_forcing_in)) {
562  amrex::Print() << "Specified abl_geo_forcing: (";
563  for (int i = 0; i < AMREX_SPACEDIM; ++i) {
564  abl_geo_forcing[i] = abl_geo_forcing_in[i];
565  amrex::Print() << abl_geo_forcing[i] << " ";
566  }
567  amrex::Print() << ")" << std::endl;
568  }
569 
570  if (use_coriolis)
571  {
573  }
574 
575  pp.query("add_custom_rhotheta_forcing", custom_rhotheta_forcing);
576  pp.query("add_custom_moisture_forcing", custom_moisture_forcing);
577  pp.query("add_custom_w_subsidence", custom_w_subsidence);
578  pp.query("add_do_theta_advection", do_theta_advection); // If true, apply custom subsidence to (rho*theta) when add_custom_w_subsidence is used
579  pp.query("add_do_mom_advection", do_mom_advection); // If true, apply custom subsidence to momentum when add_custom_w_subsidence is used
580  pp.query("add_custom_geostrophic_profile", custom_geostrophic_profile);
581  pp.query("custom_forcing_uses_primitive_vars", custom_forcing_prim_vars);
582  pp.query("spatial_rhotheta_forcing", spatial_rhotheta_forcing);
583  pp.query("spatial_moisture_forcing", spatial_moisture_forcing);
584 
585  pp.query("nudging_from_input_sounding", nudging_from_input_sounding);
586 
588  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(!(!abl_geo_wind_table.empty() && custom_geostrophic_profile),
589  "Should not have both abl_geo_wind_table and custom_geostrophic_profile set.");
590 
591  pp.query("Ave_Plane", ave_plane);
592 
593  // Use numerical diffusion?
594  pp.query("num_diff_coeff",num_diff_coeff);
596  "Numerical diffusion coefficient must be between 0 & one");
598  if (use_num_diff) {
599  amrex::Print() << "6th-order numerical diffusion turned on with coefficient = "
600  << num_diff_coeff << std::endl;
601  num_diff_coeff *= amrex::Math::powi<-6>(two);
602  }
603 
604  advChoice.init_params(pp_prefix);
605  diffChoice.init_params(pp_prefix);
606  dampingChoice.init_params(pp_prefix);
607  spongeChoice.init_params(pp_prefix);
608  ebChoice.init_params(pp_prefix);
609 
610  turbChoice.resize(max_level+1);
611  for (int lev = 0; lev <= max_level; lev++) {
612  turbChoice[lev].init_params(lev,max_level,pp_prefix);
613  }
614 
615  // YSU PBL: use consistent coriolis frequency
616  for (int lev = 0; lev <= max_level; lev++) {
617  if (turbChoice[lev].pbl_ysu_use_consistent_coriolis) {
618  if (use_coriolis) {
619  turbChoice[lev].pbl_ysu_coriolis_freq = coriolis_factor * sinphi;
620  if (lev == 0) {
621  amrex::Print() << "YSU PBL using ERF coriolis frequency: " << turbChoice[lev].pbl_ysu_coriolis_freq << std::endl;
622  }
623  } else {
624  amrex::Error("YSU cannot use ERF coriolis frequency if not using coriolis");
625  }
626  }
627  }
628  // MRF
629  for (int lev = 0; lev <= max_level; lev++) {
630  if (turbChoice[lev].pbl_ysu_use_consistent_coriolis) {
631  if (use_coriolis) {
632  turbChoice[lev].pbl_ysu_coriolis_freq = coriolis_factor * sinphi;
633  if (lev == 0) {
634  amrex::Print() << "MRF PBL using ERF coriolis frequency: " << turbChoice[lev].pbl_ysu_coriolis_freq << std::endl;
635  }
636  } else {
637  amrex::Error("MRF cannot use ERF coriolis frequency if not using coriolis");
638  }
639  }
640  }
641 
642  // What's the strength of the bdy nudging?
643  pp.query("bdy_nudge_factor",bdy_nudge_factor);
644 
645  // Are me transporting the scalar component?
646  pp.query("transport_scalar",transport_scalar);
647 
648  // Are we using SHOC? (test on compilation done in turb struct)
649  if (turbChoice[0].pbl_type == PBLType::SHOC) { use_shoc = true; }
650 
651  // Implicit vertical diffusion (not available with Shoc)
652  if (!use_shoc) {
653  // This controls the time-centering of the vertical differences in the diffusive term
654  bool do_vert_implicit = false;
655  if (pp.query("vert_implicit", do_vert_implicit) && do_vert_implicit) {
656  // set to default here
657  vert_implicit_fac[0] = one;
658  vert_implicit_fac[1] = one;
659  vert_implicit_fac[2] = zero;
660  }
661 
662  // This may be one value for all RK stages or a different value in each stage
663  int n_impfac = pp.countval("vert_implicit_fac");
664  AMREX_ALWAYS_ASSERT(n_impfac == 0 || n_impfac == 1 || n_impfac==3);
665  if (n_impfac > 0 && do_vert_implicit) {
666  amrex::Print() << "Overriding defaults with specified implicit factor(s)" << std::endl;
667  }
668 
669  if (n_impfac == 1) {
670  amrex::Real fac_in;
671  pp.get("vert_implicit_fac", fac_in);
672  for (int i=0; i<3; ++i) { vert_implicit_fac[i] = fac_in; }
673  } else if (n_impfac == 3) {
674  pp.getarr("vert_implicit_fac", vert_implicit_fac);
675  }
676 
677  // If true (default), include implicit contributions to vertical
678  // thermal diffusion
679  pp.query("implicit_thermal_diffusion", implicit_thermal_diffusion);
680 
681  // If true (default), include implicit contributions to vertical
682  // moisture diffusion
683  pp.query("implicit_moisture_diffusion", implicit_moisture_diffusion);
684 
685  // If true (default), include implicit contributions in tau13, tau23,
686  // (and if ERF_IMPLICIT_W is set, tau33) to correct u, v, (and w).
687  pp.query("implicit_momentum_diffusion", implicit_momentum_diffusion);
688 
692  amrex::Print() << "Thermal and momentum diffusion are both turned off -- turning off vertical implicit solve" << std::endl;
693  vert_implicit_fac[0] = zero;
694  vert_implicit_fac[1] = zero;
695  vert_implicit_fac[2] = zero;
696  }
697 
698  // This controls when the vertical implicit solve for the diffusive terms will happen relative to
699  // the acoustic substepping (if it happens, i.e. if any of the implicit_fac > zero)
700  // The default is true (i.e. that it happens before the acoustic substepping).
701  pp.query("implicit_before_substep", implicit_before_substep);
702  }
703 
704  // Which type of multilevel coupling
705  coupling_type = CouplingType::TwoWay; // Default
706  pp.query_enum_case_insensitive("coupling_type",coupling_type);
707 
708  // Test for hybrid (compressible + anelastic) -- in this case we must use one-way coupling
709  bool any_anelastic = false;
710  bool any_compress = false;
711  for (int lev = 0; lev <= max_level; lev++) {
712  if (anelastic[lev] == 0) {
713  any_compress = true;
714  } else {
715  any_anelastic = true;
716  }
717  }
718  if (any_anelastic && any_compress) {
719  coupling_type = CouplingType::OneWay;
720  }
721 
722  // Which type of windfarm model
723  windfarm_type = WindFarmType::None; // Default
724  pp.query_enum_case_insensitive("windfarm_type",windfarm_type);
725 
726  windfarm_loc_type = WindFarmLocType::None;
727  pp.query_enum_case_insensitive("windfarm_loc_type",windfarm_loc_type);
728 
729  pp.query("windfarm_loc_table", windfarm_loc_table);
730  pp.query("windfarm_spec_table", windfarm_spec_table);
731  pp.query("windfarm_blade_table", windfarm_blade_table);
732  pp.query("windfarm_airfoil_tables", windfarm_airfoil_tables);
733  pp.query("windfarm_spec_table_extra", windfarm_spec_table_extra);
734 
735  // Sampling distance upstream of the turbine to find the
736  // incoming free stream velocity as a factor of the diameter of the
737  // turbine. ie. the sampling distance will be this number multiplied
738  // by the diameter of the turbine
739  pp.query("sampling_distance_by_D", sampling_distance_by_D);
740  pp.query("turb_disk_angle_from_x", turb_disk_angle);
741 
742  pp.query("windfarm_x_shift",windfarm_x_shift);
743  pp.query("windfarm_y_shift",windfarm_y_shift);
744  // Test if time averaged data is to be output
745  pp.query("time_avg_vel",time_avg_vel);
746 
747  pp.query("hindcast_lateral_forcing", hindcast_lateral_forcing);
748 
750  pp.query("hindcast_boundary_data_dir", hindcast_boundary_data_dir);
751 
752  if(hindcast_boundary_data_dir.empty()) {
753  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_boundary_data_dir' for boundary data for lateral forcing");
754  }
755  pp.query("hindcast_data_interval_in_hrs", hindcast_data_interval_in_hrs);
757  amrex::Error("ERROR: Input parameter 'erf.hindcast_data_interval_in_hrs' which is the time interval between the "
758  "data files is either missing or set to less than zero");
759  }
760  pp.query("hindcast_lateral_sponge_strength", hindcast_lateral_sponge_strength);
761  pp.query("hindcast_lateral_sponge_length", hindcast_lateral_sponge_length);
762 
763  pp.query("hindcast_zhi_sponge_length", hindcast_zhi_sponge_length);
764  pp.query("hindcast_zhi_sponge_strength", hindcast_zhi_sponge_strength);
765 
766  pp.query("hindcast_zhi_sponge_damping", hindcast_zhi_sponge_damping);
767 
769  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_lateral_sponge_strength' or it is specified to be less than zero");
770  }
771 
773  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_lateral_sponge_length' or it is specified to be less than zero");
774  }
775 
777  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_zhi_sponge_strength' or it is specified to be less than zero");
778  }
779 
781  amrex::Error("ERROR: Missing input parameter 'erf.hindcast_zhi_sponge_strength' or it is specified to be less than zero");
782  }
783  }
784 
785  pp.query("hindcast_surface_bcs", hindcast_surface_bcs);
787  pp.query("hindcast_surface_data_dir", hindcast_surface_data_dir);
788  }
789 
790  pp.query("io_hurricane_eye_tracker", io_hurricane_eye_tracker);
792  pp.query("hurricane_eye_latitude", hurricane_eye_latitude);
793  pp.query("hurricane_eye_longitude", hurricane_eye_longitude);
795  amrex::Error("ERROR: You are using 'erf.io_hurricane_eye_tracker' to write out the files that track the eye of the hurricane"
796  " but have not provided the initial location of the eye of the hurricane to be tracked. There has to be two"
797  " options in the inputs - erf.hurricane_eye_latitude and erf.hurricane_eye_longitude that gives an approximate"
798  " location of the eye in the initial condition");
799  }
800  }
801 
802  pp.query("is_init_for_ensemble", is_init_for_ensemble);
804  amrex::ParmParse pp_ens("ensemble");
805  pp_ens.query("n_members", n_ensemble);
806  pp_ens.query("coarse_bckgnd_data_file", coarse_bckgnd_data_file);
807  pp_ens.query("ens_pert_amplitude", ens_pert_amplitude);
808  pp_ens.query("ens_pert_correlated_radius", ens_pert_correlated_radius);
809  if (n_ensemble < 0) {
810  amrex::Abort("You are running an ensemble simulation, There needs to be an entry in the inputs "
811  "ensemble.n_ensemble which is the number of ensemble members, and should be greater than 0.");
812  }
813  if (coarse_bckgnd_data_file.empty()) {
814  amrex::Abort("coarse_bckgnd_data_file is empty! For ensmeble simulations, there needs to be a coarse background file which "
815  "contains the data which will be interpolated onto the fine mesh. There has to a entry ensemble.coarse_bckgnd_data_file "
816  "which contains the filename in the inputs.");
817  }
818  if(ens_pert_amplitude <= 0.0) {
819  amrex::Error("You are using initialization for ensemble simulations using the inputs option "
820  "ensemble.is_init_for_ensemble=true. In this case, there has to be an option "
821  "ensemble.ens_pert_amplitude which is the value of the amplitude of the perturbation "
822  "to be added to the background state and has to be greater than 0.0");
823  }
824  if(ens_pert_correlated_radius <= 0.0) {
825  amrex::Error("You are using initialization with spatially correlated perturbations using the inputs option "
826  "ensemble.is_init_for_ensemble=true. In this case, there has to be an option "
827  "ensemble.ens_pert_correlated_radius which is the value of the the spatial correlation radius, "
828  "and has to be greater than 0.0");
829  }
830  }
831  }
832 
833  void check_params (int max_level, const amrex::Vector<amrex::Geometry>& geom_vect, amrex::GpuArray<ERF_BC, AMREX_SPACEDIM*2> phys_bc_type)
834  {
835 #if 0
836  // Warn for PBL models and moisture - these may not yet be compatible
837  for (int lev = 0; lev <= max_level; lev++) {
838  if ((moisture_type != MoistureType::None) && (turbChoice[lev].pbl_type != PBLType::None)) {
839  amrex::Warning("\n*** WARNING: Moisture may not yet be compatible with PBL models, \n proceed with caution ***");
840  }
841  }
842 #endif
843  //
844  // Buoyancy type check
845  //
846  for (int lev = 0; lev <= max_level; lev++) {
847  if (buoyancy_type[lev] != 1 && buoyancy_type[lev] != 2 && buoyancy_type[lev] != 3 && buoyancy_type[lev] != 4) {
848  amrex::Error("buoyancy_type must be 1, 2, 3 or 4");
849  }
850  }
851 
852  if (!use_lagged_delta_rt && !(terrain_type == TerrainType::MovingFittedMesh)) {
853  amrex::Error("Can't turn off lagged_delta_rt when terrain not moving");
854  }
855 
856  //
857  // Wind farm checks
858  //
859  if (windfarm_type==WindFarmType::SimpleAD and sampling_distance_by_D < zero) {
860  amrex::Error("To use simplified actuator disks, you need to provide a variable"
861  " erf.sampling_distance_by_D in the inputs which specifies the upstream"
862  " distance as a factor of the turbine diameter at which the incoming free stream"
863  " velocity will be computed at.");
864  }
865  if ( (windfarm_type==WindFarmType::SimpleAD ||
866  windfarm_type==WindFarmType::GeneralAD ) && turb_disk_angle < zero) {
867  amrex::Error("To use simplified actuator disks, you need to provide a variable"
868  " erf.turb_disk_angle_from_x in the inputs which is the angle of the face of the"
869  " turbine disk from the x-axis. A turbine facing an oncoming flow in the x-direction"
870  " will have turb_disk_angle value of 90 deg.");
871  }
872  if (windfarm_loc_type == WindFarmLocType::lat_lon and (windfarm_x_shift < zero or windfarm_y_shift < zero)) {
873  amrex::Error("You are using windfarms with latitude-logitude option to position the turbines."
874  " For this you should provide the inputs erf.windfarm_x_shift and"
875  " erf.windfarm_y_shift which are the values by which the bounding box of the"
876  " windfarm is shifted from the x and the y axes.");
877  }
878 
879 
880  if ( (const_massflux_u != 0) && !(geom_vect[0].isPeriodic(0)) ) {
881  amrex::Error("Constant mass flux (in x) should be used with periodic boundaries");
882  }
883 
884  if ( (const_massflux_v != 0) && !(geom_vect[0].isPeriodic(1)) ) {
885  amrex::Error("Constant mass flux (in y) should be used with periodic boundaries");
886  }
887 
888  // Mesoscale diffusion -- test if LES appropriate with this dx,dy
889  for (int lev = 0; lev <= max_level; lev++) {
890  if ((geom_vect[lev].CellSize(0) > amrex::Real(2000.)) || (geom_vect[lev].CellSize(1) > amrex::Real(2000.)))
891  {
892  if ( (turbChoice[lev].les_type == LESType::Smagorinsky) && !turbChoice[lev].smag2d ) {
893  amrex::Warning("Should use 2-D Smagorinsky for mesoscale resolution");
894  } else if (turbChoice[lev].les_type == LESType::Deardorff) {
895  amrex::Warning("Should not use Deardorff LES for mesoscale resolution");
896  }
897  }
898  }
899 
900  // Turn off implicit solve if we have no diffusion
901  bool l_use_kturb = turbChoice[0].use_kturb;
902  for (int lev = 1; lev <= max_level; lev++) {
903  l_use_kturb = (l_use_kturb || turbChoice[lev].use_kturb);
904  }
905  bool l_use_diff = ( (diffChoice.molec_diff_type != MolecDiffType::None) || l_use_kturb );
906  bool l_implicit_diff = (vert_implicit_fac[0] > 0 ||
907  vert_implicit_fac[1] > 0 ||
908  vert_implicit_fac[2] > 0);
909  if (l_implicit_diff && !l_use_diff) {
910  amrex:: Print() << "No molecular or turbulent diffusion, turning off implicit solve" << std::endl;
911  vert_implicit_fac[0] = 0;
912  vert_implicit_fac[1] = 0;
913  vert_implicit_fac[2] = 0;
914  }
915 
916  for (int lev = 0; lev <= max_level; lev++) {
917  turbChoice[lev].check_params(phys_bc_type);
918  }
919  }
920 
921  void display (int max_level, std::string pp_prefix)
922  {
923  amrex::Print() << "SOLVER CHOICE: " << std::endl;
924  for (int lev = 0; lev <= max_level; lev++) {
925  amrex::Print() << "At level " << lev << " : " << std::endl;
926  if (anelastic[lev]) {
927  amrex::Print() << " anelastic with no substepping" << std::endl;
928  } else {
929  if (substepping_type[lev] == SubsteppingType::None) {
930  amrex::Print() << " compressible with no substepping" << std::endl;
931  } else if (substepping_type[lev] == SubsteppingType::Implicit) {
932  amrex::Print() << " compressible with implicit substepping" << std::endl;
933  }
934  }
935  if (fixed_density[lev]) {
936  amrex::Print() << " and fixed density" << std::endl;
937  }
938  }
939 
940  amrex::Print() << "vert_implicit_fac : " << vert_implicit_fac[0] << " "
941  << vert_implicit_fac[1] << " "
942  << vert_implicit_fac[2];
943  if (vert_implicit_fac[0] > 0 ||
944  vert_implicit_fac[0] > 1 ||
945  vert_implicit_fac[0] > 2)
946  {
947  amrex::Print() << " (theta=" << implicit_thermal_diffusion
948  << ", moisture=" << implicit_moisture_diffusion
949  << ", momenta=" << implicit_momentum_diffusion;
950 #ifdef ERF_IMPLICIT_W
951  amrex::Print() << ", including w";
952 #endif
953  amrex::Print() << ")";
954  }
955  amrex::Print() << std::endl;
956  amrex::Print() << "use_coriolis : " << use_coriolis << std::endl;
957  amrex::Print() << "use_gravity : " << use_gravity << std::endl;
958 
959  if (moisture_type == MoistureType::SAM) {
960  amrex::Print() << "Moisture Model: SAM" << std::endl;
961  } else if (moisture_type == MoistureType::SAM_NoIce) {
962  amrex::Print() << "Moisture Model: SAM No Ice" << std::endl;
963  } else if (moisture_type == MoistureType::SAM_NoPrecip_NoIce) {
964  amrex::Print() << "Moisture Model: SAM No Precip No Ice" << std::endl;
965  } else if (moisture_type == MoistureType::Morrison) {
966  amrex::Print() << "Moisture Model: Morrison" << std::endl;
967  } else if (moisture_type == MoistureType::Morrison_NoIce) {
968  amrex::Print() << "Moisture Model: Morrison_NoIce" << std::endl;
969  } else if (moisture_type == MoistureType::WSM6) {
970  amrex::Print() << "Moisture Model: WSM6" << std::endl;
971  } else if (moisture_type == MoistureType::Kessler) {
972  amrex::Print() << "Moisture Model: Kessler" << std::endl;
973  } else if (moisture_type == MoistureType::Kessler_NoRain) {
974  amrex::Print() << "Moisture Model: Kessler No Rain" << std::endl;
975  } else if (moisture_type == MoistureType::SatAdj) {
976  amrex::Print() << "Moisture Model: Saturation Adjustment" << std::endl;
977  } else {
978  amrex::Print() << "Moisture Model: None" << std::endl;
979  }
980 
981  if (terrain_type == TerrainType::StaticFittedMesh) {
982  amrex::Print() << "Terrain Type: StaticFittedMesh" << std::endl;
983  } else if (terrain_type == TerrainType::MovingFittedMesh) {
984  amrex::Print() << "Terrain Type: MovingFittedMesh" << std::endl;
985  } else if (terrain_type == TerrainType::EB) {
986  amrex::Print() << "Terrain Type: EB" << std::endl;
987  ebChoice.display();
988  } else if (terrain_type == TerrainType::ImmersedForcing) {
989  amrex::Print() << "Terrain Type: ImmersedForcing" << std::endl;
990  } else {
991  amrex::Print() << "Terrain Type: None" << std::endl;
992  }
993 
994  if (buildings_type == BuildingsType::ImmersedForcing) {
995  amrex::Print() << "Buildings Type: ImmersedForcing" << std::endl;
996  } else {
997  amrex::Print() << "Buildings Type: None" << std::endl;
998  }
999 
1000  if (mesh_type == MeshType::ConstantDz) {
1001  amrex::Print() << " Mesh Type: ConstantDz" << std::endl;
1002  } else if (mesh_type == MeshType::StretchedDz) {
1003  amrex::Print() << " Mesh Type: StretchedDz" << std::endl;
1004  } else if (mesh_type == MeshType::VariableDz) {
1005  amrex::Print() << " Mesh Type: VariableDz" << std::endl;
1006  } else {
1007  amrex::Error("No mesh_type set!");
1008  }
1009 
1010  amrex::Print() << "ABL Driver Type: " << std::endl;
1011  if (abl_driver_type == ABLDriverType::None) {
1012  amrex::Print() << " None" << std::endl;
1013  } else if (abl_driver_type == ABLDriverType::PressureGradient) {
1014  amrex::Print() << " Pressure Gradient "
1015  << amrex::RealVect(abl_pressure_grad[0],abl_pressure_grad[1],abl_pressure_grad[2])
1016  << std::endl;
1017  } else if (abl_driver_type == ABLDriverType::GeostrophicWind) {
1018  amrex::Print() << " Geostrophic Wind "
1019  << amrex::RealVect(abl_geo_forcing[0],abl_geo_forcing[1],abl_geo_forcing[2])
1020  << std::endl;
1021  }
1022 
1023  if (max_level > 0) {
1024  amrex::Print() << "Coupling Type: " << std::endl;
1025  if (coupling_type == CouplingType::TwoWay) {
1026  amrex::Print() << " Two-way" << std::endl;
1027  } else if (coupling_type == CouplingType::OneWay) {
1028  amrex::Print() << " One-way" << std::endl;
1029  }
1030  }
1031 
1032  if (rad_type == RadiationType::RRTMGP) {
1033  amrex::Print() << "Radiation Model: RRTMGP" << std::endl;
1034  } else {
1035  amrex::Print() << "Radiation Model: None" << std::endl;
1036  }
1037 
1038  amrex::Print() << "Gradp_type : " << gradp_type << std::endl;
1039 
1040  for (int lev = 0; lev <= max_level; lev++) {
1041  amrex::Print() << "Buoyancy_type at level " << lev << " : " << buoyancy_type[lev] << std::endl;
1042  }
1043 
1044  advChoice.display(pp_prefix);
1045  diffChoice.display();
1048 
1049  for (int lev = 0; lev <= max_level; lev++) {
1050  turbChoice[lev].display(lev);
1051  }
1052  }
1053 
1054  void build_coriolis_forcings_const_lat (std::string pp_prefix)
1055  {
1056  amrex::ParmParse pp(pp_prefix);
1057 
1058  // Read the rotational time period (in seconds)
1059  amrex::Real rot_time_period = amrex::Real(86400.0);
1060  pp.query("rotational_time_period", rot_time_period);
1061 
1062  coriolis_factor = two * two * PI / rot_time_period;
1063 
1064  amrex::Real latitude = amrex::Real(90.0);
1065  pp.query("latitude", latitude);
1066 
1067  pp.query("coriolis_3d", coriolis_3d);
1068 
1069  // Convert to radians
1070  latitude *= (PI/amrex::Real(180.));
1071  sinphi = std::sin(latitude);
1072  if (coriolis_3d) {
1073  cosphi = std::cos(latitude);
1074  }
1075 
1076  amrex::Print() << "Coriolis frequency, f = " << coriolis_factor * sinphi << " 1/s" << std::endl;
1077 
1078  if (abl_driver_type == ABLDriverType::GeostrophicWind) {
1079  // Read in the geostrophic wind -- we only use this to construct
1080  // the forcing term so no need to keep it
1081  amrex::Vector<amrex::Real> abl_geo_wind(3);
1082  pp.queryarr("abl_geo_wind",abl_geo_wind);
1083 
1084  if(!pp.query("abl_geo_wind_table",abl_geo_wind_table)) {
1085  abl_geo_forcing = {
1086  -coriolis_factor * (abl_geo_wind[1]*sinphi - abl_geo_wind[2]*cosphi),
1087  coriolis_factor * abl_geo_wind[0]*sinphi,
1088  -coriolis_factor * abl_geo_wind[0]*cosphi
1089  };
1090  } else {
1091  amrex::Print() << "NOTE: abl_geo_wind_table provided, ignoring input abl_geo_wind" << std::endl;
1092  }
1093  }
1094  }
1095 
1096  void read_int_string (int max_level, const char* string_to_read,
1097  amrex::Vector<int>& vec_to_fill, int default_int)
1098  {
1099  amrex::ParmParse pp("erf");
1100  int nvals = pp.countval(string_to_read);
1101  AMREX_ALWAYS_ASSERT(nvals == 0 || nvals == 1 || nvals >= max_level+1);
1102  amrex::Vector<int> temp; temp.resize(nvals);
1103  pp.queryarr(string_to_read,temp);
1104 
1105  if (vec_to_fill.size() < max_level+1) {
1106  vec_to_fill.resize(max_level+1);
1107  }
1108 
1109  if (nvals == 0) {
1110  for (int i = 0; i <= max_level; ++i) vec_to_fill[i] = default_int;
1111  } else if (nvals == 1) {
1112  for (int i = 0; i <= max_level; ++i) vec_to_fill[i] = temp[0];
1113  } else {
1114  for (int i = 0; i <= max_level; ++i) vec_to_fill[i] = temp[i];
1115  }
1116  }
1117 
1118  inline static
1119  InitType init_type = InitType::None;
1120 
1121  inline static
1122  SoundingType sounding_type = SoundingType::Ideal;
1123 
1124  inline static
1125  TerrainType terrain_type = TerrainType::None;
1126 
1127  inline static
1128  BuildingsType buildings_type = BuildingsType::None;
1129 
1130  inline static
1131  bool use_real_bcs = false;
1132 
1133  inline static
1134  MeshType mesh_type = MeshType::ConstantDz;
1135 
1136  static
1137  void set_mesh_type (MeshType new_mesh_type)
1138  {
1139  mesh_type = new_mesh_type;
1140  }
1141 
1146  amrex::Vector<TurbChoice> turbChoice;
1148 
1150 
1151  amrex::Vector<SubsteppingType> substepping_type;
1152  amrex::Vector<int> anelastic;
1153  amrex::Vector<int> fixed_density;
1154  amrex::Vector<int> project_initial_velocity;
1155  amrex::Vector<int> buoyancy_type;
1156  amrex::Vector<int> is_land;
1157 
1158  // do some extra CFL diagnostics for compressible with substepping
1159  bool substepping_diag = false;
1160 
1161  // time off-centering coefficient, > 0 for forward weighting (i.e., bias
1162  // towards the future time step)
1164 
1165  // This controls the time-centering of the *vertical* differences in the diffusive term for
1166  // theta, u, v (and w if ERF_IMPLICIT_W is set)
1167  // 0: fully explicit
1168  // 1: fully implicit
1169  amrex::Vector<amrex::Real> vert_implicit_fac = {zero, zero, zero}; // one value per RK stage
1170  // if any vert_implicit_fac > 0, then the following apply:
1175 
1176  int ncorr = 1;
1177 #ifdef AMREX_USE_FLOAT
1180 #else
1183 #endif
1184 
1185  bool test_mapfactor = false;
1186 
1187  int gradp_type = 0;
1188 
1190 
1191  // Specify what additional physics/forcing modules we use
1192  bool use_gravity = false;
1193  bool use_coriolis = false;
1194  bool coriolis_3d = true;
1195 
1197 
1198  // Specify whether to apply other various source terms on substep only
1200  bool forest_substep = false;
1201 
1202  // immersed forcing parameters
1205  // immersed forcing MOST parameters.
1211  bool if_use_most = false;
1212 
1213  // This defaults to true but can be set to false for moving terrain cases only
1214  bool use_lagged_delta_rt = true;
1215 
1216  // Flag to rebalance state from wrf input
1217  bool rebalance_wrf_input = true;
1218 
1219  // Constants
1221  amrex::Real c_p = Cp_d; // specific heat at constant pressure for dry air [J/(kg-K)]
1223 
1224  // Staggered z levels for vertical grid stretching
1228 
1229  // Coriolis forcing
1233 
1234  // User-specified forcings in problem definition
1237  bool custom_w_subsidence = false;
1238  bool do_theta_advection = true; // Apply custom vertical subsidence to (rho*theta) equation when using custom w subsidence
1239  bool do_mom_advection = true; // Apply custom vertical subsidence to momentum equations when using custom w subsidence
1244 
1245  // Do we use source terms to nudge the solution towards
1246  // the time-varying data provided in input sounding files?
1248 
1249  // MOST stress rotations
1251 
1252  // Should we use SHOC?
1253  bool use_shoc = false;
1254 
1255  // Transport the passive scalar?
1256  bool transport_scalar = true;
1257 
1258  // User wishes to output time averaged velocity fields
1259  bool time_avg_vel = false;
1260 
1261  bool use_perturbation (int lev) const
1262  {
1263  return pert_type[lev] == PerturbationType::Source ||
1264  pert_type[lev] == PerturbationType::Direct ||
1265  pert_type[lev] == PerturbationType::CPM;
1266  }
1267 
1268  bool use_direct_perturbation (int lev) const
1269  {
1270  return pert_type[lev] == PerturbationType::Direct ||
1271  pert_type[lev] == PerturbationType::CPM;
1272  }
1273 
1274  bool use_source_perturbation (int lev) const
1275  {
1276  return pert_type[lev] == PerturbationType::Source;
1277  }
1278 
1279  bool any_perturbation () const
1280  {
1281  for (const auto& type : pert_type) {
1282  if (type == PerturbationType::Source ||
1283  type == PerturbationType::Direct ||
1284  type == PerturbationType::CPM) {
1285  return true;
1286  }
1287  }
1288  return false;
1289  }
1290 
1291  // Type of perturbation
1292  amrex::Vector<PerturbationType> pert_type;
1293 
1294  // Numerical diffusion
1295  bool use_num_diff{false};
1297 
1298  CouplingType coupling_type;
1299  MoistureType moisture_type;
1300  WindFarmType windfarm_type;
1301  WindFarmLocType windfarm_loc_type;
1302  LandSurfaceType lsm_type;
1303  RadiationType rad_type;
1304 
1305  ABLDriverType abl_driver_type;
1306  amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> abl_pressure_grad;
1307  amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> abl_geo_forcing;
1308  std::string abl_geo_wind_table;
1310 
1311  bool variable_coriolis{false};
1312 
1313  int ave_plane {2};
1314 
1315  // Microphysics params
1317 
1319 
1326 
1327  // Nudging factor for bdy sponging : F1 = 1/(nudge_factor * dt)
1329 
1330  // Use forest canopy model?
1331  bool do_forest_drag {false};
1332 
1333  // Enforce constant mass flux?
1339  int massflux_klo {0}; // these are updated in ERF.cpp
1340  int massflux_khi {0};
1341 
1345  bool hindcast_surface_bcs = false;
1349 
1352 
1353  bool is_init_for_ensemble = false;
1354  int n_ensemble = -1;
1358 };
1359 #endif
constexpr amrex::Real Cp_d
Definition: ERF_Constants.H:31
constexpr amrex::Real two
Definition: ERF_Constants.H:8
constexpr amrex::Real one
Definition: ERF_Constants.H:7
constexpr amrex::Real zero
Definition: ERF_Constants.H:6
constexpr amrex::Real PI
Definition: ERF_Constants.H:24
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:40
constexpr amrex::Real R_d
Definition: ERF_Constants.H:29
TauType
Definition: ERF_DataStruct.H:31
@ tau12
Definition: ERF_DataStruct.H:32
@ tau23
Definition: ERF_DataStruct.H:32
@ tau33
Definition: ERF_DataStruct.H:32
@ tau22
Definition: ERF_DataStruct.H:32
@ tau11
Definition: ERF_DataStruct.H:32
@ tau32
Definition: ERF_DataStruct.H:32
@ tau31
Definition: ERF_DataStruct.H:32
@ tau21
Definition: ERF_DataStruct.H:32
@ tau13
Definition: ERF_DataStruct.H:32
AMREX_ENUM(InitType, None, Input_Sounding, NCFile, WRFInput, Metgrid, Uniform, ConstantDensity, ConstantDensityLinearTheta, Isentropic, MoistBaseState, HindCast)
Rayleigh
Definition: ERF_DataStruct.H:97
@ ubar
Definition: ERF_DataStruct.H:98
@ wbar
Definition: ERF_DataStruct.H:98
@ nvars
Definition: ERF_DataStruct.H:98
@ vbar
Definition: ERF_DataStruct.H:98
@ thetabar
Definition: ERF_DataStruct.H:98
Sponge
Definition: ERF_DataStruct.H:102
@ nvars_sponge
Definition: ERF_DataStruct.H:103
@ vbar_sponge
Definition: ERF_DataStruct.H:103
@ ubar_sponge
Definition: ERF_DataStruct.H:103
MapFacType
Definition: ERF_DataStruct.H:22
@ v_x
Definition: ERF_DataStruct.H:24
@ num
Definition: ERF_DataStruct.H:24
@ u_y
Definition: ERF_DataStruct.H:25
@ v_y
Definition: ERF_DataStruct.H:25
@ m_y
Definition: ERF_DataStruct.H:25
@ u_x
Definition: ERF_DataStruct.H:24
@ m_x
Definition: ERF_DataStruct.H:24
Coord
Definition: ERF_DataStruct.H:92
#define RhoQ4_comp
Definition: ERF_IndexDefines.H:45
#define RhoQ2_comp
Definition: ERF_IndexDefines.H:43
#define RhoQ3_comp
Definition: ERF_IndexDefines.H:44
#define RhoQ11_comp
Definition: ERF_IndexDefines.H:52
#define RhoQ9_comp
Definition: ERF_IndexDefines.H:50
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:42
#define RhoQ6_comp
Definition: ERF_IndexDefines.H:47
#define RhoQ8_comp
Definition: ERF_IndexDefines.H:49
#define RhoQ5_comp
Definition: ERF_IndexDefines.H:46
#define RhoQ7_comp
Definition: ERF_IndexDefines.H:48
#define RhoQ10_comp
Definition: ERF_IndexDefines.H:51
ParmParse pp("prob")
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
amrex::Real Real
Definition: ERF_ShocInterface.H:19
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)
Definition: ERF_TurbStruct.H:48
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:39
Definition: ERF_MM5.H:26
Definition: ERF_MoistNoCondensation.H:13
Definition: ERF_Morrison.H:58
Definition: ERF_NOAHMP.H:84
Definition: ERF_OceanSurf.H:19
Definition: ERF_SAM.H:54
Definition: ERF_SLM.H:26
Definition: ERF_SatAdj.H:45
Definition: ERF_SimpleAD.H:8
Definition: ERF_WSM6.H:37
Definition: ERF_AdvStruct.H:19
void display(std::string &pp_prefix)
Definition: ERF_AdvStruct.H:235
void init_params(std::string pp_prefix)
Definition: ERF_AdvStruct.H:21
Definition: ERF_DampingStruct.H:19
void init_params(std::string pp_prefix)
Definition: ERF_DampingStruct.H:21
void display()
Definition: ERF_DampingStruct.H:61
Definition: ERF_DiffStruct.H:19
void init_params(std::string pp_prefix)
Definition: ERF_DiffStruct.H:21
void display()
Definition: ERF_DiffStruct.H:67
MolecDiffType molec_diff_type
Definition: ERF_DiffStruct.H:84
Definition: ERF_EBStruct.H:27
void init_params(std::string pp_prefix)
Definition: ERF_EBStruct.H:29
void display()
Definition: ERF_EBStruct.H:47
Definition: ERF_DataStruct.H:106
int nc
Definition: ERF_DataStruct.H:113
int qs
Definition: ERF_DataStruct.H:111
int qr
Definition: ERF_DataStruct.H:110
MoistureComponentIndices()=default
int qi
Definition: ERF_DataStruct.H:109
int ni
Definition: ERF_DataStruct.H:114
MoistureComponentIndices(int qv_comp, int qc_comp, int qi_comp=-1, int qr_comp=-1, int qs_comp=-1, int qg_comp=-1, int nc_comp=-1, int ni_comp=-1, int nr_comp=-1, int ns_comp=-1, int ng_comp=-1)
Definition: ERF_DataStruct.H:120
int qv
Definition: ERF_DataStruct.H:107
int nr
Definition: ERF_DataStruct.H:115
int qc
Definition: ERF_DataStruct.H:108
int ng
Definition: ERF_DataStruct.H:117
int qg
Definition: ERF_DataStruct.H:112
int ns
Definition: ERF_DataStruct.H:116
Definition: ERF_DataStruct.H:141
bool rebalance_wrf_input
Definition: ERF_DataStruct.H:1217
amrex::Real hurricane_eye_latitude
Definition: ERF_DataStruct.H:1351
bool do_mom_advection
Definition: ERF_DataStruct.H:1239
amrex::Real if_init_surf_temp
Definition: ERF_DataStruct.H:1208
amrex::Real dz0
Definition: ERF_DataStruct.H:1227
amrex::Real const_massflux_layer_lo
Definition: ERF_DataStruct.H:1337
bool use_lagged_delta_rt
Definition: ERF_DataStruct.H:1214
amrex::Real coriolis_factor
Definition: ERF_DataStruct.H:1230
static MeshType mesh_type
Definition: ERF_DataStruct.H:1134
amrex::Real if_surf_temp_flux
Definition: ERF_DataStruct.H:1207
amrex::Real windfarm_x_shift
Definition: ERF_DataStruct.H:1324
void check_params(int max_level, const amrex::Vector< amrex::Geometry > &geom_vect, amrex::GpuArray< ERF_BC, AMREX_SPACEDIM *2 > phys_bc_type)
Definition: ERF_DataStruct.H:833
void display(int max_level, std::string pp_prefix)
Definition: ERF_DataStruct.H:921
amrex::Real hindcast_lateral_sponge_strength
Definition: ERF_DataStruct.H:1346
amrex::Real poisson_reltol
Definition: ERF_DataStruct.H:1182
void build_coriolis_forcings_const_lat(std::string pp_prefix)
Definition: ERF_DataStruct.H:1054
bool if_use_most
Definition: ERF_DataStruct.H:1211
DampingChoice dampingChoice
Definition: ERF_DataStruct.H:1144
int n_ensemble
Definition: ERF_DataStruct.H:1354
amrex::Real rdOcp
Definition: ERF_DataStruct.H:1222
bool spatial_moisture_forcing
Definition: ERF_DataStruct.H:1243
RadiationType rad_type
Definition: ERF_DataStruct.H:1303
void read_int_string(int max_level, const char *string_to_read, amrex::Vector< int > &vec_to_fill, int default_int)
Definition: ERF_DataStruct.H:1096
amrex::Vector< int > project_initial_velocity
Definition: ERF_DataStruct.H:1154
std::string windfarm_spec_table
Definition: ERF_DataStruct.H:1320
amrex::Real hindcast_zhi_sponge_length
Definition: ERF_DataStruct.H:1347
DiffChoice diffChoice
Definition: ERF_DataStruct.H:1143
amrex::Real const_massflux_v
Definition: ERF_DataStruct.H:1335
amrex::Real if_z0
Definition: ERF_DataStruct.H:1206
bool use_gravity
Definition: ERF_DataStruct.H:1192
int ncorr
Definition: ERF_DataStruct.H:1176
amrex::Vector< PerturbationType > pert_type
Definition: ERF_DataStruct.H:1292
int force_stage1_single_substep
Definition: ERF_DataStruct.H:1149
bool hindcast_zhi_sponge_damping
Definition: ERF_DataStruct.H:1348
std::string windfarm_spec_table_extra
Definition: ERF_DataStruct.H:1320
amrex::Real cosphi
Definition: ERF_DataStruct.H:1231
LandSurfaceType lsm_type
Definition: ERF_DataStruct.H:1302
amrex::Real c_p
Definition: ERF_DataStruct.H:1221
amrex::Vector< int > buoyancy_type
Definition: ERF_DataStruct.H:1155
std::string windfarm_loc_table
Definition: ERF_DataStruct.H:1320
amrex::Real ens_pert_amplitude
Definition: ERF_DataStruct.H:1356
bool do_theta_advection
Definition: ERF_DataStruct.H:1238
amrex::Real gravity
Definition: ERF_DataStruct.H:1220
bool any_perturbation() const
Definition: ERF_DataStruct.H:1279
amrex::Vector< int > is_land
Definition: ERF_DataStruct.H:1156
amrex::Real bdy_nudge_factor
Definition: ERF_DataStruct.H:1328
amrex::Real beta_s
Definition: ERF_DataStruct.H:1163
bool custom_rhotheta_forcing
Definition: ERF_DataStruct.H:1235
amrex::Real hindcast_lateral_sponge_length
Definition: ERF_DataStruct.H:1346
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_geo_forcing
Definition: ERF_DataStruct.H:1307
bool use_shoc
Definition: ERF_DataStruct.H:1253
WindFarmLocType windfarm_loc_type
Definition: ERF_DataStruct.H:1301
bool hindcast_lateral_forcing
Definition: ERF_DataStruct.H:1344
int massflux_klo
Definition: ERF_DataStruct.H:1339
bool moisture_tight_coupling
Definition: ERF_DataStruct.H:1318
bool custom_w_subsidence
Definition: ERF_DataStruct.H:1237
bool nudging_from_input_sounding
Definition: ERF_DataStruct.H:1247
bool custom_geostrophic_profile
Definition: ERF_DataStruct.H:1240
amrex::Real if_Cd_scalar
Definition: ERF_DataStruct.H:1203
bool immersed_forcing_substep
Definition: ERF_DataStruct.H:1199
amrex::Real grid_stretching_ratio
Definition: ERF_DataStruct.H:1225
amrex::Real sinphi
Definition: ERF_DataStruct.H:1232
bool have_geo_wind_profile
Definition: ERF_DataStruct.H:1309
amrex::Vector< amrex::Real > vert_implicit_fac
Definition: ERF_DataStruct.H:1169
bool use_perturbation(int lev) const
Definition: ERF_DataStruct.H:1261
amrex::Real hurricane_eye_longitude
Definition: ERF_DataStruct.H:1351
amrex::Real const_massflux_u
Definition: ERF_DataStruct.H:1334
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_pressure_grad
Definition: ERF_DataStruct.H:1306
bool implicit_moisture_diffusion
Definition: ERF_DataStruct.H:1172
std::string hindcast_surface_data_dir
Definition: ERF_DataStruct.H:1342
void init_params(int max_level, std::string pp_prefix)
Definition: ERF_DataStruct.H:143
bool io_hurricane_eye_tracker
Definition: ERF_DataStruct.H:1350
bool use_direct_perturbation(int lev) const
Definition: ERF_DataStruct.H:1268
amrex::Vector< SubsteppingType > substepping_type
Definition: ERF_DataStruct.H:1151
bool coriolis_3d
Definition: ERF_DataStruct.H:1194
amrex::Real if_Olen_in
Definition: ERF_DataStruct.H:1210
bool use_num_diff
Definition: ERF_DataStruct.H:1295
amrex::Real sampling_distance_by_D
Definition: ERF_DataStruct.H:1322
bool implicit_thermal_diffusion
Definition: ERF_DataStruct.H:1171
amrex::Real hindcast_zhi_sponge_strength
Definition: ERF_DataStruct.H:1347
bool test_mapfactor
Definition: ERF_DataStruct.H:1185
bool use_coriolis
Definition: ERF_DataStruct.H:1193
static SoundingType sounding_type
Definition: ERF_DataStruct.H:1122
bool four_stream_radiation
Definition: ERF_DataStruct.H:1196
std::string coarse_bckgnd_data_file
Definition: ERF_DataStruct.H:1357
bool custom_moisture_forcing
Definition: ERF_DataStruct.H:1236
amrex::Real num_diff_coeff
Definition: ERF_DataStruct.H:1296
std::string windfarm_blade_table
Definition: ERF_DataStruct.H:1321
amrex::Real zsurf
Definition: ERF_DataStruct.H:1226
amrex::Real if_surf_heating_rate
Definition: ERF_DataStruct.H:1209
amrex::Vector< TurbChoice > turbChoice
Definition: ERF_DataStruct.H:1146
bool variable_coriolis
Definition: ERF_DataStruct.H:1311
amrex::Vector< int > anelastic
Definition: ERF_DataStruct.H:1152
amrex::Real if_Cd_momentum
Definition: ERF_DataStruct.H:1204
AdvChoice advChoice
Definition: ERF_DataStruct.H:1142
bool use_pert_pres_gradient
Definition: ERF_DataStruct.H:1189
MoistureType moisture_type
Definition: ERF_DataStruct.H:1299
bool custom_forcing_prim_vars
Definition: ERF_DataStruct.H:1241
std::string abl_geo_wind_table
Definition: ERF_DataStruct.H:1308
static BuildingsType buildings_type
Definition: ERF_DataStruct.H:1128
static TerrainType terrain_type
Definition: ERF_DataStruct.H:1125
amrex::Real hindcast_data_interval_in_hrs
Definition: ERF_DataStruct.H:1343
ABLDriverType abl_driver_type
Definition: ERF_DataStruct.H:1305
amrex::Vector< int > fixed_density
Definition: ERF_DataStruct.H:1153
SpongeChoice spongeChoice
Definition: ERF_DataStruct.H:1145
WindFarmType windfarm_type
Definition: ERF_DataStruct.H:1300
static InitType init_type
Definition: ERF_DataStruct.H:1119
bool substepping_diag
Definition: ERF_DataStruct.H:1159
bool implicit_momentum_diffusion
Definition: ERF_DataStruct.H:1173
amrex::Real ens_pert_correlated_radius
Definition: ERF_DataStruct.H:1355
amrex::Real const_massflux_layer_hi
Definition: ERF_DataStruct.H:1338
bool use_source_perturbation(int lev) const
Definition: ERF_DataStruct.H:1274
bool implicit_before_substep
Definition: ERF_DataStruct.H:1174
static bool use_real_bcs
Definition: ERF_DataStruct.H:1131
amrex::Real poisson_abstol
Definition: ERF_DataStruct.H:1181
MoistureComponentIndices moisture_indices
Definition: ERF_DataStruct.H:1316
amrex::Real turb_disk_angle
Definition: ERF_DataStruct.H:1323
bool hindcast_surface_bcs
Definition: ERF_DataStruct.H:1345
amrex::Real windfarm_y_shift
Definition: ERF_DataStruct.H:1325
bool use_rotate_surface_flux
Definition: ERF_DataStruct.H:1250
bool do_forest_drag
Definition: ERF_DataStruct.H:1331
amrex::Real const_massflux_tau
Definition: ERF_DataStruct.H:1336
int massflux_khi
Definition: ERF_DataStruct.H:1340
bool time_avg_vel
Definition: ERF_DataStruct.H:1259
bool spatial_rhotheta_forcing
Definition: ERF_DataStruct.H:1242
bool forest_substep
Definition: ERF_DataStruct.H:1200
EBChoice ebChoice
Definition: ERF_DataStruct.H:1147
CouplingType coupling_type
Definition: ERF_DataStruct.H:1298
std::string windfarm_airfoil_tables
Definition: ERF_DataStruct.H:1321
bool transport_scalar
Definition: ERF_DataStruct.H:1256
int gradp_type
Definition: ERF_DataStruct.H:1187
static void set_mesh_type(MeshType new_mesh_type)
Definition: ERF_DataStruct.H:1137
bool is_init_for_ensemble
Definition: ERF_DataStruct.H:1353
int ave_plane
Definition: ERF_DataStruct.H:1313
std::string hindcast_boundary_data_dir
Definition: ERF_DataStruct.H:1342
Definition: ERF_SpongeStruct.H:19
void display()
Definition: ERF_SpongeStruct.H:66
void init_params(std::string pp_prefix)
Definition: ERF_SpongeStruct.H:21