5 #ifndef ERF_MICROPHYSICSCOLUMNS_H
6 #define ERF_MICROPHYSICSCOLUMNS_H
11 #include <AMReX_BoxArray.H>
12 #include <AMReX_DistributionMapping.H>
13 #include <AMReX_MultiFab.H>
14 #include <AMReX_iMultiFab.H>
35 using FabPtr = std::shared_ptr<amrex::MultiFab>;
38 void define (
const amrex::BoxArray& ba,
const amrex::Box& domain);
47 template <std::
size_t N>
48 void gather (std::array<FabPtr,N>& vars, std::array<FabPtr,N>& saved)
const
50 for (std::size_t n = 0; n < N; ++n) {
52 if (vars[n]) { vars[n] =
gather_one(*vars[n]); }
57 template <std::
size_t N>
58 void scatter (std::array<FabPtr,N>& vars, std::array<FabPtr,N>& saved)
const
60 for (std::size_t n = 0; n < N; ++n) {
61 if (saved[n]) { saved[n]->ParallelCopy(*vars[n], 0, 0, vars[n]->nComp()); }
71 [[nodiscard]] std::unique_ptr<amrex::MultiFab>
gather_nodal (
const amrex::MultiFab* src)
const;
74 [[nodiscard]] std::unique_ptr<amrex::iMultiFab>
gather_2d (
const amrex::iMultiFab* src)
const;
Definition: ERF_MicrophysicsColumns.H:33
bool boxes_span_domain() const
True when every box spans the domain in z (required by the Fortran bridges)
Definition: ERF_MicrophysicsColumns.H:44
void gather(std::array< FabPtr, N > &vars, std::array< FabPtr, N > &saved) const
Swap each non-null field for a copy on the column layout; the originals go to saved.
Definition: ERF_MicrophysicsColumns.H:48
bool m_boxes_span_domain
Definition: ERF_MicrophysicsColumns.H:78
FabPtr gather_one(const amrex::MultiFab &src) const
Copy of a field (cell-centered or z-face; with its ghost cells) on the column layout.
Definition: ERF_MicrophysicsColumns.cpp:100
bool m_needs_gather
Definition: ERF_MicrophysicsColumns.H:77
void scatter(std::array< FabPtr, N > &vars, std::array< FabPtr, N > &saved) const
Copy the column-layout fields back into the originals and restore them.
Definition: ERF_MicrophysicsColumns.H:58
std::unique_ptr< amrex::MultiFab > gather_nodal(const amrex::MultiFab *src) const
Copy of a nodal field (e.g. z_phys_nd) on the column layout, or null for null input.
Definition: ERF_MicrophysicsColumns.cpp:116
std::shared_ptr< amrex::MultiFab > FabPtr
Definition: ERF_MicrophysicsColumns.H:35
bool needs_gather() const
True when some column is split between boxes, so the fields must be gathered.
Definition: ERF_MicrophysicsColumns.H:41
amrex::BoxArray m_col_ba
Definition: ERF_MicrophysicsColumns.H:79
std::unique_ptr< amrex::iMultiFab > gather_2d(const amrex::iMultiFab *src) const
Copy of a 2D (z-flattened) integer field (e.g. lmask) on the column layout, or null.
Definition: ERF_MicrophysicsColumns.cpp:128
amrex::DistributionMapping m_col_dm
Definition: ERF_MicrophysicsColumns.H:80
void define(const amrex::BoxArray &ba, const amrex::Box &domain)
Build from a level's grids; call from the scheme's Init (which also runs on regrid)
Definition: ERF_MicrophysicsColumns.cpp:9