ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPert_DensityCurrent.H
Go to the documentation of this file.
1  // Parse params
2  ParmParse pp("prob");
3  Real x_c = 0.; pp.query("x_c", x_c);
4  Real z_c = 3000.; pp.query("z_c", z_c);
5  Real x_r = 4000.; pp.query("x_r", x_r);
6  Real z_r = 2000.; pp.query("z_r", z_r);
7  Real T_pert = -15.; pp.query("T_pert", T_pert);
8 
9  const bool const_rho = (sc.fixed_density[lev] == 1);
10 
11  const Real rdOcp = sc.rdOcp;
12 
13  ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
14  {
15  // Geometry (note we must include these here to get the data on device)
16  const auto prob_lo = geomdata.ProbLo();
17  const auto dx = geomdata.CellSize();
18 
19  const Real x = ( prob_lo[0] + (i + 0.5) * dx[0] ) / mf_m(i,j,0);
20  const Real z = z_cc(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 <= 1.0)
27  {
28  Real dT = T_pert * (std::cos(PI*L) + 1.0)/2.0;
29  Real Tbar_hse = p_hse(i,j,k) / (R_d * r_hse(i,j,k));
30 
31  // Note: dT is a perturbation in temperature, theta_perturbed is base state + perturbation
32  Real theta_perturbed = (Tbar_hse+dT)*std::pow(p_0/p_hse(i,j,k), rdOcp);
33  Real theta_0 = (Tbar_hse )*std::pow(p_0/p_hse(i,j,k), rdOcp);
34 
35  if (const_rho) {
36  state_pert(i, j, k, RhoTheta_comp) = r_hse(i,j,k) * (theta_perturbed - theta_0);
37  } else {
38  state_pert(i, j, k, Rho_comp) = getRhoThetagivenP(p_hse(i,j,k)) / theta_perturbed - r_hse(i,j,k);
39  }
40  }
41  });
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
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:37
const auto dx
Definition: ERF_InitCustomPertVels_ParticleTests.H:15
const bool const_rho
Definition: ERF_InitCustomPert_DensityCurrent.H:9
Real z_c
Definition: ERF_InitCustomPert_DensityCurrent.H:4
Real x_r
Definition: ERF_InitCustomPert_DensityCurrent.H:5
const Real rdOcp
Definition: ERF_InitCustomPert_DensityCurrent.H:11
Real x_c
Definition: ERF_InitCustomPert_DensityCurrent.H:3
ParmParse pp("prob")
Real z_r
Definition: ERF_InitCustomPert_DensityCurrent.H:6
Real T_pert
Definition: ERF_InitCustomPert_DensityCurrent.H:7
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])/mf_m(i, j, 0);const Real z=z_cc(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 Tbar_hse=p_hse(i, j, k)/(R_d *r_hse(i, j, k));Real theta_perturbed=(Tbar_hse+dT) *std::pow(p_0/p_hse(i, j, k), rdOcp);Real theta_0=(Tbar_hse) *std::pow(p_0/p_hse(i, j, k), rdOcp);if(const_rho) { state_pert(i, j, k, RhoTheta_comp)=r_hse(i, j, k) *(theta_perturbed - theta_0);} else { state_pert(i, j, k, Rho_comp)=getRhoThetagivenP(p_hse(i, j, k))/theta_perturbed - r_hse(i, j, k);} } })
const amrex::Real * prob_lo
Definition: ERF_InitCustomPert_IsentropicVortex.H:16
amrex::Real Real
Definition: ERF_ShocInterface.H:19