ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
erf_actuator::ZBounds Struct Reference

#include <ERF_ActuatorSampling.H>

Collaboration diagram for erf_actuator::ZBounds:

Public Member Functions

bool has_ground () const
 
bool has_table () const
 
void k_range (amrex::Real zl, amrex::Real zh, int klo, int khi, int &kb, int &kt) const
 

Public Attributes

amrex::Real ground_lo {0.0}
 
amrex::Real ground_hi {0.0}
 
amrex::Real dz_lo {0.0}
 
amrex::Real dz_hi {0.0}
 
bool all_ground {true}
 every box of the level reaches the ground (else the bounds hold for those that do) More...
 
int k0 {0}
 the node level of node_lo[0] and the cell of has_cell[0] More...
 
std::vector< amrex::Real > node_lo
 
std::vector< amrex::Real > node_hi
 node level k0 + n: the lowest and highest height (empty: no table) More...
 
std::vector< char > has_cell
 cell k0 + n is in one of the boxes More...
 

Detailed Description

The lowest and highest ground and the smallest and largest spacing of the levels (m) of a mesh, and, over one rank's boxes (mesh_z_bounds with over_all_ranks false) or the level's (mesh_z_levels), a table of each node level's lowest and highest height and of the cells those boxes hold, which bounds the cells a height may lie in whether or not the boxes reach the ground (a column split in z, a level aloft).

Member Function Documentation

◆ has_ground()

bool erf_actuator::ZBounds::has_ground ( ) const
inline

Whether the level's grids reach the ground (a refined level aloft does not, and has no bounds).

154 { return ground_lo <= ground_hi && dz_lo > amrex::Real(0.0); }

Referenced by k_range().

Here is the caller graph for this function:

◆ has_table()

bool erf_actuator::ZBounds::has_table ( ) const
inline

Whether the bounds come with the table of node heights: of one rank's boxes (mesh_z_bounds) or of every rank's (mesh_z_levels).

157 { return !has_cell.empty(); }
std::vector< char > has_cell
cell k0 + n is in one of the boxes
Definition: ERF_ActuatorSampling.H:151

Referenced by k_range(), erf_actuator::points_covered_by(), and erf_actuator::region_touches_grids().

Here is the caller graph for this function:

◆ k_range()

void erf_actuator::ZBounds::k_range ( amrex::Real  zl,
amrex::Real  zh,
int  klo,
int  khi,
int &  kb,
int &  kt 
) const
inline

The cells k that heights from zl to zh may lie in, whatever the column: [kb, kt], clamped to [klo - 1, khi + 1] (so a range outside the domain stays outside it); [klo, khi] without bounds. With the table: exactly the boxes' cells k whose lowest bottom node is not above zh and whose highest top node is not below zl, or kb > kt when there is none. zl or zh may be infinite (not NaN): heights from -infinity take every cell up to zh's, and a range at one infinity takes no cell of the domain.

168  {
169  kb = klo;
170  kt = khi;
171  if (has_table()) {
172  kb = khi + 1;
173  kt = klo - 1;
174  // a relative 1e-5 more each way: the caller's zl and zh are rounded sums (a point's height and
175  // its reach), and a face at a node level's own height h just past them still has weight
176  // From the finite ends only: an infinite end needs none. An infinite end is replaced by 0 before
177  // the difference is taken, not skipped by a test, so that inf - inf is never computed (a compiler
178  // may evaluate both sides of a test, and the invalid operation would trap)
179  const amrex::Real fl = std::isinf(zl) ? amrex::Real(0.0) : zl;
180  const amrex::Real fh = std::isinf(zh) ? amrex::Real(0.0) : zh;
181  const amrex::Real slack = amrex::Real(1.0e-5) * std::max(std::abs(fl), std::max(std::abs(fh), std::abs(fh - fl)));
182  const amrex::Real lo = zl - slack, hi = zh + slack;
183  for (std::size_t n = 0; n < has_cell.size(); ++n) {
184  if (has_cell[n] == 0 || node_lo[n] > hi || node_hi[n+1] < lo) { continue; }
185  const int k = k0 + static_cast<int>(n);
186  kb = std::min(kb, k);
187  kt = std::max(kt, k);
188  }
189  return;
190  }
191  if (!has_ground()) { return; }
192  // counted from the ground's cell klo. A cell that only touches the range at a node is not always
193  // within [kb, kt]: the spreader takes one face level more each way (reach_box_k())
194  const double b = klo + std::floor((static_cast<double>(zl) - ground_hi) / dz_hi);
195  const double t = klo + std::floor((static_cast<double>(zh) - ground_lo) / dz_lo);
196  kb = static_cast<int>(std::min<double>(khi + 1, std::max<double>(klo - 1, b)));
197  kt = static_cast<int>(std::min<double>(khi + 1, std::max<double>(klo - 1, t)));
198  }
const int khi
Definition: ERF_InitCustomPert_Bubble.H:25
const int klo
Definition: ERF_InitCustomPert_KE.H:9
@ t
Definition: ERF_WSM6.H:295
int k0
the node level of node_lo[0] and the cell of has_cell[0]
Definition: ERF_ActuatorSampling.H:149
bool has_ground() const
Definition: ERF_ActuatorSampling.H:154
amrex::Real dz_lo
Definition: ERF_ActuatorSampling.H:147
std::vector< amrex::Real > node_hi
node level k0 + n: the lowest and highest height (empty: no table)
Definition: ERF_ActuatorSampling.H:150
amrex::Real ground_hi
Definition: ERF_ActuatorSampling.H:147
amrex::Real dz_hi
Definition: ERF_ActuatorSampling.H:147
bool has_table() const
Definition: ERF_ActuatorSampling.H:157
amrex::Real ground_lo
Definition: ERF_ActuatorSampling.H:147
std::vector< amrex::Real > node_lo
Definition: ERF_ActuatorSampling.H:150

Referenced by erf_actuator::points_covered_by(), and erf_actuator::region_touches_grids().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ all_ground

bool erf_actuator::ZBounds::all_ground {true}

every box of the level reaches the ground (else the bounds hold for those that do)

Referenced by erf_actuator::mesh_z_bounds(), and erf_actuator::region_touches_grids().

◆ dz_hi

amrex::Real erf_actuator::ZBounds::dz_hi {0.0}

◆ dz_lo

amrex::Real erf_actuator::ZBounds::dz_lo {0.0}

◆ ground_hi

amrex::Real erf_actuator::ZBounds::ground_hi {0.0}

◆ ground_lo

amrex::Real erf_actuator::ZBounds::ground_lo {0.0}

◆ has_cell

std::vector<char> erf_actuator::ZBounds::has_cell

◆ k0

int erf_actuator::ZBounds::k0 {0}

the node level of node_lo[0] and the cell of has_cell[0]

Referenced by k_range(), and erf_actuator::erf_detail_ActuatorSampling::node_level_table().

◆ node_hi

std::vector<amrex::Real> erf_actuator::ZBounds::node_hi

node level k0 + n: the lowest and highest height (empty: no table)

Referenced by k_range(), erf_actuator::mesh_z_levels(), and erf_actuator::erf_detail_ActuatorSampling::node_level_table().

◆ node_lo

std::vector<amrex::Real> erf_actuator::ZBounds::node_lo

The documentation for this struct was generated from the following file: