ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF::ParticlePos Namespace Reference

Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real z_face_at_xy (amrex::Real x, amrex::Real y, int k_face, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &plo, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &dxi, amrex::Array4< amrex::Real const > const &height_arr) noexcept
 Bilinear interpolation of the height array at (x, y) for a given vertical node index k_face. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real z_from_zeta (amrex::Real x, amrex::Real y, amrex::Real zeta, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &plo, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &dxi, amrex::Array4< amrex::Real const > const &height_arr) noexcept
 Convert computational vertical coordinate zeta to physical z at column (x, y). More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real zeta_from_z (amrex::Real x, amrex::Real y, amrex::Real z, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &plo, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &dxi, amrex::Array4< amrex::Real const > const &height_arr, int k_max) noexcept
 Convert physical z to computational vertical coordinate zeta at column (x, y). More...
 

Function Documentation

◆ z_face_at_xy()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real ERF::ParticlePos::z_face_at_xy ( amrex::Real  x,
amrex::Real  y,
int  k_face,
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &  plo,
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &  dxi,
amrex::Array4< amrex::Real const > const &  height_arr 
)
noexcept

Bilinear interpolation of the height array at (x, y) for a given vertical node index k_face.

Parameters
[in]xPhysical x-coordinate.
[in]yPhysical y-coordinate.
[in]k_faceVertical node index.
[in]ploLower bound of the box.
[in]dxiInverse grid spacing.
[in]height_arrArray of node-centered heights.
Returns
Physical height z at the specified coordinates.
40 {
41  const amrex::Real lx = (x - plo[0]) * dxi[0];
42  const amrex::Real ly = (y - plo[1]) * dxi[1];
43  const int ix = static_cast<int>(amrex::Math::floor(lx));
44  const int iy = static_cast<int>(amrex::Math::floor(ly));
45  const amrex::Real fx = lx - static_cast<amrex::Real>(ix);
46  const amrex::Real fy = ly - static_cast<amrex::Real>(iy);
47  return height_arr(ix , iy , k_face) * (amrex::Real(1) - fx) * (amrex::Real(1) - fy)
48  + height_arr(ix+1, iy , k_face) * fx * (amrex::Real(1) - fy)
49  + height_arr(ix , iy+1, k_face) * (amrex::Real(1) - fx) * fy
50  + height_arr(ix+1, iy+1, k_face) * fx * fy;
51 }
amrex::Real Real
Definition: ERF_ShocInterface.H:19

Referenced by z_from_zeta(), and zeta_from_z().

Here is the caller graph for this function:

◆ z_from_zeta()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real ERF::ParticlePos::z_from_zeta ( amrex::Real  x,
amrex::Real  y,
amrex::Real  zeta,
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &  plo,
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &  dxi,
amrex::Array4< amrex::Real const > const &  height_arr 
)
noexcept

Convert computational vertical coordinate zeta to physical z at column (x, y).

Parameters
[in]xPhysical x-coordinate.
[in]yPhysical y-coordinate.
[in]zetaComputational vertical coordinate.
[in]ploLower bound of the box.
[in]dxiInverse grid spacing.
[in]height_arrArray of node-centered heights.
Returns
Physical height z.
75 {
76  if (!height_arr) {
77  return zeta; // no terrain: identity
78  }
79  const amrex::Real lz = (zeta - plo[AMREX_SPACEDIM-1]) * dxi[AMREX_SPACEDIM-1];
80  const int k = static_cast<int>(amrex::Math::floor(lz));
81  const amrex::Real fz = lz - static_cast<amrex::Real>(k);
82  const amrex::Real z_lo = z_face_at_xy(x, y, k , plo, dxi, height_arr);
83  const amrex::Real z_hi = z_face_at_xy(x, y, k + 1, plo, dxi, height_arr);
84  return (amrex::Real(1) - fz) * z_lo + fz * z_hi;
85 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real z_face_at_xy(amrex::Real x, amrex::Real y, int k_face, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &plo, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &dxi, amrex::Array4< amrex::Real const > const &height_arr) noexcept
Bilinear interpolation of the height array at (x, y) for a given vertical node index k_face.
Definition: ERF_TerrainConversion.H:36
Here is the call graph for this function:

◆ zeta_from_z()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real ERF::ParticlePos::zeta_from_z ( amrex::Real  x,
amrex::Real  y,
amrex::Real  z,
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &  plo,
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &  dxi,
amrex::Array4< amrex::Real const > const &  height_arr,
int  k_max 
)
noexcept

Convert physical z to computational vertical coordinate zeta at column (x, y).

Parameters
[in]xPhysical x-coordinate.
[in]yPhysical y-coordinate.
[in]zPhysical z-coordinate.
[in]ploLower bound of the box.
[in]dxiInverse grid spacing.
[in]height_arrArray of node-centered heights.
[in]k_maxLargest valid cell index in the level.
Returns
Computational vertical coordinate zeta.
111 {
112  if (!height_arr) {
113  return z; // no terrain: identity
114  }
115  const int k_lo = amrex::max(0, height_arr.begin[2]);
116  const int k_hi = amrex::min(k_max, height_arr.end[2] - 2);
117  int k = k_lo;
118  while (k < k_hi) {
119  const amrex::Real z_hi = z_face_at_xy(x, y, k + 1, plo, dxi, height_arr);
120  if (z < z_hi) { break; }
121  ++k;
122  }
123  const amrex::Real z_lo = z_face_at_xy(x, y, k , plo, dxi, height_arr);
124  const amrex::Real z_hi = z_face_at_xy(x, y, k + 1, plo, dxi, height_arr);
125  const amrex::Real fz = (z_hi > z_lo)
126  ? (z - z_lo) / (z_hi - z_lo)
127  : amrex::Real(0);
128  return plo[AMREX_SPACEDIM-1]
129  + (static_cast<amrex::Real>(k) + fz) / dxi[AMREX_SPACEDIM-1];
130 }
Here is the call graph for this function: