2#include <Eigen/src/Core/Matrix.h>
5#include <boost/container/flat_map.hpp>
32 _dimensions(dimensions),
34 _boundingBox(dimensions),
160 "Data \"{}\" cannot be created twice for mesh \"{}\". "
161 "Please rename or remove one of the use-data tags with name \"{}\".",
178 return dptr->getID() == dataID;
186 return dptr->getID() == dataID;
195 return dptr->getName() == dataName;
212 return dptr->getName() == dataName;
230 return (0 <= vertexID) && (
static_cast<size_t>(vertexID) <
nVertices());
238 data->allocateValues(expectedCount);
286 int valueDim = values.size() /
nVertices();
291 for (
int dim = 0; dim < valueDim; ++dim) {
297 Eigen::Map<Eigen::VectorXd> ownedData(ownedDataVector.
data(), ownedDataVector.
size());
315 boost::container::flat_map<VertexID, Vertex *> vertexMap;
316 vertexMap.reserve(deltaMesh.
nVertices());
332 for (
const Edge &edge : deltaMesh.
edges()) {
334 VertexID vertexIndex2 = edge.vertex(1).getID();
336 (vertexMap.count(vertexIndex2) == 1));
337 createEdge(*vertexMap[vertexIndex1], *vertexMap[vertexIndex2]);
341 VertexID vertexIndex1 = triangle.vertex(0).getID();
342 VertexID vertexIndex2 = triangle.vertex(1).getID();
343 VertexID vertexIndex3 = triangle.vertex(2).getID();
345 (vertexMap.count(vertexIndex2) == 1) &&
346 (vertexMap.count(vertexIndex3) == 1));
347 createTriangle(*vertexMap[vertexIndex1], *vertexMap[vertexIndex2], *vertexMap[vertexIndex3]);
351 VertexID vertexIndex1 = tetra.vertex(0).getID();
352 VertexID vertexIndex2 = tetra.vertex(1).getID();
353 VertexID vertexIndex3 = tetra.vertex(2).getID();
354 VertexID vertexIndex4 = tetra.vertex(3).getID();
357 (vertexMap.count(vertexIndex2) == 1) &&
358 (vertexMap.count(vertexIndex3) == 1) &&
359 (vertexMap.count(vertexIndex4) == 1));
360 createTetrahedron(*vertexMap[vertexIndex1], *vertexMap[vertexIndex2], *vertexMap[vertexIndex3], *vertexMap[vertexIndex4]);
401 PRECICE_DEBUG(
"Compression removed {} tetrahedra ({} to {}), {} triangles ({} to {}), and {} edges ({} to {})",
409template <
class Primitive,
int... Indices>
425template <
class Primitive>
426auto sortedVertexPtrsFor(Primitive &p)
460 for (
auto &t : _tetrahedra) {
461 auto [a, b, c, d] = sortedVertexPtrsFor(t);
463 createTriangleIfMissing(a, b, c);
464 createTriangleIfMissing(a, b, d);
465 createTriangleIfMissing(a, c, d);
466 createTriangleIfMissing(b, c, d);
473 for (
auto &e : _edges) {
474 edges.
emplace(sortedVertexPtrsFor(e));
478 auto createEdgeIfMissing = [&](Vertex *a, Vertex *b) {
479 if (edges.
count({a, b}) == 0) {
484 for (
auto &t : _triangles) {
485 auto [a, b, c] = sortedVertexPtrsFor(t);
487 createEdgeIfMissing(a, b);
488 createEdgeIfMissing(a, c);
489 createEdgeIfMissing(b, c);
492 PRECICE_DEBUG(
"Generated {} implicit triangles and {} implicit edges",
493 _triangles.size() - explTriangles,
494 _edges.size() - explEdges);
497bool Mesh::operator==(
const Mesh &other)
const
502 equal &= _edges.size() == other.
_edges.
size() &&
509bool Mesh::operator!=(
const Mesh &other)
const
511 return !(*
this == other);
517 os <<
"GEOMETRYCOLLECTION(\n";
518 const auto token =
", ";
519 const auto *sep =
"";
525 for (
auto &edge : m.
edges()) {
531 os << sep << triangle;
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
An axis-aligned bounding box around a (partition of a) mesh.
void expandBy(const BoundingBox &otherBB)
Expand bounding box using another bounding box.
Describes a set of data values belonging to the vertices of a mesh.
Linear edge of a mesh, defined by two Vertex objects.
bool connectedTo(const Edge &other) const
Checks whether both edges share a vertex.
Container and creator for meshes.
void expandBoundingBox(const BoundingBox &bounding_box)
Triangle & createTriangle(Edge &edgeOne, Edge &edgeTwo, Edge &edgeThree)
Creates and initializes a Triangle object.
MeshID _id
The ID of this mesh.
MeshID getID() const
Returns the base ID of the mesh.
std::string _name
Name of the mesh.
int _globalNumberOfVertices
Number of unique vertices for complete distributed mesh.
int getDimensions() const
VertexContainer & vertices()
Returns modifieable container holding all vertices.
bool hasDataID(DataID dataID) const
Returns whether Mesh has Data with the matchingID.
Eigen::VectorXd getOwnedVertexData(const Eigen::VectorXd &values)
void clear()
Removes all mesh elements and data values (does not remove data or the bounding boxes).
DataContainer _data
Data hold by the vertices of the mesh.
void addMesh(Mesh &deltaMesh)
std::vector< std::string > availableData() const
Returns the names of all available data.
const std::string & getName() const
Returns the name of the mesh, as set in the config file.
void removeDuplicates()
Removes all duplicate connectivity.
std::size_t nVertices() const
Returns the number of vertices.
VertexDistribution _vertexDistribution
Vertex distribution for the primary rank, holding for each secondary rank all vertex IDs it owns.
TetraContainer & tetrahedra()
Returns modifiable container holding all tetrahedra.
std::vector< Rank > _connectedRanks
each rank stores list of connected remote ranks. In the m2n package, this is used to create the initi...
TetraContainer _tetrahedra
Vertex & vertex(VertexID id)
Mutable access to a vertex by VertexID.
Mesh(std::string name, int dimensions, MeshID id)
Constructor.
VertexContainer _vertices
Holds vertices, edges, triangles and tetrahedra.
bool hasDataName(std::string_view dataName) const
Returns whether Mesh has Data with the dataName.
PtrData & createData(const std::string &name, int dimension, DataID id, int waveformDegree=time::Time::DEFAULT_WAVEFORM_DEGREE)
Create only data for vertex.
CommunicationMap _communicationMap
each rank stores list of connected ranks and corresponding vertex IDs here. In the m2n package,...
bool empty() const
Does the mesh contain any vertices?
void generateImplictPrimitives()
void clearPartitioning()
Clears the partitioning information.
void computeBoundingBox()
Computes the boundingBox for the vertices.
TriangleContainer _triangles
Tetrahedron & createTetrahedron(Vertex &vertexOne, Vertex &vertexTwo, Vertex &vertexThree, Vertex &vertexFour)
Creates and initializes a Tetrahedron object.
VertexOffsets _vertexOffsets
Holds the index of the last vertex for each rank.
bool isValidVertexID(VertexID vertexID) const
Returns true if the given vertexID is valid.
const DataContainer & data() const
Allows access to all data.
TriangleContainer & triangles()
Returns modifiable container holding all triangles.
const BoundingBox & getBoundingBox() const
Returns the bounding box of the mesh.
query::Index & index()
Call preprocess() before index() to ensure correct projection handling.
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 allocateDataValues()
Allocates memory for the vertex data values and corresponding gradient values.
int _dimensions
Dimension of mesh.
Tetrahedron of a mesh, defined by 4 vertices.
Triangle of a mesh, defined by three vertices.
VertexID getID() const
Returns the unique (among vertices of one mesh on one processor) ID of the vertex.
void setGlobalIndex(int globalIndex)
void setOwner(bool owner)
Eigen::VectorXd getCoords() const
Returns the coordinates of the vertex.
int getGlobalIndex() const
Globally unique index.
void clear()
Clear the index.
T emplace_back(T... args)
T is_permutation(T... args)
provides Mesh, Data and primitives.