ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPert_EBPoiseuille.H
Go to the documentation of this file.
1  ParmParse pp("prob");
2  Real A_0 = 1.0 ; pp.query("A_0", A_0);
3  Real B_0 = 0.0 ; pp.query("B_0", B_0);
4  Real rad_0 = 0.0; pp.query("rad_0", rad_0);
5  Real rho_0 = 1.0; pp.query("rho_0", rho_0);
6 
7  // Location of "center" of scalar (multiplies domain length)
8  Real xc_frac = 0.5; pp.query("xc_frac", xc_frac);
9  Real yc_frac = 0.5; pp.query("yc_frac", yc_frac);
10  Real zc_frac = 0.5; pp.query("zc_frac", zc_frac);
11 
12  int prob_type = -1;
13  pp.query("prob_type", prob_type);
14 
15  Real xradius = 10.0; pp.query("xradius", xradius); // x-radius of scalar bubble
16  Real zradius = 10.0; pp.query("zradius", zradius); // z-radius of scalar bubble
17 
18  AMREX_ALWAYS_ASSERT(sc.terrain_type == TerrainType::EB);
19 
20  // Set the state_pert
21  ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
22  {
23  // Geometry
24  const Real* prob_lo = geomdata.ProbLo();
25  const Real* prob_hi = geomdata.ProbHi();
26  const Real* dx = geomdata.CellSize();
27 
28  const Real x = prob_lo[0] + (i + 0.5) * dx[0];
29  const Real y = prob_lo[1] + (j + 0.5) * dx[1];
30  const Real z = prob_lo[2] + (k + 0.5) * dx[2];
31 
32  // Define a point (xc,yc,zc) at the center of the domain
33  const Real xc = xc_frac * (prob_lo[0] + prob_hi[0]);
34  const Real yc = yc_frac * (prob_lo[1] + prob_hi[1]);
35  const Real zc = zc_frac * (prob_lo[2] + prob_hi[2]);
36 
37  // Define ellipse parameters
38  const Real r0 = rad_0 * (prob_hi[0] - prob_lo[0]);
39  const Real r3d = std::sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc) + (z-zc)*(z-zc));
40  const Real r2d_xz = std::sqrt((x-xc)*(x-xc) + (z-zc)*(z-zc));
41  const Real r2d_xz_nd = std::sqrt((x-xc)*(x-xc)/xradius/xradius
42  +(z-zc)*(z-zc)/zradius/zradius);
43 
44  if (prob_type == 10)
45  {
46  // Set scalar = A_0*exp(-10r^2), where r is distance from center of domain,
47  // + B_0*sin(x)
48  // state_pert(i, j, k, RhoScalar_comp) = A_0 * exp(-10.*r3d*r3d) + B_0*sin(x);
49  state_pert(i, j, k, RhoScalar_comp) = A_0 * exp(-0.1*r2d_xz*r2d_xz) + B_0*sin(x);
50 
51  } else if (prob_type == 11) {
52  if (r2d_xz_nd < 1.0)
53  {
54  state_pert(i, j, k, RhoScalar_comp) = 0.5 * A_0 * (1.0 + std::cos(PI*r2d_xz_nd));
55  }
56  } else {
57  // Set scalar = A_0 in a ball of radius r0 and 0 elsewhere
58  if (r3d < r0) {
59  state_pert(i, j, k, RhoScalar_comp) = A_0;
60  }
61  }
62 
63  state_pert(i, j, k, RhoScalar_comp) *= rho_0;
64  });
constexpr amrex::Real PI
Definition: ERF_Constants.H:6
#define RhoScalar_comp
Definition: ERF_IndexDefines.H:40
const Real zc
Definition: ERF_InitCustomPert_ABL.H:35
const Real yc
Definition: ERF_InitCustomPert_ABL.H:34
const Real xc
Definition: ERF_InitCustomPert_ABL.H:33
const Real dx
Definition: ERF_InitCustomPert_ABL.H:23
state_pert(i, j, k, RhoTheta_comp)
Real zradius
Definition: ERF_InitCustomPert_EBPoiseuille.H:16
Real B_0
Definition: ERF_InitCustomPert_EBPoiseuille.H:3
Real zc_frac
Definition: ERF_InitCustomPert_EBPoiseuille.H:10
AMREX_ALWAYS_ASSERT(sc.terrain_type==TerrainType::EB)
Real xc_frac
Definition: ERF_InitCustomPert_EBPoiseuille.H:8
Real rho_0
Definition: ERF_InitCustomPert_EBPoiseuille.H:5
ParmParse pp("prob")
Real yc_frac
Definition: ERF_InitCustomPert_EBPoiseuille.H:9
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const Real *prob_lo=geomdata.ProbLo();const Real *prob_hi=geomdata.ProbHi();const Real *dx=geomdata.CellSize();const Real x=prob_lo[0]+(i+0.5) *dx[0];const Real y=prob_lo[1]+(j+0.5) *dx[1];const Real z=prob_lo[2]+(k+0.5) *dx[2];const Real xc=xc_frac *(prob_lo[0]+prob_hi[0]);const Real yc=yc_frac *(prob_lo[1]+prob_hi[1]);const Real zc=zc_frac *(prob_lo[2]+prob_hi[2]);const Real r0=rad_0 *(prob_hi[0] - prob_lo[0]);const Real r3d=std::sqrt((x-xc) *(x-xc)+(y-yc) *(y-yc)+(z-zc) *(z-zc));const Real r2d_xz=std::sqrt((x-xc) *(x-xc)+(z-zc) *(z-zc));const Real r2d_xz_nd=std::sqrt((x-xc) *(x-xc)/xradius/xradius+(z-zc) *(z-zc)/zradius/zradius);if(prob_type==10) { state_pert(i, j, k, RhoScalar_comp)=A_0 *exp(-0.1 *r2d_xz *r2d_xz)+B_0 *sin(x);} else if(prob_type==11) { if(r2d_xz_nd< 1.0) { state_pert(i, j, k, RhoScalar_comp)=0.5 *A_0 *(1.0+std::cos(PI *r2d_xz_nd));} } else { if(r3d< r0) { state_pert(i, j, k, RhoScalar_comp)=A_0;} } state_pert(i, j, k, RhoScalar_comp) *=rho_0;})
int prob_type
Definition: ERF_InitCustomPert_EBPoiseuille.H:12
Real A_0
Definition: ERF_InitCustomPert_EBPoiseuille.H:2
Real xradius
Definition: ERF_InitCustomPert_EBPoiseuille.H:15
Real rad_0
Definition: ERF_InitCustomPert_EBPoiseuille.H:4
const amrex::Real * prob_lo
Definition: ERF_InitCustomPert_IsentropicVortex.H:16
const amrex::Real * prob_hi
Definition: ERF_InitCustomPert_IsentropicVortex.H:17
amrex::Real Real
Definition: ERF_ShocInterface.H:19