Skip to content
Snippets Groups Projects
Commit bb11199e authored by Lars Bilke's avatar Lars Bilke
Browse files

Merge pull request #482 from rinkk/TestBoundaryElements

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