ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPertVels_TurbulentInflow.H
Go to the documentation of this file.
1  ParmParse pp_for_pert_vels("prob");
2 
3  Real rho_0 = one; pp_for_pert_vels.query("rho_0", rho_0);
4  Real T_0 = amrex::Real(300.0); pp_for_pert_vels.query("T_0", T_0);
5 
6  Real A_0 = one; pp_for_pert_vels.query("A_0", A_0);
7  Real KE_0 = amrex::Real(0.1); pp_for_pert_vels.query("KE_0", KE_0);
8 
9  Real KE_decay_height = -1; pp_for_pert_vels.query("KE_decay_height", KE_decay_height);
10  Real KE_decay_order = 1; pp_for_pert_vels.query("KE_decay_order", KE_decay_order);
11 
12  Real U_0 = zero; pp_for_pert_vels.query("U_0", U_0);
13  Real V_0 = zero; pp_for_pert_vels.query("V_0", V_0);
14  Real W_0 = zero; pp_for_pert_vels.query("W_0", W_0);
15 
16  // random initial perturbations (legacy code)
17  Real U_0_Pert_Mag = zero; pp_for_pert_vels.query("U_0_Pert_Mag", U_0_Pert_Mag);
18  Real V_0_Pert_Mag = zero; pp_for_pert_vels.query("V_0_Pert_Mag", V_0_Pert_Mag);
19  Real W_0_Pert_Mag = zero; pp_for_pert_vels.query("W_0_Pert_Mag", W_0_Pert_Mag);
20  Real T_0_Pert_Mag = zero; pp_for_pert_vels.query("T_0_Pert_Mag", T_0_Pert_Mag);
21  bool pert_rhotheta = true; pp_for_pert_vels.query("pert_rhotheta", pert_rhotheta);
22 
23  // divergence-free initial perturbations
24  Real pert_deltaU = zero; pp_for_pert_vels.query("pert_deltaU", pert_deltaU);
25  Real pert_deltaV = zero; pp_for_pert_vels.query("pert_deltaV", pert_deltaV);
28  Real pert_ref_height = amrex::Real(100.0); pp_for_pert_vels.query("pert_ref_height", pert_ref_height);
29 
30  // helper vars
31  const Real prob_lo_x = geomdata.ProbLo(0);
32  const Real prob_lo_y = geomdata.ProbLo(1);
33  const Real prob_hi_x = geomdata.ProbHi(0);
34  const Real prob_hi_y = geomdata.ProbHi(1);
39 
41 
42  // Set the x-velocity
43  ParallelForRNG(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine& engine) noexcept
44  {
45  const Real* prob_lo = geomdata.ProbLo();
46  const Real* dx = geomdata.CellSize();
47  const Real y = prob_lo[1] + (j + myhalf) * dx[1];
48  const Real z = use_terrain ? fourth*( z_nd(i,j ,k) + z_nd(i,j ,k+1)
49  + z_nd(i,j+1,k) + z_nd(i,j+1,k+1) )
50  : prob_lo[2] + (k + myhalf) * dx[2];
51  const Real z_agl = z - erf_prob_heights::z_ground_xface(i,j,z_sfc_nd); // height above the ground
52 
53  // Set the x-velocity
54  x_vel_pert(i, j, k) = U_0;
55  if ((z_agl <= pert_ref_height) && (U_0_Pert_Mag != zero))
56  {
57  Real rand_double = amrex::Random(engine); // Between zero and one
58  Real x_vel_prime = (rand_double*two - one)*U_0_Pert_Mag;
59  x_vel_pert(i, j, k) += x_vel_prime;
60  }
61  if (pert_deltaU != zero)
62  {
63  const Real yl = y - prob_lo[1];
64  const Real zl = z_agl / pert_ref_height;
65  const Real damp = std::exp(-myhalf * zl * zl);
66  x_vel_pert(i, j, k) += ufac * damp * z_agl * std::cos(aval * yl);
67  }
68  });
69 
70  // Set the y-velocity
71  ParallelForRNG(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine& engine) noexcept {
72  const Real* prob_lo = geomdata.ProbLo();
73  const Real* dx = geomdata.CellSize();
74  const Real x = prob_lo[0] + (i + myhalf) * dx[0];
75  const Real z = use_terrain ? fourth*( z_nd(i ,j,k) + z_nd(i ,j,k+1)
76  + z_nd(i+1,j,k) + z_nd(i+1,j,k+1) )
77  : prob_lo[2] + (k + myhalf) * dx[2];
78  const Real z_agl = z - erf_prob_heights::z_ground_yface(i,j,z_sfc_nd); // height above the ground
79 
80  // Set the y-velocity
81  y_vel_pert(i, j, k) = V_0;
82  if ((z_agl <= pert_ref_height) && (V_0_Pert_Mag != zero))
83  {
84  Real rand_double = amrex::Random(engine); // Between zero and one
85  Real y_vel_prime = (rand_double*two - one)*V_0_Pert_Mag;
86  y_vel_pert(i, j, k) += y_vel_prime;
87  }
88  if (pert_deltaV != zero)
89  {
90  const Real xl = x - prob_lo[0];
91  const Real zl = z_agl / pert_ref_height;
92  const Real damp = std::exp(-myhalf * zl * zl);
93  y_vel_pert(i, j, k) += vfac * damp * z_agl * std::cos(bval * xl);
94  }
95  });
96 
97  // Set the z-velocity
98  ParallelForRNG(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine& engine) noexcept {
99  const int dom_lo_z = geomdata.Domain().smallEnd()[2];
100  const int dom_hi_z = geomdata.Domain().bigEnd()[2];
101 
102  // Set the z-velocity
103  if (k == dom_lo_z || k == dom_hi_z+1)
104  {
105  z_vel_pert(i, j, k) = zero;
106  }
107  else
108  {
109  z_vel_pert(i, j, k) = W_0;
110  if (W_0_Pert_Mag != zero)
111  {
112  Real rand_double = amrex::Random(engine); // Between zero and one
113  Real z_vel_prime = (rand_double*two - one)*W_0_Pert_Mag;
114  z_vel_pert(i, j, k) += z_vel_prime;
115  }
116  }
117  });
const bool use_terrain
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:40
const Real prob_lo_y
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:32
Real bval
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:36
Real aval
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:35
Real W_0_Pert_Mag
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:19
Real T_0_Pert_Mag
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:20
Real pert_ref_height
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:28
Real KE_0
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:7
Real rho_0
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:3
ParmParse pp_for_pert_vels("prob")
Real U_0_Pert_Mag
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:17
const Real prob_lo_x
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:31
Real pert_periods_V
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:27
Real vfac
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:38
Real T_0
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:4
Real pert_deltaV
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:25
const Real prob_hi_y
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:34
Real U_0
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:12
const Real prob_hi_x
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:33
Real ufac
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:37
Real KE_decay_order
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:10
Real V_0
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:13
Real pert_deltaU
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:24
Real pert_periods_U
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:26
Real KE_decay_height
Definition: ERF_InitCustomPertVels_TurbulentInflow.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+myhalf) *dx[1];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)=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 Real yl=y - prob_lo[1];const Real zl=z_agl/pert_ref_height;const Real damp=std::exp(-myhalf *zl *zl);x_vel_pert(i, j, k)+=ufac *damp *z_agl *std::cos(aval *yl);} })
bool pert_rhotheta
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:21
Real W_0
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:14
Real A_0
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:6
Real V_0_Pert_Mag
Definition: ERF_InitCustomPertVels_TurbulentInflow.H:18
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 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