ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPert_IsentropicVortex.H
Go to the documentation of this file.
1 
2  // Parse params
3  ParmParse pp("prob");
4 
5  amrex::Real p_inf = p_0; pp.query("p_inf", p_inf); //freestream pressure [Pa]
6  amrex::Real T_inf = 300.0; pp.query("T_inf", T_inf);//freestream temperature [K]
7  amrex::Real M_inf = 0.2; pp.query("M_inf", M_inf);//freestream Mach number [-]
8  amrex::Real alpha = 0.0; pp.query("alpha", alpha);//inflow angle, 0 --> x-aligned [rad]
9  amrex::Real gamma = Gamma; pp.query("gamma", gamma);//specific heat ratio [-]
10  amrex::Real beta = 0.01; pp.query("beta", beta);//non-dimensional max perturbation strength [-]
11  amrex::Real sigma = 1.0; pp.query("sigma", sigma);//Gaussian standard deviation, i.e., spreading parameter [-]
12  amrex::Real R = 2.0; pp.query("R", R);//characteristic length scale for grid [m]
13  amrex::Real xc_frac = 0.5; pp.query("xc", xc_frac);//normalized x-location of vortex center [-]
14  amrex::Real yc_frac = 0.5; pp.query("yc", yc_frac);//normalized y-location of vortex center [-]
15 
16  const amrex::Real* prob_lo = geomdata.ProbLo();
17  const amrex::Real* prob_hi = geomdata.ProbHi();
18 
21 
22  // amrex::Print() << " vortex initialized at ("
23  // << parms.xc << ", "
24  // << parms.yc << ")"
25  // << std::endl;
26 
27  amrex::Real inv_gm1 = 1.0 / (gamma - 1.0);
28 
29  // amrex::Print() << " reference pressure = " << parms.p_inf << " Pa" << std::endl;
30  // amrex::Print() << " reference temperature = " << parms.T_inf << " K" << std::endl;
31  // amrex::Print() << " reference potential temperature (not used) = " << parms.T_0 << " K" << std::endl;
32 
34  // amrex::Print() << " calculated freestream air density = "
35  // << parms.rho_0 << " kg/m^3"
36  // << std::endl;
37 
38  amrex::Real a_inf = std::sqrt(gamma * R_d * T_inf);
39  // amrex::Print() << " calculated speed of sound, a = "
40  // << parms.a_inf << " m/s"
41  // << std::endl;
42 
43  // amrex::Print() << " freestream u/a = "
44  // << parms.M_inf * std::cos(parms.alpha)
45  // << std::endl;
46  // amrex::Print() << " freestream v/a = "
47  // << parms.M_inf * std::sin(parms.alpha)
48  // << std::endl;
49 
50  const amrex::Real rdOcp = sc.rdOcp;
51 
52  ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
53  {
54  const Real* dx = geomdata.CellSize();
55 
56  // Note that since we only use (x-xc) and (y-yc), we neglect the prob_lo offset in these
57  const Real x = (i + 0.5) * dx[0]; // cell center
58  const Real y = (j + 0.5) * dx[1]; // cell center
59 
60  // Calculate perturbation temperature
61  const Real Omg = erf_vortex_Gaussian(x,y,xc,yc,R,beta,sigma);
62  const Real deltaT = -(gamma - 1.0)/(2.0*sigma*sigma) * Omg*Omg;
63 
64  // Set the perturbation density
65  const Real rho_norm = std::pow(1.0 + deltaT, inv_gm1);
66  state_pert(i, j, k, Rho_comp) = rho_norm * rho_0 - r_hse(i,j,k);
67 
68  // Initial _potential_ temperature
69  const Real T = (1.0 + deltaT) * T_inf;
70  const Real p = std::pow(rho_norm, Gamma) / Gamma // isentropic relation
71  * rho_0*a_inf*a_inf;
72  const Real rho_theta = rho_0 * rho_norm * (T * std::pow(p_0 / p, rdOcp)); // T --> theta
73  state_pert(i, j, k, RhoTheta_comp) = rho_theta - getRhoThetagivenP(p_hse(i,j,k)); // Set the perturbation rho*theta
74 
75  const Real r2d_xy = std::sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc));
76  state_pert(i, j, k, RhoScalar_comp) = 0.25 * (1.0 + std::cos(PI * std::min(r2d_xy, R) / R));
77  });
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
constexpr amrex::Real Gamma
Definition: ERF_Constants.H:19
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 RhoScalar_comp
Definition: ERF_IndexDefines.H:40
#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
static AMREX_GPU_DEVICE amrex::Real erf_vortex_Gaussian(amrex::Real x, amrex::Real y, amrex::Real xc, amrex::Real yc, amrex::Real R, amrex::Real beta, amrex::Real sigma)
Definition: ERF_InitCustomPert.H:31
amrex::Real gamma
Definition: ERF_InitCustomPert_IsentropicVortex.H:9
const amrex::Real * prob_lo
Definition: ERF_InitCustomPert_IsentropicVortex.H:16
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const Real *dx=geomdata.CellSize();const Real x=(i+0.5) *dx[0];const Real y=(j+0.5) *dx[1];const Real Omg=erf_vortex_Gaussian(x, y, xc, yc, R, beta, sigma);const Real deltaT=-(gamma - 1.0)/(2.0 *sigma *sigma) *Omg *Omg;const Real rho_norm=std::pow(1.0+deltaT, inv_gm1);state_pert(i, j, k, Rho_comp)=rho_norm *rho_0 - r_hse(i, j, k);const Real T=(1.0+deltaT) *T_inf;const Real p=std::pow(rho_norm, Gamma)/Gamma *rho_0 *a_inf *a_inf;const Real rho_theta=rho_0 *rho_norm *(T *std::pow(p_0/p, rdOcp));state_pert(i, j, k, RhoTheta_comp)=rho_theta - getRhoThetagivenP(p_hse(i, j, k));const Real r2d_xy=std::sqrt((x-xc) *(x-xc)+(y-yc) *(y-yc));state_pert(i, j, k, RhoScalar_comp)=0.25 *(1.0+std::cos(PI *std::min(r2d_xy, R)/R));})
amrex::Real R
Definition: ERF_InitCustomPert_IsentropicVortex.H:12
amrex::Real yc
Definition: ERF_InitCustomPert_IsentropicVortex.H:20
amrex::Real a_inf
Definition: ERF_InitCustomPert_IsentropicVortex.H:38
ParmParse pp("prob")
amrex::Real p_inf
Definition: ERF_InitCustomPert_IsentropicVortex.H:5
amrex::Real rho_0
Definition: ERF_InitCustomPert_IsentropicVortex.H:33
amrex::Real sigma
Definition: ERF_InitCustomPert_IsentropicVortex.H:11
const amrex::Real rdOcp
Definition: ERF_InitCustomPert_IsentropicVortex.H:50
amrex::Real alpha
Definition: ERF_InitCustomPert_IsentropicVortex.H:8
amrex::Real xc_frac
Definition: ERF_InitCustomPert_IsentropicVortex.H:13
const amrex::Real * prob_hi
Definition: ERF_InitCustomPert_IsentropicVortex.H:17
amrex::Real beta
Definition: ERF_InitCustomPert_IsentropicVortex.H:10
amrex::Real M_inf
Definition: ERF_InitCustomPert_IsentropicVortex.H:7
amrex::Real inv_gm1
Definition: ERF_InitCustomPert_IsentropicVortex.H:27
amrex::Real yc_frac
Definition: ERF_InitCustomPert_IsentropicVortex.H:14
amrex::Real T_inf
Definition: ERF_InitCustomPert_IsentropicVortex.H:6
amrex::Real xc
Definition: ERF_InitCustomPert_IsentropicVortex.H:19
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ T
Definition: ERF_IndexDefines.H:110