Skip to content

Commit 1cbd20f

Browse files
committed
Add a unit test for hexagonal tiling
1 parent 9a3b472 commit 1cbd20f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/mesh/mesh_generation_test.C

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public:
3737
CPPUNIT_TEST( buildSquareQuad4 );
3838
CPPUNIT_TEST( buildSquareQuad8 );
3939
CPPUNIT_TEST( buildSquareQuad9 );
40+
CPPUNIT_TEST( buildSquareC0PolygonEven );
41+
CPPUNIT_TEST( buildSquareC0PolygonOdd );
4042
# ifdef LIBMESH_ENABLE_AMR
4143
CPPUNIT_TEST( buildSphereTri3 );
4244
CPPUNIT_TEST( buildSphereQuad4 );
@@ -107,7 +109,9 @@ public:
107109
void testBuildSquare(UnstructuredMesh & mesh, unsigned int n, ElemType type)
108110
{
109111
MeshTools::Generation::build_square (mesh, n, n, -2.0, 3.0, -4.0, 5.0, type);
110-
if (Elem::type_to_n_sides_map[type] == 4)
112+
if (type == C0POLYGON)
113+
CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n + 4 + 2 * (n - 1) + ((n - 1) / 2)));
114+
else if (Elem::type_to_n_sides_map[type] == 4)
111115
CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n));
112116
else
113117
CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*2));
@@ -132,6 +136,10 @@ public:
132136
CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
133137
cast_int<dof_id_type>((2*n+1)*(2*n+1) + 2*n*n));
134138
break;
139+
case C0POLYGON:
140+
CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
141+
cast_int<dof_id_type>(4 + 2*n*n + (n - 1) + 2*n + 2 * (n%2)));
142+
break;
135143
default: // Wait, what did we try to build?
136144
CPPUNIT_ASSERT(false);
137145
}
@@ -146,8 +154,9 @@ public:
146154

147155
// Do serial assertions *after* all parallel assertions, so we
148156
// stay in sync after failure on only some processor(s)
149-
for (auto & elem : mesh.element_ptr_range())
150-
CPPUNIT_ASSERT(elem->has_affine_map());
157+
if (type != C0POLYGON)
158+
for (auto & elem : mesh.element_ptr_range())
159+
CPPUNIT_ASSERT(elem->has_affine_map());
151160
}
152161

153162
void testBuildCube(UnstructuredMesh & mesh, unsigned int n, ElemType type)
@@ -293,6 +302,8 @@ public:
293302
void buildSquareQuad4 () { LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildSquare, 4, QUAD4); }
294303
void buildSquareQuad8 () { LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildSquare, 4, QUAD8); }
295304
void buildSquareQuad9 () { LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildSquare, 4, QUAD9); }
305+
void buildSquareC0PolygonOdd() { LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildSquare, 5, C0POLYGON); }
306+
void buildSquareC0PolygonEven(){ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildSquare, 6, C0POLYGON); }
296307

297308
void buildSphereTri3 () { LOG_UNIT_TEST; testBuildSphere(2, TRI3); }
298309
void buildSphereQuad4 () { LOG_UNIT_TEST; testBuildSphere(2, QUAD4); }

0 commit comments

Comments
 (0)