preCICE v3.1.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
precice::mesh::Mesh Class Reference

Container and creator for meshes. More...

#include <Mesh.hpp>

Collaboration diagram for precice::mesh::Mesh:
[legend]

Public Types

using VertexContainer = std::deque<Vertex>
 
using EdgeContainer = std::deque<Edge>
 
using TriangleContainer = std::deque<Triangle>
 
using TetraContainer = std::deque<Tetrahedron>
 
using DataContainer = std::vector<PtrData>
 
using BoundingBoxMap = std::map<int, BoundingBox>
 
using VertexDistribution = std::map<Rank, std::vector<VertexID>>
 A mapping from rank to used (not necessarily owned) vertex IDs.
 
using CommunicationMap = std::map<Rank, std::vector<VertexID>>
 A mapping from remote local ranks to the IDs that must be communicated.
 
using ConnectionMap = CommunicationMap
 
using VertexOffsets = std::vector<int>
 

Public Member Functions

 Mesh (std::string name, int dimensions, MeshID id)
 Constructor.
 
Vertexvertex (VertexID id)
 Mutable access to a vertex by VertexID.
 
const Vertexvertex (VertexID id) const
 Const access to a vertex by VertexID.
 
VertexContainervertices ()
 Returns modifieable container holding all vertices.
 
const VertexContainervertices () const
 Returns const container holding all vertices.
 
std::size_t nVertices () const
 Returns the number of vertices.
 
bool empty () const
 Does the mesh contain any vertices?
 
EdgeContaineredges ()
 Returns modifiable container holding all edges.
 
const EdgeContaineredges () const
 Returns const container holding all edges.
 
bool hasEdges () const
 
TriangleContainertriangles ()
 Returns modifiable container holding all triangles.
 
const TriangleContainertriangles () const
 Returns const container holding all triangles.
 
bool hasTriangles () const
 
TetraContainertetrahedra ()
 Returns modifiable container holding all tetrahedra.
 
const TetraContainertetrahedra () const
 Returns const container holding all tetrahedra.
 
bool hasTetrahedra () const
 
bool hasConnectivity () const
 
int getDimensions () const
 
VertexcreateVertex (const Eigen::VectorXd &coords)
 Creates and initializes a Vertex object.
 
EdgecreateEdge (Vertex &vertexOne, Vertex &vertexTwo)
 Creates and initializes an Edge object.
 
TrianglecreateTriangle (Edge &edgeOne, Edge &edgeTwo, Edge &edgeThree)
 Creates and initializes a Triangle object.
 
TrianglecreateTriangle (Vertex &vertexOne, Vertex &vertexTwo, Vertex &vertexThree)
 Creates and initializes a Triangle object.
 
TetrahedroncreateTetrahedron (Vertex &vertexOne, Vertex &vertexTwo, Vertex &vertexThree, Vertex &vertexFour)
 Creates and initializes a Tetrahedron object.
 
PtrDatacreateData (const std::string &name, int dimension, DataID id, int waveformDegree=time::Time::DEFAULT_WAVEFORM_DEGREE)
 Create only data for vertex.
 
const DataContainerdata () const
 Allows access to all data.
 
bool hasDataID (DataID dataID) const
 Returns whether Mesh has Data with the matchingID.
 
const PtrDatadata (DataID dataID) const
 Returns the data with the matching ID.
 
bool hasDataName (std::string_view dataName) const
 Returns whether Mesh has Data with the dataName.
 
std::vector< std::stringavailableData () const
 Returns the names of all available data.
 
const PtrDatadata (std::string_view dataName) const
 Returns the data with the matching name.
 
const std::stringgetName () const
 Returns the name of the mesh, as set in the config file.
 
MeshID getID () const
 Returns the base ID of the mesh.
 
bool isValidVertexID (VertexID vertexID) const
 Returns true if the given vertexID is valid.
 
void allocateDataValues ()
 Allocates memory for the vertex data values and corresponding gradient values.
 
void computeBoundingBox ()
 Computes the boundingBox for the vertices.
 
void clear ()
 Removes all mesh elements and data values (does not remove data or the bounding boxes).
 
void clearPartitioning ()
 Clears the partitioning information.
 
void setVertexDistribution (VertexDistribution vd)
 
const VertexDistributiongetVertexDistribution () const
 Returns a mapping from rank to used (not necessarily owned) vertex IDs.
 
const VertexOffsetsgetVertexOffsets () const
 
void setVertexOffsets (VertexOffsets vertexOffsets)
 Only used for tests.
 
int getGlobalNumberOfVertices () const
 
void setGlobalNumberOfVertices (int num)
 
Eigen::VectorXd getOwnedVertexData (const Eigen::VectorXd &values)
 
void tagAll ()
 
const std::vector< Rank > & getConnectedRanks () const
 Returns a vector of connected ranks.
 
void setConnectedRanks (std::vector< Rank > ranks)
 Returns a vector of connected ranks.
 
CommunicationMapgetCommunicationMap ()
 Returns a mapping from remote local connected ranks to the corresponding vertex IDs.
 
void addMesh (Mesh &deltaMesh)
 
const BoundingBoxgetBoundingBox () const
 Returns the bounding box of the mesh.
 
void expandBoundingBox (const BoundingBox &bounding_box)
 
bool operator== (const Mesh &other) const
 
bool operator!= (const Mesh &other) const
 
const query::Indexindex () const
 Call preprocess() before index() to ensure correct projection handling.
 
query::Indexindex ()
 Call preprocess() before index() to ensure correct projection handling.
 
void preprocess ()
 

Static Public Attributes

static constexpr MeshID MESH_ID_UNDEFINED {-1}
 Use if the id of the mesh is not necessary.
 

Private Member Functions

void removeDuplicates ()
 Removes all duplicate connectivity.
 
void generateImplictPrimitives ()
 

Private Attributes

logging::Logger _log {"mesh::Mesh"}
 
std::string _name
 Name of the mesh.
 
int _dimensions
 Dimension of mesh.
 
MeshID _id
 The ID of this mesh.
 
VertexContainer _vertices
 Holds vertices, edges, triangles and tetrahedra.
 
EdgeContainer _edges
 
TriangleContainer _triangles
 
TetraContainer _tetrahedra
 
DataContainer _data
 Data hold by the vertices of the mesh.
 
VertexDistribution _vertexDistribution
 Vertex distribution for the primary rank, holding for each secondary rank all vertex IDs it owns.
 
VertexOffsets _vertexOffsets
 Holds the index of the last vertex for each rank.
 
int _globalNumberOfVertices = -1
 Number of unique vertices for complete distributed mesh.
 
std::vector< Rank_connectedRanks
 each rank stores list of connected remote ranks. In the m2n package, this is used to create the initial communication channels.
 
CommunicationMap _communicationMap
 each rank stores list of connected ranks and corresponding vertex IDs here. In the m2n package, this is used to create the final communication channels.
 
BoundingBox _boundingBox
 
query::Index _index
 

Detailed Description

Container and creator for meshes.

A Mesh can consist of Vertices, Edges, Triangles, and nested Meshes. It provides functionality to conveniently create those objects.

In addition to creating the topological information of a mesh, the Mesh class can also be used to add data to the vertices of a mesh, such as function values or also gradient values.

Usage example: precice::mesh::tests::MeshTest::testDemonstration()

Definition at line 39 of file Mesh.hpp.

Member Typedef Documentation

◆ BoundingBoxMap

Definition at line 46 of file Mesh.hpp.

◆ CommunicationMap

A mapping from remote local ranks to the IDs that must be communicated.

Definition at line 52 of file Mesh.hpp.

◆ ConnectionMap

Definition at line 53 of file Mesh.hpp.

◆ DataContainer

Definition at line 45 of file Mesh.hpp.

◆ EdgeContainer

Definition at line 42 of file Mesh.hpp.

◆ TetraContainer

Definition at line 44 of file Mesh.hpp.

◆ TriangleContainer

Definition at line 43 of file Mesh.hpp.

◆ VertexContainer

Definition at line 41 of file Mesh.hpp.

◆ VertexDistribution

A mapping from rank to used (not necessarily owned) vertex IDs.

Definition at line 49 of file Mesh.hpp.

◆ VertexOffsets

Definition at line 55 of file Mesh.hpp.

Constructor & Destructor Documentation

◆ Mesh()

precice::mesh::Mesh::Mesh ( std::string name,
int dimensions,
MeshID id )

Constructor.

Parameters
[in]nameUnique name of the mesh.
[in]dimensionsDimensionalty of the mesh.
[in]idThe id of this mesh

Definition at line 27 of file Mesh.cpp.

Member Function Documentation

◆ addMesh()

void precice::mesh::Mesh::addMesh ( Mesh & deltaMesh)

Definition at line 309 of file Mesh.cpp.

Here is the call graph for this function:

◆ allocateDataValues()

void precice::mesh::Mesh::allocateDataValues ( )

Allocates memory for the vertex data values and corresponding gradient values.

Definition at line 233 of file Mesh.cpp.

Here is the call graph for this function:

◆ availableData()

std::vector< std::string > precice::mesh::Mesh::availableData ( ) const

Returns the names of all available data.

Definition at line 200 of file Mesh.cpp.

Here is the call graph for this function:

◆ clear()

void precice::mesh::Mesh::clear ( )

Removes all mesh elements and data values (does not remove data or the bounding boxes).

A mesh element is a

  • vertex
  • edge
  • triangle

Definition at line 256 of file Mesh.cpp.

Here is the call graph for this function:

◆ clearPartitioning()

void precice::mesh::Mesh::clearPartitioning ( )

Clears the partitioning information.

Todo
this should be handled by the Partition

Definition at line 270 of file Mesh.cpp.

Here is the call graph for this function:

◆ computeBoundingBox()

void precice::mesh::Mesh::computeBoundingBox ( )

Computes the boundingBox for the vertices.

Definition at line 242 of file Mesh.cpp.

Here is the call graph for this function:

◆ createData()

PtrData & precice::mesh::Mesh::createData ( const std::string & name,
int dimension,
DataID id,
int waveformDegree = time::Time::DEFAULT_WAVEFORM_DEGREE )

Create only data for vertex.

Definition at line 151 of file Mesh.cpp.

Here is the call graph for this function:

◆ createEdge()

Edge & precice::mesh::Mesh::createEdge ( Vertex & vertexOne,
Vertex & vertexTwo )

Creates and initializes an Edge object.

Parameters
[in]vertexOneReference to first Vertex defining the Edge.
[in]vertexTwoReference to second Vertex defining the Edge.

Definition at line 111 of file Mesh.cpp.

Here is the call graph for this function:

◆ createTetrahedron()

Tetrahedron & precice::mesh::Mesh::createTetrahedron ( Vertex & vertexOne,
Vertex & vertexTwo,
Vertex & vertexThree,
Vertex & vertexFour )

Creates and initializes a Tetrahedron object.

Parameters
[in]vertexOneReference to first vertex defining the Tetrahedron.
[in]vertexTwoReference to second vertex defining the Tetrahedron.
[in]vertexThreeReference to third vertex defining the Tetrahedron.
[in]vertexFourReference to fourth vertex defining the Tetrahedron.

Definition at line 141 of file Mesh.cpp.

Here is the call graph for this function:

◆ createTriangle() [1/2]

Triangle & precice::mesh::Mesh::createTriangle ( Edge & edgeOne,
Edge & edgeTwo,
Edge & edgeThree )

Creates and initializes a Triangle object.

Parameters
[in]edgeOneReference to first edge defining the Triangle.
[in]edgeTwoReference to second edge defining the Triangle.
[in]edgeThreeReference to third edge defining the Triangle.

Definition at line 119 of file Mesh.cpp.

Here is the call graph for this function:

◆ createTriangle() [2/2]

Triangle & precice::mesh::Mesh::createTriangle ( Vertex & vertexOne,
Vertex & vertexTwo,
Vertex & vertexThree )

Creates and initializes a Triangle object.

Parameters
[in]vertexOneReference to first edge defining the Triangle.
[in]vertexTwoReference to second edge defining the Triangle.
[in]vertexThreeReference to third edge defining the Triangle.

Definition at line 132 of file Mesh.cpp.

Here is the call graph for this function:

◆ createVertex()

Vertex & precice::mesh::Mesh::createVertex ( const Eigen::VectorXd & coords)

Creates and initializes a Vertex object.

Definition at line 103 of file Mesh.cpp.

Here is the call graph for this function:

◆ data() [1/3]

const Mesh::DataContainer & precice::mesh::Mesh::data ( ) const

Allows access to all data.

Definition at line 170 of file Mesh.cpp.

◆ data() [2/3]

const PtrData & precice::mesh::Mesh::data ( DataID dataID) const

Returns the data with the matching ID.

Definition at line 183 of file Mesh.cpp.

Here is the call graph for this function:

◆ data() [3/3]

const PtrData & precice::mesh::Mesh::data ( std::string_view dataName) const

Returns the data with the matching name.

Definition at line 209 of file Mesh.cpp.

Here is the call graph for this function:

◆ edges() [1/2]

Mesh::EdgeContainer & precice::mesh::Mesh::edges ( )

Returns modifiable container holding all edges.

Definition at line 68 of file Mesh.cpp.

◆ edges() [2/2]

const Mesh::EdgeContainer & precice::mesh::Mesh::edges ( ) const

Returns const container holding all edges.

Definition at line 73 of file Mesh.cpp.

◆ empty()

bool precice::mesh::Mesh::empty ( ) const
inline

Does the mesh contain any vertices?

Definition at line 88 of file Mesh.hpp.

Here is the call graph for this function:

◆ expandBoundingBox()

void precice::mesh::Mesh::expandBoundingBox ( const BoundingBox & bounding_box)

Definition at line 370 of file Mesh.cpp.

Here is the call graph for this function:

◆ generateImplictPrimitives()

void precice::mesh::Mesh::generateImplictPrimitives ( )
private

Generates implicit primitives for correct projection handling

removeDuplicates() should be called first to avoid unnecessary filtering.

Definition at line 432 of file Mesh.cpp.

Here is the call graph for this function:

◆ getBoundingBox()

const BoundingBox & precice::mesh::Mesh::getBoundingBox ( ) const

Returns the bounding box of the mesh.

BoundingBox is a vector of pairs (min, max), one pair for each dimension. Note that the bounding box does not necessarily need to match the bounding box of the contained vertices of the mesh. Examples are the direct mesh access or a computation of the bounding box before applying additional filtering during the repartitioning. Note that mesh::clear doesn't clear the underlying bounding box (which is potentially a user input when using and defining direct mesh access)

Definition at line 365 of file Mesh.cpp.

◆ getCommunicationMap()

CommunicationMap & precice::mesh::Mesh::getCommunicationMap ( )
inline

Returns a mapping from remote local connected ranks to the corresponding vertex IDs.

Definition at line 288 of file Mesh.hpp.

◆ getConnectedRanks()

const std::vector< Rank > & precice::mesh::Mesh::getConnectedRanks ( ) const
inline

Returns a vector of connected ranks.

Definition at line 276 of file Mesh.hpp.

◆ getDimensions()

int precice::mesh::Mesh::getDimensions ( ) const

Definition at line 98 of file Mesh.cpp.

◆ getGlobalNumberOfVertices()

int precice::mesh::Mesh::getGlobalNumberOfVertices ( ) const
inline

Definition at line 259 of file Mesh.hpp.

◆ getID()

MeshID precice::mesh::Mesh::getID ( ) const

Returns the base ID of the mesh.

Definition at line 223 of file Mesh.cpp.

◆ getName()

const std::string & precice::mesh::Mesh::getName ( ) const

Returns the name of the mesh, as set in the config file.

Definition at line 218 of file Mesh.cpp.

◆ getOwnedVertexData()

Eigen::VectorXd precice::mesh::Mesh::getOwnedVertexData ( const Eigen::VectorXd & values)

Definition at line 279 of file Mesh.cpp.

Here is the call graph for this function:

◆ getVertexDistribution()

const VertexDistribution & precice::mesh::Mesh::getVertexDistribution ( ) const
inline

Returns a mapping from rank to used (not necessarily owned) vertex IDs.

Definition at line 243 of file Mesh.hpp.

◆ getVertexOffsets()

const VertexOffsets & precice::mesh::Mesh::getVertexOffsets ( ) const
inline

Definition at line 248 of file Mesh.hpp.

◆ hasConnectivity()

bool precice::mesh::Mesh::hasConnectivity ( ) const
inline

Definition at line 126 of file Mesh.hpp.

Here is the call graph for this function:

◆ hasDataID()

bool precice::mesh::Mesh::hasDataID ( DataID dataID) const

Returns whether Mesh has Data with the matchingID.

Definition at line 175 of file Mesh.cpp.

Here is the call graph for this function:

◆ hasDataName()

bool precice::mesh::Mesh::hasDataName ( std::string_view dataName) const

Returns whether Mesh has Data with the dataName.

Definition at line 192 of file Mesh.cpp.

Here is the call graph for this function:

◆ hasEdges()

bool precice::mesh::Mesh::hasEdges ( ) const
inline

Definition at line 99 of file Mesh.hpp.

Here is the call graph for this function:

◆ hasTetrahedra()

bool precice::mesh::Mesh::hasTetrahedra ( ) const
inline

Definition at line 121 of file Mesh.hpp.

Here is the call graph for this function:

◆ hasTriangles()

bool precice::mesh::Mesh::hasTriangles ( ) const
inline

Definition at line 110 of file Mesh.hpp.

Here is the call graph for this function:

◆ index() [1/2]

query::Index & precice::mesh::Mesh::index ( )
inline

Call preprocess() before index() to ensure correct projection handling.

Definition at line 321 of file Mesh.hpp.

◆ index() [2/2]

const query::Index & precice::mesh::Mesh::index ( ) const
inline

Call preprocess() before index() to ensure correct projection handling.

Definition at line 315 of file Mesh.hpp.

◆ isValidVertexID()

bool precice::mesh::Mesh::isValidVertexID ( VertexID vertexID) const

Returns true if the given vertexID is valid.

Definition at line 228 of file Mesh.cpp.

Here is the call graph for this function:

◆ nVertices()

std::size_t precice::mesh::Mesh::nVertices ( ) const

Returns the number of vertices.

Definition at line 63 of file Mesh.cpp.

Here is the call graph for this function:

◆ operator!=()

bool precice::mesh::Mesh::operator!= ( const Mesh & other) const

Definition at line 509 of file Mesh.cpp.

◆ operator==()

bool precice::mesh::Mesh::operator== ( const Mesh & other) const

Definition at line 497 of file Mesh.cpp.

Here is the call graph for this function:

◆ preprocess()

void precice::mesh::Mesh::preprocess ( )

Removes all duplicates and generates implicit primitives.

This needs to be called for correct projection handling.

See also
removeDuplicates()
generateImplictPrimitives()

Definition at line 375 of file Mesh.cpp.

Here is the call graph for this function:

◆ removeDuplicates()

void precice::mesh::Mesh::removeDuplicates ( )
private

Removes all duplicate connectivity.

Definition at line 381 of file Mesh.cpp.

Here is the call graph for this function:

◆ setConnectedRanks()

void precice::mesh::Mesh::setConnectedRanks ( std::vector< Rank > ranks)
inline

Returns a vector of connected ranks.

Definition at line 282 of file Mesh.hpp.

◆ setGlobalNumberOfVertices()

void precice::mesh::Mesh::setGlobalNumberOfVertices ( int num)
inline

Definition at line 264 of file Mesh.hpp.

◆ setVertexDistribution()

void precice::mesh::Mesh::setVertexDistribution ( VertexDistribution vd)
inline

Definition at line 236 of file Mesh.hpp.

Here is the call graph for this function:

◆ setVertexOffsets()

void precice::mesh::Mesh::setVertexOffsets ( VertexOffsets vertexOffsets)
inline

Only used for tests.

Definition at line 254 of file Mesh.hpp.

◆ tagAll()

void precice::mesh::Mesh::tagAll ( )

Definition at line 302 of file Mesh.cpp.

Here is the call graph for this function:

◆ tetrahedra() [1/2]

Mesh::TetraContainer & precice::mesh::Mesh::tetrahedra ( )

Returns modifiable container holding all tetrahedra.

Definition at line 93 of file Mesh.cpp.

◆ tetrahedra() [2/2]

const Mesh::TetraContainer & precice::mesh::Mesh::tetrahedra ( ) const

Returns const container holding all tetrahedra.

Definition at line 88 of file Mesh.cpp.

◆ triangles() [1/2]

Mesh::TriangleContainer & precice::mesh::Mesh::triangles ( )

Returns modifiable container holding all triangles.

Definition at line 78 of file Mesh.cpp.

◆ triangles() [2/2]

const Mesh::TriangleContainer & precice::mesh::Mesh::triangles ( ) const

Returns const container holding all triangles.

Definition at line 83 of file Mesh.cpp.

◆ vertex() [1/2]

Vertex & precice::mesh::Mesh::vertex ( VertexID id)

Mutable access to a vertex by VertexID.

Definition at line 41 of file Mesh.cpp.

Here is the call graph for this function:

◆ vertex() [2/2]

const Vertex & precice::mesh::Mesh::vertex ( VertexID id) const

Const access to a vertex by VertexID.

Definition at line 47 of file Mesh.cpp.

Here is the call graph for this function:

◆ vertices() [1/2]

Mesh::VertexContainer & precice::mesh::Mesh::vertices ( )

Returns modifieable container holding all vertices.

Definition at line 53 of file Mesh.cpp.

◆ vertices() [2/2]

const Mesh::VertexContainer & precice::mesh::Mesh::vertices ( ) const

Returns const container holding all vertices.

Definition at line 58 of file Mesh.cpp.

Member Data Documentation

◆ _boundingBox

BoundingBox precice::mesh::Mesh::_boundingBox
private

Definition at line 390 of file Mesh.hpp.

◆ _communicationMap

CommunicationMap precice::mesh::Mesh::_communicationMap
private

each rank stores list of connected ranks and corresponding vertex IDs here. In the m2n package, this is used to create the final communication channels.

Definition at line 388 of file Mesh.hpp.

◆ _connectedRanks

std::vector<Rank> precice::mesh::Mesh::_connectedRanks
private

each rank stores list of connected remote ranks. In the m2n package, this is used to create the initial communication channels.

Definition at line 382 of file Mesh.hpp.

◆ _data

DataContainer precice::mesh::Mesh::_data
private

Data hold by the vertices of the mesh.

Definition at line 355 of file Mesh.hpp.

◆ _dimensions

int precice::mesh::Mesh::_dimensions
private

Dimension of mesh.

Definition at line 343 of file Mesh.hpp.

◆ _edges

EdgeContainer precice::mesh::Mesh::_edges
private

Definition at line 350 of file Mesh.hpp.

◆ _globalNumberOfVertices

int precice::mesh::Mesh::_globalNumberOfVertices = -1
private

Number of unique vertices for complete distributed mesh.

Duplicated vertices are only accounted once.

Definition at line 376 of file Mesh.hpp.

◆ _id

MeshID precice::mesh::Mesh::_id
private

The ID of this mesh.

Definition at line 346 of file Mesh.hpp.

◆ _index

query::Index precice::mesh::Mesh::_index
private

Definition at line 392 of file Mesh.hpp.

◆ _log

logging::Logger precice::mesh::Mesh::_log {"mesh::Mesh"}
mutableprivate

Definition at line 337 of file Mesh.hpp.

◆ _name

std::string precice::mesh::Mesh::_name
private

Name of the mesh.

Definition at line 340 of file Mesh.hpp.

◆ _tetrahedra

TetraContainer precice::mesh::Mesh::_tetrahedra
private

Definition at line 352 of file Mesh.hpp.

◆ _triangles

TriangleContainer precice::mesh::Mesh::_triangles
private

Definition at line 351 of file Mesh.hpp.

◆ _vertexDistribution

VertexDistribution precice::mesh::Mesh::_vertexDistribution
private

Vertex distribution for the primary rank, holding for each secondary rank all vertex IDs it owns.

For secondary ranks, this data structure is empty and should not be used.

Definition at line 362 of file Mesh.hpp.

◆ _vertexOffsets

VertexOffsets precice::mesh::Mesh::_vertexOffsets
private

Holds the index of the last vertex for each rank.

The last entry holds the total number of vertices. Needed for the matrix-matrix multiplication of the IMVJ acceleration.

Definition at line 369 of file Mesh.hpp.

◆ _vertices

VertexContainer precice::mesh::Mesh::_vertices
private

Holds vertices, edges, triangles and tetrahedra.

Definition at line 349 of file Mesh.hpp.

◆ MESH_ID_UNDEFINED

constexpr MeshID precice::mesh::Mesh::MESH_ID_UNDEFINED {-1}
staticconstexpr

Use if the id of the mesh is not necessary.

Definition at line 58 of file Mesh.hpp.


The documentation for this class was generated from the following files: