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

added method to test if element is located on boundary

parent 5f40d823
No related branches found
No related tags found
No related merge requests found
......@@ -163,6 +163,11 @@ bool Element::hasNeighbor(Element* elem) const
return false;
}
bool Element::isBoundaryElement() const
{
return std::any_of(_neighbors, _neighbors + this->getNNeighbors(),
[](MeshLib::Element* e){ return e == nullptr; });
}
}
......@@ -148,6 +148,8 @@ public:
*/
bool hasZeroVolume() const { return this->getContent() < std::numeric_limits<double>::epsilon(); }
/// Returns true if the element is located at a boundary (i.e. has at least one face without neighbour)
virtual bool isBoundaryElement() const;
/// Returns true if these two indeces form an edge and false otherwise
virtual bool isEdge(unsigned i, unsigned j) const = 0;
......
......@@ -209,6 +209,7 @@ TEST_F(MeshLibQuadMesh, ElementNeighbors)
// Test the test
EXPECT_EQ(1u, ij_neighbors.first.size());
EXPECT_EQ(1u, ij_neighbors.second.size());
ASSERT_TRUE(e->isBoundaryElement());
testNeighbors(e, i, j, ij_neighbors);
});
......@@ -222,6 +223,7 @@ TEST_F(MeshLibQuadMesh, ElementNeighbors)
std::pair<Indices, Indices> const ij_neighbors = getNeighborIndices(i, j);
// Test the test
EXPECT_EQ(3u, ij_neighbors.first.size() + ij_neighbors.second.size());
ASSERT_TRUE(e->isBoundaryElement());
testNeighbors(e, i, j, ij_neighbors);
});
......@@ -236,6 +238,7 @@ TEST_F(MeshLibQuadMesh, ElementNeighbors)
// Test the test
EXPECT_EQ(2u, ij_neighbors.first.size());
EXPECT_EQ(2u, ij_neighbors.second.size());
ASSERT_FALSE(e->isBoundaryElement());
testNeighbors(e, i, j, ij_neighbors);
});
......
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