ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_PlanarBoundary.cpp File Reference
#include <ERF_PlanarBoundary.H>
#include <algorithm>
#include <utility>
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
316 {
317  const IndexType ixtype = src.ixType();
318  const BoxArray& ba = src.boxArray();
319  const int ncomp = src.nComp();
320 
321  BoxList bl(ixtype);
322  for (int ib = 0; ib < static_cast<int>(ba.size()); ++ib) {
323  Box b = enclosedCells(ba[ib]);
324  b.setRange(2, klo);
325  bl.push_back(convert(b, ixtype));
326  }
327  auto plane = std::make_unique<MultiFab>(BoxArray(std::move(bl)), src.DistributionMap(), ncomp, 0);
328 
329  // Every box first holds the lowest plane of its own 3D box, so that it holds finite
330  // values even over columns in which no box reaches the ground
331  for (MFIter mfi(*plane); mfi.isValid(); ++mfi) {
332  const Box& pbx = mfi.validbox();
333  const int dk = enclosedCells(ba[mfi.index()]).smallEnd(2) - klo;
334  (*plane)[mfi].copy<RunOn::Device>(src[mfi], amrex::shift(pbx, 2, dk), 0, pbx, 0, ncomp);
335  }
336 
337  // Then the ground plane, from the boxes that hold it
338  plane->ParallelCopy(src, 0, 0, ncomp);
339 
340  return plane;
341 }
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
352 {
353  if (mf.boxArray().isDisjoint()) { return; }
354 
355  // The columns covered by the planar boxes, each in exactly one box
356  BoxArray ba_cols(mf.boxArray().boxList());
357  ba_cols.removeOverlap();
358  MultiFab sums(ba_cols, DistributionMapping(ba_cols), ncomp, 0);
359  sums.setVal(0.0);
360 
361  // Every planar box adds its part into the columns it covers, then each takes the totals back
362  sums.ParallelAdd(mf, comp, 0, ncomp);
363  mf.ParallelCopy(sums, 0, comp, ncomp);
364 }

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

Here is the caller graph for this function: