Skip to content
Snippets Groups Projects
Commit 5b187888 authored by Karsten Rink's avatar Karsten Rink
Browse files

returning active nodes and elements vector

parent d37f686d
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,29 @@ ElementStatus::ElementStatus(Mesh const*const mesh)
_active_nodes.push_back((*node)->getNElements());
}
std::vector<unsigned> ElementStatus::getActiveElements() const
{
std::vector<unsigned> active_elements;
active_elements.reserve(this->getNActiveElements());
const std::size_t nElems (_mesh->getNElements());
for (std::size_t i=0; i<nElems; ++i)
if (_element_status[i])
active_elements.push_back(i);
return active_elements;
}
std::vector<unsigned> ElementStatus::getActiveNodes() const
{
std::vector<unsigned> active_nodes;
active_nodes.reserve(this->getNActiveNodes());
const std::size_t nNodes (_mesh->getNNodes());
for (std::size_t i=0; i<nNodes; ++i)
if (_active_nodes[i]>0)
active_nodes.push_back(i);
return active_nodes;
}
unsigned ElementStatus::getNActiveNodes() const
{
return _active_nodes.size() - std::count(_active_nodes.begin(), _active_nodes.end(), 0);
......
......@@ -32,10 +32,10 @@ public:
ElementStatus(MeshLib::Mesh const*const mesh);
/// Returns a vector of active element IDs
std::vector<unsigned> getActiveElements() const {};
std::vector<unsigned> getActiveElements() const;
/// Returns a vector of active node IDs
std::vector<unsigned> getActiveNodes() const {};
std::vector<unsigned> getActiveNodes() const;
/// Returns the status of element i
bool getElementStatus(unsigned i) const { return _element_status[i]; }
......
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