Skip to content
Snippets Groups Projects
Commit 1b9dfdd9 authored by Norihiro Watanabe's avatar Norihiro Watanabe
Browse files

use Node::getElements()

parent 0fb1b9be
No related branches found
No related tags found
No related merge requests found
...@@ -13,20 +13,24 @@ ...@@ -13,20 +13,24 @@
#include "Node.h" #include "Node.h"
#include "Elements/Element.h" #include "Elements/Element.h"
#include <algorithm>
namespace MeshLib namespace MeshLib
{ {
std::vector<std::size_t> getConnectedElements(MeshLib::Mesh const& msh, const std::vector<std::size_t> &nodes) std::vector<std::size_t> getConnectedElements(MeshLib::Mesh const& msh, const std::vector<std::size_t> &nodes)
{ {
std::vector<std::size_t> connected_elements; std::vector<std::size_t> connected_elements;
for (auto* e : msh.getElements()) { std::for_each(nodes.begin(), nodes.end(),
for (std::size_t j=0; j<e->getNNodes(); j++) { [&](std::size_t node_id)
if (std::find(nodes.begin(), nodes.end(), e->getNodeIndex(j))!=nodes.end()) { {
for (auto* e : msh.getNode(node_id)->getElements()) {
connected_elements.push_back(e->getID()); connected_elements.push_back(e->getID());
break;
} }
} });
} std::sort(connected_elements.begin(), connected_elements.end());
auto it = std::unique(connected_elements.begin(), connected_elements.end());
connected_elements.resize(std::distance(connected_elements.begin(),it));
return connected_elements; return connected_elements;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment