|
| void | define (const amrex::BoxArray &ba3d, const amrex::BoxArray &ba2d, const amrex::DistributionMapping &dm, int surface_index, bool is_low=true, int normal_dir=2) |
| |
| void | fill (amrex::MultiFab &mf, const amrex::Periodicity &period) |
| |
| void | reconcile_outside_domain (amrex::MultiFab &mf, const amrex::Geometry &geom) |
| |
| void | gather_surface (const amrex::MultiFab &mf, amrex::MultiFab &dst, int scomp, int dcomp, int ncomp) const |
| |
| const amrex::BoxArray & | surface_boxes () const |
| | Cell-centered surface copies of the planar boxes, without duplicates. More...
|
| |
| const amrex::DistributionMapping & | surface_dm () const |
| | Ranks owning the surface copies: each is on the rank of the planar box it is a copy of. More...
|
| |
| const amrex::Vector< int > & | surface_index () const |
| | Index of each surface copy in the planar BoxArray. More...
|
| |
| AMREX_GPU_HOST bool | is_surface_copy (const int planar_index) const |
| | Whether a planar-box index is the computed copy that touches the surface. More...
|
| |
Ghost-cell fill for planar (2D) MultiFabs built on the collapse of a 3D BoxArray along a surface-normal direction.
The surface-layer fields and the MOST averages are defined on one 2D box per 3D box. When the 3D BoxArray is split in the normal direction, several 3D boxes collapse onto the same 2D box, so the planar BoxArray holds duplicate boxes with overlapping valid regions, and only the copy that belongs to the 3D box touching the surface is ever computed. A FillBoundary on such a MultiFab may fill a ghost cell from an uncomputed copy.
define() records which planar boxes are those surface copies. fill() copies them into a buffer without duplicates and ParallelCopies the buffer onto every planar box, valid region and ghost cells alike. Unlike FillBoundary it therefore also overwrites the valid region of the uncomputed copies, so that any copy can be read afterwards. Without duplicates fill() is a plain FillBoundary.
The buffer is kept for each target layout, index type, and number of components, so only the first fill of each kind allocates. For a face-centered MultiFab (the MOST velocity averages) neighboring surface boxes share a face in the buffer. Both should hold the same value there, but nothing enforces it, so fill() gives the shared faces a single value before it copies: the lowest global box index wins, which does not depend on the decomposition or the rank count, and every copy of the field then agrees.
A level none of whose boxes reaches the surface (a fine level away from the surface) has no computed copy to fill from, and fill() leaves the MultiFab as it is.
The strips beyond the non-periodic domain edges owned by each surface copy of a planar layout, built on first use.
A surface copy that touches a non-periodic edge owns the ghost cells beyond it that face its valid region, out to the ghost width of the field, and at a domain corner the cells beyond both edges. Since the surface copies do not overlap, neither do these strips.
The remaining cells beyond a non-periodic edge that lie in the ghost region of a surface copy face a column no grid of the level covers. Each goes to the surface copy with the lowest global index that holds it, in the image inside the domain in the periodic directions, so that the ParallelCopy from the strips reaches all its images.
- Parameters
-
| [in] | mf | planar MultiFab |
| [in] | geom | geometry of the level |
170 const IntVect
ng = mf.nGrowVect();
171 const BoxArray& pba = mf.boxArray();
172 const DistributionMapping& pdm = mf.DistributionMap();
174 if (s.ngrow ==
ng && s.planar_ba == pba && s.planar_dm == pdm) {
return s; }
177 const Box& dom = geom.Domain();
181 Vector<IntVect> shift;
185 const Box vbx = pba[ib];
187 for (
int d = 0; d < 2; ++d) {
188 if (geom.isPeriodic(d) ||
ng[d] == 0) {
continue; }
189 if (vbx.smallEnd(d) == dom.smallEnd(d)) { grown.growLo(d,
ng[d]); }
190 if (vbx.bigEnd(d) == dom.bigEnd(d)) { grown.growHi(d,
ng[d]); }
192 if (grown == vbx) {
continue; }
193 for (
const Box& b : boxDiff(grown, vbx)) {
195 pmap.push_back(pdm[ib]);
197 shift.emplace_back(0);
203 Vector<Box> taken(bl.begin(), bl.end());
205 const Box vbx = pba[ib];
208 for (
int d = 0; d < 2; ++d) {
209 ghost.grow(d,
ng[d]);
210 inside.grow(d,
ng[d]);
211 if (!geom.isPeriodic(d)) {
212 inside.setSmall(d, std::max(inside.smallEnd(d), dom.smallEnd(d)));
213 inside.setBig (d, std::min(inside.bigEnd(d), dom.bigEnd(d)));
216 if (inside == ghost) {
continue; }
218 for (
const Box& beyond : boxDiff(ghost, inside)) {
221 Vector<std::pair<Box,IntVect>> pieces{{beyond, IntVect(0)}};
222 for (
int d = 0; d < 2; ++d) {
223 if (!geom.isPeriodic(d)) {
continue; }
224 const int len = dom.length(d);
225 Vector<std::pair<Box,IntVect>> split;
226 for (
const auto& [b, sh] : pieces) {
227 Box
lo = b;
lo.setBig(d, std::min(b.bigEnd(d), dom.smallEnd(d)-1));
228 Box mid = b; mid.setSmall(d, std::max(b.smallEnd(d), dom.smallEnd(d)));
229 mid.setBig (d, std::min(b.bigEnd(d), dom.bigEnd(d)));
230 Box
hi = b;
hi.setSmall(d, std::max(b.smallEnd(d), dom.bigEnd(d)+1));
231 IntVect shlo = sh; shlo[d] -= len;
232 IntVect shhi = sh; shhi[d] += len;
233 if (
lo.ok()) { split.emplace_back(amrex::shift(
lo, d, len), shlo); }
234 if (mid.ok()) { split.emplace_back(mid, sh); }
235 if (
hi.ok()) { split.emplace_back(amrex::shift(
hi, d, -len), shhi); }
237 pieces = std::move(split);
240 for (
const auto& [b, sh] : pieces) {
242 for (
const Box&
t : taken) {
243 if (!
t.intersects(b)) {
continue; }
245 for (
const Box& r : rest) {
246 if (r.intersects(
t)) { next.join(boxDiff(r,
t)); }
247 else { next.push_back(r); }
249 rest = std::move(next);
250 if (rest.isEmpty()) {
break; }
252 for (
const Box& r : rest) {
254 pmap.push_back(pdm[ib]);
268 s.ba = BoxArray(std::move(bl));
269 s.dm = DistributionMapping(std::move(pmap));
270 s.owner = std::move(owner);
271 s.shift = std::move(shift);
@ ng
Definition: ERF_Morrison.H:51
@ t
Definition: ERF_WSM6.H:295
| void PlanarBoundary::reconcile_outside_domain |
( |
amrex::MultiFab & |
mf, |
|
|
const amrex::Geometry & |
geom |
|
) |
| |
Give every copy of a ghost cell outside a non-periodic lateral domain edge the value of the surface copy that holds the column it faces.
Where a box seam meets a non-periodic edge, the ghost cells beyond the edge next to the seam lie in the grown boxes of both neighbors, and no FillBoundary reconciles them: each box fills its copy from its own valid region. A cell beyond the edge is here assigned to the surface copy whose valid region holds the cell's projection into the domain (its index clamped into the domain in each non-periodic direction), and that copy's value is written into every other copy, periodic images included. The result then does not depend on the decomposition, and a checkpoint, which keeps one copy, restarts from the same values. Only ghost cells beyond a non-periodic edge are written; interior, periodic and coarse/fine ghost cells are left as they are.
On a fine level the column a cell beyond the edge faces need not be covered by any grid: where a coarse/fine boundary meets the domain edge, or two grids along the edge are separated by a gap narrower than twice the ghost width. Such a cell has no owner by projection, and it takes instead the value of the surface copy with the lowest global box index whose ghost region holds it (OverrideSync's precedence in fill()), so it too has one value that does not depend on the decomposition. Only surface copies take part: a cell held solely by the ghost region of an uncomputed copy (a 3D box above the surface whose footprint differs from those below it) is left as it is.
Call it after fill(), on a cell-centered planar MultiFab; other index types are left as they are.
- Parameters
-
| [in,out] | mf | planar MultiFab on the planar BoxArray given to define |
| [in] | geom | geometry of the level |
Give every copy of a ghost cell outside a non-periodic lateral domain edge the value of the surface copy that holds the column it faces (see ERF_PlanarBoundary.H).
- Parameters
-
| [in,out] | mf | planar MultiFab on the planar BoxArray given to define |
| [in] | geom | geometry of the level |
111 "PlanarBoundary::reconcile_outside_domain: the MultiFab is not on the planar "
112 "BoxArray given to define");
114 if (!mf.ixType().cellCentered() ||
m_src_index.empty()) {
return; }
117 if (strips.ba.empty()) {
return; }
120 const int ncomp = mf.nComp();
121 MultiFab* bufp =
nullptr;
122 for (
auto& b : strips.bufs) {
123 if (b->nComp() == ncomp) { bufp = b.get();
break; }
125 if (bufp ==
nullptr) {
126 strips.bufs.push_back(std::make_unique<MultiFab>(strips.ba, strips.dm, ncomp, 0));
127 bufp = strips.bufs.back().get();
129 MultiFab& buf = *bufp;
132 for (MFIter mfi(buf); mfi.isValid(); ++mfi) {
133 const Box& bx = mfi.validbox();
134 const int owner = strips.owner[mfi.index()];
136 "PlanarBoundary::reconcile_outside_domain: an edge strip is not on the rank of its owner");
137 const auto src = mf.const_array(owner);
138 const auto dst = buf.array(mfi);
139 const int si = strips.shift[mfi.index()][0];
140 const int sj = strips.shift[mfi.index()][1];
141 ParallelFor(bx, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n) noexcept
143 dst(i,j,k,n) = src(i+si,j+sj,k,n);
148 mf.ParallelCopy(buf, 0, 0, ncomp, IntVect(0), mf.nGrowVect(), geom.periodicity());
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
EdgeStrips & edge_strips(const amrex::MultiFab &mf, const amrex::Geometry &geom)
Definition: ERF_PlanarBoundary.cpp:168