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