OGS
BoundaryElementsOnSurface.cpp
Go to the documentation of this file.
1
11
12#include "GeoLib/Surface.h"
15#include "MeshLib/Mesh.h"
17
18namespace MeshGeoToolsLib
19{
21 MeshLib::Mesh const& mesh, MeshNodeSearcher const& mshNodeSearcher,
22 GeoLib::Surface const& sfc)
23 : _sfc(sfc)
24{
25 // search elements near the surface
26 auto node_ids_on_sfc = mshNodeSearcher.getMeshNodeIDs(sfc);
28 es.searchByNodeIDs(node_ids_on_sfc);
29 auto& ele_ids_near_sfc = es.getSearchedElementIDs();
30
31 // get a list of faces made of the nodes
32 for (auto ele_id : ele_ids_near_sfc)
33 {
34 auto* e = mesh.getElement(ele_id);
35 // skip internal elements
36 if (!e->isBoundaryElement())
37 {
38 continue;
39 }
40 // find faces on surface
41 for (unsigned i = 0; i < e->getNumberOfFaces(); i++)
42 {
43 auto* face = e->getFace(i);
44 // check
45 std::size_t cnt_match = 0;
46 for (std::size_t j = 0; j < face->getNumberOfBaseNodes(); j++)
47 {
48 if (std::find(node_ids_on_sfc.begin(), node_ids_on_sfc.end(),
49 getNodeIndex(*face, j)) != node_ids_on_sfc.end())
50 {
51 cnt_match++;
52 }
53 else
54 {
55 break;
56 }
57 }
58 // update the list
59 if (cnt_match == face->getNumberOfBaseNodes())
60 {
61 _boundary_elements.push_back(
62 const_cast<MeshLib::Element*>(face));
63 }
64 else
65 {
66 delete face;
67 }
68 }
69 }
70}
71
73{
74 for (auto p : _boundary_elements)
75 {
76 delete p;
77 }
78}
79
80} // end namespace MeshGeoToolsLib
Definition of the Element class.
Definition of the Mesh class.
A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points...
Definition Surface.h:33
BoundaryElementsOnSurface(MeshLib::Mesh const &mesh, MeshNodeSearcher const &mshNodeSearcher, GeoLib::Surface const &sfc)
std::vector< MeshLib::Element * > _boundary_elements
std::vector< std::size_t > getMeshNodeIDs(GeoLib::GeoObject const &geoObj) const
Element search class.
const std::vector< std::size_t > & getSearchedElementIDs() const
return marked elements
std::size_t searchByNodeIDs(const std::vector< std::size_t > &nodes)
Marks all elements connecting to any of the given nodes.
virtual const Element * getFace(unsigned i) const =0
Returns the i-th face of the element.
const Element * getElement(std::size_t idx) const
Get the element with the given index.
Definition Mesh.h:94