1 #ifndef ERF_INFLOW_PROFILE_H_
2 #define ERF_INFLOW_PROFILE_H_
18 #include <AMReX_Array4.H>
19 #include <AMReX_Gpu.H>
20 #include <AMReX_GpuContainers.H>
21 #include <AMReX_REAL.H>
22 #include <AMReX_Vector.H>
43 amrex::Real
speed = amrex::Real(-1.0);
44 amrex::Real
height = amrex::Real(10.0);
46 amrex::Real
z0 = amrex::Real(0.1);
49 amrex::Real
Cmu0 = amrex::Real(0.5562);
62 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
64 inflow_profile_value (
const amrex::Real* z,
const amrex::Real* f,
const int n,
const amrex::Real zq) noexcept
66 if (zq <=
z[0]) {
return f[0]; }
67 if (zq >=
z[n-1]) {
return f[n-1]; }
71 const int mid = (
lo +
hi) / 2;
72 if (
z[mid] <= zq) {
lo = mid; }
else {
hi = mid; }
74 const amrex::Real w = (zq -
z[
lo]) / (
z[
hi] -
z[
lo]);
75 return f[
lo] + w * (f[
hi] - f[
lo]);
84 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
87 int ilo,
int ihi,
int jlo,
int jhi,
const int k,
const int klo) noexcept
89 const auto lo = amrex::lbound(z_nd);
90 const auto hi = amrex::ubound(z_nd);
91 ilo = amrex::max(
lo.x, amrex::min(ilo,
hi.x));
92 ihi = amrex::max(
lo.x, amrex::min(ihi,
hi.x));
93 jlo = amrex::max(
lo.y, amrex::min(jlo,
hi.y));
94 jhi = amrex::max(
lo.y, amrex::min(jhi,
hi.y));
95 const int kc = amrex::max(
lo.z, amrex::min(k,
hi.z - 1));
96 const int kg = amrex::max(
lo.z, amrex::min(
klo,
hi.z));
97 amrex::Real sum = amrex::Real(0.0);
99 for (
int j = jlo; j <= jhi; ++j) {
100 for (
int i = ilo; i <= ihi; ++i) {
101 sum += amrex::Real(0.5) * (z_nd(i,j,kc) + z_nd(i,j,kc+1)) - z_nd(i,j,kg);
105 return sum /
static_cast<amrex::Real
>(
count);
int count
Definition: ERF_ActuatorSpreading.cpp:264
void read_inflow_profile_file(const std::string &fname, InflowProfile &prof)
Definition: ERF_InflowProfile.cpp:171
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real inflow_profile_value(const amrex::Real *z, const amrex::Real *f, const int n, const amrex::Real zq) noexcept
Definition: ERF_InflowProfile.H:64
std::string parse_inflow_profile(std::istream &is, InflowProfile &prof)
Definition: ERF_InflowProfile.cpp:53
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real height_above_ground(const amrex::Array4< const amrex::Real > &z_nd, int ilo, int ihi, int jlo, int jhi, const int k, const int klo) noexcept
Definition: ERF_InflowProfile.H:86
std::string make_log_law_inflow_profile(const InflowLogLaw &p, amrex::Real ztop, InflowProfile &prof)
const Real ztop
Definition: ERF_InitCustomPertVels_ParticleTests.H:4
const int klo
Definition: ERF_InitCustomPert_KE.H:9
@ p
Definition: ERF_WSM6.H:303
Definition: ERF_InflowProfile.H:42
amrex::Real height
reference height above the ground [m]
Definition: ERF_InflowProfile.H:44
amrex::Real speed
wind speed at height [m/s] (required)
Definition: ERF_InflowProfile.H:43
amrex::Real Cmu0
tke at the ground is u*^2 / Cmu0^2
Definition: ERF_InflowProfile.H:49
amrex::Real z0
roughness length [m]
Definition: ERF_InflowProfile.H:46
amrex::Real direction
direction the wind blows from [deg, meteorological]
Definition: ERF_InflowProfile.H:45
amrex::Real max_speed
cap on the speed; <= 0 means none
Definition: ERF_InflowProfile.H:47
amrex::Real tke_zscale
tke tapers linearly to zero at u* tke_zscale
Definition: ERF_InflowProfile.H:48
Definition: ERF_InflowProfile.H:25
amrex::Vector< amrex::Real > tke
Definition: ERF_InflowProfile.H:32
bool has_tke
Definition: ERF_InflowProfile.H:28
void copy_to_device()
Definition: ERF_InflowProfile.cpp:18
amrex::Vector< amrex::Real > theta
Definition: ERF_InflowProfile.H:32
amrex::Gpu::DeviceVector< amrex::Real > z_d
Device copies used by the boundary fills.
Definition: ERF_InflowProfile.H:35
amrex::Gpu::DeviceVector< amrex::Real > theta_d
Definition: ERF_InflowProfile.H:35
amrex::Gpu::DeviceVector< amrex::Real > tke_d
Definition: ERF_InflowProfile.H:35
amrex::Vector< amrex::Real > v
Definition: ERF_InflowProfile.H:32
std::string source
"log_law" or the profile file name
Definition: ERF_InflowProfile.H:29
amrex::Gpu::DeviceVector< amrex::Real > u_d
Definition: ERF_InflowProfile.H:35
amrex::Gpu::DeviceVector< amrex::Real > v_d
Definition: ERF_InflowProfile.H:35
amrex::Vector< amrex::Real > z
Host tables against height above the ground (strictly increasing)
Definition: ERF_InflowProfile.H:32
bool has_theta
Definition: ERF_InflowProfile.H:27
bool active
Definition: ERF_InflowProfile.H:26
amrex::Vector< amrex::Real > u
Definition: ERF_InflowProfile.H:32