25 const std::vector<std::vector<std::tuple<int64_t, std::vector<Tuple>>>>& simplices_to_update,
26 const std::vector<std::tuple<int64_t, std::array<int64_t, 2>>>& split_cell_maps)
const
31 for (
size_t j = 0; j < simplices_to_update.size(); ++j) {
46 for (
const auto& parent_data : parent_incident_datas) {
51 if (child_ptr->is_free()) {
54 if (child_ptr->top_cell_dimension() != 1) {
58 const auto& child_mmmanager = child_ptr->m_multi_mesh_manager;
59 int64_t child_id = child_mmmanager.child_id();
60 auto child_to_parent_handle = child_mmmanager.map_to_parent_handle;
61 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
62 auto child_to_parent_accessor = child_ptr->create_accessor(child_to_parent_handle);
63 auto parent_to_child_accessor = m.
create_accessor(parent_to_child_handle);
66 std::vector<std::pair<Tuple, Tuple>> update_pairs;
68 for (
int ear_index = 0; ear_index < 2; ++ear_index) {
69 const int64_t parent_ear_eid_old = parent_data.ears[ear_index].eid;
70 const int64_t parent_merged_eid = parent_data.new_edge_id;
71 const int64_t parent_new_fid = parent_data.merged_edge_fid;
74 assert(parent_merged_eid != -1);
75 assert(parent_new_fid != -1);
78 .const_vector_attribute(parent_ear_eid_old);
80 Tuple parent_tuple, child_tuple;
81 std::tie(parent_tuple, child_tuple) =
91 const bool child_tuple_exists = child_cell_flag_accessor.is_active(child_tuple);
92 if (!child_tuple_exists) {
96 const int64_t parent_old_vid =
100 int64_t parent_new_vid = -1;
102 if (parent_ear_eid_old != parent_merged_eid) {
104 if (parent_old_vid == parent_incident_vids[0]) {
105 parent_new_vid = parent_incident_vids[1];
107 parent_new_vid = parent_old_vid;
111 parent_new_vid = parent_old_vid;
114 assert(parent_new_vid != -1);
116 Tuple new_parent_tuple =
119 update_pairs.push_back(std::make_pair(new_parent_tuple, child_tuple));
122 for (
const auto& pair : update_pairs) {
124 parent_to_child_accessor,
125 child_to_parent_accessor,
141 for (
const auto& parent_data : parent_incident_tet_datas) {
144 if (child_ptr->is_free()) {
147 if (child_ptr->top_cell_dimension() == 2) {
150 const auto& child_mmmanager = child_ptr->m_multi_mesh_manager;
151 const int64_t child_id = child_mmmanager.
child_id();
152 const auto child_to_parent_handle = child_mmmanager.map_to_parent_handle;
153 const auto parent_to_child_handle =
154 parent_mmmanager.children().at(child_id).map_handle;
155 auto child_to_parent_accessor = child_ptr->create_accessor(child_to_parent_handle);
156 auto parent_to_child_accessor = m.
create_accessor(parent_to_child_handle);
157 auto child_cell_flag_accessor =
160 std::vector<std::pair<Tuple, Tuple>> update_pairs;
162 for (
int ear_index = 0; ear_index < 2; ++ear_index) {
163 const int64_t parent_ear_fid_old = parent_data.ears[ear_index].fid;
164 const int64_t parent_merged_fid = parent_data.new_face_id;
165 const int64_t parent_new_tid =
166 parent_data.merged_face_tid;
168 assert(parent_merged_fid != -1);
169 assert(parent_new_tid != -1);
172 .const_vector_attribute(parent_ear_fid_old);
175 Tuple parent_tuple, child_tuple;
176 std::tie(parent_tuple, child_tuple) =
185 bool child_tuple_exists = child_cell_flag_accessor.is_active(child_tuple);
186 if (!child_tuple_exists) {
190 const int64_t parent_old_eid =
192 const int64_t parent_old_vid =
197 int64_t parent_new_eid = -1;
198 int64_t parent_new_vid = -1;
200 if (parent_ear_fid_old != parent_merged_fid) {
202 if (parent_old_eid == parent_data.e02) {
203 parent_new_eid = parent_data.e12;
204 }
else if (parent_old_eid == parent_data.e03) {
205 parent_new_eid = parent_data.e13;
206 }
else if (parent_old_eid == parent_data.e23) {
207 parent_new_eid = parent_data.e23;
210 if (parent_old_vid == parent_data.v0) {
211 parent_new_vid = parent_data.v1;
212 }
else if (parent_old_vid == parent_data.v2) {
213 parent_new_vid = parent_data.v2;
214 }
else if (parent_old_vid == parent_data.v3) {
215 parent_new_vid = parent_data.v3;
219 parent_new_eid = parent_old_eid;
220 parent_new_vid = parent_old_vid;
223 assert(parent_new_eid != -1);
224 assert(parent_new_vid != -1);
232 update_pairs.push_back(std::make_pair(new_parent_tuple, child_tuple));
235 for (
const auto& pair : update_pairs) {
237 parent_to_child_accessor,
238 child_to_parent_accessor,
243 }
else if (child_ptr->top_cell_dimension() == 1) {
247 const auto& child_mmmanager = child_ptr->m_multi_mesh_manager;
248 int64_t child_id = child_mmmanager.child_id();
249 auto child_to_parent_handle = child_mmmanager.map_to_parent_handle;
250 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
251 auto child_to_parent_accessor = child_ptr->create_accessor(child_to_parent_handle);
252 auto parent_to_child_accessor = m.
create_accessor(parent_to_child_handle);
253 auto child_cell_flag_accessor =
256 std::vector<std::pair<Tuple, Tuple>> update_pairs;
258 for (
int ear_index = 0; ear_index < 2; ++ear_index) {
259 const int64_t parent_ear_fid_old = parent_data.ears[ear_index].fid;
260 const int64_t parent_merged_fid = parent_data.new_face_id;
261 const int64_t parent_new_tid = parent_data.merged_face_tid;
264 std::array<int64_t, 3> parent_old_eids;
265 std::array<int64_t, 3> parent_new_eids = {
266 {parent_data.e12, parent_data.e13, parent_data.e23}};
268 if (parent_ear_fid_old != parent_merged_fid) {
269 parent_old_eids = {{parent_data.e02, parent_data.e03, parent_data.e23}};
271 parent_old_eids = {{parent_data.e12, parent_data.e13, parent_data.e23}};
275 assert(parent_merged_fid != -1);
276 assert(parent_new_tid != -1);
278 for (
int i = 0; i < 3; ++i) {
280 .const_vector_attribute(parent_old_eids[i]);
283 Tuple parent_tuple, child_tuple;
284 std::tie(parent_tuple, child_tuple) =
293 bool child_tuple_exists = child_cell_flag_accessor.is_active(child_tuple);
294 if (!child_tuple_exists) {
298 const int64_t parent_old_vid =
301 int64_t parent_new_vid = -1;
302 if (parent_ear_fid_old != parent_merged_fid) {
304 if (parent_old_vid == parent_data.v0) {
305 parent_new_vid = parent_data.v1;
306 }
else if (parent_old_vid == parent_data.v2) {
307 parent_new_vid = parent_data.v2;
308 }
else if (parent_old_vid == parent_data.v3) {
309 parent_new_vid = parent_data.v3;
313 parent_new_vid = parent_old_vid;
316 assert(parent_new_vid != -1);
324 update_pairs.push_back(std::make_pair(new_parent_tuple, child_tuple));
327 for (
const auto& pair : update_pairs) {
329 parent_to_child_accessor,
330 child_to_parent_accessor,
350 throw std::runtime_error(
"not implemented");
368 int64_t child_id = child_mmmanager.child_id();
369 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
370 auto child_to_parent_accessor = child_mesh.
create_accessor(child_to_parent_handle);
371 auto parent_to_child_accessor = parent_mesh.
create_accessor(parent_to_child_handle);
375 for (int64_t index = 0; index < 2; ++index) {
377 int64_t f_parent = parent_incident_datas[0].split_f[index];
379 const int64_t e_child = child_emoe.
m_split_e[index];
382 if (f_parent == -1 || e_child == -1 || e_parent == -1) {
387 const int64_t v_parent = parent_spine_v[index];
392 assert(parent_mesh.
is_valid(parent_tuple));
393 assert(child_mesh.
is_valid(child_tuple));
396 parent_to_child_accessor,
397 child_to_parent_accessor,
430 int64_t child_id = child_mmmanager.child_id();
431 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
432 auto child_to_parent_accessor = child_mesh.
create_accessor(child_to_parent_handle);
433 auto parent_to_child_accessor = parent_mesh.
create_accessor(parent_to_child_handle);
440 for (
const auto& child_data : child_incident_datas) {
441 int64_t target_parent_fid =
parent_global_cid(child_to_parent_accessor, child_data.fid);
450 for (
const auto& parent_data : parent_incident_datas) {
456 if (parent_data.fid == target_parent_fid) {
458 const auto& child_split_f = child_data.split_f;
459 const auto& parent_split_f = parent_data.split_f;
462 for (int64_t index = 0; index < 2; ++index) {
463 int64_t f_child = child_split_f[index];
464 int64_t f_parent = parent_split_f[index];
465 if (f_child == -1 || f_parent == -1) {
469 int64_t e_child = child_data.ears[index].eid;
470 int64_t e_parent = parent_data.ears[index].eid;
472 int64_t v_child = child_spine_v[index];
473 int64_t v_parent = parent_spine_v[index];
475 const Tuple parent_tuple =
477 const Tuple child_tuple =
497 assert(parent_mesh.
is_valid(parent_tuple));
498 assert(child_mesh.
is_valid(child_tuple));
501 parent_to_child_accessor,
502 child_to_parent_accessor,
548 int64_t child_id = child_mmmanager.child_id();
549 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
550 auto child_to_parent_accessor = child_mesh.
create_accessor(child_to_parent_handle);
551 auto parent_to_child_accessor = parent_mesh.
create_accessor(parent_to_child_handle);
553 int64_t target_parent_tid =
555 int64_t target_parent_local_fid =
557 for (
const auto& parent_data : parent_incident_tet_datas) {
558 if (parent_data.tid != target_parent_tid)
continue;
560 int64_t face_index = -1;
561 for (
int i = 0; i < 2; ++i) {
562 if (parent_data.incident_face_local_fid[i] == target_parent_local_fid) {
568 assert(face_index != -1);
570 for (
int index = 0; index < 2; ++index) {
571 const int64_t t_parent = parent_data.split_t[index];
572 const int64_t f_parent =
573 parent_incident_face_datas[parent_data.incident_face_data_idx[face_index]]
577 const int64_t e_child = child_emoe.
m_split_e[index];
579 if (t_parent == -1 || f_parent == -1 || e_child == -1 || e_parent == -1) {
584 const int64_t v_child =
588 const Tuple parent_tuple =
592 assert(parent_mesh.
is_valid(parent_tuple));
593 assert(child_mesh.
is_valid(child_tuple));
596 parent_to_child_accessor,
597 child_to_parent_accessor,
626 int64_t child_id = child_mmmanager.child_id();
627 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
628 auto child_to_parent_accessor = child_mesh.
create_accessor(child_to_parent_handle);
629 auto parent_to_child_accessor = parent_mesh.
create_accessor(parent_to_child_handle);
631 for (
const auto& child_data : child_incident_face_datas) {
632 int64_t target_parent_tid =
parent_global_cid(child_to_parent_accessor, child_data.fid);
635 int64_t target_parent_local_fid =
638 for (
const auto& parent_data : parent_incident_tet_datas) {
639 if (parent_data.tid != target_parent_tid)
continue;
640 int64_t face_index = -1;
641 for (
int i = 0; i < 2; ++i) {
642 if (parent_data.incident_face_local_fid[i] == target_parent_local_fid) {
648 assert(face_index != -1);
650 for (
int index = 0; index < 2; ++index) {
652 int64_t t_parent = parent_data.split_t[index];
654 int64_t f_child = child_data.split_f[index];
656 parent_incident_face_datas[parent_data.incident_face_data_idx[face_index]]
659 if (t_parent == -1 || f_child == -1 || f_parent == -1) {
663 int64_t e_child = child_data.ears[index].eid;
665 parent_incident_face_datas[parent_data.incident_face_data_idx[face_index]]
668 int64_t v_child = child_spine_v[index];
669 int64_t v_parent = parent_spine_v[index];
671 const Tuple parent_tuple =
673 const Tuple child_tuple =
676 assert(parent_mesh.
is_valid(parent_tuple));
677 assert(child_mesh.
is_valid(child_tuple));
680 parent_to_child_accessor,
681 child_to_parent_accessor,
712 int64_t child_id = child_mmmanager.child_id();
713 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
714 auto child_to_parent_accessor = child_mesh.
create_accessor(child_to_parent_handle);
715 auto parent_to_child_accessor = parent_mesh.
create_accessor(parent_to_child_handle);
717 for (
const auto& child_data : child_incident_tet_datas) {
718 int64_t target_parent_tid =
parent_global_cid(child_to_parent_accessor, child_data.tid);
720 for (
const auto& parent_data : parent_incident_tet_datas) {
721 if (parent_data.tid != target_parent_tid)
continue;
722 const auto& child_split_t = child_data.split_t;
723 const auto& parent_split_t = parent_data.split_t;
725 for (int64_t index = 0; index < 2; ++index) {
726 int64_t t_child = child_split_t[index];
727 int64_t t_parent = parent_split_t[index];
729 if (t_child == -1 || t_parent == -1) {
733 int64_t f_child = child_data.ears[index].fid;
734 int64_t f_parent = parent_data.ears[index].fid;
737 child_incident_face_datas[child_data.incident_face_data_idx[1]].ear_eids[index];
738 int64_t e_parent = parent_incident_face_datas[parent_data.incident_face_data_idx[1]]
741 int64_t v_child = child_spine_v[index];
742 int64_t v_parent = parent_spine_v[index];
745 const Tuple parent_tuple =
747 const Tuple child_tuple =
750 assert(parent_mesh.
is_valid(parent_tuple));
751 assert(child_mesh.
is_valid(child_tuple));
754 parent_to_child_accessor,
755 child_to_parent_accessor,
774 throw std::runtime_error(
"not implemented");
777 logger().error(
"EdgeMesh update Not implemented!");
786 std::vector<std::tuple<int64_t, std::array<int64_t, 2>>> parent_split_cell_maps;
788 for (
const auto& parent_data : parent_incident_datas) {
789 if (parent_data.split_f[0] == -1)
break;
790 parent_split_cell_maps.emplace_back(parent_data.fid, parent_data.split_f);
800 parent_split_cell_maps);
809 std::vector<std::tuple<int64_t, std::array<int64_t, 2>>> parent_split_cell_maps;
811 for (
const auto& parent_data : parent_incident_tet_datas) {
812 if (parent_data.split_t[0] == -1)
break;
813 parent_split_cell_maps.emplace_back(parent_data.tid, parent_data.split_t);
822 parent_split_cell_maps);
827 int64_t parent_gid)
const
833 int64_t child_gid)
const
840 int64_t child_gid)
const
Tuple tuple_from_global_ids(int64_t eid, int64_t vid) const
bool is_valid(const Tuple &tuple) const final override
check validity of tuple including its hash
attribute::Accessor< T, Derived, Dim > create_accessor(const TypedAttributeHandle< T > &handle)
constructs an accessor that is aware of the derived mesh's type
static auto & get_index_access(attribute::Accessor< T, MeshType > &attr)
multimesh::MultiMeshManager m_multi_mesh_manager
decltype(auto) parent_scope(Functor &&f, Args &&... args) const
Evaluate the passed in function inside the parent scope.
std::vector< std::shared_ptr< Mesh > > get_child_meshes() const
returns the direct multimesh child meshes for the current mesh
Tuple tuple_from_global_ids(int64_t tid, int64_t fid, int64_t eid, int64_t vid) const
int64_t id_vertex(const Tuple &tuple) const
int64_t id_edge(const Tuple &tuple) const
bool is_valid(const Tuple &tuple) const final override
check validity of tuple including its hash
int64_t id_vertex(const Tuple &tuple) const
bool is_valid(const Tuple &tuple) const final override
check validity of tuple including its hash
Tuple tuple_from_global_ids(int64_t fid, int64_t eid, int64_t vid) const
bool is_null() const
Checks if a tuple is "null". This merely implies the global index is -1.
A CachingAccessor that uses tuples for accessing attributes instead of indices.
int64_t child_id() const
Specifies the child id of this mesh if it a child mesh in a mult-mesh tree.
static int64_t child_global_cid(const wmtk::attribute::Accessor< int64_t > &parent_to_child, int64_t parent_gid)
static int64_t parent_local_fid(const wmtk::attribute::Accessor< int64_t > &child_to_parent, int64_t child_gid)
static int64_t parent_global_cid(const wmtk::attribute::Accessor< int64_t > &child_to_parent, int64_t child_gid)
TypedAttributeHandle< int64_t > map_to_parent_handle
void update_map_tuple_hashes(Mesh &my_mesh, PrimitiveType primitive_type, const std::vector< std::tuple< int64_t, std::vector< Tuple >>> &simplices_to_update, const std::vector< std::tuple< int64_t, std::array< int64_t, 2 >>> &split_cell_maps={})
std::vector< std::vector< std::tuple< int64_t, std::vector< Tuple > > > > global_ids_to_potential_tuples
int64_t m_operating_edge_id
std::array< int64_t, 2 > m_split_e
std::array< int64_t, 2 > m_spine_vids
std::vector< IncidentTetData > incident_tet_datas() const
const std::array< int64_t, 2 > & incident_vids() const
std::array< int64_t, 2 > new_spine_eids() const
std::vector< IncidentFaceData > incident_face_datas() const
std::array< int64_t, 2 > split_spine_eids
const std::array< int64_t, 2 > & incident_vids() const
const std::vector< IncidentFaceData > & incident_face_datas() const
void update_ear_replacement(TriMesh &m, const tri_mesh::EdgeOperationData &fmoe) const
int64_t parent_global_cid(const attribute::Accessor< int64_t, Mesh, Eigen::Dynamic > &parent_to_child, int64_t parent_gid) const
int64_t parent_local_fid(const attribute::Accessor< int64_t, Mesh, Eigen::Dynamic > &parent_to_child, int64_t parent_gid) const
void operator()(EdgeMesh &, const simplex::Simplex &, const edge_mesh::EdgeOperationData &parent_tmoe, EdgeMesh &, const simplex::Simplex &, const edge_mesh::EdgeOperationData &) const
int64_t child_global_cid(const attribute::Accessor< int64_t, Mesh, Eigen::Dynamic > &parent_to_child, int64_t parent_gid) const
void update_all_hashes(Mesh &m, const std::vector< std::vector< std::tuple< int64_t, std::vector< Tuple >>>> &simplices_to_update, const std::vector< std::tuple< int64_t, std::array< int64_t, 2 >>> &split_cell_maps={}) const
constexpr wmtk::PrimitiveType PT
constexpr wmtk::PrimitiveType PF
std::tuple< Tuple, Tuple > vectors_to_tuples(const Eigen::Ref< const TwoTupleVector > &v)
void symmetric_write_tuple_map_attributes(wmtk::attribute::Accessor< int64_t, MeshA > &a_to_b, wmtk::attribute::Accessor< int64_t, MeshB > &b_to_a, const Tuple &a_tuple, const Tuple &b_tuple)
constexpr PrimitiveType PV
spdlog::logger & logger()
Retrieves the current logger.
constexpr PrimitiveType PE