ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPertVels_CouettePoiseuille.H
Go to the documentation of this file.
1  Real U_0 = 0.0;
2  Real V_0 = 0.0;
3  Real W_0 = 0.0;
4 
5  ParmParse pp_for_pert_vels("prob");
6 
7  pp_for_pert_vels.query("U_0", U_0);
8  pp_for_pert_vels.query("V_0", V_0);
9  pp_for_pert_vels.query("W_0", W_0);
10 
11  int prob_type;
12  pp_for_pert_vels.get("prob_type", prob_type);
13 
15  prob_type == 10 || prob_type == 11 ||
16  prob_type == 20 || prob_type == 21);
17 
18 
19  Real pert_periods_u = 5.0; pp_for_pert_vels.query("pert_periods_u", pert_periods_u);
20  Real pert_periods_v = 5.0; pp_for_pert_vels.query("pert_periods_v", pert_periods_v);
21 
22  Real pert_delta_u = 0.0; pp_for_pert_vels.query("pert_delta_u", pert_delta_u);
23  Real pert_delta_v = 0.0; pp_for_pert_vels.query("pert_delta_u", pert_delta_v);
24 
25  Real pert_lo = -1e34; pp_for_pert_vels.query("pert_lo", pert_lo);
26  Real pert_hi = 1e34; pp_for_pert_vels.query("pert_hi", pert_hi);
27 
28  auto problo = geomdata.ProbLo();
29  auto probhi = geomdata.ProbHi();
30 
31  Real aval = pert_periods_u * 2.0 * PI / (probhi[1] - problo[1]);
32  Real bval = pert_periods_v * 2.0 * PI / (probhi[0] - problo[0]);
33 
34  // Couette flow
35  if (prob_type == 1) {
36 
37  ParallelFor(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
38  const auto *const prob_hi = geomdata.ProbHi();
39  const auto *const dx = geomdata.CellSize();
40  const Real z = (k + 0.5) * dx[2];
41  x_vel_pert(i, j, k) = U_0 * z / prob_hi[2];
42  });
43 
44  ParallelFor(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
45  const auto *const prob_hi = geomdata.ProbHi();
46  const auto *const dx = geomdata.CellSize();
47  const Real z = (k + 0.5) * dx[2];
48  y_vel_pert(i, j, k) = V_0 * z / prob_hi[2];
49  });
50 
51  ParallelFor(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
52  z_vel_pert(i, j, k) = W_0;
53  });
54 
55  // Poiseuille flow
56  } else if (prob_type == 10 || prob_type == 11) {
57 
58  ParallelFor(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
59  {
60  const Real* prob_lo = geomdata.ProbLo();
61  const Real* dx = geomdata.CellSize();
62  const Real z_h = prob_lo[2] + (k + 0.5) * dx[2];
63 
64  // Set the x-velocity to be a parabolic profile with max 1 at z = 0 and 0 at z = +/-1
65  if (prob_type == 10) {
66  x_vel_pert(i, j, k) = 1.0 - z_h * z_h;
67  } else {
68  x_vel_pert(i, j, k) = 0.0;
69  }
70  });
71 
72  ParallelFor(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
73  {
74  const Real* prob_lo = geomdata.ProbLo();
75  const Real* dx = geomdata.CellSize();
76  const Real z_h = prob_lo[2] + (k + 0.5) * dx[2];
77 
78  // Set the x-velocity to be a parabolic profile with max 1 at z = 0 and 0 at z = +/-1
79  if (prob_type == 11) {
80  y_vel_pert(i, j, k) = 1.0 - z_h * z_h;
81  } else {
82  y_vel_pert(i, j, k) = 0.0;
83  }
84  });
85 
86  ParallelFor(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
87  {
88  z_vel_pert(i, j, k) = 0.0;
89  });
90 
91  // plane channel flow initialization
92  } else if (prob_type == 20 || prob_type == 21) {
93 
94  ParallelFor(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
95  {
96  const Real* prob_lo = geomdata.ProbLo();
97  const Real* prob_hi = geomdata.ProbHi();
98  const Real* dx = geomdata.CellSize();
99 
100 
101  const Real z = 0.25*( z_nd(i,j ,k) + z_nd(i,j ,k+1) + z_nd(i,j+1,k) + z_nd(i,j+1,k+1) );
102 
103  // Normalized wall-normal dist between -1 and 1
104  Real y_h = (prob_type == 20) ? 2.0 * (j + 0.5) * dx[1] / (prob_hi[1] - prob_lo[1]) - 1.0
105  : 2.0 * (z - prob_lo[2]) / (prob_hi[2] - prob_lo[2]) - 1.0;
106 
107  x_vel_pert(i, j, k) = U_0 * (1.0 - y_h * y_h);
108 
109  if (pert_delta_u != 0.0) {
110  const Real yl = (j + 0.5) * dx[1];
111  const Real scaling = std::cos(PI/2.0 * y_h);
112  x_vel_pert(i, j, k) += pert_delta_u * scaling * std::cos(aval * yl);
113  }
114  });
115 
116  ParallelFor(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
117  {
118  const Real* prob_lo = geomdata.ProbLo();
119  const Real* prob_hi = geomdata.ProbHi();
120  const Real* dx = geomdata.CellSize();
121 
122  // Normalized wall-normal dist between -1 and 1
123  y_vel_pert(i, j, k) = 0.0;
124 
125  const Real z = 0.25*( z_nd(i ,j,k) + z_nd(i ,j,k+1) + z_nd(i+1,j,k) + z_nd(i+1,j,k+1) );
126 
127  if (pert_delta_u != 0.0) {
128  const Real xl = (i + 0.5) * dx[0];
129  Real y_h = (prob_type == 20) ? 2.0 * (j + 0.5) * dx[1] / (prob_hi[1] - prob_lo[1]) - 1.0
130  : 2.0 * (z - prob_lo[2]) / (prob_hi[2] - prob_lo[2]) - 1.0;
131  const Real scaling = std::cos(PI/2.0 * y_h);
132  y_vel_pert(i, j, k) += pert_delta_v * scaling * std::cos(bval * xl);
133  }
134  });
135 
136  ParallelFor(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
137  {
138  z_vel_pert(i, j, k) = 0.0;
139  });
140  } // prob_type
constexpr amrex::Real PI
Definition: ERF_Constants.H:6
Real pert_delta_v
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:23
Real bval
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:32
Real aval
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:31
ParmParse pp_for_pert_vels("prob")
auto probhi
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:29
Real pert_periods_u
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:19
Real pert_periods_v
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:20
Real U_0
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:1
Real V_0
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:2
Real pert_delta_u
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:22
Real pert_lo
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:25
int prob_type
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:11
Real W_0
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:3
auto problo
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:28
AMREX_ALWAYS_ASSERT(prob_type==1||prob_type==10||prob_type==11||prob_type==20||prob_type==21)
Real pert_hi
Definition: ERF_InitCustomPertVels_CouettePoiseuille.H:26
const auto dx
Definition: ERF_InitCustomPertVels_ParticleTests.H:15
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const auto prob_lo=geomdata.ProbLo();const auto dx=geomdata.CellSize();const Real x=(prob_lo[0]+(i+0.5) *dx[0])/mf_m(i, j, 0);const Real z=z_cc(i, j, k);Real L=std::sqrt(std::pow((x - x_c)/x_r, 2)+std::pow((z - z_c)/z_r, 2));if(L<=1.0) { Real dT=T_pert *(std::cos(PI *L)+1.0)/2.0;Real Tbar_hse=p_hse(i, j, k)/(R_d *r_hse(i, j, k));Real theta_perturbed=(Tbar_hse+dT) *std::pow(p_0/p_hse(i, j, k), rdOcp);Real theta_0=(Tbar_hse) *std::pow(p_0/p_hse(i, j, k), rdOcp);if(const_rho) { state_pert(i, j, k, RhoTheta_comp)=r_hse(i, j, k) *(theta_perturbed - theta_0);} else { state_pert(i, j, k, Rho_comp)=getRhoThetagivenP(p_hse(i, j, k))/theta_perturbed - r_hse(i, j, k);} } })
const amrex::Real * prob_lo
Definition: ERF_InitCustomPert_IsentropicVortex.H:16
const amrex::Real * prob_hi
Definition: ERF_InitCustomPert_IsentropicVortex.H:17
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