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 char child_flag =
92 child_cell_flag_accessor.const_scalar_attribute(child_tuple);
93 bool child_tuple_exists = 1 == (child_flag & 1);
94 if (!child_tuple_exists) {
98 const int64_t parent_old_vid =
102 int64_t parent_new_vid = -1;
104 if (parent_ear_eid_old != parent_merged_eid) {
106 if (parent_old_vid == parent_incident_vids[0]) {
107 parent_new_vid = parent_incident_vids[1];
109 parent_new_vid = parent_old_vid;
113 parent_new_vid = parent_old_vid;
116 assert(parent_new_vid != -1);
118 Tuple new_parent_tuple =
121 update_pairs.push_back(std::make_pair(new_parent_tuple, child_tuple));
124 for (
const auto& pair : update_pairs) {
126 parent_to_child_accessor,
127 child_to_parent_accessor,
143 for (
const auto& parent_data : parent_incident_tet_datas) {
146 if (child_ptr->is_free()) {
149 if (child_ptr->top_cell_dimension() == 2) {
152 const auto& child_mmmanager = child_ptr->m_multi_mesh_manager;
153 const int64_t child_id = child_mmmanager.
child_id();
154 const auto child_to_parent_handle = child_mmmanager.map_to_parent_handle;
155 const auto parent_to_child_handle =
156 parent_mmmanager.children().at(child_id).map_handle;
157 auto child_to_parent_accessor = child_ptr->create_accessor(child_to_parent_handle);
158 auto parent_to_child_accessor = m.
create_accessor(parent_to_child_handle);
159 auto child_cell_flag_accessor =
162 std::vector<std::pair<Tuple, Tuple>> update_pairs;
164 for (
int ear_index = 0; ear_index < 2; ++ear_index) {
165 const int64_t parent_ear_fid_old = parent_data.ears[ear_index].fid;
166 const int64_t parent_merged_fid = parent_data.new_face_id;
167 const int64_t parent_new_tid =
168 parent_data.merged_face_tid;
170 assert(parent_merged_fid != -1);
171 assert(parent_new_tid != -1);
174 .const_vector_attribute(parent_ear_fid_old);
177 Tuple parent_tuple, child_tuple;
178 std::tie(parent_tuple, child_tuple) =
187 const char child_flag =
188 child_cell_flag_accessor.const_scalar_attribute(child_tuple);
189 bool child_tuple_exists = 1 == (child_flag & 1);
190 if (!child_tuple_exists) {
194 const int64_t parent_old_eid =
196 const int64_t parent_old_vid =
201 int64_t parent_new_eid = -1;
202 int64_t parent_new_vid = -1;
204 if (parent_ear_fid_old != parent_merged_fid) {
206 if (parent_old_eid == parent_data.e02) {
207 parent_new_eid = parent_data.e12;
208 }
else if (parent_old_eid == parent_data.e03) {
209 parent_new_eid = parent_data.e13;
210 }
else if (parent_old_eid == parent_data.e23) {
211 parent_new_eid = parent_data.e23;
214 if (parent_old_vid == parent_data.v0) {
215 parent_new_vid = parent_data.v1;
216 }
else if (parent_old_vid == parent_data.v2) {
217 parent_new_vid = parent_data.v2;
218 }
else if (parent_old_vid == parent_data.v3) {
219 parent_new_vid = parent_data.v3;
223 parent_new_eid = parent_old_eid;
224 parent_new_vid = parent_old_vid;
227 assert(parent_new_eid != -1);
228 assert(parent_new_vid != -1);
236 update_pairs.push_back(std::make_pair(new_parent_tuple, child_tuple));
239 for (
const auto& pair : update_pairs) {
241 parent_to_child_accessor,
242 child_to_parent_accessor,
247 }
else if (child_ptr->top_cell_dimension() == 1) {
251 const auto& child_mmmanager = child_ptr->m_multi_mesh_manager;
252 int64_t child_id = child_mmmanager.child_id();
253 auto child_to_parent_handle = child_mmmanager.map_to_parent_handle;
254 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
255 auto child_to_parent_accessor = child_ptr->create_accessor(child_to_parent_handle);
256 auto parent_to_child_accessor = m.
create_accessor(parent_to_child_handle);
257 auto child_cell_flag_accessor =
260 std::vector<std::pair<Tuple, Tuple>> update_pairs;
262 for (
int ear_index = 0; ear_index < 2; ++ear_index) {
263 const int64_t parent_ear_fid_old = parent_data.ears[ear_index].fid;
264 const int64_t parent_merged_fid = parent_data.new_face_id;
265 const int64_t parent_new_tid = parent_data.merged_face_tid;
268 std::array<int64_t, 3> parent_old_eids;
269 std::array<int64_t, 3> parent_new_eids = {
270 {parent_data.e12, parent_data.e13, parent_data.e23}};
272 if (parent_ear_fid_old != parent_merged_fid) {
273 parent_old_eids = {{parent_data.e02, parent_data.e03, parent_data.e23}};
275 parent_old_eids = {{parent_data.e12, parent_data.e13, parent_data.e23}};
279 assert(parent_merged_fid != -1);
280 assert(parent_new_tid != -1);
282 for (
int i = 0; i < 3; ++i) {
284 .const_vector_attribute(parent_old_eids[i]);
287 Tuple parent_tuple, child_tuple;
288 std::tie(parent_tuple, child_tuple) =
297 const char child_flag =
298 child_cell_flag_accessor.const_scalar_attribute(child_tuple);
299 bool child_tuple_exists = 1 == (child_flag & 1);
300 if (!child_tuple_exists) {
304 const int64_t parent_old_vid =
307 int64_t parent_new_vid = -1;
308 if (parent_ear_fid_old != parent_merged_fid) {
310 if (parent_old_vid == parent_data.v0) {
311 parent_new_vid = parent_data.v1;
312 }
else if (parent_old_vid == parent_data.v2) {
313 parent_new_vid = parent_data.v2;
314 }
else if (parent_old_vid == parent_data.v3) {
315 parent_new_vid = parent_data.v3;
319 parent_new_vid = parent_old_vid;
322 assert(parent_new_vid != -1);
330 update_pairs.push_back(std::make_pair(new_parent_tuple, child_tuple));
333 for (
const auto& pair : update_pairs) {
335 parent_to_child_accessor,
336 child_to_parent_accessor,
356 throw std::runtime_error(
"not implemented");
374 int64_t child_id = child_mmmanager.child_id();
375 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
376 auto child_to_parent_accessor = child_mesh.
create_accessor(child_to_parent_handle);
377 auto parent_to_child_accessor = parent_mesh.
create_accessor(parent_to_child_handle);
381 for (int64_t index = 0; index < 2; ++index) {
383 int64_t f_parent = parent_incident_datas[0].split_f[index];
385 const int64_t e_child = child_emoe.
m_split_e[index];
388 if (f_parent == -1 || e_child == -1 || e_parent == -1) {
393 const int64_t v_parent = parent_spine_v[index];
398 assert(parent_mesh.
is_valid(parent_tuple));
399 assert(child_mesh.
is_valid(child_tuple));
402 parent_to_child_accessor,
403 child_to_parent_accessor,
436 int64_t child_id = child_mmmanager.child_id();
437 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
438 auto child_to_parent_accessor = child_mesh.
create_accessor(child_to_parent_handle);
439 auto parent_to_child_accessor = parent_mesh.
create_accessor(parent_to_child_handle);
446 for (
const auto& child_data : child_incident_datas) {
447 int64_t target_parent_fid =
parent_global_cid(child_to_parent_accessor, child_data.fid);
456 for (
const auto& parent_data : parent_incident_datas) {
462 if (parent_data.fid == target_parent_fid) {
464 const auto& child_split_f = child_data.split_f;
465 const auto& parent_split_f = parent_data.split_f;
468 for (int64_t index = 0; index < 2; ++index) {
469 int64_t f_child = child_split_f[index];
470 int64_t f_parent = parent_split_f[index];
471 if (f_child == -1 || f_parent == -1) {
475 int64_t e_child = child_data.ears[index].eid;
476 int64_t e_parent = parent_data.ears[index].eid;
478 int64_t v_child = child_spine_v[index];
479 int64_t v_parent = parent_spine_v[index];
481 const Tuple parent_tuple =
483 const Tuple child_tuple =
503 assert(parent_mesh.
is_valid(parent_tuple));
504 assert(child_mesh.
is_valid(child_tuple));
507 parent_to_child_accessor,
508 child_to_parent_accessor,
554 int64_t child_id = child_mmmanager.child_id();
555 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
556 auto child_to_parent_accessor = child_mesh.
create_accessor(child_to_parent_handle);
557 auto parent_to_child_accessor = parent_mesh.
create_accessor(parent_to_child_handle);
559 int64_t target_parent_tid =
561 int64_t target_parent_local_fid =
563 for (
const auto& parent_data : parent_incident_tet_datas) {
564 if (parent_data.tid != target_parent_tid)
continue;
566 int64_t face_index = -1;
567 for (
int i = 0; i < 2; ++i) {
568 if (parent_data.incident_face_local_fid[i] == target_parent_local_fid) {
574 assert(face_index != -1);
576 for (
int index = 0; index < 2; ++index) {
577 const int64_t t_parent = parent_data.split_t[index];
578 const int64_t f_parent =
579 parent_incident_face_datas[parent_data.incident_face_data_idx[face_index]]
583 const int64_t e_child = child_emoe.
m_split_e[index];
585 if (t_parent == -1 || f_parent == -1 || e_child == -1 || e_parent == -1) {
590 const int64_t v_child =
594 const Tuple parent_tuple =
598 assert(parent_mesh.
is_valid(parent_tuple));
599 assert(child_mesh.
is_valid(child_tuple));
602 parent_to_child_accessor,
603 child_to_parent_accessor,
632 int64_t child_id = child_mmmanager.child_id();
633 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
634 auto child_to_parent_accessor = child_mesh.
create_accessor(child_to_parent_handle);
635 auto parent_to_child_accessor = parent_mesh.
create_accessor(parent_to_child_handle);
637 for (
const auto& child_data : child_incident_face_datas) {
638 int64_t target_parent_tid =
parent_global_cid(child_to_parent_accessor, child_data.fid);
641 int64_t target_parent_local_fid =
644 for (
const auto& parent_data : parent_incident_tet_datas) {
645 if (parent_data.tid != target_parent_tid)
continue;
646 int64_t face_index = -1;
647 for (
int i = 0; i < 2; ++i) {
648 if (parent_data.incident_face_local_fid[i] == target_parent_local_fid) {
654 assert(face_index != -1);
656 for (
int index = 0; index < 2; ++index) {
658 int64_t t_parent = parent_data.split_t[index];
660 int64_t f_child = child_data.split_f[index];
662 parent_incident_face_datas[parent_data.incident_face_data_idx[face_index]]
665 if (t_parent == -1 || f_child == -1 || f_parent == -1) {
669 int64_t e_child = child_data.ears[index].eid;
671 parent_incident_face_datas[parent_data.incident_face_data_idx[face_index]]
674 int64_t v_child = child_spine_v[index];
675 int64_t v_parent = parent_spine_v[index];
677 const Tuple parent_tuple =
679 const Tuple child_tuple =
682 assert(parent_mesh.
is_valid(parent_tuple));
683 assert(child_mesh.
is_valid(child_tuple));
686 parent_to_child_accessor,
687 child_to_parent_accessor,
718 int64_t child_id = child_mmmanager.child_id();
719 auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle;
720 auto child_to_parent_accessor = child_mesh.
create_accessor(child_to_parent_handle);
721 auto parent_to_child_accessor = parent_mesh.
create_accessor(parent_to_child_handle);
723 for (
const auto& child_data : child_incident_tet_datas) {
724 int64_t target_parent_tid =
parent_global_cid(child_to_parent_accessor, child_data.tid);
726 for (
const auto& parent_data : parent_incident_tet_datas) {
727 if (parent_data.tid != target_parent_tid)
continue;
728 const auto& child_split_t = child_data.split_t;
729 const auto& parent_split_t = parent_data.split_t;
731 for (int64_t index = 0; index < 2; ++index) {
732 int64_t t_child = child_split_t[index];
733 int64_t t_parent = parent_split_t[index];
735 if (t_child == -1 || t_parent == -1) {
739 int64_t f_child = child_data.ears[index].fid;
740 int64_t f_parent = parent_data.ears[index].fid;
743 child_incident_face_datas[child_data.incident_face_data_idx[1]].ear_eids[index];
744 int64_t e_parent = parent_incident_face_datas[parent_data.incident_face_data_idx[1]]
747 int64_t v_child = child_spine_v[index];
748 int64_t v_parent = parent_spine_v[index];
751 const Tuple parent_tuple =
753 const Tuple child_tuple =
756 assert(parent_mesh.
is_valid(parent_tuple));
757 assert(child_mesh.
is_valid(child_tuple));
760 parent_to_child_accessor,
761 child_to_parent_accessor,
780 throw std::runtime_error(
"not implemented");
783 logger().error(
"EdgeMesh update Not implemented!");
792 std::vector<std::tuple<int64_t, std::array<int64_t, 2>>> parent_split_cell_maps;
794 for (
const auto& parent_data : parent_incident_datas) {
795 if (parent_data.split_f[0] == -1)
break;
796 parent_split_cell_maps.emplace_back(parent_data.fid, parent_data.split_f);
806 parent_split_cell_maps);
815 std::vector<std::tuple<int64_t, std::array<int64_t, 2>>> parent_split_cell_maps;
817 for (
const auto& parent_data : parent_incident_tet_datas) {
818 if (parent_data.split_t[0] == -1)
break;
819 parent_split_cell_maps.emplace_back(parent_data.tid, parent_data.split_t);
828 parent_split_cell_maps);
833 int64_t parent_gid)
const
839 int64_t child_gid)
const
846 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