OGS
MeshLib::MeshSubset Class Reference

Detailed Description

A subset of nodes on a single mesh.

Definition at line 16 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 24 of file MeshSubset.h.

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

References _msh, _nodes, _use_taylor_hood_elements, and OGS_FATAL.

Member Function Documentation

◆ elementsBegin()

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

Definition at line 71 of file MeshSubset.h.

72 {
73 return _msh.getElements().cbegin();
74 }

References _msh.

◆ elementsEnd()

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

Definition at line 76 of file MeshSubset.h.

77 {
78 return _msh.getElements().cend();
79 }

References _msh.

◆ getMesh()

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

Definition at line 83 of file MeshSubset.h.

83{ return _msh; }

References _msh.

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

◆ getMeshID()

std::size_t MeshLib::MeshSubset::getMeshID ( ) const
inline

return this mesh ID

Definition at line 67 of file MeshSubset.h.

67{ return _msh.getID(); }

References _msh.

Referenced by addPrimaryVariablesToMesh(), NumLib::MeshComponentMap::getSubset(), MeshLib::views::meshLocations(), and NumLib::transformVariableFromGlobalVector().

◆ getNodes()

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

Definition at line 81 of file MeshSubset.h.

81{ return _nodes; }

References _nodes.

Referenced by NumLib::MeshComponentMap::getSubset(), and MeshLib::views::meshLocations().

◆ useTaylorHoodElements()

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

Definition at line 69 of file MeshSubset.h.

References _use_taylor_hood_elements.

Member Data Documentation

◆ _msh

Mesh const& MeshLib::MeshSubset::_msh
private

Definition at line 86 of file MeshSubset.h.

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

◆ _nodes

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

Definition at line 87 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 88 of file MeshSubset.h.

Referenced by MeshSubset(), and useTaylorHoodElements().


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