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) {
40 validIDs.
insert(ids[2 * vertex + 1]);
42 for (
std::size_t idx = 2 * nVertices; idx < ids.size(); ++idx) {
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;
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) {
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();
173 static_cast<int>(numberOfVertices),
174 static_cast<int>(numberOfEdges),
175 static_cast<int>(numberOfTriangles),
176 static_cast<int>(numberOfTetrahedra)};
179 if (numberOfVertices == 0) {
186 auto totalIDs = numberOfVertices;
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)
serialized representation of mesh::Mesh
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.
Triangle & createTriangle(Edge &edgeOne, Edge &edgeTwo, Edge &edgeThree)
Creates and initializes a Triangle object.
int getDimensions() const
VertexContainer & vertices()
Returns modifieable container holding all vertices.
bool hasConnectivity() const
TetraContainer & tetrahedra()
Returns modifiable container holding all tetrahedra.
Tetrahedron & createTetrahedron(Vertex &vertexOne, Vertex &vertexTwo, Vertex &vertexThree, Vertex &vertexFour)
Creates and initializes a Tetrahedron object.
TriangleContainer & triangles()
Returns modifiable container holding all triangles.
Edge & createEdge(Vertex &vertexOne, Vertex &vertexTwo)
Creates and initializes an Edge object.
EdgeContainer & edges()
Returns modifiable container holding all edges.
Vertex & createVertex(const Eigen::VectorXd &coords)
Creates and initializes a Vertex object.
void setGlobalIndex(int globalIndex)
contains serialization logic