Caribou
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
caribou::topology::Domain< Mesh, Element, NodeIndex > Class Template Referencefinal

Detailed Description

template<typename Mesh, typename Element, typename NodeIndex = UNSIGNED_INTEGER_TYPE>
class caribou::topology::Domain< Mesh, Element, NodeIndex >

A Domain is a subspace of a Mesh containing a set of points and the topological relation between them. It does not contain any world positions of the points, but only their connectivity.

The Domain class supports either internal storing of the node connectivity, or external storing ( for example when the vector of node indices for every elements are stored externally).

In a Domain, all the elements are of the same type. For example, a Domain can not contain both hexahedrons and tetrahedrons.

A Domain can only reside inside one and only one Mesh. In fact, only a Mesh can create a Domain instance. The Mesh will typically contain one or more domains.

Example of a domain that stores internally its connectivity:

// We supposed the Mesh containing the position of the nodes have been created before.
Mesh<_3D> * mesh = get_mesh();
// Set the node connectivity of 4 triangles (each having 3 nodes).
Eigen::Matrix<unsigned int, 4, 3> indices;
indices << 0, 1, 3, // Triangle 1
1, 4, 5, // Triangle 2
8, 3, 1, // Triangle 3
9, 5, 1; // Triangle 4
// Here the indices array will be copied into the domain. It can therefore
// be safely deleted once the domain has been added to the mesh
mesh->add_domain<Triangle<_3D, Linear>>(indices);

Example of a domain that uses the connectivity stored externally:

// We supposed the mesh containing the position of the nodes have been created before.
Mesh<_3D> * mesh = get_mesh();
// Set the node connectivity of 4 triangles (each having 3 nodes).
unsigned int indices[8] = {0, 1, 3, // Triangle 1
1, 4, 5, // Triangle 2
8, 3, 1, // Triangle 3
9, 5, 1}; // Triangle 4
// Here the indices array will NOT be copied into the domain.
// Hence, it must remain valid for the entire lifetime of the domain.
mesh->add_domain<Triangle<_3D, Linear>>(indices, 4, 3);
Note
More examples can be found in the file src/Caribou/Topology/test/test_domain.cpp
Template Parameters
ElementSee caribou::geometry::Element
NodeIndexThe type of integer used for a node index

#include <Domain.h>

Inheritance diagram for caribou::topology::Domain< Mesh, Element, NodeIndex >:
caribou::topology::BaseDomain

Public Types

using MeshType = Mesh
 
using ElementType = Element
 
using NodeIndexType = NodeIndex
 
using ElementsIndices = Eigen::Matrix< NodeIndex, Eigen::Dynamic, geometry::traits< Element >::NumberOfNodesAtCompileTime, Eigen::RowMajor >
 
using ElementIndices = Eigen::Matrix< NodeIndex, geometry::traits< Element >::NumberOfNodesAtCompileTime, 1 >
 

Public Member Functions

 Domain ()=delete
 
 Domain (const Domain &other) noexcept
 
auto operator= (Domain other) noexcept -> Domain &
 
 ~Domain () final=default
 
auto canonical_dimension () const -> UNSIGNED_INTEGER_TYPE final
 Get the canonical dimension of the element contained in this domain, ie, the number of coordinates of a point relative to the element basis. More...
 
auto number_of_nodes_per_elements () const -> UNSIGNED_INTEGER_TYPE final
 Get the number of nodes an element of this domain has. More...
 
auto number_of_elements () const -> UNSIGNED_INTEGER_TYPE final
 Get the number of elements contained in the domain. More...
 
template<typename EigenMatrix >
auto element (const UNSIGNED_INTEGER_TYPE &element_id, const Eigen::DenseBase< EigenMatrix > &positions) const -> Element
 
auto element (const UNSIGNED_INTEGER_TYPE &element_id) const -> Element
 
auto element_indices (const UNSIGNED_INTEGER_TYPE &index) const
 
auto mesh () const -> const Mesh &
 
template<typename Derived >
auto embed (const Eigen::MatrixBase< Derived > &points) const -> BarycentricContainer< Domain >
 Embed a set of nodes (in world coordinates) inside this domain. More...
 
- Public Member Functions inherited from caribou::topology::BaseDomain
virtual ~BaseDomain ()=default
 Destructor.
 

Static Public Attributes

static constexpr INTEGER_TYPE Dimension = geometry::traits<Element>::Dimension
 

Protected Member Functions

 Domain (const Mesh *mesh, const ElementsIndices &elements)
 
 Domain (const Mesh *mesh, ElementsIndices &elements)
 
 Domain (const Mesh *mesh, const ElementsIndices *elements)
 
 Domain (const Mesh *mesh, const NodeIndex *data, const Eigen::Index &number_of_elements, const Eigen::Index &number_of_nodes_per_elements)
 
 Domain (const Mesh *mesh, const NodeIndex *data, const Eigen::Index &number_of_elements, const Eigen::Index &number_of_nodes_per_elements, Eigen::Index outer_stride, Eigen::Index inner_stride)
 

Protected Attributes

const Meshp_mesh
 The mesh associated with this domain.
 
ElementsIndices p_buffer
 Buffer containing the element indices. More...
 
Eigen::Map< const ElementsIndices, Eigen::Unaligned, Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > > p_elements
 Actual pointer to the element indices. More...
 

Friends

void swap (Domain &first, Domain &second) noexcept
 

Member Typedef Documentation

◆ ElementIndices

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
using caribou::topology::Domain< Mesh, Element, NodeIndex >::ElementIndices = Eigen::Matrix<NodeIndex, geometry::traits<Element>::NumberOfNodesAtCompileTime, 1>

The type of container that stores the node indices of a single element.

◆ ElementsIndices

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
using caribou::topology::Domain< Mesh, Element, NodeIndex >::ElementsIndices = Eigen::Matrix<NodeIndex, Eigen::Dynamic, geometry::traits<Element>::NumberOfNodesAtCompileTime, Eigen::RowMajor>

The type of container that stores the node indices of all the elements of the domain.

The indices should be stored in a dense matrix where each row represent an element, and the columns are the node indices of the element row.

Constructor & Destructor Documentation

◆ Domain() [1/7]

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
caribou::topology::Domain< Mesh, Element, NodeIndex >::Domain ( )
delete

Empty constructor is prohibited

◆ Domain() [2/7]

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
caribou::topology::Domain< Mesh, Element, NodeIndex >::Domain ( const Domain< Mesh, Element, NodeIndex > &  other)
inlinenoexcept

Copy constructor

◆ ~Domain()

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
caribou::topology::Domain< Mesh, Element, NodeIndex >::~Domain ( )
finaldefault

Destructor

◆ Domain() [3/7]

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
caribou::topology::Domain< Mesh, Element, NodeIndex >::Domain ( const Mesh mesh,
const ElementsIndices elements 
)
inlineprotected

Construct the domain from an array of indices.

Note
The indices are copied.

◆ Domain() [4/7]

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
caribou::topology::Domain< Mesh, Element, NodeIndex >::Domain ( const Mesh mesh,
ElementsIndices elements 
)
inlineprotected

Construct the domain from an array of indices.

Note
The indices are copied.

◆ Domain() [5/7]

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
caribou::topology::Domain< Mesh, Element, NodeIndex >::Domain ( const Mesh mesh,
const ElementsIndices elements 
)
inlineprotected

Construct the domain from a reference to an external array of indices.

Note
The indices are NOT copied. If the external array of indices is deleted, or changes, the behavior of the domain is undefined.

◆ Domain() [6/7]

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
caribou::topology::Domain< Mesh, Element, NodeIndex >::Domain ( const Mesh mesh,
const NodeIndex *  data,
const Eigen::Index &  number_of_elements,
const Eigen::Index &  number_of_nodes_per_elements 
)
inlineexplicitprotected

Construct the domain from a reference to an external array of indices.

Note
The indices are NOT copied. If the external array of indices is deleted, or changes, the behavior of the domain is undefined.

◆ Domain() [7/7]

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
caribou::topology::Domain< Mesh, Element, NodeIndex >::Domain ( const Mesh mesh,
const NodeIndex *  data,
const Eigen::Index &  number_of_elements,
const Eigen::Index &  number_of_nodes_per_elements,
Eigen::Index  outer_stride,
Eigen::Index  inner_stride 
)
inlineexplicitprotected

Construct the domain from a reference to an array of indices.

Note
The indices are NOT copied. If the external array of indices is deleted, or changes, the behavior of the domain is undefined.

Member Function Documentation

◆ canonical_dimension()

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
auto caribou::topology::Domain< Mesh, Element, NodeIndex >::canonical_dimension ( ) const -> UNSIGNED_INTEGER_TYPE
inlinefinalvirtual

Get the canonical dimension of the element contained in this domain, ie, the number of coordinates of a point relative to the element basis.

For example, a triangle has a canonical dimension of 2, even if it is inside a 3 dimensions mesh : a point inside the triangle has coordinates (x,y,z) relative to the mesh's basis, and coordinates (u, v) relative to the triangle's first node.

Implements caribou::topology::BaseDomain.

◆ element() [1/2]

template<typename Mesh , typename Element , typename NodeIndex >
auto caribou::topology::Domain< Mesh, Element, NodeIndex >::element ( const UNSIGNED_INTEGER_TYPE &  element_id) const -> Element
inline

Construct an element of the domain using the positions vector of the associated mesh.

Parameters
element_idThe id of the element in this domain.
Returns
A new Element instance from the domain

◆ element() [2/2]

template<typename Mesh , typename Element , typename NodeIndex >
template<typename EigenMatrix >
auto caribou::topology::Domain< Mesh, Element, NodeIndex >::element ( const UNSIGNED_INTEGER_TYPE &  element_id,
const Eigen::DenseBase< EigenMatrix > &  positions 
) const -> Element
inline

Construct an element of the domain

Parameters
element_idThe id of the element in this domain.
positionsAn eigen matrix containing all the positions of the mesh. The matrix should have N rows and D columns for a mesh of dimension D containing N nodes.
Returns
A new Element instance from the domain

◆ element_indices()

template<typename Mesh , typename Element , typename NodeIndex >
auto caribou::topology::Domain< Mesh, Element, NodeIndex >::element_indices ( const UNSIGNED_INTEGER_TYPE &  index) const
inline

Get the indices of an element in the domain.

Parameters
indexThe index of the element.
Returns
An Eigen vector containing the element indices.

◆ embed()

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
template<typename Derived >
auto caribou::topology::Domain< Mesh, Element, NodeIndex >::embed ( const Eigen::MatrixBase< Derived > &  points) const -> BarycentricContainer<Domain>
inline

Embed a set of nodes (in world coordinates) inside this domain.

This will return a BarycentricContainer that can be used to interpolate field values on these embedded nodes.

Template Parameters
DerivedNXD Eigen matrix representing the D dimensional coordinates of the N embedded points.
Parameters
pointsThe positions (in world coordinates) of the nodes embedded in this domain.
Returns
A BarycentricContainer instance.

◆ mesh()

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
auto caribou::topology::Domain< Mesh, Element, NodeIndex >::mesh ( ) const -> const Mesh &
inline

Get the mesh associated to this domain.

◆ number_of_elements()

template<typename Mesh , typename Element , typename NodeIndex >
auto caribou::topology::Domain< Mesh, Element, NodeIndex >::number_of_elements
finalvirtual

Get the number of elements contained in the domain.

Implements caribou::topology::BaseDomain.

◆ number_of_nodes_per_elements()

template<typename Mesh , typename Element , typename NodeIndex >
auto caribou::topology::Domain< Mesh, Element, NodeIndex >::number_of_nodes_per_elements
finalvirtual

Get the number of nodes an element of this domain has.

Implements caribou::topology::BaseDomain.

◆ operator=()

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
auto caribou::topology::Domain< Mesh, Element, NodeIndex >::operator= ( Domain< Mesh, Element, NodeIndex >  other) -> Domain &
inlinenoexcept

Move constructor *‍/ Domain(Domain && other) noexcept { swap(*this, other); }

    /*! copy-and-swap assigment (valid for both copy and move assigment) 

Member Data Documentation

◆ p_buffer

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
ElementsIndices caribou::topology::Domain< Mesh, Element, NodeIndex >::p_buffer
protected

Buffer containing the element indices.

This buffer is used when the domain is constructed by copying an array of element indices. If the domain is constructed from a mapped buffer (ie, the indices are stored outside of the domain instance), then this buffer is empty.

◆ p_elements

template<typename Mesh , typename Element , typename NodeIndex = UNSIGNED_INTEGER_TYPE>
Eigen::Map<const ElementsIndices, Eigen::Unaligned, Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> > caribou::topology::Domain< Mesh, Element, NodeIndex >::p_elements
protected

Actual pointer to the element indices.

When the domain is constructed by copying an array of element indices, this map points to p_buffer. Else, it points to an external buffer.


The documentation for this class was generated from the following file:
caribou::topology::Domain::mesh
auto mesh() const -> const Mesh &
Definition: Domain.h:165