75 int rank,
int g,
const std::vector<const T*>& oldFields,
76 const std::vector<T*>& newFields,
MPI_Comm comm) {
77 const int nF =
static_cast<int>(oldFields.size());
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)
94 detail::forBox(t.origin, t.size, [&](
Index, const
IVec<3>& c) {
95 const Index si = detail::localFlat<3>(c, ob, g), di = detail::localFlat<3>(c, nbSelf, g);
96 for (
int f = 0; f < nF; ++f)
97 newFields[f][di] = oldFields[f][si];
101 halo::NbxEngine nbx(comm);
104 [&](std::vector<char>& out) ->
int {
105 while (si < sends.size() && sends[si].dst == rank)
107 if (si >= sends.size())
109 const Task t = sends[si++];
111 out.resize(
sizeof(
Index) * 6 +
sizeof(T) * cells * nF);
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);
131 const Index di = detail::localFlat<3>(c, nbSelf, g);
132 for (
int f = 0; f < nF; ++f)
133 newFields[f][di] = fp[f * cells + n];
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)