ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
SolverChoice Struct Reference

#include <DataStruct.H>

Collaboration diagram for SolverChoice:

Public Member Functions

void init_params (int max_level)
 
void display ()
 
void build_coriolis_forcings ()
 

Public Attributes

AdvChoice advChoice
 
DiffChoice diffChoice
 
SpongeChoice spongeChoice
 
amrex::Vector< TurbChoiceturbChoice
 
std::string pp_prefix {"erf"}
 
int no_substepping = 0
 
int force_stage1_single_substep = 1
 
int incompressible = 0
 
int constant_density = 0
 
int project_every_stage = 1
 
int ncorr = 1
 
amrex::Real poisson_abstol = 1e-10
 
amrex::Real poisson_reltol = 1e-10
 
bool test_mapfactor = false
 
bool use_terrain = false
 
int buoyancy_type = 1
 
bool use_gravity = false
 
bool use_coriolis = false
 
bool rayleigh_damp_U = false
 
bool rayleigh_damp_V = false
 
bool rayleigh_damp_W = false
 
bool rayleigh_damp_T = false
 
bool use_lagged_delta_rt = true
 
amrex::Real gravity
 
amrex::Real c_p = Cp_d
 
amrex::Real rdOcp
 
amrex::Real grid_stretching_ratio = 0
 
amrex::Real zsurf = 0.0
 
amrex::Real dz0
 
amrex::Real coriolis_factor = 0.0
 
amrex::Real cosphi = 0.0
 
amrex::Real sinphi = 0.0
 
bool custom_rhotheta_forcing = false
 
bool custom_moisture_forcing = false
 
bool custom_w_subsidence = false
 
bool custom_geostrophic_profile = false
 
bool custom_forcing_prim_vars = false
 
bool use_explicit_most = false
 
bool time_avg_vel = false
 
bool use_NumDiff {false}
 
amrex::Real NumDiffCoeff {0.}
 
CouplingType coupling_type
 
TerrainType terrain_type
 
MoistureType moisture_type
 
WindFarmType windfarm_type
 
LandSurfaceType lsm_type
 
ABLDriverType abl_driver_type
 
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_pressure_grad
 
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_geo_forcing
 
int ave_plane {2}
 
bool do_cloud {true}
 
bool do_precip {true}
 
bool use_moist_background {false}
 
amrex::Real latitude_lo
 
amrex::Real longitude_lo
 

Detailed Description

Container holding many of the algorithmic options and parameters

Member Function Documentation

◆ build_coriolis_forcings()

void SolverChoice::build_coriolis_forcings ( )
inline
346  {
347  amrex::ParmParse pp(pp_prefix);
348 
349  // Read the rotational time period (in seconds)
350  amrex::Real rot_time_period = 86400.0;
351  pp.query("rotational_time_period", rot_time_period);
352 
353  coriolis_factor = 2.0 * 2.0 * PI / rot_time_period;
354  amrex::Print() << "Coriolis factor = " << coriolis_factor << std::endl;
355 
356  amrex::Real latitude = 90.0;
357  pp.query("latitude", latitude);
358 
359  // Convert to radians
360  latitude *= (PI/180.);
361  sinphi = std::sin(latitude);
362  cosphi = std::cos(latitude);
363 
365  {
366  // Read in the geostrophic wind -- we only use this to construct
367  // the forcing term so no need to keep it
368  amrex::Vector<amrex::Real> abl_geo_wind(3);
369  pp.queryarr("abl_geo_wind",abl_geo_wind);
370 
371  abl_geo_forcing = {
372  -coriolis_factor * (abl_geo_wind[1]*sinphi - abl_geo_wind[2]*cosphi),
373  coriolis_factor * abl_geo_wind[0]*sinphi,
374  -coriolis_factor * abl_geo_wind[0]*cosphi
375  };
376  }
377  }
constexpr amrex::Real PI
Definition: ERF_Constants.H:6
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pp(amrex::Real y)
Definition: Microphysics_Utils.H:183
amrex::Real coriolis_factor
Definition: DataStruct.H:429
amrex::Real cosphi
Definition: DataStruct.H:430
std::string pp_prefix
Definition: DataStruct.H:385
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_geo_forcing
Definition: DataStruct.H:458
amrex::Real sinphi
Definition: DataStruct.H:431
ABLDriverType abl_driver_type
Definition: DataStruct.H:456

Referenced by init_params().

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

◆ display()

void SolverChoice::display ( )
inline
298  {
299  amrex::Print() << "SOLVER CHOICE: " << std::endl;
300  amrex::Print() << "no_substepping : " << no_substepping << std::endl;
301  amrex::Print() << "force_stage1_single_substep : " << force_stage1_single_substep << std::endl;
302  amrex::Print() << "incompressible : " << incompressible << std::endl;
303  amrex::Print() << "use_coriolis : " << use_coriolis << std::endl;
304  amrex::Print() << "use_gravity : " << use_gravity << std::endl;
305 
307  amrex::Print() << "Using two-way coupling " << std::endl;
308  } else if (coupling_type == CouplingType::OneWay) {
309  amrex::Print() << "Using one-way coupling " << std::endl;
310  }
311 
313  amrex::Print() << "Using static terrain " << std::endl;
314  } else {
315  amrex::Print() << "Using moving terrain " << std::endl;
316  }
317 
319  amrex::Print() << "ABL Driver Type: " << "None" << std::endl;
320  amrex::Print() << "No ABL driver selected " << std::endl;
322  amrex::Print() << "ABL Driver Type: " << "PressureGradient" << std::endl;
323  amrex::Print() << "Driving abl_pressure_grad: (";
324  for (int i = 0; i < AMREX_SPACEDIM; ++i)
325  amrex::Print() << abl_pressure_grad[i] << " ";
326  amrex::Print() << ")" << std::endl;
328  amrex::Print() << "ABL Driver Type: " << "GeostrophicWind" << std::endl;
329  amrex::Print() << "Driving abl_geo_forcing: (";
330  for (int i = 0; i < AMREX_SPACEDIM; ++i)
331  amrex::Print() << abl_geo_forcing[i] << " ";
332  amrex::Print() << ")" << std::endl;
333  }
334 
335  advChoice.display();
338 
339  int max_level = turbChoice.size()-1;
340  for (int lev = 0; lev <= max_level; lev++) {
341  turbChoice[lev].display(lev);
342  }
343  }
void display()
Definition: AdvStruct.H:199
void display()
Definition: DiffStruct.H:56
int no_substepping
Definition: DataStruct.H:387
DiffChoice diffChoice
Definition: DataStruct.H:380
bool use_gravity
Definition: DataStruct.H:403
int force_stage1_single_substep
Definition: DataStruct.H:388
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_pressure_grad
Definition: DataStruct.H:457
bool use_coriolis
Definition: DataStruct.H:404
amrex::Vector< TurbChoice > turbChoice
Definition: DataStruct.H:382
AdvChoice advChoice
Definition: DataStruct.H:379
TerrainType terrain_type
Definition: DataStruct.H:451
SpongeChoice spongeChoice
Definition: DataStruct.H:381
int incompressible
Definition: DataStruct.H:390
CouplingType coupling_type
Definition: DataStruct.H:450
void display()
Definition: SpongeStruct.H:45
Here is the call graph for this function:

◆ init_params()

void SolverChoice::init_params ( int  max_level)
inline
66  {
67  amrex::ParmParse pp(pp_prefix);
68 
69  // Do we have terrain (or grid stretching)?
70  pp.query("use_terrain", use_terrain);
71 
72  pp.query("grid_stretching_ratio", grid_stretching_ratio);
73  if (grid_stretching_ratio != 0) {
74  AMREX_ASSERT_WITH_MESSAGE((grid_stretching_ratio >= 1.),
75  "The grid stretching ratio must be greater than 1");
76  }
77  if (grid_stretching_ratio >= 1) {
78  if (!use_terrain) {
79  amrex::Print() << "Turning terrain on to enable grid stretching" << std::endl;
80  use_terrain = true;
81  }
82  pp.query("zsurface", zsurf);
83  if (zsurf != 0.0) {
84  amrex::Print() << "Nominal zsurface height != 0, may result in unexpected behavior"
85  << std::endl;
86  }
87  pp.get("initial_dz", dz0);
88  }
89 
90  // Do we set map scale factors to 0.5 instead of 1 for testing?
91  pp.query("test_mapfactor", test_mapfactor);
92 
93  // What type of moisture model to use
94  static std::string moisture_model_string = "None";
95  pp.query("moisture_model", moisture_model_string);
96  if (moisture_model_string == "SAM") {
98  } else if (moisture_model_string == "Kessler") {
100  }else if (moisture_model_string == "Kessler_NoRain") {
102  } else {
104  }
105 
106  // TODO: should we set default for dry??
107  // Set a different default for moist vs dry
111  buoyancy_type = 1; // asserted in make buoyancy
112  } else {
113  buoyancy_type = 2; // uses Tprime
114  }
115  }
116 
117  // Which expression (1,2 or 3) to use for buoyancy
118  pp.query("buoyancy_type", buoyancy_type);
119  if (buoyancy_type != 1 && buoyancy_type != 2 && buoyancy_type != 3 && buoyancy_type != 4) {
120  amrex::Abort("buoyancy_type must be 1, 2, 3 or 4");
121  }
122 
123  // What type of land surface model to use
124  static std::string lsm_model_string = "None";
125  pp.query("land_surface_model", lsm_model_string);
126  if (lsm_model_string == "SLM") {
128  } else if (lsm_model_string == "MM5") {
130  } else {
132  }
133 
134  // Is the terrain static or moving?
135  static std::string terrain_type_string = "Static";
136  pp.query("terrain_type",terrain_type_string);
137  if (terrain_type_string == "Moving" || terrain_type_string == "moving") {
139  } else if (terrain_type_string == "Static" || terrain_type_string == "static") {
141  } else {
142  amrex::Abort("terrain_type can be either Moving/moving or Static/static");
143  }
144 
145  // Use lagged_delta_rt in the fast integrator?
146  pp.query("use_lagged_delta_rt", use_lagged_delta_rt);
147 
149  amrex::Error("Can't turn off lagged_delta_rt when terrain not moving");
150  }
151 
152  // These default to true but are used for unit testing
153  pp.query("use_gravity", use_gravity);
155 
156  pp.query("c_p", c_p);
157  rdOcp = R_d / c_p;
158 
159 
160 #if defined(ERF_USE_POISSON_SOLVE)
161  // Should we project the initial velocity field to make it divergence-free?
162  pp.query("project_initial_velocity", project_initial_velocity);
163 
164  pp.query("incompressible", incompressible);
165  pp.query("constant_density", constant_density);
166  pp.query("project_every_stage", project_every_stage);
167  pp.query("ncorr", ncorr);
168  pp.query("poisson_abstol", poisson_abstol);
169  pp.query("poisson_reltol", poisson_reltol);
170 #endif
171 
172  // Turn off acoustic substepping?
173  pp.query("no_substepping", no_substepping);
174  pp.query("force_stage1_single_substep", force_stage1_single_substep);
175 
176 #if defined(ERF_USE_POISSON_SOLVE)
177  // If this is set, it must be even
178  if (incompressible != 0 && no_substepping == 0)
179  {
180  amrex::Abort("If you specify incompressible, you must specific no_substepping");
181  }
182 #endif
183 
184  // Include Coriolis forcing?
185  pp.query("use_coriolis", use_coriolis);
186 
187  // Include Rayleigh damping (separate flags for each variable)
188  pp.query("rayleigh_damp_U", rayleigh_damp_U);
189  pp.query("rayleigh_damp_V", rayleigh_damp_V);
190  pp.query("rayleigh_damp_W", rayleigh_damp_W);
191  pp.query("rayleigh_damp_T", rayleigh_damp_T);
192 
193  // Flag to do explicit MOST formulation
194  pp.query("use_explicit_most",use_explicit_most);
195 
196  // Which external forcings?
197  static std::string abl_driver_type_string = "None";
198  pp.query("abl_driver_type",abl_driver_type_string);
199 
200  if (!abl_driver_type_string.compare("PressureGradient")) {
202  } else if (!abl_driver_type_string.compare("GeostrophicWind")) {
204  } else if (!abl_driver_type_string.compare("None")){
205  abl_driver_type = ABLDriverType::None; // No ABL driver for simulating classical fluid dynamics problems
206  } else {
207  amrex::Error("Don't know this abl_driver_type");
208  }
209 
210  amrex::Vector<amrex::Real> abl_pressure_grad_in = {0.0, 0.0, 0.0};
211  pp.queryarr("abl_pressure_grad",abl_pressure_grad_in);
212  for(int i = 0; i < AMREX_SPACEDIM; ++i) abl_pressure_grad[i] = abl_pressure_grad_in[i];
213 
214  amrex::Vector<amrex::Real> abl_geo_forcing_in = {0.0, 0.0, 0.0};
215  if(pp.queryarr("abl_geo_forcing",abl_geo_forcing_in)) {
216  amrex::Print() << "Specified abl_geo_forcing: (";
217  for (int i = 0; i < AMREX_SPACEDIM; ++i) {
218  abl_geo_forcing[i] = abl_geo_forcing_in[i];
219  amrex::Print() << abl_geo_forcing[i] << " ";
220  }
221  amrex::Print() << ")" << std::endl;
222  }
223 
224  if (use_coriolis)
225  {
227  }
228 
229  pp.query("add_custom_rhotheta_forcing", custom_rhotheta_forcing);
230  pp.query("add_custom_moisture_forcing", custom_moisture_forcing);
231  pp.query("add_custom_w_subsidence", custom_w_subsidence);
232  pp.query("add_custom_geostrophic_profile", custom_geostrophic_profile);
233  pp.query("custom_forcing_uses_primitive_vars", custom_forcing_prim_vars);
234 
235  pp.query("Ave_Plane", ave_plane);
236 
237  pp.query("mp_clouds", do_cloud);
238  pp.query("mp_precip", do_precip);
239  pp.query("use_moist_background", use_moist_background);
240 
241  // Use numerical diffusion?
242  pp.query("use_NumDiff",use_NumDiff);
243  if(use_NumDiff) {
244  pp.query("NumDiffCoeff",NumDiffCoeff);
245  AMREX_ASSERT_WITH_MESSAGE(( (NumDiffCoeff >= 0.) && (NumDiffCoeff <= 1.) ),
246  "Numerical diffusion coefficient must be between 0 & 1.");
247  NumDiffCoeff *= std::pow(2.0,-6);
248  }
249 
253 
254  turbChoice.resize(max_level+1);
255  for (int lev = 0; lev <= max_level; lev++) {
256  turbChoice[lev].init_params(lev,max_level);
257  }
258 
259  // Warn for PBL models and moisture - these may not yet be compatible
260  for (int lev = 0; lev <= max_level; lev++) {
261  if ((moisture_type != MoistureType::None) && (turbChoice[lev].pbl_type != PBLType::None)) {
262  amrex::Warning("\n*** WARNING: Moisture may not yet be compatible with PBL models, \n proceed with caution ***");
263  }
264  }
265 
266  // Which type of refinement
267  static std::string coupling_type_string = "OneWay";
268  pp.query("coupling_type",coupling_type_string);
269  if (coupling_type_string == "TwoWay") {
271  } else if (coupling_type_string == "OneWay") {
273  } else {
274  amrex::Abort("Dont know this coupling_type");
275  }
276 
277  // Which type of windfarm model
278  static std::string windfarm_type_string = "Fitch";
279 
280  pp.query("windfarm_type", windfarm_type_string);
281  pp.query("latitude_lo", latitude_lo);
282  pp.query("longitude_lo", longitude_lo);
283  if (windfarm_type_string == "Fitch") {
285  }
286  else if(windfarm_type_string == "EWP"){
288  }
289  else {
290  amrex::Abort("Dont know this windfarm_type. Currently only Fitch and EWP models are supported.");
291  }
292 
293  // Test if time averaged data is to be output
294  pp.query("time_avg_vel",time_avg_vel);
295  }
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:21
constexpr amrex::Real R_d
Definition: ERF_Constants.H:10
void init_params()
Definition: AdvStruct.H:21
void init_params()
Definition: DiffStruct.H:21
bool use_terrain
Definition: DataStruct.H:399
bool rayleigh_damp_T
Definition: DataStruct.H:409
amrex::Real dz0
Definition: DataStruct.H:422
bool use_lagged_delta_rt
Definition: DataStruct.H:412
bool use_explicit_most
Definition: DataStruct.H:441
bool rayleigh_damp_V
Definition: DataStruct.H:407
amrex::Real poisson_reltol
Definition: DataStruct.H:395
amrex::Real rdOcp
Definition: DataStruct.H:417
void build_coriolis_forcings()
Definition: DataStruct.H:345
int ncorr
Definition: DataStruct.H:393
LandSurfaceType lsm_type
Definition: DataStruct.H:454
amrex::Real c_p
Definition: DataStruct.H:416
amrex::Real gravity
Definition: DataStruct.H:415
bool custom_rhotheta_forcing
Definition: DataStruct.H:434
bool custom_w_subsidence
Definition: DataStruct.H:436
bool rayleigh_damp_U
Definition: DataStruct.H:406
bool custom_geostrophic_profile
Definition: DataStruct.H:437
amrex::Real grid_stretching_ratio
Definition: DataStruct.H:420
amrex::Real longitude_lo
Definition: DataStruct.H:466
amrex::Real NumDiffCoeff
Definition: DataStruct.H:448
bool do_precip
Definition: DataStruct.H:463
bool test_mapfactor
Definition: DataStruct.H:397
bool use_NumDiff
Definition: DataStruct.H:447
bool custom_moisture_forcing
Definition: DataStruct.H:435
amrex::Real zsurf
Definition: DataStruct.H:421
int constant_density
Definition: DataStruct.H:391
bool use_moist_background
Definition: DataStruct.H:464
MoistureType moisture_type
Definition: DataStruct.H:452
bool custom_forcing_prim_vars
Definition: DataStruct.H:438
bool rayleigh_damp_W
Definition: DataStruct.H:408
WindFarmType windfarm_type
Definition: DataStruct.H:453
int buoyancy_type
Definition: DataStruct.H:400
amrex::Real poisson_abstol
Definition: DataStruct.H:394
amrex::Real latitude_lo
Definition: DataStruct.H:466
bool time_avg_vel
Definition: DataStruct.H:444
bool do_cloud
Definition: DataStruct.H:462
int project_every_stage
Definition: DataStruct.H:392
int ave_plane
Definition: DataStruct.H:460
void init_params()
Definition: SpongeStruct.H:17
Here is the call graph for this function:

Member Data Documentation

◆ abl_driver_type

ABLDriverType SolverChoice::abl_driver_type

◆ abl_geo_forcing

amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> SolverChoice::abl_geo_forcing

◆ abl_pressure_grad

amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> SolverChoice::abl_pressure_grad

◆ advChoice

◆ ave_plane

int SolverChoice::ave_plane {2}

◆ buoyancy_type

int SolverChoice::buoyancy_type = 1

Referenced by init_params(), and make_buoyancy().

◆ c_p

amrex::Real SolverChoice::c_p = Cp_d

◆ constant_density

int SolverChoice::constant_density = 0

Referenced by erf_slow_rhs_pre(), and init_params().

◆ coriolis_factor

amrex::Real SolverChoice::coriolis_factor = 0.0

◆ cosphi

amrex::Real SolverChoice::cosphi = 0.0

◆ coupling_type

◆ custom_forcing_prim_vars

bool SolverChoice::custom_forcing_prim_vars = false

Referenced by init_params(), and make_sources().

◆ custom_geostrophic_profile

bool SolverChoice::custom_geostrophic_profile = false

Referenced by init_params(), and make_mom_sources().

◆ custom_moisture_forcing

bool SolverChoice::custom_moisture_forcing = false

Referenced by init_params(), and make_sources().

◆ custom_rhotheta_forcing

bool SolverChoice::custom_rhotheta_forcing = false

Referenced by init_params(), and make_sources().

◆ custom_w_subsidence

bool SolverChoice::custom_w_subsidence = false

◆ diffChoice

◆ do_cloud

bool SolverChoice::do_cloud {true}

◆ do_precip

bool SolverChoice::do_precip {true}

◆ dz0

amrex::Real SolverChoice::dz0

Referenced by init_params().

◆ force_stage1_single_substep

int SolverChoice::force_stage1_single_substep = 1

Referenced by display(), and init_params().

◆ gravity

amrex::Real SolverChoice::gravity

◆ grid_stretching_ratio

amrex::Real SolverChoice::grid_stretching_ratio = 0

Referenced by init_params().

◆ incompressible

int SolverChoice::incompressible = 0

◆ latitude_lo

amrex::Real SolverChoice::latitude_lo

Referenced by init_params().

◆ longitude_lo

amrex::Real SolverChoice::longitude_lo

Referenced by init_params().

◆ lsm_type

LandSurfaceType SolverChoice::lsm_type

Referenced by init_params().

◆ moisture_type

◆ ncorr

int SolverChoice::ncorr = 1

Referenced by init_params().

◆ no_substepping

int SolverChoice::no_substepping = 0

Referenced by display(), and init_params().

◆ NumDiffCoeff

amrex::Real SolverChoice::NumDiffCoeff {0.}

◆ poisson_abstol

amrex::Real SolverChoice::poisson_abstol = 1e-10

Referenced by init_params().

◆ poisson_reltol

amrex::Real SolverChoice::poisson_reltol = 1e-10

Referenced by init_params().

◆ pp_prefix

std::string SolverChoice::pp_prefix {"erf"}

◆ project_every_stage

int SolverChoice::project_every_stage = 1

Referenced by init_params().

◆ rayleigh_damp_T

bool SolverChoice::rayleigh_damp_T = false

Referenced by init_params(), and make_sources().

◆ rayleigh_damp_U

bool SolverChoice::rayleigh_damp_U = false

Referenced by init_params(), and make_mom_sources().

◆ rayleigh_damp_V

bool SolverChoice::rayleigh_damp_V = false

Referenced by init_params(), and make_mom_sources().

◆ rayleigh_damp_W

bool SolverChoice::rayleigh_damp_W = false

Referenced by init_params(), and make_mom_sources().

◆ rdOcp

amrex::Real SolverChoice::rdOcp

Referenced by SAM::Define(), and init_params().

◆ sinphi

amrex::Real SolverChoice::sinphi = 0.0

◆ spongeChoice

SpongeChoice SolverChoice::spongeChoice

◆ terrain_type

◆ test_mapfactor

bool SolverChoice::test_mapfactor = false

Referenced by init_params().

◆ time_avg_vel

bool SolverChoice::time_avg_vel = false

Referenced by init_params().

◆ turbChoice

amrex::Vector<TurbChoice> SolverChoice::turbChoice

◆ use_coriolis

bool SolverChoice::use_coriolis = false

◆ use_explicit_most

bool SolverChoice::use_explicit_most = false

◆ use_gravity

bool SolverChoice::use_gravity = false

Referenced by display(), and init_params().

◆ use_lagged_delta_rt

bool SolverChoice::use_lagged_delta_rt = true

Referenced by init_params().

◆ use_moist_background

bool SolverChoice::use_moist_background {false}

Referenced by init_params().

◆ use_NumDiff

bool SolverChoice::use_NumDiff {false}

◆ use_terrain

bool SolverChoice::use_terrain = false

◆ windfarm_type

WindFarmType SolverChoice::windfarm_type

Referenced by init_params().

◆ zsurf

amrex::Real SolverChoice::zsurf = 0.0

Referenced by init_params().


The documentation for this struct was generated from the following file: