@@ -992,6 +992,20 @@ protected:
992992 return std ::make_pair (std ::move (elem ), std ::move (nodes ));
993993 }
994994
995+ // Helper function to create the polyhedron element
996+ Elem *
997+ buildC0Polyhedron (std ::vector < std ::shared_ptr < Polygon >> sides , MeshBase & mesh )
998+ {
999+ std ::unique_ptr < libMesh ::Node > mid_elem_node ;
1000+ std ::unique_ptr < Elem > polyhedron = std ::make_unique < C0Polyhedron > (sides , mid_elem_node );
1001+ if (mid_elem_node )
1002+ mesh .add_node (std ::move (mid_elem_node ));
1003+ polyhedron -> set_id () = 0 ;
1004+ Elem * elem = mesh .add_elem (std ::move (polyhedron ));
1005+ libmesh_assert (dynamic_cast < C0Polyhedron * > (elem ));
1006+
1007+ return elem ;
1008+ }
9951009
9961010 // Helper function to factor out common tests
9971011 void testC0PolygonMethods (MeshBase & mesh ,
@@ -1061,7 +1075,7 @@ protected:
10611075
10621076
10631077 // Helper function to factor out common tests
1064- void testC0PolyhedronMethods (MeshBase & mesh )
1078+ void testC0PolyhedronMethods (MeshBase & mesh , bool has_midnode )
10651079 {
10661080 Elem * elem = mesh .query_elem_ptr (0 );
10671081 bool found_elem = elem ;
@@ -1077,7 +1091,10 @@ protected:
10771091 const int E = elem -> n_edges ();
10781092 const int F = elem -> n_faces ();
10791093
1080- CPPUNIT_ASSERT_EQUAL (int (elem -> n_nodes ()), V );
1094+ if (!has_midnode )
1095+ CPPUNIT_ASSERT_EQUAL (int (elem -> n_nodes ()), V );
1096+ else
1097+ CPPUNIT_ASSERT_EQUAL (int (elem -> n_nodes ()), V + 1 );
10811098 CPPUNIT_ASSERT_EQUAL (int (elem -> n_sides ()), F );
10821099
10831100 // Euler characteristic for polygons homeomorphic to spheres is 2
@@ -1129,24 +1146,13 @@ protected:
11291146
11301147
11311148
1132- void testC0Polyhedron (const std :: vector < std :: shared_ptr < Polygon >> & sides ,
1133- Real expected_volume )
1149+ void testElemVolume (const Elem * elem ,
1150+ Real expected_volume )
11341151 {
1135- Mesh mesh (* TestCommWorld );
1136-
1137- std ::unique_ptr < libMesh ::Node > mid_elem_node ;
1138- std ::unique_ptr < Elem > polyhedron = std ::make_unique < C0Polyhedron > (sides , mid_elem_node );
1139- if (mid_elem_node )
1140- mesh .add_node (std ::move (mid_elem_node ));
1141- polyhedron -> set_id () = 0 ;
1142- Elem * elem = mesh .add_elem (std ::move (polyhedron ));
1143-
11441152 const Real derived_volume = elem -> volume ();
11451153 const Real base_volume = elem -> Elem ::volume ();
11461154 LIBMESH_ASSERT_FP_EQUAL (base_volume , derived_volume , TOLERANCE * TOLERANCE );
11471155 LIBMESH_ASSERT_FP_EQUAL (derived_volume , expected_volume , TOLERANCE * TOLERANCE );
1148-
1149- this -> testC0PolyhedronMethods (mesh );
11501156 }
11511157
11521158
@@ -1184,12 +1190,21 @@ protected:
11841190 sides [s ]-> set_node (i , mesh .node_ptr (nodes_on_s [i ]));
11851191 }
11861192
1187- testC0Polyhedron (sides , 1 );
1193+ const auto poly = dynamic_cast < C0Polyhedron * > (buildC0Polyhedron (sides , mesh ));
1194+ testElemVolume (poly , 1 );
1195+ testC0PolyhedronMethods (mesh , /*midnode*/ false);
1196+
1197+ // Check routine for subtet side to poly side mapping
1198+ // NOTE: this test is hard coded to the elements used right now (to be reworked)
1199+ const auto subtet0_sides_to_poly_sides = poly -> subelement_sides_to_poly_sides (0 );
1200+ CPPUNIT_ASSERT_EQUAL (libMesh ::invalid_int , subtet0_sides_to_poly_sides [0 ]);
1201+ CPPUNIT_ASSERT_EQUAL (1 , subtet0_sides_to_poly_sides [1 ]);
1202+ CPPUNIT_ASSERT_EQUAL (0 , subtet0_sides_to_poly_sides [2 ]);
1203+ CPPUNIT_ASSERT_EQUAL (2 , subtet0_sides_to_poly_sides [3 ]);
11881204 }
11891205
11901206
11911207
1192-
11931208 void testC0PolyhedronCubeWithMidNode ()
11941209 {
11951210 ReplicatedMesh mesh (* TestCommWorld );
@@ -1211,7 +1226,7 @@ protected:
12111226 {1 , 2 , 6 , 5 }, // max x
12121227 {2 , 3 , 7 , 6 }, // max y
12131228 {3 , 0 , 4 , 7 }, // min x
1214- {4 , 5 , 6 , 7 } }; // max z
1229+ {4 , 5 , 6 , 7 }}; // max z
12151230
12161231 // Build all the sides.
12171232 std ::vector < std ::shared_ptr < Polygon >> sides (nodes_on_side .size ());
@@ -1224,7 +1239,17 @@ protected:
12241239 sides [s ]-> set_node (i , mesh .node_ptr (nodes_on_s [i ]));
12251240 }
12261241
1227- testC0Polyhedron (sides , 1 );
1242+ const auto poly = dynamic_cast < C0Polyhedron * > (buildC0Polyhedron (sides , mesh ));
1243+ CPPUNIT_ASSERT_EQUAL ((unsigned int )9 , poly -> n_nodes ()); // we should have a mid node
1244+ testElemVolume (poly , 1 );
1245+ testC0PolyhedronMethods (mesh , /*midnode*/ true);
1246+
1247+ // Check routine for subtet side to poly side mapping
1248+ const auto subtet0_sides_to_poly_sides = poly -> subelement_sides_to_poly_sides (0 );
1249+ CPPUNIT_ASSERT_EQUAL (0 , subtet0_sides_to_poly_sides [0 ]);
1250+ CPPUNIT_ASSERT_EQUAL (libMesh ::invalid_int , subtet0_sides_to_poly_sides [1 ]);
1251+ CPPUNIT_ASSERT_EQUAL (libMesh ::invalid_int , subtet0_sides_to_poly_sides [2 ]);
1252+ CPPUNIT_ASSERT_EQUAL (libMesh ::invalid_int , subtet0_sides_to_poly_sides [3 ]);
12281253 }
12291254
12301255
0 commit comments