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