ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_PlanarBoundary.cpp File Reference
#include <ERF_PlanarBoundary.H>
#include <algorithm>
Include dependency graph for ERF_PlanarBoundary.cpp:

Functions

std::unique_ptr< MultiFab > copy_ground_plane (const MultiFab &src, int klo)
 
void sum_over_stacked_boxes (MultiFab &mf, int comp, int ncomp)
 

Function Documentation

◆ copy_ground_plane()

std::unique_ptr<MultiFab> copy_ground_plane ( const MultiFab &  src,
int  klo 
)

The ground plane of a field on a level's 3D grids, on one planar box per 3D box (see ERF_PlanarBoundary.H).

Parameters
[in]srcfield on the level's 3D grids
[in]kloindex of the lowest cell of the domain
137 {
138  const IndexType ixtype = src.ixType();
139  const BoxArray& ba = src.boxArray();
140  const int ncomp = src.nComp();
141 
142  BoxList bl(ixtype);
143  for (int ib = 0; ib < static_cast<int>(ba.size()); ++ib) {
144  Box b = enclosedCells(ba[ib]);
145  b.setRange(2, klo);
146  bl.push_back(convert(b, ixtype));
147  }
148  auto plane = std::make_unique<MultiFab>(BoxArray(std::move(bl)), src.DistributionMap(), ncomp, 0);
149 
150  // Every box first holds the lowest plane of its own 3D box, so that it holds finite
151  // values even over columns in which no box reaches the ground
152  for (MFIter mfi(*plane); mfi.isValid(); ++mfi) {
153  const Box& pbx = mfi.validbox();
154  const int dk = enclosedCells(ba[mfi.index()]).smallEnd(2) - klo;
155  (*plane)[mfi].copy<RunOn::Device>(src[mfi], amrex::shift(pbx, 2, dk), 0, pbx, 0, ncomp);
156  }
157 
158  // Then the ground plane, from the boxes that hold it
159  plane->ParallelCopy(src, 0, 0, ncomp);
160 
161  return plane;
162 }
const int klo
Definition: ERF_InitCustomPert_KE.H:9

Referenced by ERF::check_mesh_type(), ERF::FillPlot2DVars(), SLM::Init(), and SLM::initialize_zrefxy().

Here is the caller graph for this function:

◆ sum_over_stacked_boxes()

void sum_over_stacked_boxes ( MultiFab &  mf,
int  comp,
int  ncomp 
)

Finish a column sum computed box by box on a planar MultiFab (see ERF_PlanarBoundary.H).

Parameters
[in,out]mfplanar MultiFab, one box per 3D box
[in]compfirst component holding a column sum
[in]ncompnumber of components
173 {
174  if (mf.boxArray().isDisjoint()) { return; }
175 
176  // The columns covered by the planar boxes, each in exactly one box
177  BoxArray ba_cols(mf.boxArray().boxList());
178  ba_cols.removeOverlap();
179  MultiFab sums(ba_cols, DistributionMapping(ba_cols), ncomp, 0);
180  sums.setVal(0.0);
181 
182  // Every planar box adds its part into the columns it covers, then each takes the totals back
183  sums.ParallelAdd(mf, comp, 0, ncomp);
184  mf.ParallelCopy(sums, 0, comp, ncomp);
185 }

Referenced by ERF::FillPlot2DVars(), and ERF::volWgtColumnSum().

Here is the caller graph for this function: