ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
MOSTAverage::InterpStencilBounds Struct Reference

#include <ERF_MOSTAverage.H>

Collaboration diagram for MOSTAverage::InterpStencilBounds:

Public Member Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void clamp_to_held (const int i, const int j, amrex::Real &xp, amrex::Real &yp, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &plo, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxi) const
 

Public Attributes

amrex::GpuArray< amrex::Box, 5 > reach
 
amrex::GpuArray< amrex::Box, 5 > held
 
int nfields = 0
 

Detailed Description

Lateral bounds on the interpolation stencil of the MOST reference points in one box.

The average of field n (U, V, W, T, Qv) reads the positions of the columns in reach[n], its own staggered box grown by the ghost cells the averages fill and the radius, and interpolates from the two cells in x and in y that bracket each point; those cells must lie in held[n], the cells its FAB holds. The tangential speed and virtual temperature averages read U, V, T and Qv at cell-centered columns, which lie in the reaches of those fields.

get_ng_fill leaves the stencil one cell of room at the outermost columns, so a point displaced along the terrain normal by more than a cell can leave the data there, whatever the number of ghost cells.

Member Function Documentation

◆ clamp_to_held()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void MOSTAverage::InterpStencilBounds::clamp_to_held ( const int  i,
const int  j,
amrex::Real &  xp,
amrex::Real &  yp,
const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &  plo,
const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &  dxi 
) const
inline

Move the point (xp,yp) read by column (i,j) the least distance, in x and in y, that puts its stencil in the data of every field whose average reads the column. As set_norm_indices_T does without interpolation, a displacement past the ghost cells then uses the nearest point held; only ghost columns near the edge of the box are moved, whose averages FillBoundary overwrites where boxes abut.

622  {
623  // Lowest and highest lower cell of the two that bracket the point, as
624  // trilinear_interp_T reads them, for every field that reads this column
625  int ilo = std::numeric_limits<int>::lowest(), ihi = std::numeric_limits<int>::max();
626  int jlo = std::numeric_limits<int>::lowest(), jhi = std::numeric_limits<int>::max();
627  for (int n = 0; n < nfields; ++n) {
628  const amrex::Box& r = reach[n];
629  if (i < r.smallEnd(0) || i > r.bigEnd(0) ||
630  j < r.smallEnd(1) || j > r.bigEnd(1)) { continue; }
631  const amrex::Box& h = held[n];
632  ilo = amrex::max(ilo, h.smallEnd(0)); ihi = amrex::min(ihi, h.bigEnd(0) - 1);
633  jlo = amrex::max(jlo, h.smallEnd(1)); jhi = amrex::min(jhi, h.bigEnd(1) - 1);
634  }
635 
636  // Position in units of cells, measured from the center of cell 0; a point
637  // already held is left exactly as it is
638  const amrex::Real xi = (xp - plo[0]) * dxi[0] - myhalf;
639  const amrex::Real yj = (yp - plo[1]) * dxi[1] - myhalf;
640  if (xi < amrex::Real(ilo)) { xp = plo[0] + (amrex::Real(ilo) + myhalf) / dxi[0]; }
641  if (xi > amrex::Real(ihi)) { xp = plo[0] + (amrex::Real(ihi) + myhalf) / dxi[0]; }
642  if (yj < amrex::Real(jlo)) { yp = plo[1] + (amrex::Real(jlo) + myhalf) / dxi[1]; }
643  if (yj > amrex::Real(jhi)) { yp = plo[1] + (amrex::Real(jhi) + myhalf) / dxi[1]; }
644  }
GpuArray< Real, AMREX_SPACEDIM > plo
Definition: ERF_ActuatorSpreading.cpp:131
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
amrex::GpuArray< amrex::Box, 5 > reach
Definition: ERF_MOSTAverage.H:605
int nfields
Definition: ERF_MOSTAverage.H:607
amrex::GpuArray< amrex::Box, 5 > held
Definition: ERF_MOSTAverage.H:606

Member Data Documentation

◆ held

amrex::GpuArray<amrex::Box,5> MOSTAverage::InterpStencilBounds::held

◆ nfields

int MOSTAverage::InterpStencilBounds::nfields = 0

◆ reach

amrex::GpuArray<amrex::Box,5> MOSTAverage::InterpStencilBounds::reach

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