Skip to content

Commit a01b148

Browse files
committed
Unit tests for nodeset<->sideset conversions
1 parent 0fb8054 commit a01b148

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

tests/mesh/boundary_info.C

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public:
4141
CPPUNIT_TEST( testBoundaryOnChildrenBoundaryIDs );
4242
CPPUNIT_TEST( testBoundaryOnChildrenBoundarySides );
4343
# endif
44+
CPPUNIT_TEST( testBuildNodeListFromSideList );
45+
CPPUNIT_TEST( testBuildSideListFromNodeList );
4446
# ifdef LIBMESH_ENABLE_DIRICHLET
4547
CPPUNIT_TEST( testShellFaceConstraints );
4648
# endif
@@ -1067,6 +1069,91 @@ public:
10671069
}
10681070
}
10691071
#endif //LIBMESH_ENABLE_AMR
1072+
1073+
1074+
void testBuildNodeListFromSideList()
1075+
{
1076+
LOG_UNIT_TEST;
1077+
1078+
Mesh mesh(*TestCommWorld);
1079+
1080+
MeshTools::Generation::build_square(mesh,
1081+
2, 2,
1082+
0., 1.,
1083+
0., 1.,
1084+
QUAD4);
1085+
1086+
BoundaryInfo & bi = mesh.get_boundary_info();
1087+
1088+
// build_square gave us ids 0-3 as both side sets and node sets
1089+
bi.remove_node_id(0);
1090+
bi.remove_node_id(1);
1091+
bi.remove_node_id(2);
1092+
bi.remove_node_id(3);
1093+
1094+
CPPUNIT_ASSERT(bi.build_node_list().empty());
1095+
1096+
bi.build_node_list_from_side_list({0,2});
1097+
1098+
for (const auto & elem : mesh.element_ptr_range())
1099+
{
1100+
for (auto n : elem->node_index_range())
1101+
{
1102+
const Node * node = elem->node_ptr(n);
1103+
for (auto s : {0,2})
1104+
if (elem->is_node_on_side(n, s) && !elem->neighbor_ptr(s))
1105+
CPPUNIT_ASSERT(bi.has_boundary_id(node, s));
1106+
for (auto s : {1,3})
1107+
CPPUNIT_ASSERT(!bi.has_boundary_id(node, s));
1108+
}
1109+
}
1110+
}
1111+
1112+
1113+
void testBuildSideListFromNodeList()
1114+
{
1115+
LOG_UNIT_TEST;
1116+
1117+
Mesh mesh(*TestCommWorld);
1118+
1119+
MeshTools::Generation::build_square(mesh,
1120+
2, 2,
1121+
0., 1.,
1122+
0., 1.,
1123+
QUAD4);
1124+
1125+
BoundaryInfo & bi = mesh.get_boundary_info();
1126+
1127+
// build_square gave us ids 0-3 as both side sets and node sets
1128+
bi.remove_side_id(0);
1129+
bi.remove_side_id(1);
1130+
bi.remove_side_id(2);
1131+
bi.remove_side_id(3);
1132+
1133+
CPPUNIT_ASSERT(bi.build_side_list().empty());
1134+
1135+
bi.build_side_list_from_node_list({0,2});
1136+
1137+
for (const auto & elem : mesh.element_ptr_range())
1138+
{
1139+
for (auto s : {0,2})
1140+
{
1141+
if (!elem->neighbor_ptr(s))
1142+
{
1143+
CPPUNIT_ASSERT(bi.has_boundary_id(elem, s, s));
1144+
CPPUNIT_ASSERT_EQUAL(bi.n_boundary_ids(elem, s), 1u);
1145+
}
1146+
else
1147+
CPPUNIT_ASSERT(!bi.n_boundary_ids(elem, s));
1148+
}
1149+
for (auto s : {1,3})
1150+
{
1151+
CPPUNIT_ASSERT(!bi.has_boundary_id(elem, s, s));
1152+
CPPUNIT_ASSERT(!bi.n_boundary_ids(elem, s));
1153+
}
1154+
}
1155+
}
1156+
10701157
};
10711158

10721159
CPPUNIT_TEST_SUITE_REGISTRATION( BoundaryInfoTest );

0 commit comments

Comments
 (0)