10 #include "gtest/gtest.h" 15 #include "libmesh/elem.h" 16 #include "libmesh/mesh_generation.h" 17 #include "libmesh/replicated_mesh.h" 19 TEST(ElemExtremaTest, Test)
21 Parallel::Communicator comm;
22 std::unique_ptr<UnstructuredMesh>
mesh = std::make_unique<ReplicatedMesh>(comm);
23 MeshTools::Generation::build_cube(*
mesh, 2, 2, 2);
25 const Elem * elem =
mesh->query_elem_ptr(0);
26 EXPECT_TRUE(elem !=
nullptr);
35 EXPECT_FALSE(invalid.
atEdge());
36 EXPECT_FALSE(invalid.
atEdge(0, 1));
37 EXPECT_TRUE(invalid.
isValid(elem, elem->vertex_average()));
39 std::stringstream oss;
41 EXPECT_EQ(oss.str(),
"not at extrema");
53 EXPECT_FALSE(at_vertex.
atEdge());
54 EXPECT_FALSE(at_vertex.
atEdge(0, 1));
55 EXPECT_EQ((
unsigned short)0, at_vertex.
vertex());
57 const auto & vertex_point = at_vertex.
vertexPoint(elem);
58 const auto & point = elem->point(0);
59 for (
unsigned int d = 0;
d < 3; ++
d)
60 EXPECT_NEAR(vertex_point(
d), point(
d), 1.e-10);
62 std::stringstream oss;
64 EXPECT_EQ(oss.str(),
"at vertex 0");
66 EXPECT_TRUE(at_vertex.isValid(elem, elem->point(0)));
68 at_vertex.invalidate();
69 EXPECT_TRUE(at_vertex.isInvalid());
73 Point edge_point(0.25, 0, 0);
84 EXPECT_TRUE(at_edge.
atEdge());
89 for (
unsigned int d = 0;
d < 3; ++
d)
95 EXPECT_TRUE(at_edge.
isValid(elem, edge_point));
96 std::stringstream should_be;
97 should_be <<
"at edge with vertices " << at_edge.
edgeVertices().first <<
" and " 99 std::stringstream oss;
101 EXPECT_EQ(oss.str(), should_be.str());
106 EXPECT_TRUE(at_edge.first == 0);
107 EXPECT_TRUE(at_edge.second == 1);
unsigned short vertex() const
void setEdge(const unsigned short v1, const unsigned short v2)
Sets the "at edge" state.
Helper for defining if at an element's edge, vertex, or neither.
std::unique_ptr< const libMesh::Elem > buildEdge(const Elem *elem) const
TEST(ElemExtremaTest, Test)
bool isValid(const Elem *const elem, const Point &point) const
const std::pair< unsigned short, unsigned short > & edgeVertices() const
void setVertex(const unsigned short vertex)
Sets the "at vertex" state.
const Point & vertexPoint(const libMesh::Elem *elem) const