ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPertVels_Terrain3DHemisphere.H
Go to the documentation of this file.
1 
2  amrex::Gpu::streamSynchronize();
3  ParmParse pp_for_pert_vels("prob");
4  Real U_0 = zero; pp_for_pert_vels.query("U_0", U_0);
5  Real V_0 = zero; pp_for_pert_vels.query("V_0", V_0);
6  Real U_0_Pert_Mag = zero; pp_for_pert_vels.query("U_0_Pert_Mag", U_0_Pert_Mag);
7  Real V_0_Pert_Mag = zero; pp_for_pert_vels.query("V_0_Pert_Mag", V_0_Pert_Mag);
8  Real W_0_Pert_Mag = zero; pp_for_pert_vels.query("W_0_Pert_Mag", W_0_Pert_Mag);
9  Real pert_deltaU = zero; pp_for_pert_vels.query("pert_deltaU", pert_deltaU);
10  Real pert_deltaV = zero; pp_for_pert_vels.query("pert_deltaV", pert_deltaV);
12  Real pert_periods_V = amrex::Real(5.0); pp_for_pert_vels.query("pert_periods_V", pert_periods_V);;
14 
15  pp_for_pert_vels.query("pert_ref_height", pert_ref_height);
16 
17  // Real aval = pert_periods_U * two * PI / (probhi[1] - problo[1]);
18  // Real ufac = pert_deltaU * std::exp(myhalf) / pert_ref_height;
19 
20  const Real* problo = geomdata.ProbLo();
21  const Real* probhi = geomdata.ProbHi();
22 
23  Real bval = pert_periods_V * two * PI / (probhi[0] - problo[0]);
25 
27 
28  // Set the x-velocity
29  ParallelForRNG(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine& engine) noexcept
30  {
31  const Real* prob_lo = geomdata.ProbLo();
32  const Real* dx = geomdata.CellSize();
33  const Real z = use_terrain ? fourth*( z_nd(i,j ,k) + z_nd(i,j ,k+1)
34  + z_nd(i,j+1,k) + z_nd(i,j+1,k+1) )
35  : prob_lo[2] + (k + myhalf) * dx[2];
36  const Real z_agl = z - erf_prob_heights::z_ground_xface(i,j,z_sfc_nd); // height above the ground
37 
38  x_vel_pert(i, j, k) = zero;
39  if ((z_agl <= pert_ref_height) && (U_0_Pert_Mag != zero))
40  {
41  Real rand_double = amrex::Random(engine); // Between zero and one
42  Real x_vel_prime = (rand_double*two - one)*U_0_Pert_Mag;
43  x_vel_pert(i, j, k) += x_vel_prime;
44  }
45  });
46 
47  // Set the y-velocity
48  ParallelForRNG(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine& engine) noexcept
49  {
50  const Real* prob_lo = geomdata.ProbLo();
51  const Real* dx = geomdata.CellSize();
52  const Real x = prob_lo[0] + (i + myhalf) * dx[0];
53  const Real z = use_terrain ? fourth*( z_nd(i ,j,k) + z_nd(i ,j,k+1)
54  + z_nd(i+1,j,k) + z_nd(i+1,j,k+1) )
55  : prob_lo[2] + (k + myhalf) * dx[2];
56  const Real z_agl = z - erf_prob_heights::z_ground_yface(i,j,z_sfc_nd); // height above the ground
57 
58  // Set the y-velocity
59  y_vel_pert(i, j, k) = zero;
60  if ((z_agl <= pert_ref_height) && (V_0_Pert_Mag != zero))
61  {
62  Real rand_double = amrex::Random(engine); // Between zero and one
63  Real y_vel_prime = (rand_double*two - one)*V_0_Pert_Mag;
64  y_vel_pert(i, j, k) += y_vel_prime;
65  }
66  if (pert_deltaV != zero)
67  {
68  const Real xl = x - prob_lo[0];
69  const Real zl = z_agl / pert_ref_height;
70  const Real damp = std::exp(-myhalf * zl * zl);
71  y_vel_pert(i, j, k) += vfac * damp * z_agl * std::cos(bval * xl);
72  }
73  });
74 
75  const auto dx = geomdata.CellSize();
76  amrex::GpuArray<Real, AMREX_SPACEDIM> dxInv;
77  dxInv[0] = one / dx[0];
78  dxInv[1] = one / dx[1];
79  dxInv[2] = one / dx[2];
80 
81  // Set the z-velocity from impenetrable condition
82  ParallelForRNG(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine& engine) noexcept
83  {
84  const int dom_lo_z = geomdata.Domain().smallEnd()[2];
85  const int dom_hi_z = geomdata.Domain().bigEnd()[2];
86 
87  // Set the z-velocity
88  if (k == dom_lo_z || k == dom_hi_z+1)
89  {
90  z_vel_pert(i, j, k) = zero;
91  }
92  else if (W_0_Pert_Mag != zero)
93  {
94  Real rand_double = amrex::Random(engine); // Between zero and one
95  Real z_vel_prime = (rand_double*two - one)*W_0_Pert_Mag;
96  z_vel_pert(i, j, k) = z_vel_prime;
97  }
98  });
const bool use_terrain
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:26
Real bval
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:23
Real W_0_Pert_Mag
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:8
const Real * problo
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:20
Real pert_ref_height
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:13
ParmParse pp_for_pert_vels("prob")
Real U_0_Pert_Mag
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:6
Real pert_periods_V
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:12
Real vfac
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:24
Real pert_deltaV
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:10
Real U_0
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:4
Real V_0
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:5
Real pert_deltaU
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:9
Real pert_periods_U
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:11
const auto dx
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:75
Real V_0_Pert_Mag
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:7
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 z=use_terrain ? fourth *(z_nd(i, j, k)+z_nd(i, j, k+1)+z_nd(i, j+1, k)+z_nd(i, j+1, k+1)) :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)=zero;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;} })
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:76
const Real * probhi
Definition: ERF_InitCustomPertVels_Terrain3DHemisphere.H:21
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 fourth
Definition: ERF_NumericalConstants.H:42
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
@ None
Definition: ERF_LSM_Types.H:6
@ 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_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
static TerrainType terrain_type
Terrain or immersed-boundary representation.
Definition: ERF_DataStruct.H:2589