2#include <Eigen/src/Core/Matrix.h>
5#include <boost/container/flat_map.hpp>
117 _edges.emplace_back(vertexOne, vertexTwo);
130 _triangles.emplace_back(edgeOne, edgeTwo, edgeThree);
139 _triangles.emplace_back(vertexOne, vertexTwo, vertexThree);
149 _tetrahedra.emplace_back(vertexOne, vertexTwo, vertexThree, vertexFour);
162 "Data \"{}\" cannot be created twice for mesh \"{}\". "
163 "Please rename or remove one of the use-data tags with name \"{}\".",
180 return dptr->getID() == dataID;
182 return iter !=
_data.end();
188 return dptr->getID() == dataID;
197 return dptr->getName() == dataName;
199 return iter !=
_data.end();
214 return dptr->getName() == dataName;
232 return (0 <= vertexID) && (
static_cast<size_t>(vertexID) <
nVertices());
238 const auto expectedCount =
_vertices.size();
240 data->allocateValues(expectedCount);
268 data->values().resize(0);
285 data->timeStepsStorage().clear();
309 int valueDim = values.size() /
nVertices();
314 for (
int dim = 0; dim < valueDim; ++dim) {
320 Eigen::Map<Eigen::VectorXd> ownedData(ownedDataVector.
data(), ownedDataVector.
size());
338 boost::container::flat_map<VertexID, Vertex *> vertexMap;
339 vertexMap.reserve(deltaMesh.
nVertices());
342 coords =
vertex.getCoords();
349 vertexMap[
vertex.getID()] = &v;
355 for (
const Edge &edge : deltaMesh.
edges()) {
356 VertexID vertexIndex1 = edge.vertex(0).getID();
357 VertexID vertexIndex2 = edge.vertex(1).getID();
359 (vertexMap.count(vertexIndex2) == 1));
360 createEdge(*vertexMap[vertexIndex1], *vertexMap[vertexIndex2]);
364 VertexID vertexIndex1 = triangle.vertex(0).getID();
365 VertexID vertexIndex2 = triangle.vertex(1).getID();
366 VertexID vertexIndex3 = triangle.vertex(2).getID();
368 (vertexMap.count(vertexIndex2) == 1) &&
369 (vertexMap.count(vertexIndex3) == 1));
370 createTriangle(*vertexMap[vertexIndex1], *vertexMap[vertexIndex2], *vertexMap[vertexIndex3]);
374 VertexID vertexIndex1 = tetra.vertex(0).getID();
375 VertexID vertexIndex2 = tetra.vertex(1).getID();
376 VertexID vertexIndex3 = tetra.vertex(2).getID();
377 VertexID vertexIndex4 = tetra.vertex(3).getID();
380 (vertexMap.count(vertexIndex2) == 1) &&
381 (vertexMap.count(vertexIndex3) == 1) &&
382 (vertexMap.count(vertexIndex4) == 1));
383 createTetrahedron(*vertexMap[vertexIndex1], *vertexMap[vertexIndex2], *vertexMap[vertexIndex3], *vertexMap[vertexIndex4]);
419 auto edgeCnt =
_edges.size();
424 PRECICE_DEBUG(
"Compression removed {} tetrahedra ({} to {}), {} triangles ({} to {}), and {} edges ({} to {})",
432template <
class Primitive,
int... Indices>
448template <
class Primitive>
449auto sortedVertexPtrsFor(Primitive &p)
472 triangles.insert(sortedVertexPtrsFor(t));
484 auto [a, b, c, d] = sortedVertexPtrsFor(t);
486 createTriangleIfMissing(a, b, c);
487 createTriangleIfMissing(a, b, d);
488 createTriangleIfMissing(a, c, d);
489 createTriangleIfMissing(b, c, d);
497 edges.emplace(sortedVertexPtrsFor(e));
502 if (
edges.count({a, b}) == 0) {
508 auto [a, b, c] = sortedVertexPtrsFor(t);
510 createEdgeIfMissing(a, b);
511 createEdgeIfMissing(a, c);
512 createEdgeIfMissing(b, c);
515 PRECICE_DEBUG(
"Generated {} implicit triangles and {} implicit edges",
517 _edges.size() - explEdges);
534 return !(*
this == other);
540 os <<
"GEOMETRYCOLLECTION(\n";
541 const auto token =
", ";
542 const auto *sep =
"";
548 for (
auto &edge : m.
edges()) {
554 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.
std::deque< Triangle > TriangleContainer
int _globalNumberOfVertices
Number of unique vertices for complete distributed mesh.
int getDimensions() const
VertexContainer & vertices()
Returns modifieable container holding all vertices.
void clearDataStamples()
Clears all data stamples.
std::vector< PtrData > DataContainer
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)
bool operator!=(const Mesh &other) const
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::deque< Tetrahedron > TetraContainer
bool operator==(const Mesh &other) const
std::vector< Rank > _connectedRanks
each rank stores list of connected remote ranks. In the m2n package, this is used to create the initi...
bool _isJustInTime
for just-in-time mapping, we need an artificial mesh, which we can use
TetraContainer _tetrahedra
Vertex & vertex(VertexID id)
Mutable access to a vertex by VertexID.
bool isJustInTime() const
Mesh(std::string name, int dimensions, MeshID id, bool isJustInTime=false)
Constructor.
const query::Index & index() const
Call preprocess() before index() to ensure correct projection handling.
VertexContainer _vertices
Holds vertices, edges, triangles and tetrahedra.
bool hasDataName(std::string_view dataName) const
Returns whether Mesh has Data with the dataName.
std::deque< Edge > EdgeContainer
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
bool isPartitionEmpty(Rank rank) const
checks if the given ranks partition is empty
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.
std::deque< Vertex > VertexContainer
Edge & createEdge(Vertex &vertexOne, Vertex &vertexTwo)
Creates and initializes an Edge object.
Vertex & createVertex(const Eigen::Ref< const Eigen::VectorXd > &coords)
Creates and initializes a Vertex object.
EdgeContainer & edges()
Returns modifiable container holding all edges.
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.
void setGlobalIndex(int globalIndex)
void setOwner(bool owner)
T is_permutation(T... args)
provides Mesh, Data and primitives.
std::shared_ptr< Data > PtrData
std::ostream & operator<<(std::ostream &os, const BoundingBox &bb)