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

Go to the source code of this file.

Functions

ParmParse pp_prob ("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_prob query ("U_0", U_0)
 
pp_prob query ("V_0", V_0)
 
pp_prob query ("W_0", W_0)
 
pp_prob query ("U_0_Pert_Mag", U_0_Pert_Mag)
 
pp_prob query ("V_0_Pert_Mag", V_0_Pert_Mag)
 
pp_prob query ("W_0_Pert_Mag", W_0_Pert_Mag)
 
pp_prob query ("pert_deltaU", pert_deltaU)
 
pp_prob query ("pert_deltaV", pert_deltaV)
 
pp_prob query ("pert_periods_U", pert_periods_U)
 
pp_prob query ("pert_periods_V", pert_periods_V)
 
pp_prob query ("pert_ref_height", pert_ref_height)
 
 if (pert_ref_height > 0)
 
 ParallelForRNG (xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine &engine) noexcept { const Real *prob_lo=geomdata.ProbLo();const Real *dx=geomdata.CellSize();const Real y=prob_lo[1]+(j+myhalf) *dx[1];const Real z=(z_nd) ? fourth *(z_nd(i, j, k)+z_nd(i, j, k+1)+z_nd(i, j+1, k)+z_nd(i, j+1, k+1)) :prob_lo[2]+(k+myhalf) *dx[2];x_vel_pert(i, j, k)=U_0;if((z<=pert_ref_height) &&(U_0_Pert_Mag !=zero)) { Real rand_double;if(deterministic_ic_pert) { rand_double=erf_hash_rng::hash_uniform(i, j, k, x_velocity_hash_comp, lev, ic_pert_seed);} else { rand_double=amrex::Random(engine);} Real x_vel_prime=(rand_double *two - one) *U_0_Pert_Mag;x_vel_pert(i, j, k)+=x_vel_prime;} if(pert_deltaU !=zero) { const amrex::Real yl=y - prob_lo[1];const amrex::Real zl=z/pert_ref_height;const amrex::Real damp=std::exp(-myhalf *zl *zl);x_vel_pert(i, j, k)+=ufac *damp *z *std::cos(aval *yl);} })
 
 ParallelForRNG (ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine &engine) noexcept { const Real *prob_lo=geomdata.ProbLo();const Real *dx=geomdata.CellSize();const Real x=prob_lo[0]+(i+myhalf) *dx[0];const Real z=(z_nd) ? fourth *(z_nd(i, j, k)+z_nd(i, j, k+1)+z_nd(i+1, j, k)+z_nd(i+1, j, k+1)) :prob_lo[2]+(k+myhalf) *dx[2];y_vel_pert(i, j, k)=V_0;if((z<=pert_ref_height) &&(V_0_Pert_Mag !=zero)) { Real rand_double;if(deterministic_ic_pert) { rand_double=erf_hash_rng::hash_uniform(i, j, k, y_velocity_hash_comp, lev, ic_pert_seed);} else { rand_double=amrex::Random(engine);} Real y_vel_prime=(rand_double *two - one) *V_0_Pert_Mag;y_vel_pert(i, j, k)+=y_vel_prime;} if(pert_deltaV !=zero) { const amrex::Real xl=x - prob_lo[0];const amrex::Real zl=z/pert_ref_height;const amrex::Real damp=std::exp(-myhalf *zl *zl);y_vel_pert(i, j, k)+=vfac *damp *z *std::cos(bval *xl);} })
 
 ParallelForRNG (zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine &engine) noexcept { const int dom_lo_z=geomdata.Domain().smallEnd()[2];const int dom_hi_z=geomdata.Domain().bigEnd()[2];if(k==dom_lo_z||k==dom_hi_z+1) { z_vel_pert(i, j, k)=zero;} else { z_vel_pert(i, j, k)=W_0;if(W_0_Pert_Mag !=zero) { Real rand_double;if(deterministic_ic_pert) { rand_double=erf_hash_rng::hash_uniform(i, j, k, z_velocity_hash_comp, lev, ic_pert_seed);} else { rand_double=amrex::Random(engine);} Real z_vel_prime=(rand_double *two - one) *W_0_Pert_Mag;z_vel_pert(i, j, k)+=z_vel_prime;} } })
 

Variables

int deterministic_ic_pert = 0
 
int fix_random_seed = 0
 
long random_seed = -1
 
const std::uint64_t ic_pert_seed
 
constexpr int x_velocity_hash_comp = 1
 
constexpr int y_velocity_hash_comp = 2
 
constexpr int z_velocity_hash_comp = 3
 
Real U_0 = zero
 
Real V_0 = zero
 
Real W_0 = zero
 
Real U_0_Pert_Mag = zero
 
Real V_0_Pert_Mag = zero
 
Real W_0_Pert_Mag = zero
 
Real pert_deltaU = zero
 
Real pert_deltaV = zero
 
Real pert_periods_U = amrex::Real(5.0)
 
Real pert_periods_V = amrex::Real(5.0)
 
Real pert_ref_height = amrex::Real(100.0)
 
auto problo = geomdata.ProbLo()
 
auto probhi = geomdata.ProbHi()
 
Real aval = pert_periods_U * two * PI / (probhi[1] - problo[1])
 
Real bval = pert_periods_V * two * PI / (probhi[0] - problo[0])
 
Real ufac = pert_deltaU * std::exp(myhalf) / pert_ref_height
 
Real vfac = pert_deltaV * std::exp(myhalf) / pert_ref_height
 

Function Documentation

◆ if()

if ( pert_ref_height  ,
 
)
44  {
45  if ((pert_deltaU != zero) || (pert_deltaV != zero)) {
46  amrex::Print() << "Adding divergence-free perturbations "
47  << pert_deltaU << " " << pert_deltaV
48  << std::endl;
49  }
50  if (U_0_Pert_Mag != zero) {
51  amrex::Print() << "Adding random x-velocity perturbations" << std::endl;
52  }
53  if (V_0_Pert_Mag != zero) {
54  amrex::Print() << "Adding random y-velocity perturbations" << std::endl;
55  }
56  }
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
Real U_0_Pert_Mag
Definition: ERF_InitCustomPertVels_ABL.H:25
Real pert_deltaV
Definition: ERF_InitCustomPertVels_ABL.H:31
Real pert_deltaU
Definition: ERF_InitCustomPertVels_ABL.H:30
Real V_0_Pert_Mag
Definition: ERF_InitCustomPertVels_ABL.H:26

◆ ParallelForRNG() [1/3]

ParallelForRNG ( xbx  ,
[=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine &engine) noexcept { const Real *prob_lo=geomdata.ProbLo();const Real *dx=geomdata.CellSize();const Real y=prob_lo[1]+(j+myhalf) *dx[1];const Real z=(z_nd) ? fourth *(z_nd(i, j, k)+z_nd(i, j, k+1)+z_nd(i, j+1, k)+z_nd(i, j+1, k+1)) :prob_lo[2]+(k+myhalf) *dx[2];x_vel_pert(i, j, k)=U_0;if((z<=pert_ref_height) &&(U_0_Pert_Mag !=zero)) { Real rand_double;if(deterministic_ic_pert) { rand_double=erf_hash_rng::hash_uniform(i, j, k, x_velocity_hash_comp, lev, ic_pert_seed);} else { rand_double=amrex::Random(engine);} Real x_vel_prime=(rand_double *two - one) *U_0_Pert_Mag;x_vel_pert(i, j, k)+=x_vel_prime;} if(pert_deltaU !=zero) { const amrex::Real yl=y - prob_lo[1];const amrex::Real zl=z/pert_ref_height;const amrex::Real damp=std::exp(-myhalf *zl *zl);x_vel_pert(i, j, k)+=ufac *damp *z *std::cos(aval *yl);} }   
)
Here is the call graph for this function:

◆ ParallelForRNG() [2/3]

ParallelForRNG ( ybx  ,
[=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine &engine) noexcept { const Real *prob_lo=geomdata.ProbLo();const Real *dx=geomdata.CellSize();const Real x=prob_lo[0]+(i+myhalf) *dx[0];const Real z=(z_nd) ? fourth *(z_nd(i, j, k)+z_nd(i, j, k+1)+z_nd(i+1, j, k)+z_nd(i+1, j, k+1)) :prob_lo[2]+(k+myhalf) *dx[2];y_vel_pert(i, j, k)=V_0;if((z<=pert_ref_height) &&(V_0_Pert_Mag !=zero)) { Real rand_double;if(deterministic_ic_pert) { rand_double=erf_hash_rng::hash_uniform(i, j, k, y_velocity_hash_comp, lev, ic_pert_seed);} else { rand_double=amrex::Random(engine);} Real y_vel_prime=(rand_double *two - one) *V_0_Pert_Mag;y_vel_pert(i, j, k)+=y_vel_prime;} if(pert_deltaV !=zero) { const amrex::Real xl=x - prob_lo[0];const amrex::Real zl=z/pert_ref_height;const amrex::Real damp=std::exp(-myhalf *zl *zl);y_vel_pert(i, j, k)+=vfac *damp *z *std::cos(bval *xl);} }   
)
Here is the call graph for this function:

◆ ParallelForRNG() [3/3]

ParallelForRNG ( zbx  ,
[=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine &engine) noexcept { const int dom_lo_z=geomdata.Domain().smallEnd()[2];const int dom_hi_z=geomdata.Domain().bigEnd()[2];if(k==dom_lo_z||k==dom_hi_z+1) { z_vel_pert(i, j, k)=zero;} else { z_vel_pert(i, j, k)=W_0;if(W_0_Pert_Mag !=zero) { Real rand_double;if(deterministic_ic_pert) { rand_double=erf_hash_rng::hash_uniform(i, j, k, z_velocity_hash_comp, lev, ic_pert_seed);} else { rand_double=amrex::Random(engine);} Real z_vel_prime=(rand_double *two - one) *W_0_Pert_Mag;z_vel_pert(i, j, k)+=z_vel_prime;} } }   
)
Here is the call graph for this function:

◆ pp_prob()

ParmParse pp_prob ( "prob"  )

◆ query() [1/14]

pp_erf query ( "deterministic_ic_pert"  ,
deterministic_ic_pert   
)

◆ query() [2/14]

pp_erf query ( "fix_random_seed"  ,
fix_random_seed   
)

◆ query() [3/14]

pp_prob query ( "pert_deltaU"  ,
pert_deltaU   
)

◆ query() [4/14]

pp_prob query ( "pert_deltaV"  ,
pert_deltaV   
)

◆ query() [5/14]

pp_prob query ( "pert_periods_U"  ,
pert_periods_U   
)

◆ query() [6/14]

pp_prob query ( "pert_periods_V"  ,
pert_periods_V   
)

◆ query() [7/14]

pp_prob query ( "pert_ref_height"  ,
pert_ref_height   
)

◆ query() [8/14]

pp_erf query ( "random_seed"  ,
random_seed   
)

◆ query() [9/14]

pp_prob query ( "U_0"  ,
U_0   
)

◆ query() [10/14]

pp_prob query ( "U_0_Pert_Mag"  ,
U_0_Pert_Mag   
)

◆ query() [11/14]

pp_prob query ( "V_0"  ,
V_0   
)

◆ query() [12/14]

pp_prob query ( "V_0_Pert_Mag"  ,
V_0_Pert_Mag   
)

◆ query() [13/14]

pp_prob query ( "W_0"  ,
W_0   
)

◆ query() [14/14]

pp_prob query ( "W_0_Pert_Mag"  ,
W_0_Pert_Mag   
)

Variable Documentation

◆ aval

Real aval = pert_periods_U * two * PI / (probhi[1] - problo[1])

Referenced by ParallelForRNG().

◆ bval

Real bval = pert_periods_V * two * PI / (probhi[0] - problo[0])

Referenced by ParallelForRNG().

◆ deterministic_ic_pert

int deterministic_ic_pert = 0

Referenced by ParallelForRNG().

◆ 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_InitCustomPertVels_ABL.H:6
int fix_random_seed
Definition: ERF_InitCustomPertVels_ABL.H:5

Referenced by ParallelForRNG().

◆ pert_deltaU

Real pert_deltaU = zero

Referenced by if(), and ParallelForRNG().

◆ pert_deltaV

Real pert_deltaV = zero

Referenced by if(), and ParallelForRNG().

◆ pert_periods_U

Real pert_periods_U = amrex::Real(5.0)

◆ pert_periods_V

Real pert_periods_V = amrex::Real(5.0)

◆ pert_ref_height

Real pert_ref_height = amrex::Real(100.0)

Referenced by ParallelForRNG().

◆ probhi

auto probhi = geomdata.ProbHi()

◆ problo

auto problo = geomdata.ProbLo()

◆ random_seed

long random_seed = -1

◆ U_0

Real U_0 = zero

Referenced by ParallelForRNG().

◆ U_0_Pert_Mag

Real U_0_Pert_Mag = zero

Referenced by if(), and ParallelForRNG().

◆ ufac

Real ufac = pert_deltaU * std::exp(myhalf) / pert_ref_height

Referenced by ParallelForRNG().

◆ V_0

Real V_0 = zero

Referenced by ParallelForRNG().

◆ V_0_Pert_Mag

Real V_0_Pert_Mag = zero

Referenced by if(), and ParallelForRNG().

◆ vfac

◆ W_0

Real W_0 = zero

Referenced by ParallelForRNG().

◆ W_0_Pert_Mag

Real W_0_Pert_Mag = zero

Referenced by ParallelForRNG().

◆ x_velocity_hash_comp

constexpr int x_velocity_hash_comp = 1
constexpr

Referenced by ParallelForRNG().

◆ y_velocity_hash_comp

constexpr int y_velocity_hash_comp = 2
constexpr

Referenced by ParallelForRNG().

◆ z_velocity_hash_comp

constexpr int z_velocity_hash_comp = 3
constexpr

Referenced by ParallelForRNG().