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