OGS
MeshLib::MeshSubset Class Reference

Detailed Description

A subset of nodes on a single mesh.

Definition at line 26 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)
 
std::size_t getMeshID () const
 return this mesh ID More...
 
std::size_t getNumberOfNodes () const
 return the number of registered nodes More...
 
std::size_t getNodeID (std::size_t const i) 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
 

Constructor & Destructor Documentation

◆ MeshSubset()

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

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

Parameters
mshMesh
vec_itemsVector of Node pointers.

Definition at line 32 of file MeshSubset.h.

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

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 91 of file MeshSubset.h.

92  {
93  return _msh.getElements().cbegin();
94  }
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:98

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

◆ elementsEnd()

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

Definition at line 96 of file MeshSubset.h.

97  {
98  return _msh.getElements().cend();
99  }

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

◆ getMesh()

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

Definition at line 106 of file MeshSubset.h.

107  {
108  return _msh;
109  }

References _msh.

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

◆ getMeshID()

◆ getNodeID()

std::size_t MeshLib::MeshSubset::getNodeID ( std::size_t const  i) const
inline

Returns the global node id Node::getID() of i-th node in the mesh subset.

Precondition
The _nodes vector must be of size > i.

Definition at line 85 of file MeshSubset.h.

86  {
87  assert(i < _nodes.size());
88  return _nodes[i]->getID();
89  }

References _nodes.

◆ getNodes()

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

Definition at line 101 of file MeshSubset.h.

102  {
103  return _nodes;
104  }

References _nodes.

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

◆ getNumberOfNodes()

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

return the number of registered nodes

Definition at line 77 of file MeshSubset.h.

78  {
79  return _nodes.size();
80  }

References _nodes.

Member Data Documentation

◆ _msh

Mesh const& MeshLib::MeshSubset::_msh
private

Definition at line 112 of file MeshSubset.h.

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

◆ _nodes

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

Definition at line 113 of file MeshSubset.h.

Referenced by MeshSubset(), getNodeID(), getNodes(), and getNumberOfNodes().


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