12void SerializedMesh ::assertValid()
const
17 auto nVertices =
sizes[1];
20 auto nEdges =
sizes[2];
21 auto nTriangles =
sizes[3];
22 auto nTetrahedra =
sizes[4];
33 bool hasConnectivity = (nEdges + nTriangles + nTetrahedra) > 0;
35 if (hasConnectivity) {
38 for (
int vertex = 0; vertex < nVertices; ++vertex) {
64 auto nVertices = sm.
sizes[1];
84 constexpr int broadcasterRank{0};
88 auto nVertices = sm.
sizes[1];
101 const auto numberOfVertices =
sizes[1];
102 if (numberOfVertices == 0) {
105 const auto numberOfEdges =
sizes[2];
106 const auto numberOfTriangles =
sizes[3];
107 const auto numberOfTetrahedra =
sizes[4];
109 const bool hasConnectivity = (numberOfEdges + numberOfTriangles + numberOfTetrahedra) > 0;
111 const auto dim =
mesh.getDimensions();
115 Eigen::VectorXd coord(dim);
116 for (
std::size_t i = 0; i < static_cast<std::size_t>(numberOfVertices); ++i) {
120 if (hasConnectivity) {
129 if (!hasConnectivity) {
133 const size_t offsetEdge = numberOfVertices * 2;
134 const size_t offsetTriangle = offsetEdge + 2 * numberOfEdges;
135 const size_t offsetTetrahedron = offsetTriangle + 3 * numberOfTriangles;
137 for (
size_t idx = offsetEdge; idx != offsetTriangle; idx += 2) {
139 *vertices.
at(
ids[idx]),
140 *vertices.
at(
ids[idx + 1]));
142 for (
size_t idx = offsetTriangle; idx != offsetTetrahedron; idx += 3) {
144 *vertices.
at(
ids[idx]),
145 *vertices.
at(
ids[idx + 1]),
146 *vertices.
at(
ids[idx + 2]));
148 for (
size_t idx = offsetTetrahedron; idx !=
ids.size(); idx += 4) {
149 mesh.createTetrahedron(
150 *vertices.
at(
ids[idx]),
151 *vertices.
at(
ids[idx + 1]),
152 *vertices.
at(
ids[idx + 2]),
153 *vertices.
at(
ids[idx + 3]));
159 const auto &meshVertices =
mesh.vertices();
160 const auto &meshEdges =
mesh.edges();
161 const auto &meshTriangles =
mesh.triangles();
162 const auto &meshTetrahedra =
mesh.tetrahedra();
164 const auto numberOfVertices = meshVertices.size();
165 const auto numberOfEdges = meshEdges.size();
166 const auto numberOfTriangles = meshTriangles.size();
167 const auto numberOfTetrahedra = meshTetrahedra.size();
172 mesh.getDimensions(),
173 static_cast<int>(numberOfVertices),
174 static_cast<int>(numberOfEdges),
175 static_cast<int>(numberOfTriangles),
176 static_cast<int>(numberOfTetrahedra)};
179 if (numberOfVertices == 0) {
183 auto dim =
static_cast<size_t>(
mesh.getDimensions());
186 auto totalIDs = numberOfVertices;
187 const bool hasConnectivity =
mesh.hasConnectivity();
188 if (hasConnectivity) {
189 totalIDs += numberOfVertices
191 + numberOfTriangles * 3
192 + numberOfTetrahedra * 4;
197 for (
size_t i = 0; i < numberOfVertices; ++i) {
198 auto &v = meshVertices[i];
202 if (hasConnectivity) {
208 if (!hasConnectivity) {
213 auto pushVID = [&result](
const auto &element,
auto... id) {
214 (result.
ids.
push_back(element.vertex(
id).getID()), ...);
217 for (
const auto &e : meshEdges) {
221 for (
const auto &e : meshTriangles) {
225 for (
const auto &e : meshTetrahedra) {
226 pushVID(e, 0, 1, 2, 3);
#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 SerializedMesh serialize(const mesh::Mesh &mesh)
std::vector< double > coords
sizes[0] * dimension coordinates for vertices
void broadcastSend(Communication &communication)
static SerializedMesh receive(Communication &communication, int rankSender)
receives a SerializedMesh and calls assertValid before returning
static SerializedMesh broadcastReceive(Communication &communication)
receives a SerializedMesh and calls assertValid before returning
void send(Communication &communication, int rankReceiver)
void addToMesh(mesh::Mesh &mesh) const
std::vector< int > sizes
contains the dimension, followed by the numbers of vertices, edges, triangles, and tetrahedra
void assertValid() const
asserts the content for correctness
Container and creator for meshes.
void setGlobalIndex(int globalIndex)
contains serialization logic
constexpr auto asVector
Allows to use Communication::AsVectorTag in a less verbose way.
provides Mesh, Data and primitives.