ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPertVels_EkmanSpiral.H
Go to the documentation of this file.
1 
2  // On a mesh other than ConstantDz, heights come from z_nd and the vertical levels,
3  // not from geomdata's prob_lo[2], prob_hi[2] and CellSize(2)
4  const bool use_z_phys = use_physical_z();
5  const Real phys_z_lo = phys_zlo(geomdata, lev);
6 
7  ParmParse pp_for_pert_vels("erf");
8  InitType init_type = InitType::None; // the default of erf.init_type
9  pp_for_pert_vels.query_enum_case_insensitive("init_type",init_type);
10 
11  ParmParse pp_for_pert_vels_prob("prob");
13 
14  if (init_type == InitType::Uniform)
15  {
16  double rot_time_period;
17  pp_for_pert_vels.get("rotational_time_period", rot_time_period);
18  Real coriolis_factor = static_cast<Real>(4.0 * PI / rot_time_period);
19 
20  Real Az;
21  pp_for_pert_vels.get("dynamic_viscosity", Az); // dynamic viscosity [kg-m/s]
22  Az = Az / rho_0; // kinematic viscosity [m^2/s]
23 
24  Vector<Real> abl_geo_wind(3);
25  pp_for_pert_vels.queryarr("abl_geo_wind",abl_geo_wind);
27  (amrex::Math::abs(abl_geo_wind[1]) < amrex::Real(1.0e-15)) &&
28  (amrex::Math::abs(abl_geo_wind[2]) < amrex::Real(1.0e-15)),
29  "Ekman Spiral uses geostrophic forcing of the form (V_0, 0, 0)");
30  const Real u_0 = abl_geo_wind[0];
31 
32  const Real DE = std::sqrt(two * Az / coriolis_factor);
33  const Real a = one / DE;
34 
35  // Set the x-velocity
36  ParallelFor(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
37  const auto dx = geomdata.CellSize();
38  const Real z = use_z_phys ? erf_prob_heights::z_xface(i,j,k,z_nd) - phys_z_lo : (k + myhalf) * dx[2];
39 
40  // Set the x-velocity
41  x_vel_pert(i, j, k) = u_0 * (one - std::exp(-a * z) * std::cos(-a * z));
42  });
43 
44  // Set the y-velocity
45  ParallelFor(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
46  const auto dx = geomdata.CellSize();
47  const Real z = use_z_phys ? erf_prob_heights::z_yface(i,j,k,z_nd) - phys_z_lo : (k + myhalf) * dx[2];
48 
49  // Set the y-velocity
50  y_vel_pert(i, j, k) = -u_0 * std::exp(-a * z) * std::sin(-a * z);
51  });
52 
53  // Set the z-velocity
54  ParallelFor(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
55  z_vel_pert(i, j, k) = zero;
56  });
57  } // end if uniform
const bool use_z_phys
Definition: ERF_InitCustomPertVels_EkmanSpiral.H:4
InitType init_type
Definition: ERF_InitCustomPertVels_EkmanSpiral.H:8
Real rho_0
Definition: ERF_InitCustomPertVels_EkmanSpiral.H:12
ParmParse pp_for_pert_vels("erf")
ParmParse pp_for_pert_vels_prob("prob")
const Real phys_z_lo
Definition: ERF_InitCustomPertVels_EkmanSpiral.H:5
const Real dx
Definition: ERF_InitCustomPert_ABL.H:44
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
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 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
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