8 void require(
bool condition,
const char *message)
12 throw std::runtime_error(message);
18 std::map<size_t, Mesh::Vector> positions;
19 for (
size_t k = 0;
k < 3; ++
k)
21 positions[
k][0] = double(
k);
23 Mesh mesh(positions, {{10, {0}, {{{0}}}}, {11, {0, 1}, {{{1}}}}, {12, {1}, {{{2}}}}});
25 require(
mesh.face(10).isExternal() && !
mesh.face(11).isExternal(),
"1D external face classification incorrect");
26 require(
mesh.face(11).parents.size() == 2,
"1D shared vertex lost its regions");
27 require(
mesh.region(0).children.at({11}) ==
mesh.region(1).children.at({11}),
"1D vertex not shared");
28 require(
mesh.face(12).position[0] == 2,
"1D face position incorrect");
35 const std::map<size_t, Mesh::Vector> positions{{0, {0, 0}}, {1, {1, 0}}, {2, {2, 0}}, {3, {0, 1}},
36 {4, {1, 1}}, {5, {2, 1}}, {6, {1, 0.5}}};
37 const std::vector<Mesh::FaceInput>
faces{
38 {10, {0}, {{{0, 1}}}}, {11, {1}, {{{1, 2}}}}, {12, {0}, {{{0, 3}}}}, {13, {0, 1}, {{{1, 6}}, {{6, 4}}}},
39 {14, {1}, {{{2, 5}}}}, {15, {0}, {{{3, 4}}}}, {16, {1}, {{{4, 5}}}}};
40 std::weak_ptr<model::Polyhedron<2, 0>> weak;
44 require(
mesh.factory<2>().size() == 2 &&
mesh.factory<1>().size() == 7 &&
45 mesh.template factory<0>().size() == 6,
46 "2D factory counts incorrect");
48 "2D external face classification incorrect");
49 require(
mesh.face(13).children.count({1}) &&
mesh.face(13).children.count({4}),
50 "2D face endpoints incorrect");
51 require(
mesh.region(0).children.at({13}) ==
mesh.region(1).children.at({13}),
"2D face not shared");
52 require(
mesh.template factory<0>().at({1})->parents.size() == 3,
"Triple edge incidence lost");
53 for (
const auto ®ion :
mesh.factory<2>())
55 require(region.second->perimeter.size() == 4,
"2D region perimeter missing");
56 for (
const auto &incidence : region.second->perimeter)
58 require(incidence.sink() == incidence.next().source(),
"2D perimeter disconnected");
61 weak =
mesh.template factory<0>().at({1});
63 require(weak.expired(),
"2D ownership cycle");
66 bool rejected =
false;
71 catch (
const std::runtime_error &)
75 require(rejected,
"Open polygon accepted");
77 template <
int dim>
void simplexBoundary()
80 std::map<size_t, typename Mesh::Vector> positions;
81 positions[0] = Mesh::Vector::Zero();
82 for (
int k = 0;
k <
dim; ++
k)
84 positions[
k + 1] = Mesh::Vector::Unit(
k);
86 std::vector<typename Mesh::FaceInput>
faces;
87 for (
int excluded = 0; excluded <=
dim; ++excluded)
89 typename Mesh::FaceInput face;
90 face.id = 100 + excluded;
92 std::array<size_t, dim>
simplex;
94 for (
int k = 0;
k <=
dim; ++
k)
101 face.simplices.push_back(simplex);
102 faces.push_back(face);
106 require(
mesh.template factory<0>().size() == dim + 1,
"Simplex vertices not shared");
107 require(
mesh.region(0).children.size() == dim + 1,
"Simplex facets incorrect");
108 if constexpr (
dim >= 3)
110 for (
const auto &face :
mesh.template factory<2>())
112 for (
const auto &incidence : face.second->perimeter)
114 require(incidence.sink() == incidence.next().source(),
"Polygon connectivity incorrect");
115 require(incidence.next().prev().edge == incidence.edge,
"Polygon next/prev incorrect");
125 simplexBoundary<3>();
126 simplexBoundary<4>();
127 simplexBoundary<5>();
128 std::cout <<
"Dimension-generic polyhedral topology passed (1D through 5D)\n";
void require(bool value, const char *message)