8 ParmParse pp_erf(
"erf");
44 const Real dx = geomdata.CellSize(0);
45 const Real dy = geomdata.CellSize(1);
71 const bool use_moisture = (sc.moisture_type != MoistureType::None);
74 const bool use_eb = (sc.terrain_type == TerrainType::EB);
75 const int klo = geomdata.Domain().smallEnd(2);
82 "Vertical decomposition with KE initialization is not allowed.");
89 amrex::Print() <<
"Adding random rho*theta perturbations" << std::endl;
91 amrex::Print() <<
"Adding random theta perturbations" << std::endl;
95 amrex::Print() <<
"Adding sinusoidal temperature perturbations "
97 <<
" periods" << std::endl;
105 amrex::Print() <<
"WARNING: prob.pert_deltaT has no effect at level " << lev
106 <<
" because fixed_density is set there" << std::endl;
110 ParallelForRNG(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k,
const amrex::RandomEngine& engine) noexcept
114 const Real z = z_cc(i,j,k);
125 rand_double = amrex::Random(engine);
155 const Real damp = std::exp(-
myhalf * zl * zl);
199 + z_nd(i ,j+1,
klo) + z_nd(i+1,j+1,
klo) );
200 const Real z_agl = z_cc(i,j,k) - z_sfc;
201 state_pert(i, j, k,
RhoKE_comp) *= amrex::max(
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhogivenThetaPress(const amrex::Real th, const amrex::Real p, const amrex::Real rdOcp, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:96
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenRandRTh(const amrex::Real rho, const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:46
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getThgivenTandP(const amrex::Real T, const amrex::Real P, const amrex::Real rdOcp)
Definition: ERF_EOS.H:18
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh(const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:81
#define RhoScalar_comp
Definition: ERF_IndexDefines.H:43
#define Rho_comp
Definition: ERF_IndexDefines.H:39
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:40
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:45
#define RhoKE_comp
Definition: ERF_IndexDefines.H:41
const int klo
Definition: ERF_InitCustomPert_ABL.H:75
const Real prob_lo_z
Definition: ERF_InitCustomPert_ABL.H:48
const Real prob_lo_y
Definition: ERF_InitCustomPert_ABL.H:47
int deterministic_ic_pert
Definition: ERF_InitCustomPert_ABL.H:4
Real T_0_Pert_Mag
Definition: ERF_InitCustomPert_ABL.H:28
const bool add_sinusoidal_T
Definition: ERF_InitCustomPert_ABL.H:64
Real pert_ref_height
Definition: ERF_InitCustomPert_ABL.H:34
const bool use_moisture
Definition: ERF_InitCustomPert_ABL.H:71
Real KE_0
Definition: ERF_InitCustomPert_ABL.H:21
const Real dy
Definition: ERF_InitCustomPert_ABL.H:45
Real rho_0
Definition: ERF_InitCustomPert_ABL.H:18
const Real zc
Definition: ERF_InitCustomPert_ABL.H:56
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:72
Real rhoKE_0
Definition: ERF_InitCustomPert_ABL.H:22
const Real yc
Definition: ERF_InitCustomPert_ABL.H:55
ParmParse pp_prob("prob")
const Real prob_lo_x
Definition: ERF_InitCustomPert_ABL.H:46
constexpr int temperature_hash_comp
Definition: ERF_InitCustomPert_ABL.H:16
long random_seed
Definition: ERF_InitCustomPert_ABL.H:6
Real T_0
Definition: ERF_InitCustomPert_ABL.H:19
Real pert_deltaV
Definition: ERF_InitCustomPert_ABL.H:33
const Real prob_hi_y
Definition: ERF_InitCustomPert_ABL.H:50
const std::uint64_t ic_pert_seed
Definition: ERF_InitCustomPert_ABL.H:13
const Real tfac
Definition: ERF_InitCustomPert_ABL.H:67
const Real prob_hi_x
Definition: ERF_InitCustomPert_ABL.H:49
const Real cval
Definition: ERF_InitCustomPert_ABL.H:66
Real KE_decay_order
Definition: ERF_InitCustomPert_ABL.H:25
Real pert_deltaU
Definition: ERF_InitCustomPert_ABL.H:32
const Real prob_hi_z
Definition: ERF_InitCustomPert_ABL.H:51
Real KE_decay_height
Definition: ERF_InitCustomPert_ABL.H:24
bool pert_rhotheta
Definition: ERF_InitCustomPert_ABL.H:29
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) { const Real z_sfc=(use_eb) ? zero :fourth *(z_nd(i, j, klo)+z_nd(i+1, j, klo)+z_nd(i, j+1, klo)+z_nd(i+1, j+1, klo));const Real z_agl=z_cc(i, j, k) - z_sfc;state_pert(i, j, k, RhoKE_comp) *=amrex::max(std::pow(1 - amrex::min(z_agl/KE_decay_height, amrex::Real(1)), KE_decay_order), amrex::Real(1e-12));} } })
Real pert_periods_T
Definition: ERF_InitCustomPert_ABL.H:41
int fix_random_seed
Definition: ERF_InitCustomPert_ABL.H:5
Real A_0
Definition: ERF_InitCustomPert_ABL.H:20
const Real xc
Definition: ERF_InitCustomPert_ABL.H:54
const bool use_eb
Definition: ERF_InitCustomPert_ABL.H:74
Real pert_deltaT
Definition: ERF_InitCustomPert_ABL.H:40
const Real dx
Definition: ERF_InitCustomPert_ABL.H:44
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_cloud_chamber_config.active, "Cloud Chamber: initializer reached without a parsed configuration")
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:31
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:35
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:29
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:34
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:39
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ P
Definition: ERF_IndexDefines.H:204
@ rho
Definition: ERF_Kessler.H:25
@ qv
Definition: ERF_Kessler.H:31
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real hash_uniform(int i, int j, int k, int comp, int lev, std::uint64_t seed) noexcept
Definition: ERF_HashRNG.H:68