OGS
MeshGeoToolsLib::BoundaryElementsOnSurface Class Reference

Detailed Description

This class collects element faces located along a surface. Note that internal faces are not collected in this class.

Definition at line 27 of file BoundaryElementsOnSurface.h.

#include <BoundaryElementsOnSurface.h>

Collaboration diagram for MeshGeoToolsLib::BoundaryElementsOnSurface:
[legend]

Public Member Functions

 BoundaryElementsOnSurface (MeshLib::Mesh const &mesh, MeshNodeSearcher const &mshNodeSearcher, GeoLib::Surface const &sfc)
virtual ~BoundaryElementsOnSurface ()
 destructor
GeoLib::Surface const & getSurface () const
std::vector< MeshLib::Element * > const & getBoundaryElements () const

Private Attributes

GeoLib::Surface const & _sfc
std::vector< MeshLib::Element * > _boundary_elements

Constructor & Destructor Documentation

◆ BoundaryElementsOnSurface()

MeshGeoToolsLib::BoundaryElementsOnSurface::BoundaryElementsOnSurface ( MeshLib::Mesh const & mesh,
MeshNodeSearcher const & mshNodeSearcher,
GeoLib::Surface const & sfc )

Constructor

Parameters
mesha mesh object
mshNodeSearchera MeshNodeSearcher object which is internally used to search mesh nodes
sfca surface object where face elements are searched for

Definition at line 14 of file BoundaryElementsOnSurface.cpp.

17 : _sfc(sfc)
18{
19 // search elements near the surface
20 auto node_ids_on_sfc = mshNodeSearcher.getMeshNodeIDs(sfc);
21 MeshLib::ElementSearch es(mesh);
22 es.searchByNodeIDs(node_ids_on_sfc);
23 auto& ele_ids_near_sfc = es.getSearchedElementIDs();
24
25 // get a list of faces made of the nodes
26 for (auto ele_id : ele_ids_near_sfc)
27 {
28 auto* e = mesh.getElement(ele_id);
29 // skip internal elements
30 if (!e->isBoundaryElement())
31 {
32 continue;
33 }
34 // find faces on surface
35 for (unsigned i = 0; i < e->getNumberOfFaces(); i++)
36 {
37 auto* face = e->getFace(i);
38 // check
39 std::size_t cnt_match = 0;
40 for (std::size_t j = 0; j < face->getNumberOfBaseNodes(); j++)
41 {
42 if (std::find(node_ids_on_sfc.begin(), node_ids_on_sfc.end(),
43 getNodeIndex(*face, j)) != node_ids_on_sfc.end())
44 {
45 cnt_match++;
46 }
47 else
48 {
49 break;
50 }
51 }
52 // update the list
53 if (cnt_match == face->getNumberOfBaseNodes())
54 {
55 _boundary_elements.push_back(
56 const_cast<MeshLib::Element*>(face));
57 }
58 else
59 {
60 delete face;
61 }
62 }
63 }
64}
std::vector< MeshLib::Element * > _boundary_elements
std::size_t getNodeIndex(Element const &element, unsigned const idx)
Definition Element.cpp:226

References _boundary_elements, _sfc, MeshLib::Mesh::getElement(), MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeIDs(), MeshLib::ElementSearch::getSearchedElementIDs(), and MeshLib::ElementSearch::searchByNodeIDs().

◆ ~BoundaryElementsOnSurface()

MeshGeoToolsLib::BoundaryElementsOnSurface::~BoundaryElementsOnSurface ( )
virtual

destructor

Definition at line 66 of file BoundaryElementsOnSurface.cpp.

67{
68 for (auto p : _boundary_elements)
69 {
70 delete p;
71 }
72}

References _boundary_elements.

Member Function Documentation

◆ getBoundaryElements()

std::vector< MeshLib::Element * > const & MeshGeoToolsLib::BoundaryElementsOnSurface::getBoundaryElements ( ) const
inline

Return the vector of boundary elements (i.e. faces). The elements are unsorted.

Definition at line 53 of file BoundaryElementsOnSurface.h.

53{return _boundary_elements;}

References _boundary_elements.

◆ getSurface()

GeoLib::Surface const & MeshGeoToolsLib::BoundaryElementsOnSurface::getSurface ( ) const
inline

Deploying this method the user can get access to the underlying GeoLib::Surface.

Returns
the underlying GeoLib::Surface

Definition at line 48 of file BoundaryElementsOnSurface.h.

48{return _sfc;}

References _sfc.

Referenced by MeshGeoToolsLib::BoundaryElementsSearcher::getBoundaryElements().

Member Data Documentation

◆ _boundary_elements

std::vector<MeshLib::Element*> MeshGeoToolsLib::BoundaryElementsOnSurface::_boundary_elements
private

◆ _sfc

GeoLib::Surface const& MeshGeoToolsLib::BoundaryElementsOnSurface::_sfc
private

Definition at line 56 of file BoundaryElementsOnSurface.h.

Referenced by BoundaryElementsOnSurface(), and getSurface().


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