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