ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPert_ABL.H File Reference

Go to the source code of this file.

Functions

ParmParse pp ("prob")
 
pp_erf query ("deterministic_ic_pert", deterministic_ic_pert)
 
pp_erf query ("fix_random_seed", fix_random_seed)
 
pp_erf query ("random_seed", random_seed)
 
pp query ("rho_0", rho_0)
 
pp query ("T_0", T_0)
 
pp query ("A_0", A_0)
 
pp query ("KE_0", KE_0)
 
pp query ("rhoKE_0", rhoKE_0)
 
pp query ("KE_decay_height", KE_decay_height)
 
pp query ("KE_decay_order", KE_decay_order)
 
pp query ("T_0_Pert_Mag", T_0_Pert_Mag)
 
pp query ("pert_rhotheta", pert_rhotheta)
 
pp query ("pert_deltaU", pert_deltaU)
 
pp query ("pert_deltaV", pert_deltaV)
 
pp query ("pert_ref_height", pert_ref_height)
 
pp query ("pert_deltaT", pert_deltaT)
 
pp query ("pert_periods_T", pert_periods_T)
 
 if (KE_decay_height > 0)
 
 if (pert_ref_height > 0)
 
 if (add_sinusoidal_T &&sc.fixed_density[lev])
 
 ParallelForRNG (bx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine &engine) noexcept { const Real x=prob_lo_x+(i+myhalf) *dx;const Real y=prob_lo_y+(j+myhalf) *dy;const Real z=z_cc(i, j, k);const Real r=std::sqrt((x-xc) *(x-xc)+(y-yc) *(y-yc)+(z-zc) *(z-zc));if((z<=pert_ref_height) &&(T_0_Pert_Mag !=amrex::Real(0))) { Real rand_double;if(deterministic_ic_pert) { rand_double=erf_hash_rng::hash_uniform(i, j, k, temperature_hash_comp, lev, ic_pert_seed);} else { rand_double=amrex::Random(engine);} state_pert(i, j, k, RhoTheta_comp)=(rand_double *amrex::Real(2) - amrex::Real(1)) *T_0_Pert_Mag;if(!pert_rhotheta) { state_pert(i, j, k, RhoTheta_comp) *=r_hse(i, j, k);} } if(add_sinusoidal_T) { const Real zl=z/pert_ref_height;const Real damp=std::exp(-myhalf *zl *zl);const Real rho=state(i, j, k, Rho_comp);const Real rhotheta=state(i, j, k, RhoTheta_comp);const Real qv=(use_moisture) ? state(i, j, k, RhoQ1_comp)/rho :amrex::Real(0);const Real Told=getTgivenRandRTh(rho, rhotheta, qv);const Real P=getPgivenRTh(rhotheta, qv);const Real Tnew=Told+tfac *damp *z *std::cos(cval *(x - xc));const Real theta_new=getThgivenTandP(Tnew, P, rdOcp);const Real rho_new=getRhogivenThetaPress(theta_new, P, rdOcp, qv);state_pert(i, j, k, Rho_comp)+=rho_new - rho;if(use_moisture) { state_pert(i, j, k, RhoQ1_comp)+=(rho_new - rho) *qv;} } state_pert(i, j, k, RhoScalar_comp)=A_0 *std::exp(-amrex::Real(10.) *r *r);if(state_pert.nComp() > RhoKE_comp) { if(rhoKE_0 > 0) { state_pert(i, j, k, RhoKE_comp)=rhoKE_0;} else { state_pert(i, j, k, RhoKE_comp)=r_hse(i, j, k) *KE_0;} if(KE_decay_height > 0) { state_pert(i, j, k, RhoKE_comp) *=amrex::max(std::pow(1 - amrex::min(z/KE_decay_height, amrex::Real(1)), KE_decay_order), Real(1e-12));} } })
 

Variables

int deterministic_ic_pert = 0
 
int fix_random_seed = 0
 
long random_seed = -1
 
const std::uint64_t ic_pert_seed
 
constexpr int temperature_hash_comp = 0
 
Real rho_0 = amrex::Real(0)
 
Real T_0 = amrex::Real(0)
 
Real A_0 = amrex::Real(1)
 
Real KE_0 = amrex::Real(0.1)
 
Real rhoKE_0 = -1
 
Real KE_decay_height = -1
 
Real KE_decay_order = 1
 
Real T_0_Pert_Mag = amrex::Real(0)
 
bool pert_rhotheta = true
 
Real pert_deltaU = amrex::Real(0)
 
Real pert_deltaV = amrex::Real(0)
 
Real pert_ref_height = amrex::Real(100.0)
 
Real pert_deltaT = amrex::Real(0)
 
Real pert_periods_T = amrex::Real(5.0)
 
const Real dx = geomdata.CellSize(0)
 
const Real dy = geomdata.CellSize(1)
 
const Real prob_lo_x = geomdata.ProbLo(0)
 
const Real prob_lo_y = geomdata.ProbLo(1)
 
const Real prob_lo_z = geomdata.ProbLo(2)
 
const Real prob_hi_x = geomdata.ProbHi(0)
 
const Real prob_hi_y = geomdata.ProbHi(1)
 
const Real prob_hi_z = geomdata.ProbHi(2)
 
const Real xc = myhalf * (prob_lo_x + prob_hi_x)
 
const Real yc = myhalf * (prob_lo_y + prob_hi_y)
 
const Real zc = myhalf * (prob_lo_z + prob_hi_z)
 
const bool add_sinusoidal_T
 
const Real cval = pert_periods_T * two * PI / (prob_hi_x - prob_lo_x)
 
const Real tfac
 
const bool use_moisture = (sc.moisture_type != MoistureType::None)
 
const Real rdOcp = sc.rdOcp
 

Function Documentation

◆ if() [1/3]

if ( add_sinusoidal_T &&sc.  fixed_density[lev])
99  {
100  amrex::Print() << "WARNING: prob.pert_deltaT has no effect at level " << lev
101  << " because fixed_density is set there" << std::endl;
102  }

◆ if() [2/3]

if ( KE_decay_height  ,
 
)
74  {
75  amrex::Print() << "Initial KE profile (order " << KE_decay_order
76  << ") will extend up to " << KE_decay_height
77  << std::endl;
78  }
Real KE_decay_order
Definition: ERF_InitCustomPert_ABL.H:25
Real KE_decay_height
Definition: ERF_InitCustomPert_ABL.H:24

◆ if() [3/3]

if ( pert_ref_height  ,
 
)
81  {
82  if (T_0_Pert_Mag != amrex::Real(0)) {
83  if (pert_rhotheta) {
84  amrex::Print() << "Adding random rho*theta perturbations" << std::endl;
85  } else {
86  amrex::Print() << "Adding random theta perturbations" << std::endl;
87  }
88  }
89  if (add_sinusoidal_T) {
90  amrex::Print() << "Adding sinusoidal temperature perturbations "
91  << pert_deltaT << " over " << pert_periods_T
92  << " periods" << std::endl;
93  }
94  }
Real T_0_Pert_Mag
Definition: ERF_InitCustomPert_ABL.H:28
const bool add_sinusoidal_T
Definition: ERF_InitCustomPert_ABL.H:64
bool pert_rhotheta
Definition: ERF_InitCustomPert_ABL.H:29
Real pert_periods_T
Definition: ERF_InitCustomPert_ABL.H:41
Real pert_deltaT
Definition: ERF_InitCustomPert_ABL.H:40
amrex::Real Real
Definition: ERF_ShocInterface.H:19

◆ ParallelForRNG()

ParallelForRNG ( bx  ,
[=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine &engine) noexcept { const Real x=prob_lo_x+(i+myhalf) *dx;const Real y=prob_lo_y+(j+myhalf) *dy;const Real z=z_cc(i, j, k);const Real r=std::sqrt((x-xc) *(x-xc)+(y-yc) *(y-yc)+(z-zc) *(z-zc));if((z<=pert_ref_height) &&(T_0_Pert_Mag !=amrex::Real(0))) { Real rand_double;if(deterministic_ic_pert) { rand_double=erf_hash_rng::hash_uniform(i, j, k, temperature_hash_comp, lev, ic_pert_seed);} else { rand_double=amrex::Random(engine);} state_pert(i, j, k, RhoTheta_comp)=(rand_double *amrex::Real(2) - amrex::Real(1)) *T_0_Pert_Mag;if(!pert_rhotheta) { state_pert(i, j, k, RhoTheta_comp) *=r_hse(i, j, k);} } if(add_sinusoidal_T) { const Real zl=z/pert_ref_height;const Real damp=std::exp(-myhalf *zl *zl);const Real rho=state(i, j, k, Rho_comp);const Real rhotheta=state(i, j, k, RhoTheta_comp);const Real qv=(use_moisture) ? state(i, j, k, RhoQ1_comp)/rho :amrex::Real(0);const Real Told=getTgivenRandRTh(rho, rhotheta, qv);const Real P=getPgivenRTh(rhotheta, qv);const Real Tnew=Told+tfac *damp *z *std::cos(cval *(x - xc));const Real theta_new=getThgivenTandP(Tnew, P, rdOcp);const Real rho_new=getRhogivenThetaPress(theta_new, P, rdOcp, qv);state_pert(i, j, k, Rho_comp)+=rho_new - rho;if(use_moisture) { state_pert(i, j, k, RhoQ1_comp)+=(rho_new - rho) *qv;} } state_pert(i, j, k, RhoScalar_comp)=A_0 *std::exp(-amrex::Real(10.) *r *r);if(state_pert.nComp() > RhoKE_comp) { if(rhoKE_0 > 0) { state_pert(i, j, k, RhoKE_comp)=rhoKE_0;} else { state_pert(i, j, k, RhoKE_comp)=r_hse(i, j, k) *KE_0;} if(KE_decay_height > 0) { state_pert(i, j, k, RhoKE_comp) *=amrex::max(std::pow(1 - amrex::min(z/KE_decay_height, amrex::Real(1)), KE_decay_order), Real(1e-12));} } }   
)

Referenced by ERF::create_random_perturbations(), and TurbulentPerturbation::pseudoRandomPert().

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

◆ pp()

ParmParse pp ( "prob"  )

Referenced by add_par(), Morrison::Advance(), WDM6::Advance(), WSM6::Advance(), ERF::appendPlotVariables(), plotfile2d::available_diagnostic_names(), SolverChoice::build_coriolis_forcings_const_lat(), TurbulentPerturbation::calc_tpi_update(), eb_aux_::define(), AdvChoice::display(), erf_init_dens_hse_moist(), ERF::ERF_shared(), ERF::ErrorEst(), Morrison::Init(), WDM6::Init(), ProblemBase::init_buildings_surface(), ERF::init_custom(), init_my_custom_terrain(), TurbChoice::init_params(), SolverChoice::init_params(), AdvChoice::init_params(), DampingChoice::init_params(), DiffChoice::init_params(), EBChoice::init_params(), SpongeChoice::init_params(), ERF::init_phys_bcs(), ProblemBase::init_terrain_surface(), TurbulentPerturbation::init_tpi(), init_which_terrain_grid(), WindFarm::init_windfarm_lat_lon(), init_zlevels(), ERF::init_zphys(), ERF::InitData_post(), InputSoundingData::InputSoundingData(), InputSpongeData::InputSpongeData(), LargeScaleForcingData::LargeScaleForcingData(), LineSampler::LineSampler(), SurfaceLayer::make_SurfaceLayer_at_level(), ProblemBase::name(), plotfile2d::parse_requested_sampled_level_sets(), plotfile2d::parse_sampled_level_definition(), erf_wall_scalar_bc::parse_wall_face_scalars(), PlaneSampler::PlaneSampler(), query_one_or_per_level(), query_one_or_per_level_enum_case_insensitive(), Radiation::Radiation(), SolverChoice::read_int_string(), read_shoc_runtime_options(), read_shoc_transport_modes(), ReadBndryPlanes::ReadBndryPlanes(), ERF::ReadParameters(), ERF::refinement_criteria_setup(), erf_cloud_chamber::reject_unsupported_face_keys(), ERF::remake_zphys(), MOSTAverage::set_k_indices_N(), MOSTAverage::set_k_indices_T(), MOSTAverage::set_norm_indices_T(), MOSTAverage::set_norm_positions_T(), MOSTAverage::set_z_positions_EB(), MOSTAverage::set_z_positions_T(), ERF::setPlotVariables(), ERF::setPlotVariables2D(), ERF::setSubVolVariables(), IRadiation::setupDataLog(), SHOCInterface::SHOCInterface(), which_fine_terrain(), WriteBndryPlanes::WriteBndryPlanes(), and ERF::WriteSubvolume().

◆ query() [1/17]

pp query ( "A_0"  ,
A_0   
)

◆ query() [2/17]

pp_erf query ( "deterministic_ic_pert"  ,
deterministic_ic_pert   
)

Referenced by containerHasElement().

Here is the caller graph for this function:

◆ query() [3/17]

pp_erf query ( "fix_random_seed"  ,
fix_random_seed   
)

◆ query() [4/17]

pp query ( "KE_0"  ,
KE_0   
)

◆ query() [5/17]

pp query ( "KE_decay_height"  ,
KE_decay_height   
)

◆ query() [6/17]

pp query ( "KE_decay_order"  ,
KE_decay_order   
)

◆ query() [7/17]

pp query ( "pert_deltaT"  ,
pert_deltaT   
)

◆ query() [8/17]

pp query ( "pert_deltaU"  ,
pert_deltaU   
)

◆ query() [9/17]

pp query ( "pert_deltaV"  ,
pert_deltaV   
)

◆ query() [10/17]

pp query ( "pert_periods_T"  ,
pert_periods_T   
)

◆ query() [11/17]

pp_for_pert_vels query ( "pert_ref_height"  ,
pert_ref_height   
)

◆ query() [12/17]

pp query ( "pert_rhotheta"  ,
pert_rhotheta   
)

◆ query() [13/17]

pp_erf query ( "random_seed"  ,
random_seed   
)

◆ query() [14/17]

pp query ( "rho_0"  ,
rho_0   
)

◆ query() [15/17]

pp query ( "rhoKE_0"  ,
rhoKE_0   
)

◆ query() [16/17]

pp query ( "T_0"  ,
T_0   
)

◆ query() [17/17]

pp query ( "T_0_Pert_Mag"  ,
T_0_Pert_Mag   
)

Variable Documentation

◆ A_0

Real A_0 = amrex::Real(1)

Referenced by ParallelForRNG().

◆ add_sinusoidal_T

const bool add_sinusoidal_T
Initial value:
Real pert_ref_height
Definition: ERF_InitCustomPert_ABL.H:34

Referenced by if(), and ParallelForRNG().

◆ cval

const Real cval = pert_periods_T * two * PI / (prob_hi_x - prob_lo_x)

Referenced by ParallelForRNG().

◆ deterministic_ic_pert

int deterministic_ic_pert = 0

Referenced by ParallelForRNG().

◆ dx

const Real dx = geomdata.CellSize(0)

Referenced by ShocDriver::advance(), ERF::apply_gaussian_smoothing_to_perturbations(), ApplyBndryForcing_Forecast(), ApplySpongeZoneBCsForCC(), ApplySpongeZoneBCsForMom(), ApplySpongeZoneBCsForMom_ReadFromFile(), MOSTAverage::compute_eb_averages(), compute_gradp_xy(), compute_gradp_z(), MOSTAverage::compute_region_averages(), ERF::ComputeGlobalMinLocation(), eb_aux_::define(), ForestDrag::define_drag_field(), ShocStructure::diagnose_length_and_brunt(), ShocDiagnostics::diagnose_pre_implicit(), DiffusionSrcForMom_EB(), DiffusionSrcForState_EB(), erf_calc_slopes_eb_Dirichlet(), erf_calc_slopes_eb_Dirichlet_staggered(), erf_calc_slopes_eb_staggered(), erf_calc_slopes_eb_staggered_upwind(), derived::erf_derhelicity(), derived::erf_dervortz(), erf_slow_rhs_post(), erf_slow_rhs_pre(), erf_substep_MT(), erf_substep_NS(), erf_substep_T(), ERF::ErrorEst(), ShocPreprocess::fill_columns(), plotfile2d::fill_condensed_water_paths(), WindFarm::fill_Nturb_multifab(), WindFarm::fill_SMark_multifab(), ERF::FillForecastStateMultiFabs(), ERF::FillSurfaceStateMultiFabs(), ERF::FindInitialEye(), ERF::HurricaneEyeTrackerNotInitial(), ERF::HurricaneMaxVelTracker(), ERF::HurricaneMinPressureTracker(), if(), init_default_zphys(), init_my_custom_terrain(), init_state_from_input_sounding(), init_state_from_input_sounding_hse(), TurbulentPerturbation::init_tpi(), init_velocities_from_input_sounding(), init_zlevels(), ERF::InitData_post(), interpolate_from_coarse(), make_areas(), make_J(), MOSTAverage::make_MOSTAverage_at_level(), make_sources(), NodalReconstruction::NodalReconstruction(), ParallelFor(), ParallelForRNG(), pbl_blend_factor(), pbl_kh_blend_and_cap(), pbl_kh_ceiling_powerlaw(), pbl_kh_ceiling_smag(), ERF::poisson_wall_dist(), ERF::project_momenta(), ERF::read_box_for_refinement(), SurfaceLayer::read_custom_roughness(), ProblemBase::read_custom_terrain(), SDInjection::readInputs(), realbdy_compute_interior_ghost_rhs(), realbdy_compute_moisture_relaxation(), realbdy_compute_relaxation(), MOSTAverage::set_eb_normalization(), MOSTAverage::set_norm_positions_T(), MOSTAverage::set_z_positions_T(), ERF::setSpongeRefFromSounding(), ERF::solve_with_gmres(), EWP::source_terms_cellcentered(), Fitch::source_terms_cellcentered(), GeneralAD::source_terms_cellcentered(), SimpleAD::source_terms_cellcentered(), ERF::sum_derived_quantities(), ERF::sum_energy_quantities(), tag_on_distance_from_eye(), thinbody_wall_dist(), ERF::volWgtColumnSum(), ERF::volWgtSumMF(), ERF::Write2DPlotFile(), ERF::Write3DPlotFile(), ERF::write_1D_profiles(), ERF::write_1D_profiles_stag(), LineSampler::write_line_plotfile(), and writeNCPlotFile().

◆ dy

◆ fix_random_seed

int fix_random_seed = 0

◆ ic_pert_seed

const std::uint64_t ic_pert_seed
Initial value:
? std::uint64_t(1024)
: ((random_seed >= 0) ? static_cast<std::uint64_t>(random_seed) : std::uint64_t(0))
long random_seed
Definition: ERF_InitCustomPert_ABL.H:6
int fix_random_seed
Definition: ERF_InitCustomPert_ABL.H:5

Referenced by ParallelForRNG().

◆ KE_0

Real KE_0 = amrex::Real(0.1)

Referenced by ParallelForRNG().

◆ KE_decay_height

Real KE_decay_height = -1

Referenced by if(), and ParallelForRNG().

◆ KE_decay_order

Real KE_decay_order = 1

Referenced by if(), and ParallelForRNG().

◆ pert_deltaT

Real pert_deltaT = amrex::Real(0)

Referenced by if().

◆ pert_deltaU

Real pert_deltaU = amrex::Real(0)

◆ pert_deltaV

Real pert_deltaV = amrex::Real(0)

◆ pert_periods_T

Real pert_periods_T = amrex::Real(5.0)

Referenced by if().

◆ pert_ref_height

Real pert_ref_height = amrex::Real(100.0)

Referenced by ParallelForRNG().

◆ pert_rhotheta

bool pert_rhotheta = true

Referenced by if(), and ParallelForRNG().

◆ prob_hi_x

const Real prob_hi_x = geomdata.ProbHi(0)

◆ prob_hi_y

const Real prob_hi_y = geomdata.ProbHi(1)

◆ prob_hi_z

const Real prob_hi_z = geomdata.ProbHi(2)

◆ prob_lo_x

const Real prob_lo_x = geomdata.ProbLo(0)

Referenced by ParallelForRNG().

◆ prob_lo_y

const Real prob_lo_y = geomdata.ProbLo(1)

Referenced by ParallelForRNG().

◆ prob_lo_z

const Real prob_lo_z = geomdata.ProbLo(2)

◆ random_seed

long random_seed = -1

Referenced by ERF::ERF_shared().

◆ rdOcp

◆ rho_0

◆ rhoKE_0

Real rhoKE_0 = -1

Referenced by ParallelForRNG().

◆ T_0

◆ T_0_Pert_Mag

Real T_0_Pert_Mag = amrex::Real(0)

Referenced by if(), and ParallelForRNG().

◆ temperature_hash_comp

constexpr int temperature_hash_comp = 0
constexpr

Referenced by ParallelForRNG().

◆ tfac

const Real tfac
Initial value:
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13

Referenced by ParallelForRNG().

◆ use_moisture

◆ xc

◆ yc

◆ zc