1 #ifndef ERF_DATA_STRUCT_H_
2 #define ERF_DATA_STRUCT_H_
7 #include <AMReX_ParmParse.H>
8 #include <AMReX_Print.H>
10 #include <AMReX_Geometry.H>
21 None, PressureGradient, GeostrophicWind
29 None, Explicit, Implicit
33 ConstantDz, StretchedDz, VariableDz
37 None, StaticFittedMesh, MovingFittedMesh, EB, ImmersedForcing
41 Eulerian, Lagrangian, Undefined
91 "The grid stretching ratio must be greater than 1");
98 amrex::Print() <<
"Turning terrain on to enable grid stretching" << std::endl;
103 amrex::Print() <<
"Nominal zsurface height != 0, may result in unexpected behavior"
106 pp.get(
"initial_dz",
dz0);
123 }
else if (
moisture_type == MoistureType::SAM_NoPrecip_NoIce) {
158 pp.query_enum_case_insensitive(
"land_surface_model",
lsm_type);
161 std::string terrain_type_temp =
"";
162 pp.query(
"terrain_type", terrain_type_temp);
163 if (terrain_type_temp ==
"Moving") {
164 amrex::Warning(
"erf.terrain_type = Moving is deprecated; please replace Moving by MovingFittedMesh");
166 }
else if (terrain_type_temp ==
"Static") {
167 amrex::Warning(
"erf.terrain_type = Static is deprecated; please replace Static by StaticFittedMesh");
178 int n_zlevels =
pp.countval(
"terrain_z_levels");
196 pp.query(
"c_p",
c_p);
206 for (
int i = 0; i <= max_level; i++) {
210 int nvals =
pp.countval(
"substepping_type");
211 AMREX_ALWAYS_ASSERT(nvals == 0 || nvals == 1 || nvals >= max_level+1);
215 for (
int i = 1; i <= max_level; i++) {
218 }
else if (nvals > 1) {
219 for (
int i = 0; i <= max_level; i++) {
227 int nvals_old =
pp.countval(
"no_substepping");
229 amrex::Abort(
"The no_substepping flag is deprecated -- set substepping_type instead");
233 bool any_anelastic =
false;
234 for (
int i = 0; i <= max_level; ++i) {
235 if (
anelastic[i] == 1) any_anelastic =
true;
239 if (any_anelastic == 1) {
256 for (
int lev = 0; lev <= max_level; lev++) {
282 AMREX_ASSERT_WITH_MESSAGE(
terrain_type != TerrainType::None,
"MOST stress rotations are only valid with terrain!");
283 AMREX_ASSERT_WITH_MESSAGE(
use_explicit_most,
"MOST Stress rotations are only valid with explicit MOST!");
292 pp.query_enum_case_insensitive(
"perturbation_type",
pert_type);
294 amrex::Vector<amrex::Real> abl_pressure_grad_in = {0.0, 0.0, 0.0};
295 pp.queryarr(
"abl_pressure_grad",abl_pressure_grad_in);
296 for(
int i = 0; i < AMREX_SPACEDIM; ++i)
abl_pressure_grad[i] = abl_pressure_grad_in[i];
298 amrex::Vector<amrex::Real> abl_geo_forcing_in = {0.0, 0.0, 0.0};
299 if(
pp.queryarr(
"abl_geo_forcing",abl_geo_forcing_in)) {
300 amrex::Print() <<
"Specified abl_geo_forcing: (";
301 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
305 amrex::Print() <<
")" << std::endl;
323 "Should not have both abl_geo_wind_table and custom_geostrophic_profile set.");
334 "Numerical diffusion coefficient must be between 0 & 1.");
337 amrex::Print() <<
"6th-order numerical diffusion turned on with coefficient = "
350 for (
int lev = 0; lev <= max_level; lev++) {
355 for (
int lev = 0; lev <= max_level; lev++) {
356 if (
turbChoice[lev].pbl_ysu_use_consistent_coriolis) {
360 amrex::Print() <<
"YSU PBL using ERF coriolis frequency: " <<
turbChoice[lev].pbl_ysu_coriolis_freq << std::endl;
363 amrex::Abort(
"YSU cannot use ERF coriolis frequency if not using coriolis");
377 static std::string windfarm_loc_type_string =
"None";
405 for (
int lev = 0; lev <= max_level; lev++) {
407 amrex::Warning(
"\n*** WARNING: Moisture may not yet be compatible with PBL models, \n proceed with caution ***");
414 amrex::Abort(
"buoyancy_type must be 1, 2, 3 or 4");
418 amrex::Error(
"Can't turn off lagged_delta_rt when terrain not moving");
425 amrex::Abort(
"To use simplified actuator disks, you need to provide a variable"
426 " erf.sampling_distance_by_D in the inputs which specifies the upstream"
427 " distance as a factor of the turbine diameter at which the incoming free stream"
428 " velocity will be computed at.");
432 amrex::Abort(
"To use simplified actuator disks, you need to provide a variable"
433 " erf.turb_disk_angle_from_x in the inputs which is the angle of the face of the"
434 " turbine disk from the x-axis. A turbine facing an oncoming flow in the x-direction"
435 " will have turb_disk_angle value of 90 deg.");
438 amrex::Abort(
"You are using windfarms with latitude-logitude option to position the turbines."
439 " For this you should provide the inputs erf.windfarm_x_shift and"
440 " erf.windfarm_y_shift which are the values by which the bounding box of the"
441 " windfarm is shifted from the x and the y axes.");
447 amrex::Print() <<
"SOLVER CHOICE: " << std::endl;
449 for (
int lev = 0; lev <= max_level; lev++) {
450 amrex::Print() <<
"anelastic at level : " << lev <<
" is " <<
anelastic[lev] << std::endl;
452 amrex::Print() <<
"No substepping at level " << lev << std::endl;
454 amrex::Print() <<
"Explicit substepping at level " << lev << std::endl;
456 amrex::Print() <<
"Implicit substepping at level " << lev << std::endl;
459 amrex::Print() <<
"use_coriolis : " <<
use_coriolis << std::endl;
460 amrex::Print() <<
"use_gravity : " <<
use_gravity << std::endl;
463 amrex::Print() <<
"Terrain Type: StaticFittedMesh" << std::endl;
464 }
else if (
terrain_type == TerrainType::MovingFittedMesh) {
465 amrex::Print() <<
"Terrain Type: MovingFittedMesh" << std::endl;
467 amrex::Print() <<
"Terrain Type: EB" << std::endl;
468 }
else if (
terrain_type == TerrainType::ImmersedForcing) {
469 amrex::Print() <<
"Terrain Type: ImmersedForcing" << std::endl;
471 amrex::Print() <<
"Terrain Type: None" << std::endl;
475 amrex::Print() <<
" Mesh Type: ConstantDz" << std::endl;
476 }
else if (
mesh_type == MeshType::StretchedDz) {
477 amrex::Print() <<
" Mesh Type: StretchedDz" << std::endl;
478 }
else if (
mesh_type == MeshType::VariableDz) {
479 amrex::Print() <<
" Mesh Type: VariableDz" << std::endl;
481 amrex::Abort(
"No mesh_type set!");
484 amrex::Print() <<
"ABL Driver Type: " << std::endl;
486 amrex::Print() <<
" None" << std::endl;
488 amrex::Print() <<
" Pressure Gradient "
492 amrex::Print() <<
" Geostrophic Wind "
498 amrex::Print() <<
"Coupling Type: " << std::endl;
500 amrex::Print() <<
" Two-way" << std::endl;
502 amrex::Print() <<
" One-way" << std::endl;
506 amrex::Print() <<
"Buoyancy_type : " <<
buoyancy_type << std::endl;
512 for (
int lev = 0; lev <= max_level; lev++) {
522 amrex::Real rot_time_period = 86400.0;
523 pp.query(
"rotational_time_period", rot_time_period);
527 amrex::Real latitude = 90.0;
528 pp.query(
"latitude", latitude);
533 latitude *= (
PI/180.);
534 sinphi = std::sin(latitude);
536 cosphi = std::cos(latitude);
544 amrex::Vector<amrex::Real> abl_geo_wind(3);
545 pp.queryarr(
"abl_geo_wind",abl_geo_wind);
554 amrex::Print() <<
"NOTE: abl_geo_wind_table provided, ignoring input abl_geo_wind" << std::endl;
560 amrex::Vector<int>& vec_to_fill,
int default_int)
562 amrex::ParmParse
pp(
"erf");
563 int nvals =
pp.countval(string_to_read);
564 AMREX_ALWAYS_ASSERT(nvals == 0 || nvals == 1 || nvals >= max_level+1);
565 amrex::Vector<int> temp; temp.resize(nvals);
566 pp.queryarr(string_to_read,temp);
568 for (
int i = 0; i <= max_level; ++i) vec_to_fill.push_back(default_int);
569 }
else if (nvals == 1) {
570 for (
int i = 0; i <= max_level; ++i) vec_to_fill.push_back(temp[0]);
572 for (
int i = 0; i <= max_level; ++i) vec_to_fill.push_back(temp[i]);
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
AMREX_ENUM(ABLDriverType, None, PressureGradient, GeostrophicWind)
Rayleigh
Definition: ERF_DataStruct.H:69
@ ubar
Definition: ERF_DataStruct.H:70
@ wbar
Definition: ERF_DataStruct.H:70
@ nvars
Definition: ERF_DataStruct.H:70
@ vbar
Definition: ERF_DataStruct.H:70
@ thetabar
Definition: ERF_DataStruct.H:70
Sponge
Definition: ERF_DataStruct.H:74
@ nvars_sponge
Definition: ERF_DataStruct.H:75
@ vbar_sponge
Definition: ERF_DataStruct.H:75
@ ubar_sponge
Definition: ERF_DataStruct.H:75
Coord
Definition: ERF_DataStruct.H:64
#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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pp(amrex::Real y)
Definition: ERF_MicrophysicsUtils.H:219
Definition: ERF_Fitch.H:9
Definition: ERF_GeneralAD.H:8
Definition: ERF_Kessler.H:46
Definition: ERF_NOAH.H:20
Definition: ERF_SatAdj.H:41
Definition: ERF_SimpleAD.H:8
Definition: ERF_AdvStruct.H:19
void display()
Definition: ERF_AdvStruct.H:190
void init_params()
Definition: ERF_AdvStruct.H:21
Definition: ERF_DiffStruct.H:19
void init_params()
Definition: ERF_DiffStruct.H:21
void display()
Definition: ERF_DiffStruct.H:64
Definition: ERF_DataStruct.H:82
bool rayleigh_damp_T
Definition: ERF_DataStruct.H:621
amrex::Real dz0
Definition: ERF_DataStruct.H:637
bool use_lagged_delta_rt
Definition: ERF_DataStruct.H:627
amrex::Real coriolis_factor
Definition: ERF_DataStruct.H:642
bool use_explicit_most
Definition: ERF_DataStruct.H:658
static MeshType mesh_type
Definition: ERF_DataStruct.H:583
amrex::Real windfarm_x_shift
Definition: ERF_DataStruct.H:706
bool rayleigh_damp_V
Definition: ERF_DataStruct.H:619
int RhoQr_comp
Definition: ERF_DataStruct.H:700
amrex::Real poisson_reltol
Definition: ERF_DataStruct.H:607
amrex::Real rayleigh_zdamp
Definition: ERF_DataStruct.H:623
amrex::Real rdOcp
Definition: ERF_DataStruct.H:632
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:559
std::string windfarm_spec_table
Definition: ERF_DataStruct.H:702
bool use_mono_adv
Definition: ERF_DataStruct.H:674
DiffChoice diffChoice
Definition: ERF_DataStruct.H:592
static void set_flat_terrain_flag()
Definition: ERF_DataStruct.H:586
bool use_gravity
Definition: ERF_DataStruct.H:614
void build_coriolis_forcings()
Definition: ERF_DataStruct.H:517
int ncorr
Definition: ERF_DataStruct.H:605
int force_stage1_single_substep
Definition: ERF_DataStruct.H:599
std::string windfarm_spec_table_extra
Definition: ERF_DataStruct.H:702
amrex::Real cosphi
Definition: ERF_DataStruct.H:643
LandSurfaceType lsm_type
Definition: ERF_DataStruct.H:680
amrex::Real c_p
Definition: ERF_DataStruct.H:631
std::string windfarm_loc_table
Definition: ERF_DataStruct.H:702
amrex::Real gravity
Definition: ERF_DataStruct.H:630
std::string pp_prefix
Definition: ERF_DataStruct.H:597
void check_params(int max_level)
Definition: ERF_DataStruct.H:402
bool custom_rhotheta_forcing
Definition: ERF_DataStruct.H:647
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_geo_forcing
Definition: ERF_DataStruct.H:684
WindFarmLocType windfarm_loc_type
Definition: ERF_DataStruct.H:679
bool custom_w_subsidence
Definition: ERF_DataStruct.H:649
bool nudging_from_input_sounding
Definition: ERF_DataStruct.H:655
bool rayleigh_damp_U
Definition: ERF_DataStruct.H:618
int RhoQc_comp
Definition: ERF_DataStruct.H:694
bool custom_geostrophic_profile
Definition: ERF_DataStruct.H:650
amrex::Real rayleigh_ztop
Definition: ERF_DataStruct.H:624
amrex::Real grid_stretching_ratio
Definition: ERF_DataStruct.H:635
amrex::Real sinphi
Definition: ERF_DataStruct.H:644
bool have_geo_wind_profile
Definition: ERF_DataStruct.H:686
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_pressure_grad
Definition: ERF_DataStruct.H:683
bool do_precip
Definition: ERF_DataStruct.H:691
amrex::Vector< SubsteppingType > substepping_type
Definition: ERF_DataStruct.H:601
bool coriolis_3d
Definition: ERF_DataStruct.H:616
void init_params(int max_level)
Definition: ERF_DataStruct.H:84
bool use_num_diff
Definition: ERF_DataStruct.H:670
amrex::Real sampling_distance_by_D
Definition: ERF_DataStruct.H:704
int RhoQv_comp
Definition: ERF_DataStruct.H:693
bool test_mapfactor
Definition: ERF_DataStruct.H:609
void display(int max_level)
Definition: ERF_DataStruct.H:445
bool use_coriolis
Definition: ERF_DataStruct.H:615
bool custom_moisture_forcing
Definition: ERF_DataStruct.H:648
amrex::Real num_diff_coeff
Definition: ERF_DataStruct.H:671
std::string windfarm_blade_table
Definition: ERF_DataStruct.H:703
amrex::Real zsurf
Definition: ERF_DataStruct.H:636
amrex::Vector< TurbChoice > turbChoice
Definition: ERF_DataStruct.H:594
bool project_initial_velocity
Definition: ERF_DataStruct.H:639
amrex::Vector< int > anelastic
Definition: ERF_DataStruct.H:602
int constant_density
Definition: ERF_DataStruct.H:604
AdvChoice advChoice
Definition: ERF_DataStruct.H:591
bool use_moist_background
Definition: ERF_DataStruct.H:692
MoistureType moisture_type
Definition: ERF_DataStruct.H:677
bool custom_forcing_prim_vars
Definition: ERF_DataStruct.H:651
std::string abl_geo_wind_table
Definition: ERF_DataStruct.H:685
static TerrainType terrain_type
Definition: ERF_DataStruct.H:580
ABLDriverType abl_driver_type
Definition: ERF_DataStruct.H:682
bool rayleigh_damp_W
Definition: ERF_DataStruct.H:620
PerturbationType pert_type
Definition: ERF_DataStruct.H:667
SpongeChoice spongeChoice
Definition: ERF_DataStruct.H:593
WindFarmType windfarm_type
Definition: ERF_DataStruct.H:678
int buoyancy_type
Definition: ERF_DataStruct.H:611
amrex::Real poisson_abstol
Definition: ERF_DataStruct.H:606
amrex::Real turb_disk_angle
Definition: ERF_DataStruct.H:705
amrex::Real windfarm_y_shift
Definition: ERF_DataStruct.H:707
static bool terrain_is_flat
Definition: ERF_DataStruct.H:577
bool do_forest_drag
Definition: ERF_DataStruct.H:710
bool time_avg_vel
Definition: ERF_DataStruct.H:664
bool do_cloud
Definition: ERF_DataStruct.H:690
bool use_rotate_most
Definition: ERF_DataStruct.H:661
amrex::Real rayleigh_dampcoef
Definition: ERF_DataStruct.H:622
CouplingType coupling_type
Definition: ERF_DataStruct.H:676
std::string windfarm_airfoil_tables
Definition: ERF_DataStruct.H:703
int ave_plane
Definition: ERF_DataStruct.H:688
Definition: ERF_SpongeStruct.H:15
void display()
Definition: ERF_SpongeStruct.H:45
void init_params()
Definition: ERF_SpongeStruct.H:17