30 std::vector<Tuple> tagged_tuples;
32 if (tags.const_scalar_attribute(t) == tag_value) {
33 tagged_tuples.emplace_back(t);
37 auto run_edge = [&]() {
38 std::map<int64_t, int64_t> parent_to_child_vertex_map;
42 edge_mesh_matrix.resize(tagged_tuples.size(), 2);
44 for (
size_t i = 0; i < tagged_tuples.size(); ++i) {
45 const std::array<int64_t, 2> vs = {
53 for (
int k = 0; k < 2; k++) {
54 size_t size = parent_to_child_vertex_map.size();
55 parent_to_child_vertex_map.try_emplace(vs[k], size);
56 edge_mesh_matrix(i, k) = parent_to_child_vertex_map[vs[k]];
60 std::shared_ptr<EdgeMesh> child_ptr = std::make_shared<EdgeMesh>();
61 auto& child = *child_ptr;
62 child.initialize(edge_mesh_matrix);
66 auto run_face = [&]() {
67 std::map<int64_t, int64_t> parent_to_child_vertex_map;
68 int64_t child_vertex_count = 0;
71 tri_mesh_matrix.resize(tagged_tuples.size(), 3);
72 for (int64_t i = 0; i < tagged_tuples.size(); ++i) {
74 const std::array<int64_t, 3> vs = {
82 {PrimitiveType::Edge, PrimitiveType::Vertex}),
86 for (
int k = 0; k < 3; k++) {
87 size_t size = parent_to_child_vertex_map.size();
88 parent_to_child_vertex_map.try_emplace(vs[k], size);
89 tri_mesh_matrix(i, k) = parent_to_child_vertex_map.at(vs[k]);
92 std::shared_ptr<TriMesh> child_ptr = std::make_shared<TriMesh>();
93 auto& child = *child_ptr;
94 child.initialize(tri_mesh_matrix);
99 auto run_tet = [&]() {
100 std::map<int64_t, int64_t> parent_to_child_vertex_map;
101 int64_t child_vertex_count = 0;
105 tet_mesh_matrix.resize(tagged_tuples.size(), 4);
106 for (int64_t i = 0; i < tagged_tuples.size(); ++i) {
107 const std::array<int64_t, 4> vs = {
115 {PrimitiveType::Triangle, PrimitiveType::Edge, PrimitiveType::Vertex}),
120 {PrimitiveType::Edge, PrimitiveType::Vertex}),
123 for (
int k = 0; k < 4; ++k) {
124 size_t size = parent_to_child_vertex_map.size();
125 parent_to_child_vertex_map.try_emplace(vs[k], size);
126 tet_mesh_matrix(i, k) = parent_to_child_vertex_map[vs[k]];
133 std::shared_ptr<TetMesh> child_ptr = std::make_shared<TetMesh>();
134 auto& child = *child_ptr;
135 child.initialize(tet_mesh_matrix);
140 std::shared_ptr<Mesh> child_mesh_ptr;
146 std::shared_ptr<EdgeMesh> meshptr = std::make_shared<EdgeMesh>();
147 meshptr->initialize_free(tagged_tuples.size());
148 child_mesh_ptr = meshptr;
152 std::shared_ptr<TriMesh> meshptr = std::make_shared<TriMesh>();
153 meshptr->initialize_free(tagged_tuples.size());
154 child_mesh_ptr = meshptr;
158 std::shared_ptr<TetMesh> meshptr = std::make_shared<TetMesh>();
159 meshptr->initialize_free(tagged_tuples.size());
160 child_mesh_ptr = meshptr;
163 default:
throw(
"invalid child mesh type");
170 child_mesh_ptr = run_edge();
174 child_mesh_ptr = run_face();
178 child_mesh_ptr = run_tet();
181 default:
throw(
"invalid child mesh type");
185 assert(
bool(child_mesh_ptr));
186 auto& child = *child_mesh_ptr;
188 std::vector<std::array<Tuple, 2>> child_to_parent_map(tagged_tuples.size());
189 assert(tagged_tuples.size() == child.capacity(pt));
191 const auto child_top_dimension_tuples = child.get_all(pt);
193 for (
size_t i = 0; i < tagged_tuples.size(); ++i) {
194 child_to_parent_map[i] = {{child_top_dimension_tuples[i], tagged_tuples[i]}};
198 return child_mesh_ptr;