ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPertVels_RICO.H
Go to the documentation of this file.
1  // On a mesh other than ConstantDz, heights come from z_nd 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 
5  ParmParse pp_prob("prob");
6 
7  Real U_0 = zero; pp_prob.query("U_0", U_0);
8  Real V_0 = zero; pp_prob.query("V_0", V_0);
9  Real W_0 = zero; pp_prob.query("W_0", W_0);
10 
11  Real U_0_Pert_Mag = zero; pp_prob.query("U_0_Pert_Mag", U_0_Pert_Mag);
12  Real V_0_Pert_Mag = zero; pp_prob.query("V_0_Pert_Mag", V_0_Pert_Mag);
13  Real W_0_Pert_Mag = zero; pp_prob.query("W_0_Pert_Mag", W_0_Pert_Mag);
14  Real T_0_Pert_Mag = zero; pp_prob.query("T_0_Pert_Mag", T_0_Pert_Mag);
15  Real qv_0_Pert_Mag = zero; pp_prob.query("qv_0_Pert_Mag", qv_0_Pert_Mag);
16 
17  Real pert_deltaU = zero; pp_prob.query("pert_deltaU", pert_deltaU);
18  Real pert_deltaV = zero; pp_prob.query("pert_deltaV", pert_deltaV);
19  Real pert_periods_U = amrex::Real(5.0); pp_prob.query("pert_periods_U", pert_periods_U);
20  Real pert_periods_V = amrex::Real(5.0); pp_prob.query("pert_periods_V", pert_periods_V);
21  Real pert_ref_height = amrex::Real(100.0); pp_prob.query("pert_ref_height", pert_ref_height);
22 
23  const Real prob_lo_x = geomdata.ProbLo()[0]; const Real prob_lo_y = geomdata.ProbLo()[1];
24  const Real prob_hi_x = geomdata.ProbHi()[0]; const Real prob_hi_y = geomdata.ProbHi()[1];
25 
28 
31 
32  // Set the x-velocity
33  ParallelForRNG(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const 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 + myhalf) * dx[1];
38  const Real z = use_z_phys ? erf_prob_heights::z_xface(i,j,k,z_nd) : prob_lo[2] + (k + myhalf) * dx[2];
39  const Real z_agl = z - erf_prob_heights::z_ground_xface(i,j,z_sfc_nd); // height above the ground
40 
41  // Set the x-velocity
42  x_vel_pert(i, j, k) = U_0;
43  if ((z_agl <= pert_ref_height) && (U_0_Pert_Mag != zero))
44  {
45  Real rand_double = amrex::Random(engine); // Between zero and one
46  Real x_vel_prime = (rand_double*two - one)*U_0_Pert_Mag;
47  x_vel_pert(i, j, k) += x_vel_prime;
48  }
49  if (pert_deltaU != zero)
50  {
51  const amrex::Real yl = y - prob_lo[1];
52  const amrex::Real zl = z_agl / pert_ref_height;
53  const amrex::Real damp = std::exp(-myhalf * zl * zl);
54  x_vel_pert(i, j, k) += ufac * damp * z_agl * std::cos(aval * yl);
55  }
56  });
57 
58  // Set the y-velocity
59  ParallelForRNG(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const RandomEngine& engine) noexcept
60  {
61  const Real* prob_lo = geomdata.ProbLo();
62  const Real* dx = geomdata.CellSize();
63  const Real x = prob_lo[0] + (i + myhalf) * dx[0];
64  const Real z = use_z_phys ? erf_prob_heights::z_yface(i,j,k,z_nd) : prob_lo[2] + (k + myhalf) * dx[2];
65  const Real z_agl = z - erf_prob_heights::z_ground_yface(i,j,z_sfc_nd); // height above the ground
66 
67  // Set the y-velocity
68  y_vel_pert(i, j, k) = V_0;
69  if ((z_agl <= pert_ref_height) && (V_0_Pert_Mag != zero))
70  {
71  Real rand_double = amrex::Random(engine); // Between zero and one
72  Real y_vel_prime = (rand_double*two - one)*V_0_Pert_Mag;
73  y_vel_pert(i, j, k) += y_vel_prime;
74  }
75  if (pert_deltaV != zero)
76  {
77  const amrex::Real xl = x - prob_lo[0];
78  const amrex::Real zl = z_agl / pert_ref_height;
79  const amrex::Real damp = std::exp(-myhalf * zl * zl);
80  y_vel_pert(i, j, k) += vfac * damp * z_agl * std::cos(bval * xl);
81  }
82  });
83 
84  // Set the z-velocity
85  ParallelForRNG(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const RandomEngine& engine) noexcept
86  {
87  const int dom_lo_z = geomdata.Domain().smallEnd()[2];
88  const int dom_hi_z = geomdata.Domain().bigEnd()[2];
89 
90  // Set the z-velocity
91  if (k == dom_lo_z || k == dom_hi_z+1)
92  {
93  z_vel_pert(i, j, k) = zero;
94  }
95  else
96  {
97  z_vel_pert(i, j, k) = W_0;
98  if (W_0_Pert_Mag != zero)
99  {
100  Real rand_double = amrex::Random(engine); // Between zero and one
101  Real z_vel_prime = (rand_double*two - one)*W_0_Pert_Mag;
102  z_vel_pert(i, j, k) += z_vel_prime;
103  }
104  }
105  });
const bool use_z_phys
Definition: ERF_InitCustomPertVels_RICO.H:3
const Real prob_lo_y
Definition: ERF_InitCustomPertVels_RICO.H:23
Real bval
Definition: ERF_InitCustomPertVels_RICO.H:27
Real aval
Definition: ERF_InitCustomPertVels_RICO.H:26
Real W_0_Pert_Mag
Definition: ERF_InitCustomPertVels_RICO.H:13
Real T_0_Pert_Mag
Definition: ERF_InitCustomPertVels_RICO.H:14
Real pert_ref_height
Definition: ERF_InitCustomPertVels_RICO.H:21
ParmParse pp_prob("prob")
Real U_0_Pert_Mag
Definition: ERF_InitCustomPertVels_RICO.H:11
const Real prob_lo_x
Definition: ERF_InitCustomPertVels_RICO.H:23
Real pert_periods_V
Definition: ERF_InitCustomPertVels_RICO.H:20
Real vfac
Definition: ERF_InitCustomPertVels_RICO.H:30
Real pert_deltaV
Definition: ERF_InitCustomPertVels_RICO.H:18
const Real prob_hi_y
Definition: ERF_InitCustomPertVels_RICO.H:24
Real U_0
Definition: ERF_InitCustomPertVels_RICO.H:7
const Real prob_hi_x
Definition: ERF_InitCustomPertVels_RICO.H:24
Real ufac
Definition: ERF_InitCustomPertVels_RICO.H:29
Real V_0
Definition: ERF_InitCustomPertVels_RICO.H:8
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+myhalf) *dx[1];const Real z=use_z_phys ? erf_prob_heights::z_xface(i, j, k, z_nd) :prob_lo[2]+(k+myhalf) *dx[2];const Real z_agl=z - erf_prob_heights::z_ground_xface(i, j, z_sfc_nd);x_vel_pert(i, j, k)=U_0;if((z_agl<=pert_ref_height) &&(U_0_Pert_Mag !=zero)) { Real rand_double=amrex::Random(engine);Real x_vel_prime=(rand_double *two - one) *U_0_Pert_Mag;x_vel_pert(i, j, k)+=x_vel_prime;} if(pert_deltaU !=zero) { const amrex::Real yl=y - prob_lo[1];const amrex::Real zl=z_agl/pert_ref_height;const amrex::Real damp=std::exp(-myhalf *zl *zl);x_vel_pert(i, j, k)+=ufac *damp *z_agl *std::cos(aval *yl);} })
Real pert_deltaU
Definition: ERF_InitCustomPertVels_RICO.H:17
Real pert_periods_U
Definition: ERF_InitCustomPertVels_RICO.H:19
Real W_0
Definition: ERF_InitCustomPertVels_RICO.H:9
Real V_0_Pert_Mag
Definition: ERF_InitCustomPertVels_RICO.H:12
Real qv_0_Pert_Mag
Definition: ERF_InitCustomPertVels_RICO.H:15
const Real dx
Definition: ERF_InitCustomPert_ABL.H:44
const GpuArray< Real, AMREX_SPACEDIM > prob_lo
Definition: ERF_InitCustomPert_CloudChamber.H:33
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:38
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
@ xl
Definition: ERF_WSM6.H:345
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real z_ground_xface(int i, int j, amrex::Array4< amrex::Real const > const &z_sfc_nd) noexcept
Height of the ground under x-face (i,j)
Definition: ERF_ProbHeights.H:58
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real z_yface(int i, int j, int k, amrex::Array4< amrex::Real const > const &z_nd) noexcept
Height of the centre of y-face (i,j,k)
Definition: ERF_ProbHeights.H:30
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real z_xface(int i, int j, int k, amrex::Array4< amrex::Real const > const &z_nd) noexcept
Height of the centre of x-face (i,j,k)
Definition: ERF_ProbHeights.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real z_ground_yface(int i, int j, amrex::Array4< amrex::Real const > const &z_sfc_nd) noexcept
Height of the ground under y-face (i,j)
Definition: ERF_ProbHeights.H:66