25 const std::vector<std::size_t>& elements)
33 for (std::size_t eid : elements)
36 for (
unsigned i = 0; i < e->getNumberOfNodes(); i++)
44 std::vector<std::size_t> connected_nodes;
45 for (std::size_t i = 0; i < node_marked_counts.size(); i++)
47 if (node_marked_counts[i] ==
50 connected_nodes.push_back(i);
55 return connected_nodes.size();
62 std::vector<std::size_t> del_node_idx;
64 for (
unsigned i = 0; i < nNodes; ++i)
68 del_node_idx.push_back(i);
73 return del_node_idx.size();
78 std::vector<std::size_t> vec_boundary_nodes;
85 vec_boundary_nodes.push_back(n->getID());
97 if (!elem->isBoundaryElement())
102 std::size_t
const n_edges(elem->getNumberOfEdges());
103 for (std::size_t i = 0; i < n_edges; ++i)
105 if (elem->getNeighbor(i) !=
nullptr)
109 std::unique_ptr<MeshLib::Element const> edge(elem->getEdge(i));
110 for (
unsigned j = 0; j < edge->getNumberOfNodes(); j++)
112 vec_boundary_nodes.push_back(edge->getNode(j)->getID());
125 if (!elem->isBoundaryElement())
130 std::size_t
const n_faces(elem->getNumberOfFaces());
131 for (std::size_t i = 0; i < n_faces; ++i)
133 if (elem->getNeighbor(i) !=
nullptr)
137 std::unique_ptr<MeshLib::Element const> face(elem->getFace(i));
138 for (
unsigned j = 0; j < face->getNumberOfNodes(); j++)
140 vec_boundary_nodes.push_back(face->getNode(j)->getID());
145 std::sort(vec_boundary_nodes.begin(), vec_boundary_nodes.end());
146 vec_boundary_nodes.erase(
147 std::unique(vec_boundary_nodes.begin(), vec_boundary_nodes.end()),
148 vec_boundary_nodes.end());
151 return vec_boundary_nodes.size();
156 std::vector<std::size_t> vec_temp(vec.size() +
_marked_nodes.size());
157 auto it = std::set_union(vec.begin(), vec.end(),
_marked_nodes.begin(),
159 vec_temp.resize(it - vec_temp.begin());
165 std::set<Node*> nodes_set;
166 for (
auto e : elements)
168 Node*
const* nodes = e->getNodes();
169 unsigned const nnodes = e->getNumberOfNodes();
170 nodes_set.insert(nodes, nodes + nnodes);
173 std::vector<Node*> nodes;
174 nodes.reserve(nodes_set.size());
176 std::move(nodes_set.cbegin(), nodes_set.cend(), std::back_inserter(nodes));
Definition of the Element class.
Definition of the Mesh class.
Definition of the Node class.
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
const Node * getNode(std::size_t idx) const
Get the node with the given index.
const Element * getElement(std::size_t idx) const
Get the element with the given index.
std::size_t getNumberOfNodes() const
Get the number of nodes.
std::vector< Element const * > const & getElementsConnectedToNode(std::size_t node_id) const
std::size_t searchNodesConnectedToOnlyGivenElements(const std::vector< std::size_t > &elements)
std::vector< std::size_t > _marked_nodes
The vector of element indices that should be removed.
std::size_t searchBoundaryNodes()
Marks all boundary nodes.
const MeshLib::Mesh & _mesh
The mesh from which elements should be removed.
NodeSearch(const MeshLib::Mesh &mesh)
void updateUnion(const std::vector< std::size_t > &vec)
Updates the vector of marked items with values from vec.
std::size_t searchUnused()
Marks all unused nodes.
std::size_t getNodeIndex(Element const &element, unsigned const idx)
std::vector< Node * > getUniqueNodes(std::vector< Element * > const &elements)
Create a vector of unique nodes used by given elements.