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

add a function to search connected element ids

parent bb11199e
No related branches found
No related tags found
No related merge requests found
/**
* \copyright
* Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include "MeshSearcher.h"
#include "Mesh.h"
#include "Node.h"
#include "Elements/Element.h"
namespace MeshLib
{
std::vector<std::size_t> getConnectedElements(MeshLib::Mesh const& msh, const std::vector<std::size_t> &nodes)
{
std::vector<std::size_t> connected_elements;
for (auto* e : msh.getElements()) {
for (std::size_t j=0; j<e->getNNodes(); j++) {
if (std::find(nodes.begin(), nodes.end(), e->getNodeIndex(j))!=nodes.end()) {
connected_elements.push_back(e->getID());
break;
}
}
}
return connected_elements;
}
} // end namespace MeshLib
/**
* \copyright
* Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef MESHSEARCHER_H_
#define MESHSEARCHER_H_
#include <vector>
namespace MeshLib
{
// forward declarations
class Mesh;
/**
* get a list of elements connected to given nodes
* @param msh a mesh object
* @param node_ids a vector of mesh node ids
* @return a vector of element ids which connect to the given nodes
*/
std::vector<std::size_t> getConnectedElementIDs(MeshLib::Mesh const& msh, const std::vector<std::size_t> &node_ids);
} // end namespace MeshLib
#endif //MESHSEARCHER_H_
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