ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPertVels_CouettePoiseuille.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  const Real phys_z_lo = phys_zlo(geomdata, lev);
5  const Real phys_z_hi = phys_zhi(geomdata, lev);
6 
10 
11  ParmParse pp_for_pert_vels("prob");
12 
13  pp_for_pert_vels.query("U_0", U_0);
14  pp_for_pert_vels.query("V_0", V_0);
15  pp_for_pert_vels.query("W_0", W_0);
16 
17  int prob_type;
18  pp_for_pert_vels.get("prob_type", prob_type);
19 
21  prob_type == 10 || prob_type == 11 ||
22  prob_type == 20 || prob_type == 21);
23 
24 
27 
28  Real pert_delta_u = zero; pp_for_pert_vels.query("pert_delta_u", pert_delta_u);
29  Real pert_delta_v = zero; pp_for_pert_vels.query("pert_delta_v", pert_delta_v);
30 
31  auto problo = geomdata.ProbLo();
32  auto probhi = geomdata.ProbHi();
33 
34  Real aval = pert_periods_u * two * PI / (probhi[1] - problo[1]);
35  Real bval = pert_periods_v * two * PI / (probhi[0] - problo[0]);
36 
37  // Couette flow: the wall-parallel velocity grows linearly with the height above the bottom
38  if (prob_type == 1) {
39 
40  ParallelFor(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
41  const auto *const dx = geomdata.CellSize();
42  const Real z = use_z_phys ? erf_prob_heights::z_xface(i,j,k,z_nd) - phys_z_lo : (k + myhalf) * dx[2];
43  x_vel_pert(i, j, k) = U_0 * z / (phys_z_hi - phys_z_lo);
44  });
45 
46  ParallelFor(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
47  const auto *const dx = geomdata.CellSize();
48  const Real z = use_z_phys ? erf_prob_heights::z_yface(i,j,k,z_nd) - phys_z_lo : (k + myhalf) * dx[2];
49  y_vel_pert(i, j, k) = V_0 * z / (phys_z_hi - phys_z_lo);
50  });
51 
52  ParallelFor(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
53  z_vel_pert(i, j, k) = W_0;
54  });
55 
56  // Poiseuille flow
57  } else if (prob_type == 10 || prob_type == 11) {
58 
59  ParallelFor(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
60  {
61  const Real* prob_lo = geomdata.ProbLo();
62  const Real* dx = geomdata.CellSize();
63  const Real z_h = use_z_phys ? erf_prob_heights::z_xface(i,j,k,z_nd) : prob_lo[2] + (k + myhalf) * dx[2];
64 
65  // Set the x-velocity to be a parabolic profile with max 1 at z = 0 and 0 at z = +/-1
66  if (prob_type == 10) {
67  x_vel_pert(i, j, k) = one - z_h * z_h;
68  } else {
69  x_vel_pert(i, j, k) = zero;
70  }
71  });
72 
73  ParallelFor(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
74  {
75  const Real* prob_lo = geomdata.ProbLo();
76  const Real* dx = geomdata.CellSize();
77  const Real z_h = use_z_phys ? erf_prob_heights::z_yface(i,j,k,z_nd) : prob_lo[2] + (k + myhalf) * dx[2];
78 
79  // Set the x-velocity to be a parabolic profile with max 1 at z = 0 and 0 at z = +/-1
80  if (prob_type == 11) {
81  y_vel_pert(i, j, k) = one - z_h * z_h;
82  } else {
83  y_vel_pert(i, j, k) = zero;
84  }
85  });
86 
87  ParallelFor(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
88  {
89  z_vel_pert(i, j, k) = zero;
90  });
91 
92  // plane channel flow initialization
93  } else if (prob_type == 20 || prob_type == 21) {
94 
95  ParallelFor(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
96  {
97  const Real* prob_lo = geomdata.ProbLo();
98  const Real* prob_hi = geomdata.ProbHi();
99  const Real* dx = geomdata.CellSize();
100 
101 
102  const Real z = 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) );
103 
104  // Normalized wall-normal dist between -1 and 1
105  Real y_h = (prob_type == 20) ? two * (j + myhalf) * dx[1] / (prob_hi[1] - prob_lo[1]) - one
106  : two * (z - phys_z_lo) / (phys_z_hi - phys_z_lo) - one;
107 
108  x_vel_pert(i, j, k) = U_0 * (one - y_h * y_h);
109 
110  if (pert_delta_u != zero) {
111  const Real yl = (j + myhalf) * dx[1];
112  const Real scaling = std::cos(PI/two * y_h);
113  x_vel_pert(i, j, k) += pert_delta_u * scaling * std::cos(aval * yl);
114  }
115  });
116 
117  ParallelFor(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
118  {
119  const Real* prob_lo = geomdata.ProbLo();
120  const Real* prob_hi = geomdata.ProbHi();
121  const Real* dx = geomdata.CellSize();
122 
123  // Normalized wall-normal dist between -1 and 1
124  y_vel_pert(i, j, k) = zero;
125 
126  const Real z = fourth*( z_nd(i ,j,k) + z_nd(i ,j,k+1) + z_nd(i+1,j,k) + z_nd(i+1,j,k+1) );
127 
128  if (pert_delta_v != zero) {
129  const Real xl = (i + myhalf) * dx[0];
130  // v is on the y faces, so with y normal to the walls (prob_type 20) its
131  // position is j*dy, and the scaling vanishes on the walls themselves
132  Real y_h = (prob_type == 20) ? two * j * dx[1] / (prob_hi[1] - prob_lo[1]) - one
133  : two * (z - phys_z_lo) / (phys_z_hi - phys_z_lo) - one;
134  const Real scaling = std::cos(PI/two * y_h);
135  y_vel_pert(i, j, k) += pert_delta_v * scaling * std::cos(bval * xl);
136  }
137  });
138 
139  ParallelFor(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
140  {
141  z_vel_pert(i, j, k) = zero;
142  });
143  } // prob_type
const bool use_z_phys
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:3
Real pert_delta_v
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:29
Real bval
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:35
Real aval
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:34
ParmParse pp_for_pert_vels("prob")
auto probhi
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:32
const Real phys_z_hi
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:5
Real pert_periods_u
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:25
Real pert_periods_v
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:26
Real U_0
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:7
Real V_0
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:8
Real pert_delta_u
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:28
int prob_type
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:17
Real W_0
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:9
auto problo
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:31
AMREX_ALWAYS_ASSERT(prob_type==1||prob_type==10||prob_type==11||prob_type==20||prob_type==21)
const Real phys_z_lo
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:4
const Real dx
Definition: ERF_InitCustomPert_ABL.H:44
const GpuArray< Real, AMREX_SPACEDIM > prob_lo
Definition: ERF_InitCustomPert_CloudChamber.H:33
const amrex::Real * prob_hi
Definition: ERF_InitCustomPert_DataAssimilation_ISV.H:17
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
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
@ xl
Definition: ERF_WSM6.H:345
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