2#include <Eigen/src/Core/Matrix.h>
5#include <boost/container/flat_map.hpp>
33 _dimensions(dimensions),
35 _isJustInTime(isJustInTime),
36 _boundingBox(dimensions),
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;
188 return dptr->getID() == dataID;
197 return dptr->getName() == dataName;
214 return dptr->getName() == dataName;
232 return (0 <= vertexID) && (
static_cast<size_t>(vertexID) <
nVertices());
240 data->allocateValues(expectedCount);
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());
355 for (
const Edge &edge : deltaMesh.
edges()) {
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]);
424 PRECICE_DEBUG(
"Compression removed {} tetrahedra ({} to {}), {} triangles ({} to {}), and {} edges ({} to {})",
432template <
class Primitive,
int... Indices>
448template <
class Primitive>
449auto sortedVertexPtrsFor(Primitive &p)
483 for (
auto &t : _tetrahedra) {
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);
496 for (
auto &e : _edges) {
497 edges.
emplace(sortedVertexPtrsFor(e));
501 auto createEdgeIfMissing = [&](Vertex *a, Vertex *b) {
502 if (edges.
count({a, b}) == 0) {
507 for (
auto &t : _triangles) {
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",
516 _triangles.size() - explTriangles,
517 _edges.size() - explEdges);
520bool Mesh::operator==(
const Mesh &other)
const
525 equal &= _edges.size() == other.
_edges.
size() &&
520bool Mesh::operator==(
const Mesh &other)
const {
…}
532bool Mesh::operator!=(
const Mesh &other)
const
534 return !(*
this == other);
532bool Mesh::operator!=(
const Mesh &other)
const {
…}
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.
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.
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, bool isJustInTime=false)
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
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.
query::Index & index()
Call preprocess() before index() to ensure correct projection handling.
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.
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.