17#ifndef PECLET_CORE_DECOMP_GRID_REDISTRIBUTE_HPP
18#define PECLET_CORE_DECOMP_GRID_REDISTRIBUTE_HPP
35 for (
int d = 0; d < Dim; ++d) {
51 for (
int d = 0; d < Dim; ++d) {
66 for (
Index x = 0; x < size[0]; ++x, ++n)
67 f(n,
IVec<3>{origin[0] + x, origin[1] +
y, origin[2] +
z});
75 int rank,
int g,
const std::vector<const T*>&
oldFields,
84 std::vector<Task>
sends;
85 for (std::size_t d = 0; d <
newDec.numBlocks(); ++d) {
87 if (detail::intersectBox<3>(
ob,
newDec.block(d),
o,
s))
88 sends.push_back({
static_cast<int>(d),
o,
s});
92 for (
const auto&
t :
sends)
96 for (
int f = 0;
f <
nF; ++
f)
101 halo::NbxEngine
nbx(comm);
104 [&](std::vector<char>&
out) ->
int {
112 char* p =
out.data();
113 std::memcpy(p,
t.origin.data(),
sizeof(
Index) * 3);
114 std::memcpy(p +
sizeof(
Index) * 3,
t.size.data(),
sizeof(
Index) * 3);
115 T*
fp =
reinterpret_cast<T*
>(p +
sizeof(
Index) * 6);
117 const Index sidx = detail::localFlat<3>(c, ob, g);
118 for (int f = 0; f < nF; ++f)
119 fp[f * cells + n] = oldFields[f][sidx];
123 [&](
int, std::vector<char>&
msg) {
124 const char* p =
msg.data();
126 std::memcpy(
o.data(), p,
sizeof(
Index) * 3);
127 std::memcpy(
s.data(), p +
sizeof(
Index) * 3,
sizeof(
Index) * 3);
129 const T*
fp =
reinterpret_cast<const T*
>(p +
sizeof(
Index) * 6);
132 for (
int f = 0;
f <
nF; ++
f)
Index boxCellCount(const IVec< 3 > &size)
Index localFlat(const IVec< Dim > &gcell, const Block< Dim > &blk, int g)
bool intersectBox(const Block< Dim > &a, const Block< Dim > &b, IVec< Dim > &origin, IVec< Dim > &size)
void forBox(const IVec< 3 > &origin, const IVec< 3 > &size, F &&f)
void redistributeGridFields(const BlockDecomposer< 3 > &oldDec, const BlockDecomposer< 3 > &newDec, int rank, int g, const std::vector< const T * > &oldFields, const std::vector< T * > &newFields, MPI_Comm comm)
std::array< Index, Dim > IVec
Multi-dimensional integer index / coordinate (x-fastest order by convention).
Kokkos::View< T *, MemSpace > View
1D device array.
std::int64_t Index
Signed index type for grids and particles (supersedes block_decomposer's long int IndxT).
IVec< Dim > size
extent in cells along each axis
IVec< Dim > origin
inclusive lower corner in global cell coordinates