| 26 | |
| 27 | |
| 28 | std::unique_ptr<MultiFab> allocateSlice (int dir, const MultiFab& cell_centered_data, |
| 29 | int ncomp, const Geometry& geom, Real dir_coord, |
| 30 | Vector<int>& slice_to_full_ba_map, RealBox real_slice) { |
| 31 | |
| 32 | // Get our slice and convert to index space |
| 33 | real_slice.setLo(dir, dir_coord); |
| 34 | real_slice.setHi(dir, dir_coord); |
| 35 | Box slice_box = getIndexBox(real_slice, geom); |
| 36 | |
| 37 | // define the multifab that stores slice |
| 38 | BoxArray const& ba = cell_centered_data.boxArray(); |
| 39 | const DistributionMapping& dm = cell_centered_data.DistributionMap(); |
| 40 | std::vector< std::pair<int, Box> > isects; |
| 41 | ba.intersections(slice_box, isects, false, 0); |
| 42 | Vector<Box> boxes; |
| 43 | Vector<int> procs; |
| 44 | for (auto const& is : isects) { |
| 45 | procs.push_back(dm[is.first]); |
| 46 | boxes.push_back(is.second); |
| 47 | slice_to_full_ba_map.push_back(is.first); |
| 48 | } |
| 49 | if (!boxes.empty()) { |
| 50 | BoxArray slice_ba(boxes.data(), static_cast<int>(boxes.size())); |
| 51 | DistributionMapping slice_dmap(std::move(procs)); |
| 52 | |
| 53 | return std::make_unique<MultiFab>(slice_ba, slice_dmap, ncomp, 0, |
| 54 | MFInfo(), FArrayBoxFactory()); |
| 55 | } else { |
| 56 | return nullptr; |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | namespace amrex |
no test coverage detected