@@ -23,68 +23,112 @@ public:
2323 {
2424 LOG_UNIT_TEST ;
2525
26- // QUAD elem for vertex testing
27- Mesh mesh_2d (* TestCommWorld );
28- MeshTools ::Generation ::build_square (mesh_2d , 1 , 1 );
29- const auto & quad = mesh_2d .elem_ref (0 );
30-
3126 // Default constructor: unvalid state
3227 const ElemCorner default_corner ;
3328 CPPUNIT_ASSERT (default_corner .is_invalid ());
3429 CPPUNIT_ASSERT (!default_corner .at_corner ());
3530 CPPUNIT_ASSERT (!default_corner .at_vertex ());
36- #if LIBMESH_DIM > 2
3731 CPPUNIT_ASSERT (!default_corner .at_edge ());
38- #endif // LIBMESH_DIM > 2
3932 CPPUNIT_ASSERT_EQUAL ((std ::string )"not at corner" , default_corner .print ());
40- CPPUNIT_ASSERT (default_corner .is_valid (quad , quad .point (0 )));
41-
42- // At vertex
43- const ElemCorner at_vertex (0 , Elem ::invalid_vertex );
44- CPPUNIT_ASSERT (!at_vertex .is_invalid ());
45- CPPUNIT_ASSERT (at_vertex .at_corner ());
46- CPPUNIT_ASSERT (at_vertex .at_vertex ());
47- #if LIBMESH_DIM > 2
48- CPPUNIT_ASSERT (!at_vertex .at_edge ());
49- CPPUNIT_ASSERT (!at_vertex .at_edge (0 , 1 ));
50- CPPUNIT_ASSERT (!at_vertex .at_edge (quad , 0 ));
51- #endif // LIBMESH_DIM > 2
52- CPPUNIT_ASSERT (at_vertex .at_vertex (0 ));
53- CPPUNIT_ASSERT (!at_vertex .at_vertex (1 ));
54- CPPUNIT_ASSERT_EQUAL (at_vertex .vertex (), (unsigned short )0 );
55- CPPUNIT_ASSERT (at_vertex .is_valid (quad , quad .point (0 )));
56- CPPUNIT_ASSERT (!at_vertex .is_valid (quad , quad .point (2 )));
33+
34+ // EDGE elem for vertex testing
35+ Mesh mesh_1d (* TestCommWorld );
36+ MeshTools ::Generation ::build_line (mesh_1d , 1 );
37+ const auto edge = mesh_1d .elem_ptr (0 );
38+
39+ // At edge vertex
40+ const ElemCorner at_edge_vertex (1 , Elem ::invalid_vertex );
41+ CPPUNIT_ASSERT (!at_edge_vertex .is_invalid ());
42+ CPPUNIT_ASSERT (at_edge_vertex .at_corner ());
43+ CPPUNIT_ASSERT (at_edge_vertex .at_vertex ());
44+ CPPUNIT_ASSERT (!at_edge_vertex .at_edge ());
45+ CPPUNIT_ASSERT (at_edge_vertex .at_vertex (1 ));
46+ CPPUNIT_ASSERT_EQUAL (at_edge_vertex .vertex (), (unsigned short )1 );
47+ if (edge )
48+ for (const auto v : edge -> vertex_index_range ())
49+ {
50+ CPPUNIT_ASSERT_EQUAL (at_edge_vertex .at_vertex (v ), v == 1 );
51+ CPPUNIT_ASSERT_EQUAL (at_edge_vertex .is_valid (* edge , edge -> point (v )), v == 1 );
52+ }
53+
54+ #if LIBMESH_DIM > 1
55+ // QUAD elem for vertex testing
56+ Mesh mesh_2d (* TestCommWorld );
57+ MeshTools ::Generation ::build_square (mesh_2d , 1 , 1 );
58+ const auto quad = mesh_2d .elem_ptr (0 );
59+
60+ // At quad vertex
61+ const ElemCorner at_quad_vertex (0 , Elem ::invalid_vertex );
62+ CPPUNIT_ASSERT (!at_quad_vertex .is_invalid ());
63+ CPPUNIT_ASSERT (at_quad_vertex .at_corner ());
64+ CPPUNIT_ASSERT (at_quad_vertex .at_vertex ());
65+ CPPUNIT_ASSERT (!at_quad_vertex .at_edge ());
66+ CPPUNIT_ASSERT (!at_quad_vertex .at_edge (0 , 1 ));
67+ CPPUNIT_ASSERT (at_quad_vertex .at_vertex (0 ));
68+ CPPUNIT_ASSERT (!at_quad_vertex .at_vertex (1 ));
69+ CPPUNIT_ASSERT_EQUAL (at_quad_vertex .vertex (), (unsigned short )0 );
70+ if (quad )
71+ {
72+ for (const auto v : quad -> vertex_index_range ())
73+ CPPUNIT_ASSERT (default_corner .is_valid (* quad , quad -> point (v )));
74+ for (const auto e : quad -> edge_index_range ())
75+ CPPUNIT_ASSERT (!at_quad_vertex .at_edge (* quad , e ));
76+ for (const auto v : quad -> vertex_index_range ())
77+ CPPUNIT_ASSERT_EQUAL (at_quad_vertex .is_valid (* quad , quad -> point (v )), v == 0 );
78+ }
79+
80+ // At quad "edge" (a side)
81+ const ElemCorner at_quad_edge (1 , 2 );
82+ CPPUNIT_ASSERT (!at_quad_edge .is_invalid ());
83+ CPPUNIT_ASSERT (at_quad_edge .at_corner ());
84+ CPPUNIT_ASSERT (!at_quad_edge .at_vertex ());
85+ CPPUNIT_ASSERT (at_quad_edge .at_edge ());
86+ CPPUNIT_ASSERT (!at_quad_edge .at_edge (0 , 1 ));
87+ CPPUNIT_ASSERT (at_quad_edge .at_edge (1 , 2 ));
88+ CPPUNIT_ASSERT_EQUAL (at_quad_edge .edge_vertices ().first , (unsigned short )1 );
89+ CPPUNIT_ASSERT_EQUAL (at_quad_edge .edge_vertices ().second , (unsigned short )2 );
90+ if (quad )
91+ {
92+ CPPUNIT_ASSERT (at_quad_edge .is_valid (* quad , 0.5 * (quad -> point (1 ) + quad -> point (2 ))));
93+ for (const auto e : quad -> edge_index_range ())
94+ CPPUNIT_ASSERT_EQUAL (at_quad_edge .at_edge (* quad , e ), e == 1 );
95+ }
96+ #endif
5797
5898#if LIBMESH_DIM > 2
5999 // HEX elem for edge testing
60100 Mesh mesh_3d (* TestCommWorld );
61101 MeshTools ::Generation ::build_cube (mesh_3d , 1 , 1 , 1 );
62- const auto & hex = mesh_3d .elem_ref (0 );
102+ const auto hex = mesh_3d .elem_ptr (0 );
63103
64104 // At edge
65- const ElemCorner at_edge (0 , 1 );
66- CPPUNIT_ASSERT (!at_edge .is_invalid ());
67- CPPUNIT_ASSERT (at_edge .at_corner ());
68- CPPUNIT_ASSERT (!at_edge .at_vertex ());
69- CPPUNIT_ASSERT (!at_edge .at_vertex (0 ));
70- CPPUNIT_ASSERT (at_edge .at_edge ());
71- CPPUNIT_ASSERT (at_edge .at_edge (0 , 1 ));
72- CPPUNIT_ASSERT (at_edge .at_edge (1 , 0 ));
73- CPPUNIT_ASSERT (at_edge .at_edge (hex , 0 ));
74- CPPUNIT_ASSERT_EQUAL (at_edge .edge_vertices ().first , (unsigned short )0 );
75- CPPUNIT_ASSERT_EQUAL (at_edge .edge_vertices ().second , (unsigned short )1 );
76- CPPUNIT_ASSERT (!at_edge .is_invalid ());
77- CPPUNIT_ASSERT (at_edge .is_valid (hex , (hex .point (0 ) + hex .point (1 )) * 0.5 ));
78- CPPUNIT_ASSERT (at_edge .is_valid (hex , hex .point (0 )));
79- CPPUNIT_ASSERT (at_edge .is_valid (hex , hex .point (1 )));
80- CPPUNIT_ASSERT (!at_edge .is_valid (hex , (hex .point (2 )) * 0.5 ));
81-
82- // build_edge
83- auto edge_elem = at_edge .build_edge (hex );
84- CPPUNIT_ASSERT ((edge_elem -> point (0 ).absolute_fuzzy_equals (hex .point (0 ))
85- && edge_elem -> point (1 ).absolute_fuzzy_equals (hex .point (1 ))) ||
86- ((edge_elem -> point (1 ).absolute_fuzzy_equals (hex .point (0 ))
87- && edge_elem -> point (0 ).absolute_fuzzy_equals (hex .point (1 )))));
105+ const ElemCorner at_hex_edge (0 , 1 );
106+ CPPUNIT_ASSERT (!at_hex_edge .is_invalid ());
107+ CPPUNIT_ASSERT (at_hex_edge .at_corner ());
108+ CPPUNIT_ASSERT (!at_hex_edge .at_vertex ());
109+ CPPUNIT_ASSERT (!at_hex_edge .at_vertex (0 ));
110+ CPPUNIT_ASSERT (at_hex_edge .at_edge ());
111+ CPPUNIT_ASSERT (at_hex_edge .at_edge (0 , 1 ));
112+ CPPUNIT_ASSERT (at_hex_edge .at_edge (1 , 0 ));
113+ CPPUNIT_ASSERT_EQUAL (at_hex_edge .edge_vertices ().first , (unsigned short )0 );
114+ CPPUNIT_ASSERT_EQUAL (at_hex_edge .edge_vertices ().second , (unsigned short )1 );
115+ CPPUNIT_ASSERT (!at_hex_edge .is_invalid ());
116+ if (hex )
117+ {
118+ CPPUNIT_ASSERT (at_hex_edge .is_valid (* hex , (hex -> point (0 ) + hex -> point (1 )) * 0.5 ));
119+ for (const auto e : hex -> edge_index_range ())
120+ CPPUNIT_ASSERT_EQUAL (at_hex_edge .at_edge (* hex , e ), e == 0 );
121+ for (const auto v : hex -> vertex_index_range ())
122+ CPPUNIT_ASSERT_EQUAL (at_hex_edge .is_valid (* hex , hex -> point (v )), v == 0 || v == 1 );
123+ CPPUNIT_ASSERT (!at_hex_edge .is_valid (* hex , (hex -> point (2 )) * 0.5 ));
124+
125+ // build_edge
126+ auto edge_elem = at_hex_edge .build_edge (* hex );
127+ CPPUNIT_ASSERT ((edge_elem -> point (0 ).absolute_fuzzy_equals (hex -> point (0 ))
128+ && edge_elem -> point (1 ).absolute_fuzzy_equals (hex -> point (1 ))) ||
129+ ((edge_elem -> point (1 ).absolute_fuzzy_equals (hex -> point (0 ))
130+ && edge_elem -> point (0 ).absolute_fuzzy_equals (hex -> point (1 )))));
131+ }
88132#endif // LIBMESH_DIM > 2
89133
90134 // For testing non-const methods
0 commit comments