OGS
MeshLib::MeshSubset Class Reference

Detailed Description

A subset of nodes on a single mesh.

Definition at line 25 of file MeshSubset.h.

#include <MeshSubset.h>

Collaboration diagram for MeshLib::MeshSubset:
[legend]

Public Member Functions

 MeshSubset (const Mesh &msh, std::vector< Node * > const &vec_items, const bool use_taylor_hood_elements=false)
 
std::size_t getMeshID () const
 return this mesh ID
 
bool useTaylorHoodElements () const
 
std::vector< Element * >::const_iterator elementsBegin () const
 
std::vector< Element * >::const_iterator elementsEnd () const
 
std::vector< Node * > const & getNodes () const
 
Mesh const & getMesh () const
 

Private Attributes

Mesh const & _msh
 
std::vector< Node * > const & _nodes
 
bool const _use_taylor_hood_elements
 

Constructor & Destructor Documentation

◆ MeshSubset()

MeshLib::MeshSubset::MeshSubset ( const Mesh & msh,
std::vector< Node * > const & vec_items,
const bool use_taylor_hood_elements = false )
inline

Construct a mesh subset from vector of nodes on the given mesh.

Parameters
mshMesh
vec_itemsVector of Node pointers.
use_taylor_hood_elementsFlag to indicate whether the Taylor-Hood elements are used.

Definition at line 33 of file MeshSubset.h.

35 : _msh(msh),
36 _nodes(vec_items),
37 _use_taylor_hood_elements(use_taylor_hood_elements)
38 {
39 // If the mesh nodes and the given nodes point to the same vector, they
40 // must be equal.
41 if (&_msh.getNodes() == &_nodes)
42 {
43 return;
44 }
45
46 //
47 // Testing if the given nodes belong to the mesh.
48 //
49 {
50 // Need sorted version of the large vector.
51 auto sorted_nodes = _msh.getNodes(); // full copy of pointers.
52 sort(begin(sorted_nodes), end(sorted_nodes));
53
54 // Then proceed with the search function.
55 auto node_is_part_of_mesh =
56 [&mesh_nodes = sorted_nodes](MeshLib::Node* const& n)
57 {
58 auto it = lower_bound(begin(mesh_nodes), end(mesh_nodes), n);
59 if (it == end(mesh_nodes))
60 {
61 ERR("A node {:d} ({:g}, {:g}, {:g}) in mesh subset is not "
62 "a part of the mesh.",
63 n->getID(), (*n)[0], (*n)[1], (*n)[2]);
64 return false;
65 }
66 return true;
67 };
68 if (!std::all_of(begin(_nodes), end(_nodes), node_is_part_of_mesh))
69 {
70 OGS_FATAL("The mesh subset construction failed.");
71 }
72 }
73 }
#define OGS_FATAL(...)
Definition Error.h:26
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
std::vector< Node * > const & _nodes
Definition MeshSubset.h:96
Mesh const & _msh
Definition MeshSubset.h:95
bool const _use_taylor_hood_elements
Definition MeshSubset.h:97
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:106

References _msh, _nodes, ERR(), MeshLib::Mesh::getNodes(), and OGS_FATAL.

Member Function Documentation

◆ elementsBegin()

std::vector< Element * >::const_iterator MeshLib::MeshSubset::elementsBegin ( ) const
inline

Definition at line 80 of file MeshSubset.h.

81 {
82 return _msh.getElements().cbegin();
83 }
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109

References _msh, and MeshLib::Mesh::getElements().

◆ elementsEnd()

std::vector< Element * >::const_iterator MeshLib::MeshSubset::elementsEnd ( ) const
inline

Definition at line 85 of file MeshSubset.h.

86 {
87 return _msh.getElements().cend();
88 }

References _msh, and MeshLib::Mesh::getElements().

◆ getMesh()

Mesh const & MeshLib::MeshSubset::getMesh ( ) const
inline

Definition at line 92 of file MeshSubset.h.

92{ return _msh; }

References _msh.

Referenced by ProcessLib::createSourceTerm(), and NumLib::MeshComponentMap::getSubset().

◆ getMeshID()

◆ getNodes()

std::vector< Node * > const & MeshLib::MeshSubset::getNodes ( ) const
inline

Definition at line 90 of file MeshSubset.h.

90{ return _nodes; }

References _nodes.

Referenced by NumLib::MeshComponentMap::getSubset().

◆ useTaylorHoodElements()

bool MeshLib::MeshSubset::useTaylorHoodElements ( ) const
inline

Definition at line 78 of file MeshSubset.h.

References _use_taylor_hood_elements.

Member Data Documentation

◆ _msh

Mesh const& MeshLib::MeshSubset::_msh
private

Definition at line 95 of file MeshSubset.h.

Referenced by MeshSubset(), elementsBegin(), elementsEnd(), getMesh(), and getMeshID().

◆ _nodes

std::vector<Node*> const& MeshLib::MeshSubset::_nodes
private

Definition at line 96 of file MeshSubset.h.

Referenced by MeshSubset(), and getNodes().

◆ _use_taylor_hood_elements

bool const MeshLib::MeshSubset::_use_taylor_hood_elements
private

Definition at line 97 of file MeshSubset.h.

Referenced by useTaylorHoodElements().


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