ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPert_EBPoiseuille.H
Go to the documentation of this file.
1  // On a mesh other than ConstantDz, heights come from z_cc and the vertical levels,
2  // not from geomdata's prob_lo[2], prob_hi[2] and CellSize(2)
3  const bool use_z_phys = use_physical_z();
4  const Real phys_z_lo = phys_zlo(geomdata, lev);
5  const Real phys_z_hi = phys_zhi(geomdata, lev);
6 
7  ParmParse pp("prob");
8  Real A_0 = one ; pp.query("A_0", A_0);
9  Real B_0 = zero ; pp.query("B_0", B_0);
10  Real rad_0 = zero; pp.query("rad_0", rad_0);
11  Real rho_0 = one; pp.query("rho_0", rho_0);
12 
13  // Location of "center" of scalar (multiplies domain length)
14  Real xc_frac = myhalf; pp.query("xc_frac", xc_frac);
15  Real yc_frac = myhalf; pp.query("yc_frac", yc_frac);
16  Real zc_frac = myhalf; pp.query("zc_frac", zc_frac);
17 
18  int prob_type = -1;
19  pp.query("prob_type", prob_type);
20 
21  Real xradius = amrex::Real(10.0); pp.query("xradius", xradius); // x-radius of scalar bubble
22  Real zradius = amrex::Real(10.0); pp.query("zradius", zradius); // z-radius of scalar bubble
23 
24  // prob_type 11 divides by the radii
25  if (prob_type == 11) {
27  "prob.xradius and prob.zradius must be > 0 for prob.prob_type = 11");
28  }
29 
30  AMREX_ALWAYS_ASSERT(sc.terrain_type == TerrainType::EB);
31 
32  // Set the state_pert
33  ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
34  {
35  // Geometry
36  const Real* prob_lo = geomdata.ProbLo();
37  const Real* prob_hi = geomdata.ProbHi();
38  const Real* dx = geomdata.CellSize();
39 
40  const Real x = prob_lo[0] + (i + myhalf) * dx[0];
41  const Real y = prob_lo[1] + (j + myhalf) * dx[1];
42  const Real z = use_z_phys ? z_cc(i,j,k) : prob_lo[2] + (k + myhalf) * dx[2];
43 
44  // Define a point (xc,yc,zc) at the given fractions of the domain extent
45  const Real xc = prob_lo[0] + xc_frac * (prob_hi[0] - prob_lo[0]);
46  const Real yc = prob_lo[1] + yc_frac * (prob_hi[1] - prob_lo[1]);
47  const Real zc = phys_z_lo + zc_frac * (phys_z_hi - phys_z_lo);
48 
49  // Define ellipse parameters
50  const Real r0 = rad_0 * (prob_hi[0] - prob_lo[0]);
51  const Real r3d = std::sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc) + (z-zc)*(z-zc));
52  const Real r2d_xz = std::sqrt((x-xc)*(x-xc) + (z-zc)*(z-zc));
53  const Real r2d_xz_nd = std::sqrt((x-xc)*(x-xc)/xradius/xradius
54  +(z-zc)*(z-zc)/zradius/zradius);
55 
56  if (prob_type == 10)
57  {
58  // Set scalar = A_0*exp(-10r^2), where r is distance from center of domain,
59  // + B_0*sin(x)
60  // state_pert(i, j, k, RhoScalar_comp) = A_0 * std::exp(-amrex::Real(10.)*r3d*r3d) + B_0*std::sin(x);
61  state_pert(i, j, k, RhoScalar_comp) = A_0 * std::exp(-amrex::Real(0.1)*r2d_xz*r2d_xz) + B_0*std::sin(x);
62 
63  } else if (prob_type == 11) {
64  if (r2d_xz_nd < one)
65  {
66  state_pert(i, j, k, RhoScalar_comp) = myhalf * A_0 * (one + std::cos(PI*r2d_xz_nd));
67  }
68  } else {
69  // Set scalar = A_0 in a ball of radius r0 and 0 elsewhere
70  if (r3d < r0) {
71  state_pert(i, j, k, RhoScalar_comp) = A_0;
72  }
73  }
74 
75  state_pert(i, j, k, RhoScalar_comp) *= rho_0;
76  });
#define RhoScalar_comp
Definition: ERF_IndexDefines.H:57
const Real zc
Definition: ERF_InitCustomPert_ABL.H:56
const Real yc
Definition: ERF_InitCustomPert_ABL.H:55
const Real xc
Definition: ERF_InitCustomPert_ABL.H:54
const Real dx
Definition: ERF_InitCustomPert_ABL.H:44
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
const GpuArray< Real, AMREX_SPACEDIM > prob_lo
Definition: ERF_InitCustomPert_CloudChamber.H:33
const amrex::Real * prob_hi
Definition: ERF_InitCustomPert_DataAssimilation_ISV.H:17
const bool use_z_phys
Definition: ERF_InitCustomPert_EBPoiseuille.H:3
Real zradius
Definition: ERF_InitCustomPert_EBPoiseuille.H:22
Real B_0
Definition: ERF_InitCustomPert_EBPoiseuille.H:9
Real zc_frac
Definition: ERF_InitCustomPert_EBPoiseuille.H:16
AMREX_ALWAYS_ASSERT(sc.terrain_type==TerrainType::EB)
Real xc_frac
Definition: ERF_InitCustomPert_EBPoiseuille.H:14
Real rho_0
Definition: ERF_InitCustomPert_EBPoiseuille.H:11
const Real phys_z_hi
Definition: ERF_InitCustomPert_EBPoiseuille.H:5
ParmParse pp("prob")
Real yc_frac
Definition: ERF_InitCustomPert_EBPoiseuille.H:15
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+myhalf) *dx[0];const Real y=prob_lo[1]+(j+myhalf) *dx[1];const Real z=use_z_phys ? z_cc(i, j, k) :prob_lo[2]+(k+myhalf) *dx[2];const Real xc=prob_lo[0]+xc_frac *(prob_hi[0] - prob_lo[0]);const Real yc=prob_lo[1]+yc_frac *(prob_hi[1] - prob_lo[1]);const Real zc=phys_z_lo+zc_frac *(phys_z_hi - phys_z_lo);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 *std::exp(-amrex::Real(0.1) *r2d_xz *r2d_xz)+B_0 *std::sin(x);} else if(prob_type==11) { if(r2d_xz_nd< one) { state_pert(i, j, k, RhoScalar_comp)=myhalf *A_0 *(one+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:18
Real A_0
Definition: ERF_InitCustomPert_EBPoiseuille.H:8
Real xradius
Definition: ERF_InitCustomPert_EBPoiseuille.H:21
Real rad_0
Definition: ERF_InitCustomPert_EBPoiseuille.H:10
const Real phys_z_lo
Definition: ERF_InitCustomPert_EBPoiseuille.H:4
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46
amrex::Real Real
Definition: ERF_ShocInterface.H:19
real(kind=kind_phys), parameter, private r0
Definition: ERF_module_mp_wdm6.F90:75