ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPert_ParticleTests.H
Go to the documentation of this file.
1  ParmParse pp("prob");
2  Real x_c = zero; pp.query("x_c", x_c);
3  Real z_c = amrex::Real(3000.0); pp.query("z_c", z_c);
4  Real x_r = amrex::Real(4000.0); pp.query("x_r", x_r);
5  Real z_r = amrex::Real(2000.0); pp.query("z_r", z_r);
6  Real T_pert = -amrex::Real(15.0); pp.query("T_pert", T_pert);
7 
8  // Overridden physical constants
9  Real C_p = amrex::Real(1004.0);
10 
11  ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
12  {
13  // Geometry (note we must include these here to get the data on device)
14  const auto prob_lo = geomdata.ProbLo();
15  const auto dx = geomdata.CellSize();
16  const Real x = prob_lo[0] + (i + myhalf) * dx[0];
17  const Real z = z_cc(i,j,k);
18 
19  // Temperature that satisfies the EOS given the hydrostatically balanced (r,p)
20  const Real Tbar_hse = p_hse(i,j,k) / (R_d * r_hse(i,j,k));
21 
22  Real L = std::sqrt(
23  std::pow((x - x_c)/x_r, 2) +
24  std::pow((z - z_c)/z_r, 2)
25  );
26  if (L <= one) {
27  Real dT = T_pert * (std::cos(PI*L) + one)/two;
28 
29  // Note: dT is a temperature perturbation, theta_perturbed is base state + perturbation in theta
30  Real theta_perturbed = (Tbar_hse+dT)*std::pow(p_0/p_hse(i,j,k), R_d/C_p);
31 
32  // This version perturbs rho but not p
33  state_pert(i, j, k, Rho_comp) = getRhoThetagivenP(p_hse(i,j,k)) / theta_perturbed - r_hse(i,j,k);
34  }
35  });
constexpr amrex::Real two
Definition: ERF_Constants.H:8
constexpr amrex::Real one
Definition: ERF_Constants.H:7
constexpr amrex::Real zero
Definition: ERF_Constants.H:6
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:11
constexpr amrex::Real PI
Definition: ERF_Constants.H:16
constexpr amrex::Real p_0
Definition: ERF_Constants.H:28
constexpr amrex::Real R_d
Definition: ERF_Constants.H:20
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhoThetagivenP(const amrex::Real p, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:172
#define Rho_comp
Definition: ERF_IndexDefines.H:36
const Real dx
Definition: ERF_InitCustomPert_ABL.H:23
state_pert(i, j, k, RhoTheta_comp)
const amrex::Real * prob_lo
Definition: ERF_InitCustomPert_IsentropicVortex.H:16
Real z_c
Definition: ERF_InitCustomPert_ParticleTests.H:3
Real x_r
Definition: ERF_InitCustomPert_ParticleTests.H:4
Real x_c
Definition: ERF_InitCustomPert_ParticleTests.H:2
ParmParse pp("prob")
Real z_r
Definition: ERF_InitCustomPert_ParticleTests.H:5
Real T_pert
Definition: ERF_InitCustomPert_ParticleTests.H:6
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const auto prob_lo=geomdata.ProbLo();const auto dx=geomdata.CellSize();const Real x=prob_lo[0]+(i+myhalf) *dx[0];const Real z=z_cc(i, j, k);const Real Tbar_hse=p_hse(i, j, k)/(R_d *r_hse(i, j, k));Real L=std::sqrt(std::pow((x - x_c)/x_r, 2)+std::pow((z - z_c)/z_r, 2));if(L<=one) { Real dT=T_pert *(std::cos(PI *L)+one)/two;Real theta_perturbed=(Tbar_hse+dT) *std::pow(p_0/p_hse(i, j, k), R_d/C_p);state_pert(i, j, k, Rho_comp)=getRhoThetagivenP(p_hse(i, j, k))/theta_perturbed - r_hse(i, j, k);} })
Real C_p
Definition: ERF_InitCustomPert_ParticleTests.H:9
amrex::Real Real
Definition: ERF_ShocInterface.H:19