20 auto elements = std::transform_reduce(
23 std::plus<size_t>{}, [](
const auto &kv) {
25 return 2 + kv.second.size();
30 for (
const auto &[rank, ids] : cm) {
43 int numEntries = *begin;
45 if (numEntries == 0) {
48 std::advance(begin, 1);
51 for (
int entry = 0; entry < numEntries; ++entry) {
54 std::advance(begin, 1);
57 std::advance(begin, 1);
59 auto verticesStart = begin;
60 std::advance(begin, size);
62 cm.emplace(rank, std::vector<int>(verticesStart, begin));
69 const size_t totalSize =
content.size();
72 const auto numEntries =
content.front();
77 for (
int entry = 0; entry < numEntries; ++entry) {
81 auto rank =
content[consumed++];
84 auto size =
content[consumed++];
88 PRECICE_ASSERT(totalSize >= consumed + size,
"size larger than remaining");
89 std::set<int> ids(
content.begin() + consumed,
content.begin() + consumed + size);
90 PRECICE_ASSERT(ids.size() ==
static_cast<std::size_t
>(size),
"Duplicate vertex IDs");
133 coords.reserve(1 + 2 * dims);
137 std::copy_n(min.data(), dims, std::back_inserter(
coords));
139 std::copy_n(max.data(), dims, std::back_inserter(
coords));
147 auto dims =
static_cast<int>(
coords.at(0));
150 std::vector<double> buffer(dims * 2);
155 for (
int d = 0; d < dims; ++d) {
157 buffer[offset] =
coords[1 + d];
158 buffer[offset + 1] =
coords[1 + d + dims];
166 auto dims =
static_cast<size_t>(
coords.front());
199 auto size = bbm.size();
200 info.reserve(2 + size);
201 const auto dims = bbm.begin()->second.getDimension();
203 info.push_back(size);
204 info.push_back(dims);
205 coords.reserve(size * dims);
207 for (
const auto &[rank, bb] : bbm) {
208 info.push_back(rank);
209 auto min = bb.minCorner();
210 std::copy_n(min.data(), dims, std::back_inserter(
coords));
211 auto max = bb.maxCorner();
212 std::copy_n(max.data(), dims, std::back_inserter(
coords));
220 if (
info.size() == 1) {
230 std::vector<double> buffer(dims * 2);
232 auto rankIter = std::next(
info.begin(), 2);
233 auto coordIter =
coords.begin();
234 for (
int entry = 0; entry < size; ++entry) {
238 for (
int d = 0; d < dims; ++d) {
240 buffer[offset] = coordIter[d];
241 buffer[offset + 1] = coordIter[d + dims];
246 std::advance(rankIter, 1);
247 std::advance(coordIter, dims * 2);
255 if (
info.size() == 1) {
261 auto numEntries =
info[0];
267 for (
int entry = 0; entry < numEntries; ++entry) {
275 if (
info.size() > 1) {
284 if (sbbm.
info.size() > 1) {
294 if (
info.size() > 1) {
303 if (sbbm.
info.size() > 1) {
#define PRECICE_ASSERT(...)
Interface for all interprocess communication classes.
std::vector< int > receiveRange(Rank rankSender, AsVectorTag< int >)
Receives a range of ints as a vector<int>
void sendRange(precice::span< const double > itemsToSend, Rank rankReceiver)
Sends a range of doubles (size + content)
virtual void broadcast(precice::span< const int > itemsToSend)
static SerializedBoundingBoxMap broadcastReceive(Communication &communication)
receives a SerializedBoundingBoxMap and calls assertValid before returning
SerializedBoundingBoxMap()=default
std::map< Rank, mesh::BoundingBox > BoundingBoxMap
std::vector< double > coords
static SerializedBoundingBoxMap receive(Communication &communication, int rankSender)
receives a SerializedBoundingBoxMap and calls assertValid before returning
void broadcastSend(Communication &communication)
BoundingBoxMap toBoundingBoxMap() const
Builds and returns the BoundingBoxMap represented by the serialized state.
void send(Communication &communication, int rankReceiver)
static SerializedBoundingBoxMap serialize(const BoundingBoxMap &bbm)
void assertValid() const
asserts the content for correctness
static SerializedBoundingBox receive(Communication &communication, int rankSender)
receives a SerializedBoundingBox and calls assertValid before returning
static SerializedBoundingBox serialize(const mesh::BoundingBox &bbm)
mesh::BoundingBox toBoundingBox() const
Builds and returns the BoundingBox represented by the serialized state.
void send(Communication &communication, int rankReceiver)
std::vector< double > coords
void assertValid() const
asserts the content for correctness
SerializedBoundingBox()=default
void broadcastSend(Communication &communication) const
static SerializedConnectionMap receive(Communication &communication, int rankSender)
receives a SerializedConnectionMap and calls assertValid before returning
ConnectionMap toConnectionMap() const
Builds and returns the connection map represented by the serialized state.
std::vector< int > content
static SerializedConnectionMap serialize(const ConnectionMap &cm)
static SerializedConnectionMap broadcastReceive(Communication &communication)
receives a SerializedConnectionMap and calls assertValid before returning
SerializedConnectionMap()=default
std::map< Rank, std::vector< VertexID > > ConnectionMap
void assertValid() const
asserts the content for correctness
void send(Communication &communication, int rankReceiver) const
An axis-aligned bounding box around a (partition of a) mesh.
Eigen::VectorXd maxCorner() const
the max corner of the bounding box
Eigen::VectorXd minCorner() const
the min corner of the bounding box
int getDimension() const
Getter dimension of the bounding box.
contains serialization logic
constexpr auto asVector
Allows to use Communication::AsVectorTag in a less verbose way.