ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPertVels_RICO.H
Go to the documentation of this file.
1  ParmParse pp_prob("prob");
2 
3  Real U_0 = 0.0; pp_prob.query("U_0", U_0);
4  Real V_0 = 0.0; pp_prob.query("V_0", V_0);
5  Real W_0 = 0.0; pp_prob.query("W_0", W_0);
6 
7  Real U_0_Pert_Mag = 0.0; pp_prob.query("U_0_Pert_Mag", U_0_Pert_Mag);
8  Real V_0_Pert_Mag = 0.0; pp_prob.query("V_0_Pert_Mag", V_0_Pert_Mag);
9  Real W_0_Pert_Mag = 0.0; pp_prob.query("W_0_Pert_Mag", W_0_Pert_Mag);
10  Real T_0_Pert_Mag = 0.0; pp_prob.query("T_0_Pert_Mag", T_0_Pert_Mag);
11  Real qv_0_Pert_Mag = 0.0; pp_prob.query("qv_0_Pert_Mag", qv_0_Pert_Mag);
12 
13  Real pert_deltaU = 0.0; pp_prob.query("pert_deltaU", pert_deltaU);
14  Real pert_deltaV = 0.0; pp_prob.query("pert_deltaV", pert_deltaV);
15  Real pert_periods_U = 5.0; pp_prob.query("pert_periods_U", pert_periods_U);
16  Real pert_periods_V = 5.0; pp_prob.query("pert_periods_V", pert_periods_V);
17  Real pert_ref_height = 100.0; pp_prob.query("pert_ref_height", pert_ref_height);
18 
19  const Real prob_lo_x = geomdata.ProbLo()[0]; const Real prob_lo_y = geomdata.ProbLo()[1];
20  const Real prob_hi_x = geomdata.ProbHi()[0]; const Real prob_hi_y = geomdata.ProbHi()[1];
21 
24 
25  Real ufac = pert_deltaU * std::exp(0.5) / pert_ref_height;
26  Real vfac = pert_deltaV * std::exp(0.5) / pert_ref_height;
27 
28  // Set the x-velocity
29  ParallelForRNG(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const RandomEngine& engine) noexcept
30  {
31  const Real* prob_lo = geomdata.ProbLo();
32  const Real* dx = geomdata.CellSize();
33  const Real y = prob_lo[1] + (j + 0.5) * dx[1];
34  const Real z = prob_lo[2] + (k + 0.5) * dx[2];
35 
36  // Set the x-velocity
37  x_vel_pert(i, j, k) = U_0;
38  if ((z <= pert_ref_height) && (U_0_Pert_Mag != 0.0))
39  {
40  Real rand_double = amrex::Random(engine); // Between 0.0 and 1.0
41  Real x_vel_prime = (rand_double*2.0 - 1.0)*U_0_Pert_Mag;
42  x_vel_pert(i, j, k) += x_vel_prime;
43  }
44  if (pert_deltaU != 0.0)
45  {
46  const amrex::Real yl = y - prob_lo[1];
47  const amrex::Real zl = z / pert_ref_height;
48  const amrex::Real damp = std::exp(-0.5 * zl * zl);
49  x_vel_pert(i, j, k) += ufac * damp * z * std::cos(aval * yl);
50  }
51  });
52 
53  // Set the y-velocity
54  ParallelForRNG(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const RandomEngine& engine) noexcept
55  {
56  const Real* prob_lo = geomdata.ProbLo();
57  const Real* dx = geomdata.CellSize();
58  const Real x = prob_lo[0] + (i + 0.5) * dx[0];
59  const Real z = prob_lo[2] + (k + 0.5) * dx[2];
60 
61  // Set the y-velocity
62  y_vel_pert(i, j, k) = V_0;
63  if ((z <= pert_ref_height) && (V_0_Pert_Mag != 0.0))
64  {
65  Real rand_double = amrex::Random(engine); // Between 0.0 and 1.0
66  Real y_vel_prime = (rand_double*2.0 - 1.0)*V_0_Pert_Mag;
67  y_vel_pert(i, j, k) += y_vel_prime;
68  }
69  if (pert_deltaV != 0.0)
70  {
71  const amrex::Real xl = x - prob_lo[0];
72  const amrex::Real zl = z / pert_ref_height;
73  const amrex::Real damp = std::exp(-0.5 * zl * zl);
74  y_vel_pert(i, j, k) += vfac * damp * z * std::cos(bval * xl);
75  }
76  });
77 
78  // Set the z-velocity
79  ParallelForRNG(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const RandomEngine& engine) noexcept
80  {
81  const int dom_lo_z = geomdata.Domain().smallEnd()[2];
82  const int dom_hi_z = geomdata.Domain().bigEnd()[2];
83 
84  // Set the z-velocity
85  if (k == dom_lo_z || k == dom_hi_z+1)
86  {
87  z_vel_pert(i, j, k) = 0.0;
88  }
89  else if (W_0_Pert_Mag != 0.0)
90  {
91  Real rand_double = amrex::Random(engine); // Between 0.0 and 1.0
92  Real z_vel_prime = (rand_double*2.0 - 1.0)*W_0_Pert_Mag;
93  z_vel_pert(i, j, k) = W_0 + z_vel_prime;
94  }
95  });
constexpr amrex::Real PI
Definition: ERF_Constants.H:6
const Real prob_lo_y
Definition: ERF_InitCustomPertVels_RICO.H:19
Real bval
Definition: ERF_InitCustomPertVels_RICO.H:23
Real aval
Definition: ERF_InitCustomPertVels_RICO.H:22
Real W_0_Pert_Mag
Definition: ERF_InitCustomPertVels_RICO.H:9
Real T_0_Pert_Mag
Definition: ERF_InitCustomPertVels_RICO.H:10
Real pert_ref_height
Definition: ERF_InitCustomPertVels_RICO.H:17
ParallelForRNG(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const RandomEngine &engine) noexcept { const Real *prob_lo=geomdata.ProbLo();const Real *dx=geomdata.CellSize();const Real y=prob_lo[1]+(j+0.5) *dx[1];const Real z=prob_lo[2]+(k+0.5) *dx[2];x_vel_pert(i, j, k)=U_0;if((z<=pert_ref_height) &&(U_0_Pert_Mag !=0.0)) { Real rand_double=amrex::Random(engine);Real x_vel_prime=(rand_double *2.0 - 1.0) *U_0_Pert_Mag;x_vel_pert(i, j, k)+=x_vel_prime;} if(pert_deltaU !=0.0) { const amrex::Real yl=y - prob_lo[1];const amrex::Real zl=z/pert_ref_height;const amrex::Real damp=std::exp(-0.5 *zl *zl);x_vel_pert(i, j, k)+=ufac *damp *z *std::cos(aval *yl);} })
ParmParse pp_prob("prob")
Real U_0_Pert_Mag
Definition: ERF_InitCustomPertVels_RICO.H:7
const Real prob_lo_x
Definition: ERF_InitCustomPertVels_RICO.H:19
Real pert_periods_V
Definition: ERF_InitCustomPertVels_RICO.H:16
Real vfac
Definition: ERF_InitCustomPertVels_RICO.H:26
Real pert_deltaV
Definition: ERF_InitCustomPertVels_RICO.H:14
const Real prob_hi_y
Definition: ERF_InitCustomPertVels_RICO.H:20
Real U_0
Definition: ERF_InitCustomPertVels_RICO.H:3
const Real prob_hi_x
Definition: ERF_InitCustomPertVels_RICO.H:20
Real ufac
Definition: ERF_InitCustomPertVels_RICO.H:25
Real V_0
Definition: ERF_InitCustomPertVels_RICO.H:4
Real pert_deltaU
Definition: ERF_InitCustomPertVels_RICO.H:13
Real pert_periods_U
Definition: ERF_InitCustomPertVels_RICO.H:15
Real W_0
Definition: ERF_InitCustomPertVels_RICO.H:5
Real V_0_Pert_Mag
Definition: ERF_InitCustomPertVels_RICO.H:8
Real qv_0_Pert_Mag
Definition: ERF_InitCustomPertVels_RICO.H:11
const Real dx
Definition: ERF_InitCustomPert_ABL.H:23
const amrex::Real * prob_lo
Definition: ERF_InitCustomPert_IsentropicVortex.H:16
const Box zbx
Definition: ERF_SetupDiff.H:9
const Box xbx
Definition: ERF_SetupDiff.H:7
const Box ybx
Definition: ERF_SetupDiff.H:8
amrex::Real Real
Definition: ERF_ShocInterface.H:19