From b93acf0f13fff595bf0eb3923e6cdc995e5afccb Mon Sep 17 00:00:00 2001 From: Michael Tao Date: Fri, 16 Aug 2024 19:07:24 -0400 Subject: [PATCH 1/6] mostly done removing the hash update cases --- src/wmtk/EdgeMesh.cpp | 37 +---- src/wmtk/EdgeMeshOperationExecutor.cpp | 23 --- src/wmtk/EdgeMeshOperationExecutor.hpp | 10 -- src/wmtk/Mesh.cpp | 137 ----------------- src/wmtk/Mesh.hpp | 87 ----------- src/wmtk/PointMesh.cpp | 4 - src/wmtk/TetMesh.cpp | 42 ------ src/wmtk/TetMeshOperationExecutor.cpp | 30 ---- src/wmtk/TetMeshOperationExecutor.hpp | 7 - src/wmtk/TriMesh.cpp | 49 ------ src/wmtk/TriMeshOperationExecutor.cpp | 17 --- src/wmtk/TriMeshOperationExecutor.hpp | 7 - src/wmtk/Tuple.hpp | 13 +- src/wmtk/Tuple.hxx | 16 -- .../autogen/edge_mesh/local_switch_tuple.hxx | 4 +- .../autogen/tet_mesh/local_switch_tuple.hxx | 10 +- .../autogen/tri_mesh/local_switch_tuple.hxx | 6 +- src/wmtk/multimesh/MultiMeshManager.cpp | 142 ------------------ src/wmtk/multimesh/MultiMeshManager.hpp | 17 --- src/wmtk/operations/AndOperationSequence.cpp | 5 - src/wmtk/operations/Operation.cpp | 26 ---- src/wmtk/operations/Operation.hpp | 10 -- src/wmtk/operations/OperationSequence.cpp | 5 - src/wmtk/operations/composite/TetEdgeSwap.cpp | 8 - src/wmtk/operations/composite/TetFaceSwap.cpp | 8 - src/wmtk/operations/utils/CMakeLists.txt | 2 - .../utils/MultiMeshEdgeCollapseFunctor.cpp | 15 -- .../utils/MultiMeshEdgeSplitFunctor.cpp | 15 -- ...UpdateEdgeOperationMultiMeshMapFunctor.cpp | 42 ------ .../utils/UpdateVertexMultiMeshMapHash.cpp | 103 ------------- .../utils/UpdateVertexMultiMeshMapHash.hpp | 34 ----- src/wmtk/utils/TupleInspector.cpp | 5 +- src/wmtk/utils/TupleInspector.hpp | 1 - 33 files changed, 11 insertions(+), 926 deletions(-) delete mode 100644 src/wmtk/operations/utils/UpdateVertexMultiMeshMapHash.cpp delete mode 100644 src/wmtk/operations/utils/UpdateVertexMultiMeshMapHash.hpp diff --git a/src/wmtk/EdgeMesh.cpp b/src/wmtk/EdgeMesh.cpp index 9b050189fc..a80fb42e41 100644 --- a/src/wmtk/EdgeMesh.cpp +++ b/src/wmtk/EdgeMesh.cpp @@ -45,8 +45,7 @@ Tuple EdgeMesh::switch_tuple(const Tuple& tuple, PrimitiveType type) const 1 - tuple.m_local_vid, tuple.m_local_eid, tuple.m_local_fid, - tuple.m_global_cid, - tuple.m_hash); + tuple.m_global_cid); case PrimitiveType::Edge: { const int64_t gvid = id(tuple, PrimitiveType::Vertex); @@ -77,18 +76,7 @@ Tuple EdgeMesh::switch_tuple(const Tuple& tuple, PrimitiveType type) const assert(lvid_new != -1); -#if defined(WMTK_ENABLE_HASH_UPDATE) - const attribute::Accessor hash_accessor = get_const_cell_hash_accessor(); - const Tuple res( - lvid_new, - tuple.m_local_eid, - tuple.m_local_fid, - gcid_new, - get_cell_hash(gcid_new, hash_accessor)); -#else const Tuple res(lvid_new, tuple.m_local_eid, tuple.m_local_fid, gcid_new); - -#endif assert(is_valid(res)); return res; } @@ -187,11 +175,7 @@ Tuple EdgeMesh::vertex_tuple_from_id(int64_t id) const auto ev = ev_accessor.index_access().const_vector_attribute<2>(e); for (int64_t i = 0; i < 2; ++i) { if (ev(i) == id) { -#if defined(WMTK_ENABLE_HASH_UPDATE) - Tuple v_tuple = Tuple(i, -1, -1, e, get_cell_hash_slow(e)); -#else Tuple v_tuple = Tuple(i, -1, -1, e); -#endif return v_tuple; } } @@ -202,11 +186,7 @@ Tuple EdgeMesh::vertex_tuple_from_id(int64_t id) const Tuple EdgeMesh::edge_tuple_from_id(int64_t id) const { -#if defined(WMTK_ENABLE_HASH_UPDATE) - Tuple e_tuple = Tuple(0, -1, -1, id, get_cell_hash_slow(id)); -#else Tuple e_tuple = Tuple(0, -1, -1, id); -#endif assert(is_valid(e_tuple)); return e_tuple; @@ -226,16 +206,7 @@ Tuple EdgeMesh::tuple_from_global_ids(int64_t eid, int64_t vid) const } assert(lvid != -1); -#if defined(WMTK_ENABLE_HASH_UPDATE) - return Tuple( - lvid, - -1, - -1, - eid, - get_cell_hash_slow(eid)); // TODO replace by function that takes hash accessor as parameter -#else return Tuple(lvid, -1, -1, eid); -#endif } @@ -302,13 +273,7 @@ std::vector>> EdgeMesh::connectivity_a std::vector EdgeMesh::orient_vertices(const Tuple& tuple) const { int64_t cid = tuple.m_global_cid; -#if defined(WMTK_ENABLE_HASH_UPDATE) - auto hash = get_cell_hash_slow(cid); - - return {Tuple(0, -1, -1, cid, hash), Tuple(1, -1, -1, cid, hash)}; -#else return {Tuple(0, -1, -1, cid), Tuple(1, -1, -1, cid)}; -#endif } diff --git a/src/wmtk/EdgeMeshOperationExecutor.cpp b/src/wmtk/EdgeMeshOperationExecutor.cpp index b8dbacc08b..4c7cc26172 100644 --- a/src/wmtk/EdgeMeshOperationExecutor.cpp +++ b/src/wmtk/EdgeMeshOperationExecutor.cpp @@ -3,23 +3,13 @@ namespace wmtk { // constructor -#if defined(WMTK_ENABLE_HASH_UPDATE) -EdgeMesh::EdgeMeshOperationExecutor::EdgeMeshOperationExecutor( - EdgeMesh& m, - const Tuple& operating_tuple, - attribute::Accessor& hash_acc) -#else EdgeMesh::EdgeMeshOperationExecutor::EdgeMeshOperationExecutor( EdgeMesh& m, const Tuple& operating_tuple) -#endif : flag_accessors{{m.get_flag_accessor(PrimitiveType::Vertex), m.get_flag_accessor(PrimitiveType::Edge)}} , ee_accessor(m.create_accessor(m.m_ee_handle)) , ev_accessor(m.create_accessor(m.m_ev_handle)) , ve_accessor(m.create_accessor(m.m_ve_handle)) -#if defined(WMTK_ENABLE_HASH_UPDATE) - , hash_accessor(hash_acc) -#endif , m_mesh(m) { m_operating_tuple = operating_tuple; @@ -30,20 +20,11 @@ EdgeMesh::EdgeMeshOperationExecutor::EdgeMeshOperationExecutor( m_spine_vids[1] = m_mesh.id_vertex(operating_tuple_switch_vertex); // update hash on neighborhood -#if defined(WMTK_ENABLE_HASH_UPDATE) - cell_ids_to_update_hash.emplace_back(m_mesh.id_edge(m_operating_tuple)); -#endif if (!m_mesh.is_boundary_vertex(m_operating_tuple)) { m_neighbor_eids[0] = m_mesh.id_edge(m_mesh.switch_edge(m_operating_tuple)); -#if defined(WMTK_ENABLE_HASH_UPDATE) - cell_ids_to_update_hash.emplace_back(m_neighbor_eids[0]); -#endif } if (!m_mesh.is_boundary_vertex(operating_tuple_switch_vertex)) { m_neighbor_eids[1] = m_mesh.id_edge(m_mesh.switch_edge(operating_tuple_switch_vertex)); -#if defined(WMTK_ENABLE_HASH_UPDATE) - cell_ids_to_update_hash.emplace_back(m_neighbor_eids[1]); -#endif } @@ -63,10 +44,6 @@ void EdgeMesh::EdgeMeshOperationExecutor::delete_simplices() void EdgeMesh::EdgeMeshOperationExecutor::update_cell_hash() { -#if defined(WMTK_ENABLE_HASH_UPDATE) - - m_mesh.update_cell_hashes(cell_ids_to_update_hash, hash_accessor); -#endif } const std::array, 2> diff --git a/src/wmtk/EdgeMeshOperationExecutor.hpp b/src/wmtk/EdgeMeshOperationExecutor.hpp index c0c9ab5be7..bc965db4c9 100644 --- a/src/wmtk/EdgeMeshOperationExecutor.hpp +++ b/src/wmtk/EdgeMeshOperationExecutor.hpp @@ -7,16 +7,9 @@ namespace wmtk { class EdgeMesh::EdgeMeshOperationExecutor : public operations::edge_mesh::EdgeOperationData { public: -#if defined(WMTK_ENABLE_HASH_UPDATE) - EdgeMeshOperationExecutor( - EdgeMesh& m, - const Tuple& operating_tuple, - attribute::Accessor& hash_acc); -#else EdgeMeshOperationExecutor( EdgeMesh& m, const Tuple& operating_tuple); -#endif void delete_simplices(); void update_cell_hash(); @@ -24,9 +17,6 @@ class EdgeMesh::EdgeMeshOperationExecutor : public operations::edge_mesh::EdgeOp attribute::Accessor ee_accessor; attribute::Accessor ev_accessor; attribute::Accessor ve_accessor; -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor& hash_accessor; -#endif /** * @brief gather all simplices that are deleted in a split diff --git a/src/wmtk/Mesh.cpp b/src/wmtk/Mesh.cpp index 22a6e5f62a..3aaa2a220d 100644 --- a/src/wmtk/Mesh.cpp +++ b/src/wmtk/Mesh.cpp @@ -61,48 +61,6 @@ bool Mesh::is_boundary(const simplex::Simplex& s) const } -#if defined(WMTK_ENABLE_HASH_UPDATE) -bool Mesh::is_hash_valid(const Tuple& tuple, const attribute::Accessor& hash_accessor) - const -{ - const int64_t cid = tuple.m_global_cid; - - const int64_t desired_hash = get_cell_hash(cid, hash_accessor); - if (tuple.m_hash != desired_hash) { - // logger().debug("Hash is not valid: {} != {}", tuple.m_hash, desired_hash); - return false; - } - return true; -} - -bool Mesh::is_hash_valid(const Tuple& tuple) const -{ - auto ha = get_const_cell_hash_accessor(); - return is_hash_valid(tuple, ha); -} - - -bool Mesh::is_valid_with_hash(const Tuple& tuple) const -{ - auto ha = get_const_cell_hash_accessor(); - return is_valid_with_hash(tuple, ha); -} -bool Mesh::is_valid_with_hash(const Tuple& tuple, const attribute::Accessor& hash_accessor) - const -{ - if (!is_valid(tuple)) { - return false; - } - if (!is_hash_valid(tuple, hash_accessor)) { - return false; - } - // #else - // const auto& flag_accessor = get_const_flag_accessor(top_simplex_type()); - // return flag_accessor.index_access().const_scalar_attribute(tuple.m_global_cid) & 0x1; - // #endif - return true; -} -#endif bool Mesh::is_valid(const Tuple& tuple) const { @@ -154,95 +112,8 @@ attribute::Accessor Mesh::get_flag_accessor(PrimitiveType type) return create_accessor(m_flag_handles.at(get_primitive_type_id(type))); } -#if defined(WMTK_ENABLE_HASH_UPDATE) -const attribute::Accessor Mesh::get_const_cell_hash_accessor() const -{ - return create_const_accessor(m_cell_hash_handle); -} -const attribute::Accessor Mesh::get_cell_hash_accessor() const -{ - return get_const_cell_hash_accessor(); -} -attribute::Accessor Mesh::get_cell_hash_accessor() -{ - return create_accessor(m_cell_hash_handle); -} -void Mesh::update_cell_hash(const Tuple& cell, attribute::Accessor& hash_accessor) -{ - const int64_t cid = cell.m_global_cid; - update_cell_hash(cid, hash_accessor); -} -void Mesh::update_cell_hash(const int64_t cid, attribute::Accessor& hash_accessor) -{ - auto& h = hash_accessor.index_access().scalar_attribute(cid); - h = (h + 1) % (1 << 6); -} - -void Mesh::update_cell_hashes( - const std::vector& cells, - attribute::Accessor& hash_accessor) -{ - for (const Tuple& t : cells) { - update_cell_hash(t, hash_accessor); - } -} -void Mesh::update_cell_hashes( - const std::vector& cells, - attribute::Accessor& hash_accessor) -{ - for (const int64_t t : cells) { - update_cell_hash(t, hash_accessor); - } -} - -void Mesh::update_cell_hashes_slow(const std::vector& cells) -{ - attribute::Accessor hash_accessor = get_cell_hash_accessor(); - update_cell_hashes(cells, hash_accessor); -} -#endif - - -#if defined(WMTK_ENABLE_HASH_UPDATE) -Tuple Mesh::resurrect_tuple(const Tuple& tuple, const attribute::Accessor& hash_accessor) - const -{ -#if defined(WMTK_ENABLE_HASH_UPDATE) - - Tuple t = tuple; - t.m_hash = get_cell_hash(tuple.m_global_cid, hash_accessor); - return t; -#else - return tuple; -#endif -} - -Tuple Mesh::resurrect_tuple_slow(const Tuple& tuple) const -{ -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor hash_accessor = get_cell_hash_accessor(); - return resurrect_tuple(tuple, hash_accessor); -#else - return tuple; -#endif -} -#endif - -#if defined(WMTK_ENABLE_HASH_UPDATE) -int64_t Mesh::get_cell_hash(int64_t cell_index, const attribute::Accessor& hash_accessor) - const -{ - return hash_accessor.index_access().const_scalar_attribute(cell_index); -} - -int64_t Mesh::get_cell_hash_slow(int64_t cell_index) const -{ - const attribute::Accessor hash_accessor = get_cell_hash_accessor(); - return get_cell_hash(cell_index, hash_accessor); -} -#endif void Mesh::set_capacities_from_flags() { @@ -289,14 +160,6 @@ Tuple Mesh::switch_tuples_unsafe( } -#if defined(WMTK_ENABLE_HASH_UPDATE) -void Mesh::update_vertex_operation_hashes( - const Tuple& vertex, - attribute::Accessor& hash_accessor) -{ - MultiMeshManager::update_vertex_operation_hashes_internal(*this, vertex, hash_accessor); -} -#endif void Mesh::assert_capacity_valid() const { diff --git a/src/wmtk/Mesh.hpp b/src/wmtk/Mesh.hpp index 2b57665d82..7bae8e40dd 100644 --- a/src/wmtk/Mesh.hpp +++ b/src/wmtk/Mesh.hpp @@ -122,17 +122,6 @@ class Mesh : public std::enable_shared_from_this, public wmtk::utils::Merk friend class operations::EdgeSplit; friend class operations::EdgeOperationData; -#if defined(WMTK_ENABLE_HASH_UPDATE) - friend void operations::utils::update_vertex_operation_multimesh_map_hash( - Mesh& m, - const simplex::SimplexCollection& vertex_closed_star, - attribute::Accessor& parent_hash_accessor); - - friend void operations::utils::update_vertex_operation_hashes( - Mesh& m, - const Tuple& vertex, - attribute::Accessor& hash_accessor); -#endif int64_t top_cell_dimension() const; @@ -277,16 +266,6 @@ class Mesh : public std::enable_shared_from_this, public wmtk::utils::Merk const attribute::Accessor get_flag_accessor(PrimitiveType type) const; const attribute::Accessor get_const_flag_accessor(PrimitiveType type) const; -#if defined(WMTK_ENABLE_HASH_UPDATE) - const attribute::Accessor get_cell_hash_accessor() const; - const attribute::Accessor get_const_cell_hash_accessor() const; - - - int64_t get_cell_hash(int64_t cell_index, const attribute::Accessor& hash_accessor) - const; - // utility function for getting a cell's hash - slow because it creates a new accessor - int64_t get_cell_hash_slow(int64_t cell_index) const; -#endif bool operator==(const Mesh& other) const; @@ -298,67 +277,6 @@ class Mesh : public std::enable_shared_from_this, public wmtk::utils::Merk protected: // member functions attribute::Accessor get_flag_accessor(PrimitiveType type); -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor get_cell_hash_accessor(); - - /** - * @brief update hash in given cell - * - * @param cell tuple in which the hash should be updated - * @param hash_accessor hash accessor - */ - void update_cell_hash(const Tuple& cell, attribute::Accessor& hash_accessor); - - /** - * @brief update hashes in given cells - * - * @param cells vector of tuples in which the hash should be updated - * @param hash_accessor hash accessor - */ - void update_cell_hashes( - const std::vector& cells, - attribute::Accessor& hash_accessor); - /** - * @brief same as `update_cell_hashes` but slow because it creates a new accessor - */ - /** - * @brief update hash in given cell - * - * @param cell tuple in which the hash should be updated - * @param hash_accessor hash accessor - */ - void update_cell_hash(const int64_t cell_index, attribute::Accessor& hash_accessor); - - /** - * @brief update hashes in given cells - * - * @param cells vector of tuples in which the hash should be updated - * @param hash_accessor hash accessor - */ - void update_cell_hashes( - const std::vector& cell_indices, - attribute::Accessor& hash_accessor); - - void update_cell_hashes_slow(const std::vector& cells); - - /** - * @brief return the same tuple but with updated hash - * - * This function should only be used in operations to create a valid return tuple in a known - * position. - * - * @param tuple tuple with potentially outdated hash - * @param hash_accessor hash accessor - * @return tuple with updated hash - */ - Tuple resurrect_tuple(const Tuple& tuple, const attribute::Accessor& hash_accessor) - const; - - /** - * @brief same as `resurrect_tuple` but slow because it creates a new accessor - */ - Tuple resurrect_tuple_slow(const Tuple& tuple) const; -#endif protected: @@ -495,11 +413,6 @@ class Mesh : public std::enable_shared_from_this, public wmtk::utils::Merk * @return false */ virtual bool is_valid(const Tuple& tuple) const; -#if defined(WMTK_ENABLE_HASH_UPDATE) - bool is_valid_with_hash(const Tuple& tuple) const; - bool is_valid_with_hash(const Tuple& tuple, const attribute::Accessor& hash_accessor) - const; -#endif // whether the tuple refers to a removed / invalid dart in the mesh bool is_removed(const Tuple& tuple) const; diff --git a/src/wmtk/PointMesh.cpp b/src/wmtk/PointMesh.cpp index a1d051e46c..6eadada074 100644 --- a/src/wmtk/PointMesh.cpp +++ b/src/wmtk/PointMesh.cpp @@ -3,11 +3,7 @@ namespace wmtk { Tuple PointMesh::vertex_tuple_from_id(int64_t id) const { -#if defined(WMTK_ENABLE_HASH_UPDATE) - return Tuple(-1, -1, -1, id, get_cell_hash_slow(id)); -#else return Tuple(-1, -1, -1, id); -#endif } PointMesh::PointMesh() diff --git a/src/wmtk/TetMesh.cpp b/src/wmtk/TetMesh.cpp index 62dc305d97..aaa118d11c 100644 --- a/src/wmtk/TetMesh.cpp +++ b/src/wmtk/TetMesh.cpp @@ -166,13 +166,7 @@ Tuple TetMesh::vertex_tuple_from_id(int64_t id) const if (lvid < 0 || leid < 0 || lfid < 0) throw std::runtime_error("vertex_tuple_from_id failed"); -#if defined(WMTK_ENABLE_HASH_UPDATE) - const attribute::Accessor hash_accessor = get_const_cell_hash_accessor(); - - Tuple v_tuple = Tuple(lvid, leid, lfid, t, get_cell_hash(t, hash_accessor)); -#else Tuple v_tuple = Tuple(lvid, leid, lfid, t); -#endif assert(is_ccw(v_tuple)); assert(is_valid(v_tuple)); return v_tuple; @@ -197,13 +191,7 @@ Tuple TetMesh::edge_tuple_from_id(int64_t id) const if (lvid < 0 || leid < 0 || lfid < 0) throw std::runtime_error("edge_tuple_from_id failed"); -#if defined(WMTK_ENABLE_HASH_UPDATE) - const attribute::Accessor hash_accessor = get_const_cell_hash_accessor(); - - Tuple e_tuple = Tuple(lvid, leid, lfid, t, get_cell_hash(t, hash_accessor)); -#else Tuple e_tuple = Tuple(lvid, leid, lfid, t); -#endif assert(is_ccw(e_tuple)); assert(is_valid(e_tuple)); return e_tuple; @@ -228,13 +216,7 @@ Tuple TetMesh::face_tuple_from_id(int64_t id) const if (lvid < 0 || leid < 0 || lfid < 0) throw std::runtime_error("face_tuple_from_id failed"); -#if defined(WMTK_ENABLE_HASH_UPDATE) - const attribute::Accessor hash_accessor = get_const_cell_hash_accessor(); - - Tuple f_tuple = Tuple(lvid, leid, lfid, t, get_cell_hash(t, hash_accessor)); -#else Tuple f_tuple = Tuple(lvid, leid, lfid, t); -#endif assert(is_ccw(f_tuple)); assert(is_valid(f_tuple)); return f_tuple; @@ -246,13 +228,7 @@ Tuple TetMesh::tet_tuple_from_id(int64_t id) const const auto [nlvid, leid, lfid] = autogen::tet_mesh::auto_3d_table_complete_vertex[lvid]; assert(lvid == nlvid); -#if defined(WMTK_ENABLE_HASH_UPDATE) - const attribute::Accessor hash_accessor = get_const_cell_hash_accessor(); - - Tuple t_tuple = Tuple(lvid, leid, lfid, id, get_cell_hash(id, hash_accessor)); -#else Tuple t_tuple = Tuple(lvid, leid, lfid, id); -#endif assert(is_ccw(t_tuple)); assert(is_valid(t_tuple)); return t_tuple; @@ -337,11 +313,7 @@ Tuple TetMesh::switch_tuple(const Tuple& tuple, PrimitiveType type) const assert(leid_new != -1); assert(lfid_new != -1); -#if defined(WMTK_ENABLE_HASH_UPDATE) - const Tuple res(lvid_new, leid_new, lfid_new, gcid_new, get_cell_hash_slow(gcid_new)); -#else const Tuple res(lvid_new, leid_new, lfid_new, gcid_new); -#endif assert(is_valid(res)); return res; } @@ -579,27 +551,13 @@ Tuple TetMesh::tuple_from_global_ids(int64_t tid, int64_t fid, int64_t eid, int6 assert(leid != -1); assert(lfid != -1); -#if defined(WMTK_ENABLE_HASH_UPDATE) - return Tuple(lvid, leid, lfid, tid, get_cell_hash_slow(tid)); -#else return Tuple(lvid, leid, lfid, tid); -#endif } std::vector TetMesh::orient_vertices(const Tuple& tuple) const { int64_t cid = tuple.m_global_cid; -#if defined(WMTK_ENABLE_HASH_UPDATE) - auto hash = get_cell_hash_slow(cid); - - return { - Tuple(0, 0, 2, cid, hash), - Tuple(1, 0, 3, cid, hash), - Tuple(2, 1, 1, cid, hash), - Tuple(3, 2, 2, cid, hash)}; -#else return {Tuple(0, 0, 2, cid), Tuple(1, 0, 3, cid), Tuple(2, 1, 1, cid), Tuple(3, 2, 2, cid)}; -#endif } diff --git a/src/wmtk/TetMeshOperationExecutor.cpp b/src/wmtk/TetMeshOperationExecutor.cpp index d164780416..377eb1cd21 100644 --- a/src/wmtk/TetMeshOperationExecutor.cpp +++ b/src/wmtk/TetMeshOperationExecutor.cpp @@ -91,16 +91,9 @@ TetMesh::TetMeshOperationExecutor::get_incident_tets_and_faces(Tuple t) // constructor -#if defined(WMTK_ENABLE_HASH_UPDATE) -TetMesh::TetMeshOperationExecutor::TetMeshOperationExecutor( - TetMesh& m, - const Tuple& operating_tuple, - attribute::Accessor& hash_acc) -#else TetMesh::TetMeshOperationExecutor::TetMeshOperationExecutor( TetMesh& m, const Tuple& operating_tuple) -#endif : flag_accessors{{m.get_flag_accessor(PrimitiveType::Vertex), m.get_flag_accessor(PrimitiveType::Edge), m.get_flag_accessor(PrimitiveType::Triangle), m.get_flag_accessor(PrimitiveType::Tetrahedron)}} , tt_accessor(m.create_accessor(m.m_tt_handle)) , tf_accessor(m.create_accessor(m.m_tf_handle)) @@ -109,9 +102,6 @@ TetMesh::TetMeshOperationExecutor::TetMeshOperationExecutor( , vt_accessor(m.create_accessor(m.m_vt_handle)) , et_accessor(m.create_accessor(m.m_et_handle)) , ft_accessor(m.create_accessor(m.m_ft_handle)) -#if defined(WMTK_ENABLE_HASH_UPDATE) - , hash_accessor(hash_acc) -#endif , m_mesh(m) { m_operating_tuple = operating_tuple; @@ -150,9 +140,6 @@ TetMesh::TetMeshOperationExecutor::TetMeshOperationExecutor( faces.reserve(hash_update_region.simplex_vector().size() * 15); for (const simplex::Simplex& t : hash_update_region.simplex_vector()) { -#if defined(WMTK_ENABLE_HASH_UPDATE) - cell_ids_to_update_hash.push_back(m_mesh.id(t)); -#endif faces.add(wmtk::simplex::faces(m, t, false)); faces.add(t); @@ -191,10 +178,6 @@ void TetMesh::TetMeshOperationExecutor::delete_simplices() void TetMesh::TetMeshOperationExecutor::update_cell_hash() { -#if defined(WMTK_ENABLE_HASH_UPDATE) - - m_mesh.update_cell_hashes(cell_ids_to_update_hash, hash_accessor); -#endif } const std::array, 4> @@ -753,14 +736,8 @@ void TetMesh::TetMeshOperationExecutor::split_edge() assert(return_local_vid == utils::TupleInspector::local_vid(m_operating_tuple)); assert(return_local_eid == utils::TupleInspector::local_eid(m_operating_tuple)); assert(return_local_fid == utils::TupleInspector::local_fid(m_operating_tuple)); -#if defined(WMTK_ENABLE_HASH_UPDATE) - const int64_t return_tet_hash = hash_accessor.index_access().scalar_attribute(return_tid); - m_output_tuple = - Tuple(return_local_vid, return_local_eid, return_local_fid, return_tid, return_tet_hash); -#else m_output_tuple = Tuple(return_local_vid, return_local_eid, return_local_fid, return_tid); -#endif assert(m_split_new_vid == m_mesh.id(simplex::Simplex::vertex(m_mesh, m_output_tuple))); assert(m_split_new_spine_eids[1] == m_mesh.id(simplex::Simplex::edge(m_mesh, m_output_tuple))); @@ -1077,15 +1054,8 @@ void TetMesh::TetMeshOperationExecutor::collapse_edge() assert(return_local_fid > -1); assert(return_local_eid > -1); assert(return_local_vid > -1); -#if defined(WMTK_ENABLE_HASH_UPDATE) - const int64_t return_tet_hash = hash_accessor.index_access().scalar_attribute(return_tid); - - m_output_tuple = - Tuple(return_local_vid, return_local_eid, return_local_fid, return_tid, return_tet_hash); -#else m_output_tuple = Tuple(return_local_vid, return_local_eid, return_local_fid, return_tid); -#endif assert(m_mesh.id_vertex(m_output_tuple) == v1); } diff --git a/src/wmtk/TetMeshOperationExecutor.hpp b/src/wmtk/TetMeshOperationExecutor.hpp index a4550e551f..ae92cf532e 100644 --- a/src/wmtk/TetMeshOperationExecutor.hpp +++ b/src/wmtk/TetMeshOperationExecutor.hpp @@ -7,11 +7,7 @@ namespace wmtk { class TetMesh::TetMeshOperationExecutor : public operations::tet_mesh::EdgeOperationData { public: -#if defined(WMTK_ENABLE_HASH_UPDATE) - TetMeshOperationExecutor(TetMesh& m, const Tuple& operating_tuple, attribute::Accessor& hash_acc); -#else TetMeshOperationExecutor(TetMesh& m, const Tuple& operating_tuple); -#endif void delete_simplices(); void update_cell_hash(); @@ -23,9 +19,6 @@ class TetMesh::TetMeshOperationExecutor : public operations::tet_mesh::EdgeOpera attribute::Accessor vt_accessor; attribute::Accessor et_accessor; attribute::Accessor ft_accessor; -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor& hash_accessor; -#endif /** diff --git a/src/wmtk/TriMesh.cpp b/src/wmtk/TriMesh.cpp index eec7026825..f37a8d33e2 100644 --- a/src/wmtk/TriMesh.cpp +++ b/src/wmtk/TriMesh.cpp @@ -150,18 +150,7 @@ Tuple TriMesh::switch_tuple(const Tuple& tuple, PrimitiveType type) const assert(lvid_new != -1); assert(leid_new != -1); -#if defined(WMTK_ENABLE_HASH_UPDATE) - const attribute::Accessor hash_accessor = get_const_cell_hash_accessor(); - - const Tuple res( - lvid_new, - leid_new, - tuple.m_local_fid, - gcid_new, - get_cell_hash(gcid_new, hash_accessor)); -#else const Tuple res(lvid_new, leid_new, tuple.m_local_fid, gcid_new); -#endif assert(is_valid(res)); return res; } @@ -270,16 +259,7 @@ Tuple TriMesh::tuple_from_global_ids(int64_t fid, int64_t eid, int64_t vid) cons assert(lvid != -1); assert(leid != -1); -#if defined(WMTK_ENABLE_HASH_UPDATE) - return Tuple( - lvid, - leid, - -1, - fid, - get_cell_hash_slow(fid)); // TODO replace by function that takes hash accessor as parameter -#else return Tuple(lvid, leid, -1, fid); -#endif } Tuple TriMesh::tuple_from_id(const PrimitiveType type, const int64_t gid) const @@ -311,16 +291,7 @@ Tuple TriMesh::vertex_tuple_from_id(int64_t id) const if (fv(i) == id) { assert(autogen::tri_mesh::auto_2d_table_complete_vertex[i][0] == i); const int64_t leid = autogen::tri_mesh::auto_2d_table_complete_vertex[i][1]; -#if defined(WMTK_ENABLE_HASH_UPDATE) - Tuple v_tuple = Tuple( - i, - leid, - -1, - f, - get_cell_hash_slow(f)); // TODO replace by function that takes hash -#else Tuple v_tuple = Tuple(i, leid, -1, f); -#endif // accessor as parameter assert(is_ccw(v_tuple)); // is_ccw also checks for validity return v_tuple; @@ -341,12 +312,7 @@ Tuple TriMesh::edge_tuple_from_id(int64_t id) const const int64_t lvid = autogen::tri_mesh::auto_2d_table_complete_edge[i][0]; -#if defined(WMTK_ENABLE_HASH_UPDATE) - const attribute::Accessor hash_accessor = get_const_cell_hash_accessor(); - Tuple e_tuple = Tuple(lvid, i, -1, f, get_cell_hash(f, hash_accessor)); -#else Tuple e_tuple = Tuple(lvid, i, -1, f); -#endif assert(is_ccw(e_tuple)); assert(is_valid(e_tuple)); return e_tuple; @@ -359,20 +325,11 @@ Tuple TriMesh::edge_tuple_from_id(int64_t id) const Tuple TriMesh::face_tuple_from_id(int64_t id) const { -#if defined(WMTK_ENABLE_HASH_UPDATE) - Tuple f_tuple = Tuple( - autogen::tri_mesh::auto_2d_table_complete_vertex[0][0], - autogen::tri_mesh::auto_2d_table_complete_vertex[0][1], - -1, - id, - get_cell_hash_slow(id)); -#else Tuple f_tuple = Tuple( autogen::tri_mesh::auto_2d_table_complete_vertex[0][0], autogen::tri_mesh::auto_2d_table_complete_vertex[0][1], -1, id); -#endif assert(is_ccw(f_tuple)); assert(is_valid(f_tuple)); return f_tuple; @@ -582,13 +539,7 @@ std::vector>> TriMesh::connectivity_at std::vector TriMesh::orient_vertices(const Tuple& tuple) const { int64_t cid = tuple.m_global_cid; -#if defined(WMTK_ENABLE_HASH_UPDATE) - auto hash = get_cell_hash_slow(cid); - - return {Tuple(0, 2, -1, cid, hash), Tuple(1, 0, -1, cid, hash), Tuple(2, 1, -1, cid, hash)}; -#else return {Tuple(0, 2, -1, cid), Tuple(1, 0, -1, cid), Tuple(2, 1, -1, cid)}; -#endif } diff --git a/src/wmtk/TriMeshOperationExecutor.cpp b/src/wmtk/TriMeshOperationExecutor.cpp index f8e67428c6..da33affbf7 100644 --- a/src/wmtk/TriMeshOperationExecutor.cpp +++ b/src/wmtk/TriMeshOperationExecutor.cpp @@ -90,25 +90,15 @@ auto TriMesh::TriMeshOperationExecutor::get_incident_face_data(Tuple t) -> Incid } // constructor -#if defined(WMTK_ENABLE_HASH_UPDATE) -TriMesh::TriMeshOperationExecutor::TriMeshOperationExecutor( - TriMesh& m, - const Tuple& operating_tuple, - attribute::Accessor& hash_acc) -#else TriMesh::TriMeshOperationExecutor::TriMeshOperationExecutor( TriMesh& m, const Tuple& operating_tuple) -#endif : flag_accessors{{m.get_flag_accessor(PrimitiveType::Vertex), m.get_flag_accessor(PrimitiveType::Edge), m.get_flag_accessor(PrimitiveType::Triangle)}} , ff_accessor(m.create_accessor(m.m_ff_handle)) , fe_accessor(m.create_accessor(m.m_fe_handle)) , fv_accessor(m.create_accessor(m.m_fv_handle)) , vf_accessor(m.create_accessor(m.m_vf_handle)) , ef_accessor(m.create_accessor(m.m_ef_handle)) -#if defined(WMTK_ENABLE_HASH_UPDATE) - , hash_accessor(hash_acc) -#endif , m_mesh(m) { @@ -149,10 +139,6 @@ TriMesh::TriMeshOperationExecutor::TriMeshOperationExecutor( simplex::SimplexCollection faces(m_mesh); for (const simplex::Simplex& f : hash_update_region.simplex_vector(PrimitiveType::Triangle)) { -#if defined(WMTK_ENABLE_HASH_UPDATE) - - cell_ids_to_update_hash.push_back(m_mesh.id(f)); -#endif faces.add(wmtk::simplex::faces(m, f, false)); faces.add(f); @@ -195,9 +181,6 @@ void TriMesh::TriMeshOperationExecutor::delete_simplices() void TriMesh::TriMeshOperationExecutor::update_cell_hash() { -#if defined(WMTK_ENABLE_HASH_UPDATE) - m_mesh.update_cell_hashes(cell_ids_to_update_hash, hash_accessor); -#endif } const std::array, 3> diff --git a/src/wmtk/TriMeshOperationExecutor.hpp b/src/wmtk/TriMeshOperationExecutor.hpp index cb361d6878..edc73b6595 100644 --- a/src/wmtk/TriMeshOperationExecutor.hpp +++ b/src/wmtk/TriMeshOperationExecutor.hpp @@ -9,11 +9,7 @@ namespace wmtk { class TriMesh::TriMeshOperationExecutor : public operations::tri_mesh::EdgeOperationData { public: -#if defined(WMTK_ENABLE_HASH_UPDATE) - TriMeshOperationExecutor(TriMesh& m, const Tuple& operating_tuple, attribute::Accessor& hash_acc); -#else TriMeshOperationExecutor(TriMesh& m, const Tuple& operating_tuple); -#endif void delete_simplices(); void update_cell_hash(); @@ -23,9 +19,6 @@ class TriMesh::TriMeshOperationExecutor : public operations::tri_mesh::EdgeOpera attribute::Accessor fv_accessor; attribute::Accessor vf_accessor; attribute::Accessor ef_accessor; -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor& hash_accessor; -#endif /** * @brief jump to the next edge diff --git a/src/wmtk/Tuple.hpp b/src/wmtk/Tuple.hpp index f030a317fa..9f94f6eedc 100644 --- a/src/wmtk/Tuple.hpp +++ b/src/wmtk/Tuple.hpp @@ -42,7 +42,6 @@ class Tuple int8_t m_local_vid = -1; int8_t m_local_eid = -1; int8_t m_local_fid = -1; - int8_t m_hash = -1; public: friend class Mesh; @@ -61,10 +60,7 @@ class Tuple // friend Mesh::is_ccw(const Tuple& tuple) const; // friend Mesh::switch_tuple(const Tuple& tuple, const PrimitiveType& type) const; - Tuple(int8_t local_vid, int8_t local_eid, int8_t local_fid, int64_t global_cid, int8_t hash -#if !defined(WMTK_ENABLE_HASH_UPDATE) - = -1 -#endif + Tuple(int8_t local_vid, int8_t local_eid, int8_t local_fid, int64_t global_cid ); //#if !defined(WMTK_ENABLE_HASH_UPDATE) // Tuple(int8_t local_vid, int8_t local_eid, int8_t local_fid, int64_t global_cid); @@ -90,9 +86,6 @@ class Tuple /// Checks if a tuple is "null". This merely implies the global index is -1 bool is_null() const; -#if defined(WMTK_ENABLE_HASH_UPDATE) - Tuple with_updated_hash(int64_t new_hash) const; -#endif private: int8_t local_vid() const; @@ -103,13 +96,11 @@ inline Tuple::Tuple( int8_t local_vid, int8_t local_eid, int8_t local_fid, - int64_t global_cid, - int8_t hash) + int64_t global_cid) : m_global_cid(global_cid) , m_local_vid(local_vid) , m_local_eid(local_eid) , m_local_fid(local_fid) - , m_hash(hash) {} //#if !defined(WMTK_ENABLE_HASH_UPDATE) //inline Tuple::Tuple( diff --git a/src/wmtk/Tuple.hxx b/src/wmtk/Tuple.hxx index 395d460b02..1acdac8b5f 100644 --- a/src/wmtk/Tuple.hxx +++ b/src/wmtk/Tuple.hxx @@ -21,25 +21,15 @@ inline bool Tuple::operator!=(const wmtk::Tuple& t) const } inline bool Tuple::operator==(const wmtk::Tuple& t) const { -#if defined(WMTK_ENABLE_HASH_UPDATE) - return std::tie(m_local_vid, m_local_eid, m_local_fid, m_global_cid, m_hash) == - std::tie(t.m_local_vid, t.m_local_eid, t.m_local_fid, t.m_global_cid, t.m_hash); -#else return std::tie(m_local_vid, m_local_eid, m_local_fid, m_global_cid) == std::tie(t.m_local_vid, t.m_local_eid, t.m_local_fid, t.m_global_cid); -#endif } inline bool Tuple::operator<(const wmtk::Tuple& t) const { -#if defined(WMTK_ENABLE_HASH_UPDATE) - return std::tie(m_local_vid, m_local_eid, m_local_fid, m_global_cid, m_hash) < - std::tie(t.m_local_vid, t.m_local_eid, t.m_local_fid, t.m_global_cid, t.m_hash); -#else return std::tie(m_local_vid, m_local_eid, m_local_fid, m_global_cid) < std::tie(t.m_local_vid, t.m_local_eid, t.m_local_fid, t.m_global_cid); -#endif } inline bool Tuple::same_ids(const wmtk::Tuple& t) const { @@ -52,12 +42,6 @@ inline bool Tuple::is_null() const return m_global_cid == -1; } -#if defined(WMTK_ENABLE_HASH_UPDATE) -inline Tuple Tuple::with_updated_hash(int64_t new_hash) const -{ - return Tuple(m_local_vid, m_local_eid, m_local_fid, m_global_cid, new_hash); -} -#endif inline int8_t Tuple::local_vid() const { diff --git a/src/wmtk/autogen/edge_mesh/local_switch_tuple.hxx b/src/wmtk/autogen/edge_mesh/local_switch_tuple.hxx index ce419b5705..a3a8ece6d3 100644 --- a/src/wmtk/autogen/edge_mesh/local_switch_tuple.hxx +++ b/src/wmtk/autogen/edge_mesh/local_switch_tuple.hxx @@ -8,15 +8,13 @@ inline Tuple local_switch_tuple(const Tuple& tuple, PrimitiveType pt) { using namespace utils; const int64_t global_cid = TupleInspector::global_cid(tuple); - const int64_t hash = TupleInspector::hash(tuple); switch (pt) { case PrimitiveType::Vertex: return Tuple( 1 - TupleInspector::local_vid(tuple), TupleInspector::local_eid(tuple), TupleInspector::local_fid(tuple), - global_cid, - hash); + global_cid); case PrimitiveType::Edge: case PrimitiveType::Triangle: diff --git a/src/wmtk/autogen/tet_mesh/local_switch_tuple.hxx b/src/wmtk/autogen/tet_mesh/local_switch_tuple.hxx index e4c74f0fc3..625cb1b60b 100644 --- a/src/wmtk/autogen/tet_mesh/local_switch_tuple.hxx +++ b/src/wmtk/autogen/tet_mesh/local_switch_tuple.hxx @@ -14,30 +14,26 @@ inline Tuple local_switch_tuple(const Tuple& tuple, PrimitiveType pt) const int64_t global_cid = TupleInspector::global_cid(tuple); - const int64_t hash = TupleInspector::hash(tuple); switch (pt) { case PrimitiveType::Vertex: return Tuple( auto_3d_table_vertex[offset][0], auto_3d_table_vertex[offset][1], auto_3d_table_vertex[offset][2], - global_cid, - hash); + global_cid); case PrimitiveType::Edge: return Tuple( auto_3d_table_edge[offset][0], auto_3d_table_edge[offset][1], auto_3d_table_edge[offset][2], - global_cid, - hash); + global_cid); case PrimitiveType::Triangle: return Tuple( auto_3d_table_face[offset][0], auto_3d_table_face[offset][1], auto_3d_table_face[offset][2], - global_cid, - hash); + global_cid); case PrimitiveType::Tetrahedron: default: assert(false); // "Tuple switch: Invalid primitive type" diff --git a/src/wmtk/autogen/tri_mesh/local_switch_tuple.hxx b/src/wmtk/autogen/tri_mesh/local_switch_tuple.hxx index e70a8a505a..3cd3a5c340 100644 --- a/src/wmtk/autogen/tri_mesh/local_switch_tuple.hxx +++ b/src/wmtk/autogen/tri_mesh/local_switch_tuple.hxx @@ -17,16 +17,14 @@ inline Tuple local_switch_tuple(const Tuple& tuple, PrimitiveType pt) auto_2d_table_vertex[offset][0], auto_2d_table_vertex[offset][1], TupleInspector::local_fid(tuple), - TupleInspector::global_cid(tuple), - TupleInspector::hash(tuple)); + TupleInspector::global_cid(tuple)); case PrimitiveType::Edge: return Tuple( auto_2d_table_edge[offset][0], auto_2d_table_edge[offset][1], TupleInspector::local_fid(tuple), - TupleInspector::global_cid(tuple), - TupleInspector::hash(tuple)); + TupleInspector::global_cid(tuple)); case PrimitiveType::Triangle: case PrimitiveType::Tetrahedron: diff --git a/src/wmtk/multimesh/MultiMeshManager.cpp b/src/wmtk/multimesh/MultiMeshManager.cpp index 3f2801974c..adde58c742 100644 --- a/src/wmtk/multimesh/MultiMeshManager.cpp +++ b/src/wmtk/multimesh/MultiMeshManager.cpp @@ -54,10 +54,6 @@ Tuple MultiMeshManager::map_tuple_between_meshes( return Tuple(); // return null tuple } -#if defined(WMTK_ENABLE_HASH_UPDATE) - source_mesh_base_tuple = source_mesh.resurrect_tuple_slow(source_mesh_base_tuple); - target_mesh_base_tuple = target_mesh.resurrect_tuple_slow(target_mesh_base_tuple); -#endif // assert(source_mesh.is_valid(source_mesh_base_tuple)); // assert(target_mesh.is_valid(target_mesh_base_tuple)); @@ -780,9 +776,6 @@ void MultiMeshManager::update_map_tuple_hashes( const PrimitiveType parent_primitive_type = my_mesh.top_simplex_type(); -#if defined(WMTK_ENABLE_HASH_UPDATE) - auto parent_hash_accessor = my_mesh.get_const_cell_hash_accessor(); -#endif auto parent_flag_accessor = my_mesh.get_const_flag_accessor(primitive_type); // auto& update_tuple = [&](const auto& flag_accessor, Tuple& t) -> bool { // if(acc.index_access(). @@ -805,9 +798,6 @@ void MultiMeshManager::update_map_tuple_hashes( auto& [parent_to_child_accessor, child_to_parent_accessor] = maps; auto child_flag_accessor = child_mesh.get_const_flag_accessor(primitive_type); -#if defined(WMTK_ENABLE_HASH_UPDATE) - auto child_hash_accessor = child_mesh.get_const_cell_hash_accessor(); -#endif std::vector is_gid_visited(my_mesh.capacity(primitive_type), false); @@ -835,34 +825,13 @@ void MultiMeshManager::update_map_tuple_hashes( // If the parent tuple is valid, it means this parent-child pair has already been // handled, so we can skip it -#if defined(WMTK_ENABLE_HASH_UPDATE) // optimization if hash is available - if (my_mesh.is_valid_with_hash(parent_tuple)) { - continue; - } -#endif // If the parent tuple is invalid then there was no map so we can try the next cell if (parent_tuple.is_null()) { continue; } -#if defined(WMTK_ENABLE_HASH_UPDATE) - // navigate parent_original_sharer -> parent_tuple - // then take parent_new_sharer -> parent_tuple - parent_tuple = my_mesh.resurrect_tuple(parent_tuple, parent_hash_accessor); - child_tuple = child_mesh.resurrect_tuple(child_tuple, child_hash_accessor); -#endif // check if the map is handled in the ear case -#if defined(WMTK_ENABLE_HASH_UPDATE) // optimization if hash is available - auto child_to_parent_data = - child_to_parent_accessor.const_vector_attribute(child_tuple); - Tuple parent_tuple_from_child_map = wmtk::multimesh::utils::vector_to_tuple( - child_to_parent_data.tail()); - if (my_mesh.is_valid_with_hash( - parent_tuple_from_child_map)) { // optimization if hash is available - continue; - } -#endif // if the child simplex is deleted then we can skip it const bool child_exists = !child_mesh.is_removed(child_tuple); if (!child_exists) { @@ -870,11 +839,6 @@ void MultiMeshManager::update_map_tuple_hashes( continue; } std::vector equivalent_parent_tuples_good_hash = equivalent_parent_tuples; -#if defined(WMTK_ENABLE_HASH_UPDATE) - for (Tuple& t : equivalent_parent_tuples_good_hash) { - t = my_mesh.resurrect_tuple(t, parent_hash_accessor); - } -#endif // Find a valid representation of this simplex representation of the original tupl Tuple old_tuple; @@ -916,9 +880,6 @@ void MultiMeshManager::update_map_tuple_hashes( my_mesh.top_simplex_type(), new_parent_tuple_shared, my_mesh.top_simplex_type()); -#if defined(WMTK_ENABLE_HASH_UPDATE) - parent_tuple = my_mesh.resurrect_tuple(parent_tuple, parent_hash_accessor); -#endif assert(my_mesh.is_valid(parent_tuple)); assert(child_mesh.is_valid(child_tuple)); @@ -1000,21 +961,11 @@ std::optional MultiMeshManager::find_valid_tuple_from_split( const Tuple& old_cid_tuple = old_tuple_opt.value(); for (const int64_t new_cid : new_cids) { -#if defined(WMTK_ENABLE_HASH_UPDATE) - // try seeing if we get the right gid by shoving in the new face id - Tuple tuple( - old_cid_tuple.m_local_vid, - old_cid_tuple.m_local_eid, - old_cid_tuple.m_local_fid, - new_cid, - my_mesh.get_cell_hash_slow(new_cid)); -#else Tuple tuple( old_cid_tuple.m_local_vid, old_cid_tuple.m_local_eid, old_cid_tuple.m_local_fid, new_cid); -#endif if (my_mesh.is_valid(tuple) && !my_mesh.is_removed(tuple) && @@ -1089,100 +1040,7 @@ int64_t MultiMeshManager::parent_local_fid( } -#if defined(WMTK_ENABLE_HASH_UPDATE) -void MultiMeshManager::update_vertex_operation_hashes_internal( - Mesh& m, - const Tuple& vertex, - wmtk::attribute::Accessor& hash_accessor) -{ - const PrimitiveType pt = m.top_simplex_type(); - const simplex::SimplexCollection star = - simplex::closed_star(m, simplex::Simplex::vertex(m, vertex)); - std::vector tuples_to_update; - switch (pt) { - case PrimitiveType::Vertex: { - const auto star_vertices = star.simplex_vector(PrimitiveType::Vertex); - tuples_to_update.reserve(star_vertices.size()); - for (const simplex::Simplex& s : star_vertices) { - tuples_to_update.emplace_back(s.tuple()); - } - break; - } - case PrimitiveType::Edge: { - const auto star_edges = star.simplex_vector(PrimitiveType::Edge); - tuples_to_update.reserve(star_edges.size()); - for (const simplex::Simplex& s : star_edges) { - tuples_to_update.emplace_back(s.tuple()); - } - break; - } - case PrimitiveType::Triangle: { - const auto star_faces = star.simplex_vector(PrimitiveType::Triangle); - tuples_to_update.reserve(star_faces.size()); - for (const simplex::Simplex& s : star_faces) { - tuples_to_update.emplace_back(s.tuple()); - } - break; - } - case PrimitiveType::Tetrahedron: { - const auto star_tets = star.simplex_vector(PrimitiveType::Tetrahedron); - tuples_to_update.reserve(star_tets.size()); - for (const simplex::Simplex& s : star_tets) { - tuples_to_update.emplace_back(s.tuple()); - } - break; - } - default: assert(false); // "Invalid case" - } - - -#if defined(WMTK_ENABLE_HASH_UPDATE) - m.update_cell_hashes(tuples_to_update, hash_accessor); - - // need to get a star with new hash, otherwise cannot get_simplices() - auto vertex_new_hash = m.resurrect_tuple(vertex, hash_accessor); - const simplex::SimplexCollection star_new_hash = - simplex::closed_star(m, simplex::Simplex::vertex(m, vertex_new_hash)); - update_vertex_operation_multimesh_map_hash_internal(m, star_new_hash, hash_accessor); -#endif -} -#endif - -#if defined(WMTK_ENABLE_HASH_UPDATE) -void MultiMeshManager::update_vertex_operation_multimesh_map_hash_internal( - Mesh& m, - const simplex::SimplexCollection& vertex_closed_star, - wmtk::attribute::Accessor& parent_hash_accessor) -{ - auto& mm_manager = m.m_multi_mesh_manager; - - for (auto& child_data : mm_manager.children()) { - auto& child_mesh = *child_data.mesh; - auto child_mesh_pt = child_mesh.top_simplex_type(); - auto maps = mm_manager.get_map_accessors(m, child_data); - auto& [parent_to_child_accessor, child_to_parent_accessor] = maps; - - const auto parent_simplices_to_update = vertex_closed_star.simplex_vector(child_mesh_pt); - for (auto& s : parent_simplices_to_update) { - auto s_tuple = s.tuple(); - auto [parent_tuple, child_tuple] = - wmtk::multimesh::utils::read_tuple_map_attribute(parent_to_child_accessor, s_tuple); - - if (parent_tuple.is_null()) continue; - - // resurrect the parent tuple - parent_tuple = m.resurrect_tuple(parent_tuple, parent_hash_accessor); - // write back to map - wmtk::multimesh::utils::symmetric_write_tuple_map_attributes( - parent_to_child_accessor, - child_to_parent_accessor, - parent_tuple, - child_tuple); - } - } -} -#endif // remove after bug fix void MultiMeshManager::check_map_valid(const Mesh& my_mesh) const diff --git a/src/wmtk/multimesh/MultiMeshManager.hpp b/src/wmtk/multimesh/MultiMeshManager.hpp index de515e348b..82127db201 100644 --- a/src/wmtk/multimesh/MultiMeshManager.hpp +++ b/src/wmtk/multimesh/MultiMeshManager.hpp @@ -6,7 +6,6 @@ #include // included to make a friend as this requires IDs #include -#include #include // debug function that reads into this structure @@ -63,12 +62,6 @@ class MultiMeshManager : public wmtk::utils::MerkleTreeInteriorNode friend class multimesh::MultiMeshSimplexVisitorExecutor; friend class operations::utils::UpdateEdgeOperationMultiMeshMapFunctor; -#if defined(WMTK_ENABLE_HASH_UPDATE) - friend void operations::utils::update_vertex_operation_multimesh_map_hash( - Mesh& m, - const simplex::SimplexCollection& vertex_closed_star, - wmtk::attribute::Accessor& parent_hash_accessor); -#endif template friend class multimesh::MultiMeshVisitor; template @@ -548,16 +541,6 @@ class MultiMeshManager : public wmtk::utils::MerkleTreeInteriorNode * @param vertex operating vertex tuple * @param hash_accessor hash accessor of m */ -#if defined(WMTK_ENABLE_HASH_UPDATE) - static void update_vertex_operation_hashes_internal( - Mesh& m, - const Tuple& vertex, - wmtk::attribute::Accessor& hash_accessor); - static void update_vertex_operation_multimesh_map_hash_internal( - Mesh& m, - const simplex::SimplexCollection& vertex_closed_star, - wmtk::attribute::Accessor& parent_hash_accessor); -#endif public: // remove after bug fix diff --git a/src/wmtk/operations/AndOperationSequence.cpp b/src/wmtk/operations/AndOperationSequence.cpp index d400a09af0..a6b3522cd6 100644 --- a/src/wmtk/operations/AndOperationSequence.cpp +++ b/src/wmtk/operations/AndOperationSequence.cpp @@ -23,12 +23,7 @@ std::vector AndOperationSequence::execute_operations( auto& o = m_operations[i]; // assert(queue.size() == 1); -#if defined(WMTK_ENABLE_HASH_UPDATE) - auto tuple_resurrected = resurrect_tuple(queue.front().tuple()); - -#else auto tuple_resurrected = queue.front().tuple(); -#endif const auto new_queue = (*o)(simplex::Simplex(mesh(), o->primitive_type(), tuple_resurrected)); diff --git a/src/wmtk/operations/Operation.cpp b/src/wmtk/operations/Operation.cpp index ee5d3da284..157c14caf0 100644 --- a/src/wmtk/operations/Operation.cpp +++ b/src/wmtk/operations/Operation.cpp @@ -63,12 +63,7 @@ std::vector Operation::operator()(const simplex::Simplex& simp return {}; } -#if defined(WMTK_ENABLE_HASH_UPDATE) - const auto simplex_resurrect = - simplex::Simplex(mesh(), simplex.primitive_type(), resurrect_tuple(simplex.tuple())); -#else const auto simplex_resurrect = simplex; -#endif auto scope = mesh().create_scope(); assert(simplex.primitive_type() == primitive_type()); @@ -99,12 +94,7 @@ bool Operation::before(const simplex::Simplex& simplex) const return false; } -#if defined(WMTK_ENABLE_HASH_UPDATE) - const auto simplex_resurrect = - simplex::Simplex(mesh(), simplex.primitive_type(), resurrect_tuple(simplex.tuple())); -#else const auto simplex_resurrect = simplex; -#endif // map simplex to the invariant mesh const Mesh& invariant_mesh = m_invariants.mesh(); @@ -171,22 +161,6 @@ void Operation::apply_attribute_transfer(const std::vector& di } } -#if defined(WMTK_ENABLE_HASH_UPDATE) -Tuple Operation::resurrect_tuple(const Tuple& tuple) const -{ - return mesh().resurrect_tuple(tuple, hash_accessor()); -} - -attribute::Accessor Operation::hash_accessor() -{ - return m_mesh.get_cell_hash_accessor(); -} - -const attribute::Accessor Operation::hash_accessor() const -{ - return m_mesh.get_const_cell_hash_accessor(); -} -#endif void Operation::reserve_enough_simplices() diff --git a/src/wmtk/operations/Operation.hpp b/src/wmtk/operations/Operation.hpp index 8602c17a29..1a8725612a 100644 --- a/src/wmtk/operations/Operation.hpp +++ b/src/wmtk/operations/Operation.hpp @@ -84,16 +84,6 @@ class Operation const std::vector& unmods, const std::vector& mods) const; -#if defined(WMTK_ENABLE_HASH_UPDATE) - /// @brief utility for subclasses - /// @param tuple - Tuple resurrect_tuple(const Tuple& tuple) const; - - /// @brief utility for subclasses - attribute::Accessor hash_accessor(); - /// @brief utility for subclasses - const attribute::Accessor hash_accessor() const; -#endif void apply_attribute_transfer(const std::vector& direct_mods); diff --git a/src/wmtk/operations/OperationSequence.cpp b/src/wmtk/operations/OperationSequence.cpp index 1add222802..cba805113f 100644 --- a/src/wmtk/operations/OperationSequence.cpp +++ b/src/wmtk/operations/OperationSequence.cpp @@ -22,12 +22,7 @@ std::vector OperationSequence::operator()(const simplex::Simpl return {}; } -#if defined(WMTK_ENABLE_HASH_UPDATE) - const auto simplex_resurrect = - simplex::Simplex(mesh(), simplex.primitive_type(), resurrect_tuple(simplex.tuple())); -#else const auto simplex_resurrect = simplex; -#endif auto mods = execute_operations(simplex_resurrect); if (!mods.empty()) { // success should be marked here diff --git a/src/wmtk/operations/composite/TetEdgeSwap.cpp b/src/wmtk/operations/composite/TetEdgeSwap.cpp index 40fe32124c..0f9b4bfaf4 100644 --- a/src/wmtk/operations/composite/TetEdgeSwap.cpp +++ b/src/wmtk/operations/composite/TetEdgeSwap.cpp @@ -142,22 +142,14 @@ std::vector TetEdgeSwap::execute(const simplex::Simplex& simpl if (able_to_return_edges) { for (int64_t i = 0; i < edges_generated_by_swap.size(); ++i) { edges_generated_by_swap[i] = -#if defined(WMTK_ENABLE_HASH_UPDATE) - simplex::Simplex::edge(mesh(), resurrect_tuple(edges_generated_by_swap[i].tuple())); -#else simplex::Simplex::edge(mesh(), edges_generated_by_swap[i].tuple()); -#endif } return edges_generated_by_swap; } else { for (int64_t i = 0; i < faces_generated_by_swap.size(); ++i) { faces_generated_by_swap[i] = -#if defined(WMTK_ENABLE_HASH_UPDATE) - simplex::Simplex::face(mesh(), resurrect_tuple(faces_generated_by_swap[i].tuple())); -#else simplex::Simplex::face(mesh(), faces_generated_by_swap[i].tuple()); -#endif } return faces_generated_by_swap; diff --git a/src/wmtk/operations/composite/TetFaceSwap.cpp b/src/wmtk/operations/composite/TetFaceSwap.cpp index a1a86babf2..57fbd416c5 100644 --- a/src/wmtk/operations/composite/TetFaceSwap.cpp +++ b/src/wmtk/operations/composite/TetFaceSwap.cpp @@ -51,22 +51,14 @@ std::vector TetFaceSwap::execute(const simplex::Simplex& simpl // prepare the simplex for the second collapse const auto edge_input_for_second_collapse = -#if defined(WMTK_ENABLE_HASH_UPDATE) - simplex::Simplex::edge(mesh(), resurrect_tuple(edge_tuple_input_for_second_collapse)); -#else simplex::Simplex::edge(mesh(), edge_tuple_input_for_second_collapse); -#endif // second collapse, drag the interior vertex on the ground to the "peak" const auto collapse_simplicies_second = m_collapse(edge_input_for_second_collapse); if (collapse_simplicies_second.empty()) return {}; assert(collapse_simplicies_second.size() == 1); -#if defined(WMTK_ENABLE_HASH_UPDATE) - return {simplex::Simplex::edge(mesh(), resurrect_tuple(edge_tuple_for_return))}; -#else return {simplex::Simplex::edge(mesh(), edge_tuple_for_return)}; -#endif } std::vector TetFaceSwap::unmodified_primitives( diff --git a/src/wmtk/operations/utils/CMakeLists.txt b/src/wmtk/operations/utils/CMakeLists.txt index 994e9ecc0e..c47a3ae9fc 100644 --- a/src/wmtk/operations/utils/CMakeLists.txt +++ b/src/wmtk/operations/utils/CMakeLists.txt @@ -9,8 +9,6 @@ set(SRC_FILES multi_mesh_edge_collapse.hpp multi_mesh_edge_split.cpp multi_mesh_edge_split.hpp - UpdateVertexMultiMeshMapHash.hpp - UpdateVertexMultiMeshMapHash.cpp VertexLaplacianSmooth.hpp diff --git a/src/wmtk/operations/utils/MultiMeshEdgeCollapseFunctor.cpp b/src/wmtk/operations/utils/MultiMeshEdgeCollapseFunctor.cpp index f510898019..0dc3baf3c8 100644 --- a/src/wmtk/operations/utils/MultiMeshEdgeCollapseFunctor.cpp +++ b/src/wmtk/operations/utils/MultiMeshEdgeCollapseFunctor.cpp @@ -16,12 +16,7 @@ edge_mesh::EdgeOperationData MultiMeshEdgeCollapseFunctor::operator()( EdgeMesh& m, const simplex::Simplex& s) const { -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - EdgeMesh::EdgeMeshOperationExecutor exec(m, s.tuple(), hash_accessor); -#else EdgeMesh::EdgeMeshOperationExecutor exec(m, s.tuple()); -#endif exec.collapse_edge(); return exec; } @@ -29,12 +24,7 @@ tri_mesh::EdgeOperationData MultiMeshEdgeCollapseFunctor::operator()( TriMesh& m, const simplex::Simplex& s) const { -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - TriMesh::TriMeshOperationExecutor exec(m, s.tuple(), hash_accessor); -#else TriMesh::TriMeshOperationExecutor exec(m, s.tuple()); -#endif exec.collapse_edge(); return exec; @@ -43,12 +33,7 @@ tet_mesh::EdgeOperationData MultiMeshEdgeCollapseFunctor::operator()( TetMesh& m, const simplex::Simplex& s) const { -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - TetMesh::TetMeshOperationExecutor exec(m, s.tuple(), hash_accessor); -#else TetMesh::TetMeshOperationExecutor exec(m, s.tuple()); -#endif exec.collapse_edge(); return exec; } diff --git a/src/wmtk/operations/utils/MultiMeshEdgeSplitFunctor.cpp b/src/wmtk/operations/utils/MultiMeshEdgeSplitFunctor.cpp index e680533041..d3bbee9e12 100644 --- a/src/wmtk/operations/utils/MultiMeshEdgeSplitFunctor.cpp +++ b/src/wmtk/operations/utils/MultiMeshEdgeSplitFunctor.cpp @@ -18,12 +18,7 @@ edge_mesh::EdgeOperationData MultiMeshEdgeSplitFunctor::operator()( EdgeMesh& m, const simplex::Simplex& s) const { -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - EdgeMesh::EdgeMeshOperationExecutor exec(m, s.tuple(), hash_accessor); -#else EdgeMesh::EdgeMeshOperationExecutor exec(m, s.tuple()); -#endif exec.split_edge(); return exec; } @@ -31,12 +26,7 @@ tri_mesh::EdgeOperationData MultiMeshEdgeSplitFunctor::operator()( TriMesh& m, const simplex::Simplex& s) const { -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - TriMesh::TriMeshOperationExecutor exec(m, s.tuple(), hash_accessor); -#else TriMesh::TriMeshOperationExecutor exec(m, s.tuple()); -#endif exec.split_edge(); for (const auto& id : exec.incident_face_datas()) { @@ -53,12 +43,7 @@ tet_mesh::EdgeOperationData MultiMeshEdgeSplitFunctor::operator()( TetMesh& m, const simplex::Simplex& s) const { -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - TetMesh::TetMeshOperationExecutor exec(m, s.tuple(), hash_accessor); -#else TetMesh::TetMeshOperationExecutor exec(m, s.tuple()); -#endif exec.split_edge(); return exec; } diff --git a/src/wmtk/operations/utils/UpdateEdgeOperationMultiMeshMapFunctor.cpp b/src/wmtk/operations/utils/UpdateEdgeOperationMultiMeshMapFunctor.cpp index f485b56609..be72b7bfe4 100644 --- a/src/wmtk/operations/utils/UpdateEdgeOperationMultiMeshMapFunctor.cpp +++ b/src/wmtk/operations/utils/UpdateEdgeOperationMultiMeshMapFunctor.cpp @@ -104,9 +104,6 @@ void UpdateEdgeOperationMultiMeshMapFunctor::update_ear_replacement( { const auto& parent_incident_datas = fmoe.incident_face_datas(); auto& parent_mmmanager = m.m_multi_mesh_manager; -#if defined(WMTK_ENABLE_HASH_UPDATE) - auto parent_hash_accessor = m.get_const_cell_hash_accessor(); -#endif const auto& parent_incident_vids = fmoe.incident_vids(); for (const auto& parent_data : parent_incident_datas) { @@ -121,9 +118,6 @@ void UpdateEdgeOperationMultiMeshMapFunctor::update_ear_replacement( const auto& child_mmmanager = child_ptr->m_multi_mesh_manager; int64_t child_id = child_mmmanager.child_id(); -#if defined(WMTK_ENABLE_HASH_UPDATE) - auto child_hash_accessor = child_ptr->get_const_cell_hash_accessor(); -#endif auto child_to_parent_handle = child_mmmanager.map_to_parent_handle; auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle; auto child_to_parent_accessor = child_ptr->create_accessor(child_to_parent_handle); @@ -152,9 +146,6 @@ void UpdateEdgeOperationMultiMeshMapFunctor::update_ear_replacement( } -#if defined(WMTK_ENABLE_HASH_UPDATE) - child_tuple = child_ptr->resurrect_tuple(child_tuple, child_hash_accessor); -#endif // check also the flag accessor of child mesh const char child_flag = @@ -164,14 +155,6 @@ void UpdateEdgeOperationMultiMeshMapFunctor::update_ear_replacement( continue; } -#if defined(WMTK_ENABLE_HASH_UPDATE) - // parent_tuple need to be ressurected in the parent scope and get id in the parent - // scope. - // TODO: remove the resurrect cuz parent_tuple should be already valid in the parent - // scope - parent_tuple = m.parent_scope( - [&]() { return m.resurrect_tuple(parent_tuple, parent_hash_accessor); }); -#endif const int64_t parent_old_vid = m.parent_scope([&]() { return m.id_vertex(parent_tuple); }); @@ -212,9 +195,6 @@ void UpdateEdgeOperationMultiMeshMapFunctor::update_ear_replacement( const auto& parent_incident_tet_datas = tmoe.incident_tet_datas(); const auto& parent_incident_face_datas = tmoe.incident_face_datas(); auto parent_mmmanager = m.m_multi_mesh_manager; -#if defined(WMTK_ENABLE_HASH_UPDATE) - auto parent_hash_accessor = m.get_const_cell_hash_accessor(); -#endif for (const auto& parent_data : parent_incident_tet_datas) { for (int ear_index = 0; ear_index < 2; ++ear_index) { @@ -228,9 +208,6 @@ void UpdateEdgeOperationMultiMeshMapFunctor::update_ear_replacement( // update merge faces here const auto& child_mmmanager = child_ptr->m_multi_mesh_manager; const int64_t child_id = child_mmmanager.child_id(); -#if defined(WMTK_ENABLE_HASH_UPDATE) - auto child_hash_accessor = child_ptr->get_const_cell_hash_accessor(); -#endif const auto child_to_parent_handle = child_mmmanager.map_to_parent_handle; const auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle; @@ -262,10 +239,6 @@ void UpdateEdgeOperationMultiMeshMapFunctor::update_ear_replacement( } -#if defined(WMTK_ENABLE_HASH_UPDATE) - // change to index access - child_tuple = child_ptr->resurrect_tuple(child_tuple, child_hash_accessor); -#endif const char child_flag = child_cell_flag_accessor.const_scalar_attribute(child_tuple); @@ -274,10 +247,6 @@ void UpdateEdgeOperationMultiMeshMapFunctor::update_ear_replacement( continue; } -#if defined(WMTK_ENABLE_HASH_UPDATE) - parent_tuple = m.parent_scope( - [&]() { return m.resurrect_tuple(parent_tuple, parent_hash_accessor); }); -#endif const int64_t parent_old_eid = m.parent_scope([&]() { return m.id_edge(parent_tuple); }); const int64_t parent_old_vid = @@ -333,9 +302,6 @@ void UpdateEdgeOperationMultiMeshMapFunctor::update_ear_replacement( // there are three ear edges per side const auto& child_mmmanager = child_ptr->m_multi_mesh_manager; int64_t child_id = child_mmmanager.child_id(); -#if defined(WMTK_ENABLE_HASH_UPDATE) - auto child_hash_accessor = child_ptr->get_const_cell_hash_accessor(); -#endif auto child_to_parent_handle = child_mmmanager.map_to_parent_handle; auto parent_to_child_handle = parent_mmmanager.children().at(child_id).map_handle; @@ -379,9 +345,6 @@ void UpdateEdgeOperationMultiMeshMapFunctor::update_ear_replacement( } -#if defined(WMTK_ENABLE_HASH_UPDATE) - child_tuple = child_ptr->resurrect_tuple(child_tuple, child_hash_accessor); -#endif const char child_flag = child_cell_flag_accessor.const_scalar_attribute(child_tuple); @@ -390,11 +353,6 @@ void UpdateEdgeOperationMultiMeshMapFunctor::update_ear_replacement( continue; } -#if defined(WMTK_ENABLE_HASH_UPDATE) - parent_tuple = m.parent_scope([&]() { - return m.resurrect_tuple(parent_tuple, parent_hash_accessor); - }); -#endif const int64_t parent_old_vid = m.parent_scope([&]() { return m.id_vertex(parent_tuple); }); diff --git a/src/wmtk/operations/utils/UpdateVertexMultiMeshMapHash.cpp b/src/wmtk/operations/utils/UpdateVertexMultiMeshMapHash.cpp deleted file mode 100644 index a899ea8967..0000000000 --- a/src/wmtk/operations/utils/UpdateVertexMultiMeshMapHash.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "UpdateVertexMultiMeshMapHash.hpp" -#include -#include -#include -#include -#include -#include -#include -#include - -namespace wmtk::operations::utils { -#if defined(WMTK_ENABLE_HASH_UPDATE) -void update_vertex_operation_hashes( - Mesh& m, - const Tuple& vertex, - attribute::Accessor& hash_accessor) -{ - const PrimitiveType pt = m.top_simplex_type(); - const simplex::SimplexCollection star = - simplex::closed_star(m, simplex::Simplex::vertex(m, vertex)); - std::vector tuples_to_update; - switch (pt) { - case PrimitiveType::Vertex: { - const auto star_vertices = star.simplex_vector(PrimitiveType::Vertex); - tuples_to_update.reserve(star_vertices.size()); - for (const simplex::Simplex& s : star_vertices) { - tuples_to_update.emplace_back(s.tuple()); - } - break; - } - case PrimitiveType::Edge: { - const auto star_edges = star.simplex_vector(PrimitiveType::Edge); - tuples_to_update.reserve(star_edges.size()); - for (const simplex::Simplex& s : star_edges) { - tuples_to_update.emplace_back(s.tuple()); - } - break; - } - case PrimitiveType::Triangle: { - const auto star_faces = star.simplex_vector(PrimitiveType::Triangle); - tuples_to_update.reserve(star_faces.size()); - for (const simplex::Simplex& s : star_faces) { - tuples_to_update.emplace_back(s.tuple()); - } - break; - } - case PrimitiveType::Tetrahedron: { - const auto star_tets = star.simplex_vector(PrimitiveType::Tetrahedron); - tuples_to_update.reserve(star_tets.size()); - for (const simplex::Simplex& s : star_tets) { - tuples_to_update.emplace_back(s.tuple()); - } - break; - } - default: assert(false); // "invalid input" - } - - - m.update_cell_hashes(tuples_to_update, hash_accessor); - - // need to get a star with new hash, otherwise cannot get_simplices() - auto vertex_new_hash = m.resurrect_tuple(vertex, hash_accessor); - const simplex::SimplexCollection star_new_hash = - simplex::closed_star(m, simplex::Simplex::vertex(m, vertex_new_hash)); - update_vertex_operation_multimesh_map_hash(m, star_new_hash, hash_accessor); -} - -void update_vertex_operation_multimesh_map_hash( - Mesh& m, - const simplex::SimplexCollection& vertex_closed_star, - attribute::Accessor& parent_hash_accessor) -{ - auto& mm_manager = m.m_multi_mesh_manager; - - for (auto& child_data : mm_manager.children()) { - auto& child_mesh = *child_data.mesh; - auto child_mesh_pt = child_mesh.top_simplex_type(); - auto maps = mm_manager.get_map_accessors(m, child_data); - auto& [parent_to_child_accessor, child_to_parent_accessor] = maps; - - const auto parent_simplices_to_update = vertex_closed_star.simplex_vector(child_mesh_pt); - for (auto& s : parent_simplices_to_update) { - auto s_tuple = s.tuple(); - auto [parent_tuple, child_tuple] = - wmtk::multimesh::utils::read_tuple_map_attribute(parent_to_child_accessor, s_tuple); - - if (parent_tuple.is_null()) continue; - - // resurrect the parent tuple - parent_tuple = m.resurrect_tuple(parent_tuple, parent_hash_accessor); - - // write back to map - wmtk::multimesh::utils::symmetric_write_tuple_map_attributes( - parent_to_child_accessor, - child_to_parent_accessor, - parent_tuple, - child_tuple); - } - } -} - -#endif -} // namespace wmtk::operations::utils diff --git a/src/wmtk/operations/utils/UpdateVertexMultiMeshMapHash.hpp b/src/wmtk/operations/utils/UpdateVertexMultiMeshMapHash.hpp deleted file mode 100644 index dd6538b07c..0000000000 --- a/src/wmtk/operations/utils/UpdateVertexMultiMeshMapHash.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -// #include -// #include -// #include -// #include -// #include - -namespace wmtk { -class Mesh; -class PointMesh; -class EdgeMesh; -class TriMesh; -class TetMesh; -class Tuple; -namespace simplex { -class SimplexCollection; -} -} // namespace wmtk - - -namespace wmtk::operations::utils { - -#if defined(WMTK_ENABLE_HASH_UPDATE) -void update_vertex_operation_hashes(Mesh& m, const Tuple& vertex, attribute::Accessor& hash_accessor); - -void update_vertex_operation_multimesh_map_hash( - Mesh& m, - const simplex::SimplexCollection& vertex_closed_star, - attribute::Accessor& parent_hash_accessor); -#endif - -} // namespace wmtk::operations::utils diff --git a/src/wmtk/utils/TupleInspector.cpp b/src/wmtk/utils/TupleInspector.cpp index 7f209af5f0..6d7aaaf8ba 100644 --- a/src/wmtk/utils/TupleInspector.cpp +++ b/src/wmtk/utils/TupleInspector.cpp @@ -6,11 +6,10 @@ namespace wmtk::utils { std::string TupleInspector::as_string(const Tuple& t) { return fmt::format( - "(gid {}:lids[v{},e{},f{}]:hash{})", + "(gid {}:lids[v{},e{},f{}])", global_cid(t), local_vid(t), local_eid(t), - local_fid(t), - hash(t)); + local_fid(t)); } } // namespace wmtk::utils diff --git a/src/wmtk/utils/TupleInspector.hpp b/src/wmtk/utils/TupleInspector.hpp index b86730c088..97537ca648 100644 --- a/src/wmtk/utils/TupleInspector.hpp +++ b/src/wmtk/utils/TupleInspector.hpp @@ -13,7 +13,6 @@ class TupleInspector static int64_t local_fid(const Tuple& t) { return t.m_local_fid; } static int64_t global_cid(const Tuple& t) { return t.m_global_cid; } - static int64_t hash(const Tuple& t) { return t.m_hash; } static std::string as_string(const Tuple& t); }; } // namespace wmtk::utils From 3c73f4541dc30e75d5536235e6c8b513bf81c0e0 Mon Sep 17 00:00:00 2001 From: Michael Tao Date: Sat, 17 Aug 2024 13:27:30 -0400 Subject: [PATCH 2/6] more remocving hash updates --- src/wmtk/multimesh/MultiMeshManager.hpp | 3 +- .../utils/tuple_map_attribute_io.cpp | 7 +- .../utils/tuple_map_attribute_io.hpp | 2 +- tests/attributes/tuple_accessor.cpp | 32 ++++---- tests/test_autogen.cpp | 4 +- tests/test_performance.cpp | 4 +- tests/test_simplex_collection.cpp | 9 +-- tests/test_simplicial_complex.cpp | 15 ++-- tests/test_tuple.cpp | 77 ++++++++----------- tests/tools/DEBUG_EdgeMesh.cpp | 19 ----- tests/tools/DEBUG_EdgeMesh.hpp | 6 -- tests/tools/DEBUG_TetMesh.cpp | 21 +---- tests/tools/DEBUG_TetMesh.hpp | 6 -- tests/tools/DEBUG_TriMesh.cpp | 28 ------- tests/tools/DEBUG_TriMesh.hpp | 6 -- tests/tools/DEBUG_Tuple.cpp | 5 +- tests/tools/DEBUG_Tuple.hpp | 1 - tests/tools/all_valid_local_tuples.cpp | 4 +- 18 files changed, 75 insertions(+), 174 deletions(-) diff --git a/src/wmtk/multimesh/MultiMeshManager.hpp b/src/wmtk/multimesh/MultiMeshManager.hpp index 82127db201..d04303b49b 100644 --- a/src/wmtk/multimesh/MultiMeshManager.hpp +++ b/src/wmtk/multimesh/MultiMeshManager.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include // included to make a friend as this requires IDs @@ -83,7 +84,7 @@ class MultiMeshManager : public wmtk::utils::MerkleTreeInteriorNode // attribute directly hashes its "children" components so it overrides "child_hashes" std::map child_hashables() const override; std::map child_hashes() const override; - + void detach_children(); diff --git a/src/wmtk/multimesh/utils/tuple_map_attribute_io.cpp b/src/wmtk/multimesh/utils/tuple_map_attribute_io.cpp index a858b7e988..2f7c484088 100644 --- a/src/wmtk/multimesh/utils/tuple_map_attribute_io.cpp +++ b/src/wmtk/multimesh/utils/tuple_map_attribute_io.cpp @@ -27,20 +27,19 @@ Tuple vector2_to_tuple(const Eigen::Ref& v) const Tuple* data = reinterpret_cast(v.data()); return *data; } -Vector tuple_to_vector5(const Tuple& t) +Vector tuple_to_vector5(const Tuple& t) { - Vector v; + Vector v; v(0) = wmtk::utils::TupleInspector::local_vid(t); v(1) = wmtk::utils::TupleInspector::local_eid(t); v(2) = wmtk::utils::TupleInspector::local_fid(t); v(3) = wmtk::utils::TupleInspector::global_cid(t); - v(4) = wmtk::utils::TupleInspector::hash(t); return v; } Tuple vector5_to_tuple(const Eigen::Ref& v) { - return Tuple(v(0), v(1), v(2), v(3), v(4)); + return Tuple(v(0), v(1), v(2), v(3)); } Vector tuple_to_vector(const Tuple& t) diff --git a/src/wmtk/multimesh/utils/tuple_map_attribute_io.hpp b/src/wmtk/multimesh/utils/tuple_map_attribute_io.hpp index f288b55cac..65f1150da9 100644 --- a/src/wmtk/multimesh/utils/tuple_map_attribute_io.hpp +++ b/src/wmtk/multimesh/utils/tuple_map_attribute_io.hpp @@ -4,7 +4,7 @@ // #define WMTK_DISABLE_COMPRESSED_MULTIMESH_TUPLE namespace wmtk::multimesh::utils { #if defined WMTK_DISABLE_COMPRESSED_MULTIMESH_TUPLE -constexpr static int64_t TUPLE_SIZE = 5; // in terms of int64_t +constexpr static int64_t TUPLE_SIZE = 4; // in terms of int64_t constexpr static int64_t GLOBAL_ID_INDEX = 3; #else constexpr static int64_t TUPLE_SIZE = 2; // in terms of int64_t diff --git a/tests/attributes/tuple_accessor.cpp b/tests/attributes/tuple_accessor.cpp index b52c7762ab..ef25d3db93 100644 --- a/tests/attributes/tuple_accessor.cpp +++ b/tests/attributes/tuple_accessor.cpp @@ -16,16 +16,16 @@ namespace {} // namespace TEST_CASE("tuple_to_int64_t_storage", "[accessor]") { std::array basic_data = { - wmtk::Tuple(0, 0, 0, 0, 0), - wmtk::Tuple(1, 0, 0, 0, 0), - wmtk::Tuple(0, 1, 0, 0, 0), - wmtk::Tuple(0, 0, 1, 0, 0), - wmtk::Tuple(0, 0, 0, 1, 0), - wmtk::Tuple(0, 0, 0, 0, 1), - wmtk::Tuple(-1, -1, -1, -1, -1), - wmtk::Tuple(0, 0, 0, 0, 0), - wmtk::Tuple(0, 20, 30, 40, 50), - wmtk::Tuple(-20, 0, -3, 16, -4)}; + wmtk::Tuple(0, 0, 0, 0), + wmtk::Tuple(1, 0, 0, 0), + wmtk::Tuple(0, 1, 0, 0), + wmtk::Tuple(0, 0, 1, 0), + wmtk::Tuple(0, 0, 0, 1), + wmtk::Tuple(0, 0, 0, 0), + wmtk::Tuple(-1, -1, -1, -1), + wmtk::Tuple(0, 0, 0, 0), + wmtk::Tuple(0, 20, 30, 40), + wmtk::Tuple(-20, 0, -3, 16)}; for (const auto& t : basic_data) { wmtk::Vector idat = wmtk::multimesh::utils::tuple_to_vector(t); const int64_t* iptr = reinterpret_cast(&t); @@ -62,14 +62,13 @@ TEST_CASE("test_single_tuple_accessor", "[accessor]") wmtk::Tuple& t_ref = tuple_accessor.scalar_attribute(tup); CHECK(t == t_ref); CHECK(t.is_null()); - t_ref = wmtk::Tuple(gid, gid + 1, gid + 2, gid + 3, gid + 4); + t_ref = wmtk::Tuple(gid, gid + 1, gid + 2, gid + 3); { const wmtk::Tuple t2 = tuple_accessor.const_scalar_attribute(tup); CHECK(wmtk::utils::TupleInspector::local_vid(t2) == gid); CHECK(wmtk::utils::TupleInspector::local_eid(t2) == gid + 1); CHECK(wmtk::utils::TupleInspector::local_fid(t2) == gid + 2); CHECK(wmtk::utils::TupleInspector::global_cid(t2) == gid + 3); - CHECK(wmtk::utils::TupleInspector::hash(t2) == gid + 4); } } for (const wmtk::Tuple& tup : vertices) { @@ -81,7 +80,6 @@ TEST_CASE("test_single_tuple_accessor", "[accessor]") CHECK(wmtk::utils::TupleInspector::local_eid(t) == gid + 1); CHECK(wmtk::utils::TupleInspector::local_fid(t) == gid + 2); CHECK(wmtk::utils::TupleInspector::global_cid(t) == gid + 3); - CHECK(wmtk::utils::TupleInspector::hash(t) == gid + 4); } } @@ -115,8 +113,8 @@ TEST_CASE("test_multi_tuple_accessor", "[accessor]") CHECK(t(0).is_null()); CHECK(t(1).is_null()); int64_t gid = m.id(tup); - t(0) = wmtk::Tuple(gid, gid + 1, gid + 2, gid + 3, gid + 4); - t(1) = wmtk::Tuple(gid, gid + 5, gid + 6, gid + 7, gid + 8); + t(0) = wmtk::Tuple(gid, gid + 1, gid + 2, gid + 3); + t(1) = wmtk::Tuple(gid, gid + 4, gid + 5, gid + 6); } for (const wmtk::Tuple& tup : vertices) { auto v = int64_t_acc.const_vector_attribute(tup); @@ -128,8 +126,8 @@ TEST_CASE("test_multi_tuple_accessor", "[accessor]") CHECK(!t(0).is_null()); CHECK(!t(1).is_null()); int64_t gid = m.id(tup); - CHECK(t(0) == wmtk::Tuple(gid, gid + 1, gid + 2, gid + 3, gid + 4)); - CHECK(t(1) == wmtk::Tuple(gid, gid + 5, gid + 6, gid + 7, gid + 8)); + CHECK(t(0) == wmtk::Tuple(gid, gid + 1, gid + 2, gid + 3)); + CHECK(t(1) == wmtk::Tuple(gid, gid + 4, gid + 5, gid + 6)); } } TEST_CASE("test_multi_tuple_accessor_gid", "[accessor]") diff --git a/tests/test_autogen.cpp b/tests/test_autogen.cpp index 8beee97aac..a89befd6bd 100644 --- a/tests/test_autogen.cpp +++ b/tests/test_autogen.cpp @@ -144,7 +144,7 @@ TEST_CASE("tuple_autogen_local_id_inversion", "[tuple]") for (const auto& t : tuples) { int64_t id = tri_mesh::local_id_table_offset(t); auto [lvid, leid] = tri_mesh::lvid_leid_from_table_offset(id); - Tuple nt(lvid, leid, 0, 0, 0); + Tuple nt(lvid, leid, 0, 0); int64_t nid = tri_mesh::local_id_table_offset(nt); CHECK(t == nt); @@ -157,7 +157,7 @@ TEST_CASE("tuple_autogen_local_id_inversion", "[tuple]") for (const auto& t : tuples) { int64_t id = tet_mesh::local_id_table_offset(t); auto [lvid, leid, lfid] = tet_mesh::lvid_leid_lfid_from_table_offset(id); - Tuple nt(lvid, leid, lfid, 0, 0); + Tuple nt(lvid, leid, lfid, 0); int64_t nid = tet_mesh::local_id_table_offset(nt); CHECK(t == nt); CHECK(id == nid); diff --git a/tests/test_performance.cpp b/tests/test_performance.cpp index 800a56946e..ea4829420e 100644 --- a/tests/test_performance.cpp +++ b/tests/test_performance.cpp @@ -421,7 +421,7 @@ TEST_CASE("navigation_performance_tri", "[simplex][performance][.]") } else { e = (e + 1) % 3; } - return Tuple(v, e, TI::local_fid(t), c, 0); + return Tuple(v, e, TI::local_fid(t), c); }; POLYSOLVE_SCOPED_STOPWATCH("chache vertex neighbors", logger()); @@ -603,4 +603,4 @@ TEST_CASE("navigation_performance_tet", "[simplex][performance][.]") } logger().info("sum = {}", counter); } -} \ No newline at end of file +} diff --git a/tests/test_simplex_collection.cpp b/tests/test_simplex_collection.cpp index 1d6a6ea81e..8669bcf665 100644 --- a/tests/test_simplex_collection.cpp +++ b/tests/test_simplex_collection.cpp @@ -1734,8 +1734,7 @@ TEST_CASE("simplex_link_condtion_edgemesh", "[simplex_collection]") tests::DEBUG_EdgeMesh m1 = tests::loop_lines(); tests::DEBUG_EdgeMesh m2 = tests::two_line_loop(); - int64_t hash = 0; - Tuple t(0, -1, -1, 0, hash); + Tuple t(0, -1, -1, 0); REQUIRE(link_condition(m0, t) == true); REQUIRE(link_condition(m1, t) == true); REQUIRE(link_condition(m2, t) == true); @@ -1746,8 +1745,7 @@ TEST_CASE("simplex_link_condtion_edgemesh", "[simplex_collection]") tests::DEBUG_EdgeMesh m0 = tests::single_line(); tests::DEBUG_EdgeMesh m1 = tests::self_loop(); - int64_t hash = 0; - Tuple t(0, -1, -1, 0, hash); + Tuple t(0, -1, -1, 0); REQUIRE(link_condition(m0, t) == false); REQUIRE(link_condition(m1, t) == false); } @@ -1760,8 +1758,7 @@ TEST_CASE("simplex_link_condtion_trimesh", "[simplex_collection]") tests::DEBUG_TriMesh m; m = tests::three_neighbors(); // get the tuple point to V(0), E(01), F(012) - int64_t hash = 0; - Tuple t(0, 2, -1, 1, hash); + Tuple t(0, 2, -1, 1); REQUIRE(link_condition(m, t) == false); } diff --git a/tests/test_simplicial_complex.cpp b/tests/test_simplicial_complex.cpp index d349960aeb..04cd274736 100644 --- a/tests/test_simplicial_complex.cpp +++ b/tests/test_simplicial_complex.cpp @@ -138,8 +138,7 @@ TEST_CASE("link-case1", "[simplicial_complex][link][2D]") m.initialize(F); // get the tuple point to V(0), E(01), F(013) - int64_t hash = 0; - Tuple t(0, 2, -1, 1, hash); + Tuple t(0, 2, -1, 1); // make sure this is the right tuple REQUIRE(m.id(t, PF) == 1); @@ -177,8 +176,7 @@ TEST_CASE("link-case2", "[simplicial_complex][link][2D]") m = tests::three_neighbors(); // get the tuple point to V(0), E(01), F(012) - int64_t hash = 0; - Tuple t(0, 2, -1, 1, hash); + Tuple t(0, 2, -1, 1); // make sure this is the right tuple REQUIRE(m.id(t, PF) == 1); REQUIRE(m.id(t, PV) == 0); @@ -242,8 +240,7 @@ TEST_CASE("k-ring", "[simplicial_complex][k-ring][2D]") m = tests::three_neighbors(); // get the tuple point to V(3) - int64_t hash = 0; - Tuple t(1, 0, -1, 0, hash); + Tuple t(1, 0, -1, 0); Simplex s = Simplex::vertex(m, t); REQUIRE(m.id(t, PV) == 3); // Old code @@ -315,8 +312,7 @@ TEST_CASE("open_star", "[simplicial_complex][star][2D]") m = tests::three_neighbors(); // get the tuple point to V(0), E(01), F(012) - int64_t hash = 0; - Tuple t(0, 2, -1, 1, hash); + Tuple t(0, 2, -1, 1); auto sc_v = open_star(m, Simplex(m, PV, t)).simplex_vector(); @@ -353,8 +349,7 @@ TEST_CASE("closed_star", "[simplicial_complex][star][2D]") m = tests::three_neighbors(); // get the tuple point to V(0), E(01), F(012) - int64_t hash = 0; - Tuple t(0, 2, -1, 1, hash); + Tuple t(0, 2, -1, 1); REQUIRE(m.id(t, PV) == 0); REQUIRE(m.id(m.switch_tuple(t, PV), PV) == 1); REQUIRE(m.id(m.switch_tuple(m.switch_tuple(t, PE), PV), PV) == 2); diff --git a/tests/test_tuple.cpp b/tests/test_tuple.cpp index 62f428ad4b..60ac448ff7 100644 --- a/tests/test_tuple.cpp +++ b/tests/test_tuple.cpp @@ -8,62 +8,53 @@ using namespace wmtk; TEST_CASE("tuple_is_null", "[tuple]") { - Tuple a(0, 0, 0, 0, 0); + Tuple a(0, 0, 0, 0); CHECK(!a.is_null()); - Tuple b(0, 0, 0, -1, 0); + Tuple b(0, 0, 0, -1); CHECK(b.is_null()); - Tuple c(-1, -1, -1, -1, -1); + Tuple c(-1, -1, -1, -1); CHECK(c.is_null()); - Tuple d(-1, -1, -1, 0, -1); + Tuple d(-1, -1, -1, 0); CHECK(!d.is_null()); - Tuple e(-1, -1, -1, -2, -1); + Tuple e(-1, -1, -1, -2); CHECK(!e.is_null()); } TEST_CASE("tuple_comparison", "[tuple]") { - { // check that equals are detected properly - Tuple a(0, 0, 0, 0, 0); - Tuple b(0, 0, 0, 0, 0); + { // check that equals works + Tuple a(0, 0, 0, 0); + Tuple b(0, 0, 0, 0); CHECK(a == b); CHECK(a.same_ids(b)); } - {// check that diff ids are equivalent - {Tuple a(1, 0, 0, 0, 0); - Tuple b(0, 0, 0, 0, 0); - CHECK(a != b); - CHECK(!a.same_ids(b)); -} -{ - Tuple a(0, 1, 0, 0, 0); - Tuple b(0, 0, 0, 0, 0); - CHECK(a != b); - CHECK(!a.same_ids(b)); -} -{ - Tuple a(0, 0, 1, 0, 0); - Tuple b(0, 0, 0, 0, 0); - CHECK(a != b); - CHECK(!a.same_ids(b)); -} -{ - Tuple a(0, 0, 0, 1, 0); - Tuple b(0, 0, 0, 0, 0); - CHECK(a != b); - CHECK(!a.same_ids(b)); -} -} -{ - Tuple a(0, 0, 0, 0, 1); - Tuple b(0, 0, 0, 0, 0); -#if defined(WMTK_ENABLE_HASH_UPDATE) - CHECK(a != b); -#else - CHECK(a == b); -#endif - CHECK(a.same_ids(b)); -} + { // check that diff ids are equivalent + { + Tuple a(1, 0, 0, 0); + Tuple b(0, 0, 0, 0); + CHECK(a != b); + CHECK(!a.same_ids(b)); + } + { + Tuple a(0, 1, 0, 0); + Tuple b(0, 0, 0, 0); + CHECK(a != b); + CHECK(!a.same_ids(b)); + } + { + Tuple a(0, 0, 1, 0); + Tuple b(0, 0, 0, 0); + CHECK(a != b); + CHECK(!a.same_ids(b)); + } + { + Tuple a(0, 0, 0, 1); + Tuple b(0, 0, 0, 0); + CHECK(a != b); + CHECK(!a.same_ids(b)); + } + } } diff --git a/tests/tools/DEBUG_EdgeMesh.cpp b/tests/tools/DEBUG_EdgeMesh.cpp index 0d228481f8..f4265c9bd0 100644 --- a/tests/tools/DEBUG_EdgeMesh.cpp +++ b/tests/tools/DEBUG_EdgeMesh.cpp @@ -65,11 +65,7 @@ auto DEBUG_EdgeMesh::edge_tuple_from_vids(const int64_t v1, const int64_t v2) co } } if (local_vid1 != -1 && local_vid2 != -1) { -#if defined(WMTK_ENABLE_HASH_UPDATE) - return Tuple(local_vid1, -1, -1, eid, get_cell_hash_slow(eid)); -#else return Tuple(local_vid1, -1, -1, eid); -#endif } } return Tuple(); @@ -108,26 +104,11 @@ void DEBUG_EdgeMesh::reserve_attributes(PrimitiveType type, int64_t size) } -#if defined(WMTK_ENABLE_HASH_UPDATE) -attribute::Accessor DEBUG_EdgeMesh::get_cell_hash_accessor() -{ - return EdgeMesh::get_cell_hash_accessor(); -} -/** - * @brief returns the EdgeMeshOperationExecutor - */ -auto DEBUG_EdgeMesh::get_emoe(const Tuple& t, wmtk::attribute::Accessor& hash_accessor) - -> EdgeMeshOperationExecutor -{ - return EdgeMeshOperationExecutor(*this, t, hash_accessor); -} -#else auto DEBUG_EdgeMesh::get_emoe(const Tuple& t) -> EdgeMeshOperationExecutor { return EdgeMeshOperationExecutor(*this, t); } -#endif bool DEBUG_EdgeMesh::is_simplex_deleted(PrimitiveType type, const int64_t id) const { diff --git a/tests/tools/DEBUG_EdgeMesh.hpp b/tests/tools/DEBUG_EdgeMesh.hpp index 81aa952c5c..a49ad78300 100644 --- a/tests/tools/DEBUG_EdgeMesh.hpp +++ b/tests/tools/DEBUG_EdgeMesh.hpp @@ -63,13 +63,7 @@ class DEBUG_EdgeMesh : public EdgeMesh */ using EdgeMesh::tuple_from_id; -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor get_cell_hash_accessor(); - - EdgeMeshOperationExecutor get_emoe(const Tuple& t, attribute::Accessor& hash_accessor); -#else EdgeMeshOperationExecutor get_emoe(const Tuple& t); -#endif bool is_simplex_deleted(PrimitiveType type, const int64_t id) const; }; diff --git a/tests/tools/DEBUG_TetMesh.cpp b/tests/tools/DEBUG_TetMesh.cpp index a58c609149..6b8ef89f52 100644 --- a/tests/tools/DEBUG_TetMesh.cpp +++ b/tests/tools/DEBUG_TetMesh.cpp @@ -54,7 +54,7 @@ auto DEBUG_TetMesh::edge_tuple_between_v1_v2(const int64_t v1, const int64_t v2, int64_t local_fid = wmtk::autogen::tet_mesh::auto_3d_table_complete_edge[local_eid][2]; assert(local_fid > -1); - return Tuple(local_vid1, local_eid, local_fid, tid, 0); + return Tuple(local_vid1, local_eid, local_fid, tid); } auto DEBUG_TetMesh::edge_tuple_between_v1_v2( @@ -108,7 +108,7 @@ auto DEBUG_TetMesh::edge_tuple_between_v1_v2( } assert(local_fid > -1); - return Tuple(local_vid1, local_eid, local_fid, tid, 0); + return Tuple(local_vid1, local_eid, local_fid, tid); } auto DEBUG_TetMesh::edge_tuple_from_vids(const int64_t v1, const int64_t v2) const -> Tuple @@ -154,7 +154,7 @@ auto DEBUG_TetMesh::edge_tuple_from_vids(const int64_t v1, const int64_t v2) con int64_t local_vid = wmtk::autogen::tet_mesh::auto_3d_table_complete_edge[local_eid][0]; - return Tuple(local_vid, local_eid, local_fid, tid, 0); + return Tuple(local_vid, local_eid, local_fid, tid); } return Tuple(); } @@ -204,7 +204,7 @@ auto DEBUG_TetMesh::face_tuple_from_vids(const int64_t v1, const int64_t v2, con int64_t local_vid = wmtk::autogen::tet_mesh::auto_3d_table_complete_face[local_fid][0]; - return Tuple(local_vid, local_eid, local_fid, tid, 0); + return Tuple(local_vid, local_eid, local_fid, tid); } return Tuple(); } @@ -275,24 +275,11 @@ void DEBUG_TetMesh::reserve_attributes(PrimitiveType type, int64_t size) } -#if defined(WMTK_ENABLE_HASH_UPDATE) -attribute::Accessor DEBUG_TetMesh::get_cell_hash_accessor() -{ - return TetMesh::get_cell_hash_accessor(); -} - -auto DEBUG_TetMesh::get_tmoe(const Tuple& t, wmtk::attribute::Accessor& hash_accessor) - -> TetMeshOperationExecutor -{ - return TetMeshOperationExecutor(*this, t, hash_accessor); -} -#else auto DEBUG_TetMesh::get_tmoe(const Tuple& t) -> TetMeshOperationExecutor { return TetMeshOperationExecutor(*this, t); } -#endif int64_t DEBUG_TetMesh::valid_primitive_count(PrimitiveType type) const { diff --git a/tests/tools/DEBUG_TetMesh.hpp b/tests/tools/DEBUG_TetMesh.hpp index 7e55709f66..39d040aba2 100644 --- a/tests/tools/DEBUG_TetMesh.hpp +++ b/tests/tools/DEBUG_TetMesh.hpp @@ -82,13 +82,7 @@ class DEBUG_TetMesh : public TetMesh using TetMesh::tuple_from_id; -#if defined(WMTK_ENABLE_HASH_UPDATE) - attribute::Accessor get_cell_hash_accessor(); - - TetMeshOperationExecutor get_tmoe(const Tuple& t, attribute::Accessor& hash_accessor); -#else TetMeshOperationExecutor get_tmoe(const Tuple& t); -#endif int64_t valid_primitive_count(PrimitiveType type) const; diff --git a/tests/tools/DEBUG_TriMesh.cpp b/tests/tools/DEBUG_TriMesh.cpp index 25b4252882..ba522298f4 100644 --- a/tests/tools/DEBUG_TriMesh.cpp +++ b/tests/tools/DEBUG_TriMesh.cpp @@ -70,11 +70,7 @@ auto DEBUG_TriMesh::edge_tuple_between_v1_v2(const int64_t v1, const int64_t v2, local_vid2 = i; } } -#if defined(WMTK_ENABLE_HASH_UPDATE) - return Tuple(local_vid1, (3 - local_vid1 - local_vid2) % 3, -1, fid, get_cell_hash_slow(fid)); -#else return Tuple(local_vid1, (3 - local_vid1 - local_vid2) % 3, -1, fid); -#endif } auto DEBUG_TriMesh::edge_tuple_from_vids(const int64_t v1, const int64_t v2) const -> Tuple @@ -94,20 +90,11 @@ auto DEBUG_TriMesh::edge_tuple_from_vids(const int64_t v1, const int64_t v2) con } } if (local_vid1 != -1 && local_vid2 != -1) { -#if defined(WMTK_ENABLE_HASH_UPDATE) - return Tuple( - local_vid1, - (3 - local_vid1 - local_vid2) % 3, - -1, - fid, - get_cell_hash_slow(fid)); -#else return Tuple( local_vid1, (3 - local_vid1 - local_vid2) % 3, -1, fid); -#endif } } return Tuple(); @@ -172,24 +159,9 @@ void DEBUG_TriMesh::reserve_attributes(PrimitiveType type, int64_t size) } -#if defined(WMTK_ENABLE_HASH_UPDATE) -attribute::Accessor DEBUG_TriMesh::get_cell_hash_accessor() -{ - return TriMesh::get_cell_hash_accessor(); -} -/** - * @brief returns the TriMeshOperationExecutor - */ -auto DEBUG_TriMesh::get_tmoe(const Tuple& t, wmtk::attribute::Accessor& hash_accessor) - -> TriMeshOperationExecutor -{ - return TriMeshOperationExecutor(*this, t, hash_accessor); -} -#else auto DEBUG_TriMesh::get_tmoe(const Tuple& t) -> TriMeshOperationExecutor { return TriMeshOperationExecutor(*this, t); } -#endif } // namespace wmtk::tests diff --git a/tests/tools/DEBUG_TriMesh.hpp b/tests/tools/DEBUG_TriMesh.hpp index a6001048d0..a7db197282 100644 --- a/tests/tools/DEBUG_TriMesh.hpp +++ b/tests/tools/DEBUG_TriMesh.hpp @@ -80,13 +80,7 @@ class DEBUG_TriMesh : public TriMesh //, public virtual DEBUG_Mesh using TriMesh::custom_attributes; -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor get_cell_hash_accessor(); - - TriMeshOperationExecutor get_tmoe(const Tuple& t, attribute::Accessor& hash_accessor); -#else TriMeshOperationExecutor get_tmoe(const Tuple& t); -#endif }; } // namespace wmtk::tests diff --git a/tests/tools/DEBUG_Tuple.cpp b/tests/tools/DEBUG_Tuple.cpp index 8907fe2d97..87772eac9e 100644 --- a/tests/tools/DEBUG_Tuple.cpp +++ b/tests/tools/DEBUG_Tuple.cpp @@ -6,12 +6,11 @@ namespace wmtk::tests { DEBUG_Tuple::operator std::string() const { return fmt::format( - "(gid {}:lids{},{},{}:hash{})", + "(gid {}:lids{},{},{})", global_cid(), local_vid(), local_eid(), - local_fid(), - hash()); + local_fid()); } } // namespace wmtk::tests diff --git a/tests/tools/DEBUG_Tuple.hpp b/tests/tools/DEBUG_Tuple.hpp index d4e62eb005..6eb252bbfb 100644 --- a/tests/tools/DEBUG_Tuple.hpp +++ b/tests/tools/DEBUG_Tuple.hpp @@ -16,7 +16,6 @@ struct DEBUG_Tuple int64_t local_eid() const { return wmtk::utils::TupleInspector::local_eid(m_data); } int64_t local_fid() const { return wmtk::utils::TupleInspector::local_fid(m_data); } int64_t global_cid() const { return wmtk::utils::TupleInspector::global_cid(m_data); } - int64_t hash() const { return wmtk::utils::TupleInspector::hash(m_data); } operator std::string() const; diff --git a/tests/tools/all_valid_local_tuples.cpp b/tests/tools/all_valid_local_tuples.cpp index 226c91932f..0fb1ddbc06 100644 --- a/tests/tools/all_valid_local_tuples.cpp +++ b/tests/tools/all_valid_local_tuples.cpp @@ -41,7 +41,7 @@ int64_t max_tuple_count(PrimitiveType pt) Tuple tuple_from_offset_id(PrimitiveType pt, int offset) { - int64_t lvid = 0, leid = 0, lfid = 0, gcid = 0, hash = 0; + int64_t lvid = 0, leid = 0, lfid = 0, gcid = 0; switch (pt) { case PrimitiveType::Triangle: { @@ -60,7 +60,7 @@ Tuple tuple_from_offset_id(PrimitiveType pt, int offset) case PrimitiveType::Vertex: break; } - Tuple r(lvid, leid, lfid, gcid, hash); + Tuple r(lvid, leid, lfid, gcid); if (!tuple_is_valid_for_ccw(pt, r)) { r = Tuple(); } From 8d8b3bccb683d56af87949ba9bade5ea96a191af Mon Sep 17 00:00:00 2001 From: Michael Tao Date: Sat, 17 Aug 2024 16:35:28 -0400 Subject: [PATCH 3/6] removed teh WMTK_ENABLE_HASH_UPDATE / completely removed teh ahsh --- CMakeLists.txt | 4 - .../autogen/edge_mesh/local_switch_tuple.hxx | 3 +- .../edge_mesh/tuple_from_valid_index.hpp | 1 - .../edge_mesh/tuple_from_valid_index.hxx | 6 - .../autogen/tet_mesh/local_switch_tuple.hxx | 3 +- .../tet_mesh/tuple_from_valid_index.hpp | 1 - .../tet_mesh/tuple_from_valid_index.hxx | 6 - .../autogen/tri_mesh/local_switch_tuple.hxx | 3 +- .../tri_mesh/tuple_from_valid_index.hpp | 1 - .../tri_mesh/tuple_from_valid_index.hxx | 6 - tests/operations/split_2d.cpp | 156 ------------------ tests/test_example_meshes.cpp | 12 +- 12 files changed, 9 insertions(+), 193 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8182e6fd8f..d472a7c95d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,10 +139,6 @@ if(WMTK_ENABLE_TRANSACTION_STACK) target_compile_definitions(wildmeshing_toolkit PUBLIC WMTK_ENABLE_TRANSACTION_STACK) endif() -option(WMTK_ENABLE_HASH_UPDATE "Enable hash update" OFF) -if(WMTK_ENABLE_HASH_UPDATE) - target_compile_definitions(wildmeshing_toolkit PUBLIC WMTK_ENABLE_HASH_UPDATE) -endif() target_link_libraries(wildmeshing_toolkit PRIVATE wmtk::warnings) diff --git a/src/wmtk/autogen/edge_mesh/local_switch_tuple.hxx b/src/wmtk/autogen/edge_mesh/local_switch_tuple.hxx index e0d52170bd..dfefb069d7 100644 --- a/src/wmtk/autogen/edge_mesh/local_switch_tuple.hxx +++ b/src/wmtk/autogen/edge_mesh/local_switch_tuple.hxx @@ -32,9 +32,8 @@ inline Tuple local_switch_tuple(const Tuple& t, int8_t valid_tuple_index) { int8_t input_index = valid_index_from_tuple(t); const int64_t global_cid = wmtk::utils::TupleInspector::global_cid(t); - const int64_t hash = wmtk::utils::TupleInspector::hash(t); const int8_t product_result = auto_valid_switch_product_table[input_index][valid_tuple_index]; - return tuple_from_valid_index(global_cid, product_result, hash); + return tuple_from_valid_index(global_cid, product_result); } namespace internal { diff --git a/src/wmtk/autogen/edge_mesh/tuple_from_valid_index.hpp b/src/wmtk/autogen/edge_mesh/tuple_from_valid_index.hpp index 86e39b668d..23eaf7f53e 100644 --- a/src/wmtk/autogen/edge_mesh/tuple_from_valid_index.hpp +++ b/src/wmtk/autogen/edge_mesh/tuple_from_valid_index.hpp @@ -3,7 +3,6 @@ namespace wmtk::autogen::edge_mesh { Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index); -Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index, int64_t hash); } // namespace wmtk::autogen::edge_mesh diff --git a/src/wmtk/autogen/edge_mesh/tuple_from_valid_index.hxx b/src/wmtk/autogen/edge_mesh/tuple_from_valid_index.hxx index 8d5f2ccfc0..d3add1e2fe 100644 --- a/src/wmtk/autogen/edge_mesh/tuple_from_valid_index.hxx +++ b/src/wmtk/autogen/edge_mesh/tuple_from_valid_index.hxx @@ -10,11 +10,5 @@ inline Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index return Tuple(lvid, -1, -1, global_cid); } -inline Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index, int64_t hash) -{ - const auto& [lvid] = auto_valid_tuples[valid_tuple_index]; - - return Tuple(lvid, -1, -1, global_cid, hash); -} } // namespace wmtk::autogen::edge_mesh diff --git a/src/wmtk/autogen/tet_mesh/local_switch_tuple.hxx b/src/wmtk/autogen/tet_mesh/local_switch_tuple.hxx index c140d02754..8d5a168a10 100644 --- a/src/wmtk/autogen/tet_mesh/local_switch_tuple.hxx +++ b/src/wmtk/autogen/tet_mesh/local_switch_tuple.hxx @@ -47,9 +47,8 @@ inline Tuple local_switch_tuple(const Tuple& t, int8_t valid_tuple_index) { int8_t input_index = valid_index_from_tuple(t); const int64_t global_cid = wmtk::utils::TupleInspector::global_cid(t); - const int64_t hash = wmtk::utils::TupleInspector::hash(t); const int8_t product_result = auto_valid_switch_product_table[input_index][valid_tuple_index]; - return tuple_from_valid_index(global_cid, product_result, hash); + return tuple_from_valid_index(global_cid, product_result); } namespace internal { diff --git a/src/wmtk/autogen/tet_mesh/tuple_from_valid_index.hpp b/src/wmtk/autogen/tet_mesh/tuple_from_valid_index.hpp index 2c9ffffa3d..bb859ff5f2 100644 --- a/src/wmtk/autogen/tet_mesh/tuple_from_valid_index.hpp +++ b/src/wmtk/autogen/tet_mesh/tuple_from_valid_index.hpp @@ -3,7 +3,6 @@ namespace wmtk::autogen::tet_mesh { Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index); -Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index, int64_t hash); } // namespace wmtk::autogen::tet_mesh diff --git a/src/wmtk/autogen/tet_mesh/tuple_from_valid_index.hxx b/src/wmtk/autogen/tet_mesh/tuple_from_valid_index.hxx index 0dee9a84c7..3bb9330048 100644 --- a/src/wmtk/autogen/tet_mesh/tuple_from_valid_index.hxx +++ b/src/wmtk/autogen/tet_mesh/tuple_from_valid_index.hxx @@ -10,11 +10,5 @@ inline Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index return Tuple(lvid, leid, lfid, global_cid); } -inline Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index, int64_t hash) -{ - const auto& [lvid, leid, lfid] = auto_valid_tuples[valid_tuple_index]; - - return Tuple(lvid, leid, lfid, global_cid, hash); -} } // namespace wmtk::autogen::tet_mesh diff --git a/src/wmtk/autogen/tri_mesh/local_switch_tuple.hxx b/src/wmtk/autogen/tri_mesh/local_switch_tuple.hxx index 0d6fc0445d..3eab85e571 100644 --- a/src/wmtk/autogen/tri_mesh/local_switch_tuple.hxx +++ b/src/wmtk/autogen/tri_mesh/local_switch_tuple.hxx @@ -38,9 +38,8 @@ inline Tuple local_switch_tuple(const Tuple& t, int8_t valid_tuple_index) { int8_t input_index = valid_index_from_tuple(t); const int64_t global_cid = wmtk::utils::TupleInspector::global_cid(t); - const int64_t hash = wmtk::utils::TupleInspector::hash(t); const int8_t product_result = auto_valid_switch_product_table[input_index][valid_tuple_index]; - return tuple_from_valid_index(global_cid, product_result, hash); + return tuple_from_valid_index(global_cid, product_result); } namespace internal { diff --git a/src/wmtk/autogen/tri_mesh/tuple_from_valid_index.hpp b/src/wmtk/autogen/tri_mesh/tuple_from_valid_index.hpp index 6a3e146937..83d232dd68 100644 --- a/src/wmtk/autogen/tri_mesh/tuple_from_valid_index.hpp +++ b/src/wmtk/autogen/tri_mesh/tuple_from_valid_index.hpp @@ -3,7 +3,6 @@ namespace wmtk::autogen::tri_mesh { Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index); -Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index, int64_t hash); } // namespace wmtk::autogen::tri_mesh diff --git a/src/wmtk/autogen/tri_mesh/tuple_from_valid_index.hxx b/src/wmtk/autogen/tri_mesh/tuple_from_valid_index.hxx index 832e580e8b..e01bf1de28 100644 --- a/src/wmtk/autogen/tri_mesh/tuple_from_valid_index.hxx +++ b/src/wmtk/autogen/tri_mesh/tuple_from_valid_index.hxx @@ -10,11 +10,5 @@ inline Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index return Tuple(lvid, leid, -1, global_cid); } -inline Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index, int64_t hash) -{ - const auto& [lvid, leid] = auto_valid_tuples[valid_tuple_index]; - - return Tuple(lvid, leid, -1, global_cid, hash); -} } // namespace wmtk::autogen::tri_mesh diff --git a/tests/operations/split_2d.cpp b/tests/operations/split_2d.cpp index 6fddfc9ed2..dd6fbe56e8 100644 --- a/tests/operations/split_2d.cpp +++ b/tests/operations/split_2d.cpp @@ -131,12 +131,7 @@ TEST_CASE("delete_simplices", "[operations][2D]") simplices_to_delete[1].emplace_back(edge_index); simplices_to_delete[2].emplace_back(face_index); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else auto executor = m.get_tmoe(edge); -#endif // new way of getting simplices executor.simplex_ids_to_delete = TMOE::get_split_simplices_to_delete(edge, m); @@ -161,12 +156,7 @@ TEST_CASE("operation_state", "[operations][2D]") REQUIRE(m.id(edge, PV) == 0); REQUIRE(m.id(edge, PF) == 0); REQUIRE(m.id(m.switch_tuple(edge, PV), PV) == 2); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else auto executor = m.get_tmoe(edge); -#endif REQUIRE(executor.flag_accessors.size() == 3); REQUIRE(executor.incident_vids().size() == 2); @@ -181,12 +171,7 @@ TEST_CASE("operation_state", "[operations][2D]") REQUIRE(m.is_connectivity_valid()); Tuple edge = m.edge_tuple_between_v1_v2(1, 2, 0); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else auto executor = m.get_tmoe(edge); -#endif REQUIRE(executor.flag_accessors.size() == 3); REQUIRE(executor.incident_vids().size() == 2); @@ -214,12 +199,7 @@ TEST_CASE("operation_state", "[operations][2D]") REQUIRE(m.is_connectivity_valid()); Tuple edge = m.edge_tuple_between_v1_v2(1, 2, 0); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else auto executor = m.get_tmoe(edge); -#endif REQUIRE(executor.flag_accessors.size() == 3); REQUIRE(executor.incident_vids().size() == 2); @@ -257,12 +237,7 @@ TEST_CASE("operation_state", "[operations][2D]") }(); for (Tuple edge : m.get_all(PrimitiveType::Edge)) { REQUIRE(m.is_connectivity_valid()); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else auto executor = m.get_tmoe(edge); -#endif REQUIRE(executor.flag_accessors.size() == 3); REQUIRE(executor.incident_face_datas().size() == 1); @@ -291,12 +266,7 @@ TEST_CASE("glue_ear_to_face", "[operations][2D]") const Tuple left_ear_edge = m.switch_tuple(edge, PE); REQUIRE(m.id(left_ear_edge, PV) == 4); REQUIRE(m.id(m.switch_tuple(left_ear_edge, PV), PV) == 1); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else auto executor = m.get_tmoe(edge); -#endif auto ff_accessor_before = m.create_base_accessor(m.f_handle(PF)); REQUIRE(ff_accessor_before.vector_attribute(1)(2) == 2); TMOE::EarData ear{1, m.id(edge, PE)}; @@ -305,71 +275,6 @@ TEST_CASE("glue_ear_to_face", "[operations][2D]") REQUIRE(ff_accessor_after.vector_attribute(1)(2) == 3); } -#if defined(WMTK_ENABLE_HASH_UPDATE) -TEST_CASE("hash_update", "[operations][2D]") -{ - SECTION("single_triangle") - { - DEBUG_TriMesh m = single_triangle(); - REQUIRE(m.is_connectivity_valid()); - - const Tuple edge = m.edge_tuple_between_v1_v2(0, 2, 0); - -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else - auto executor = m.get_tmoe(edge); -#endif - // auto& ha = executor.hash_accessor; - - CHECK(m.get_cell_hash_slow(0) == 0); - - executor.update_cell_hash(); - - CHECK(m.get_cell_hash_slow(0) == 1); - } - SECTION("edge_region") - { - DEBUG_TriMesh m = edge_region(); - REQUIRE(m.is_connectivity_valid()); - - const Tuple edge = m.edge_tuple_between_v1_v2(3, 7, 5); - -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else - auto executor = m.get_tmoe(edge); -#endif - // auto& ha = executor.hash_accessor; - - CHECK(m.get_cell_hash_slow(0) == 0); - CHECK(m.get_cell_hash_slow(1) == 0); - CHECK(m.get_cell_hash_slow(2) == 0); - CHECK(m.get_cell_hash_slow(3) == 0); - CHECK(m.get_cell_hash_slow(4) == 0); - CHECK(m.get_cell_hash_slow(5) == 0); - CHECK(m.get_cell_hash_slow(6) == 0); - CHECK(m.get_cell_hash_slow(7) == 0); - CHECK(m.get_cell_hash_slow(8) == 0); - CHECK(m.get_cell_hash_slow(9) == 0); - - executor.update_cell_hash(); - - CHECK(m.get_cell_hash_slow(0) == 1); - CHECK(m.get_cell_hash_slow(1) == 1); - CHECK(m.get_cell_hash_slow(2) == 1); - CHECK(m.get_cell_hash_slow(3) == 0); - CHECK(m.get_cell_hash_slow(4) == 0); - CHECK(m.get_cell_hash_slow(5) == 1); - CHECK(m.get_cell_hash_slow(6) == 1); - CHECK(m.get_cell_hash_slow(7) == 1); - CHECK(m.get_cell_hash_slow(8) == 0); - CHECK(m.get_cell_hash_slow(9) == 0); - } -} -#endif //////////// SPLIT TESTS //////////// TEST_CASE("connect_faces_across_spine", "[operations][split][2D]") @@ -378,12 +283,7 @@ TEST_CASE("connect_faces_across_spine", "[operations][split][2D]") m.reserve_attributes(PF, 10); REQUIRE(m.is_connectivity_valid()); const Tuple edge = m.edge_tuple_between_v1_v2(1, 2, 0); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else auto executor = m.get_tmoe(edge); -#endif auto& incident_face_datas = executor.m_incident_face_datas; REQUIRE(executor.incident_face_datas().size() == 2); @@ -418,12 +318,7 @@ TEST_CASE("replace_incident_face", "[operations][split][2D]") DEBUG_TriMesh m = single_triangle(); REQUIRE(m.is_connectivity_valid()); Tuple edge = m.edge_tuple_between_v1_v2(1, 2, 0); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else auto executor = m.get_tmoe(edge); -#endif auto& incident_face_datas = executor.m_incident_face_datas; // create new vertex @@ -505,12 +400,7 @@ TEST_CASE("replace_incident_face", "[operations][split][2D]") DEBUG_TriMesh m = interior_edge(); REQUIRE(m.is_connectivity_valid()); Tuple edge = m.edge_tuple_between_v1_v2(1, 2, 0); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else auto executor = m.get_tmoe(edge); -#endif auto& incident_face_datas = executor.m_incident_face_datas; // create new vertex @@ -654,12 +544,7 @@ TEST_CASE("simplices_to_delete_for_split", "[operations][split][2D]") REQUIRE(m.is_connectivity_valid()); const Tuple edge = m.edge_tuple_between_v1_v2(1, 2, 0); const int64_t edge_id = m.id(edge, PE); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else auto executor = m.get_tmoe(edge); -#endif executor.split_edge(); @@ -696,12 +581,7 @@ TEST_CASE("simplices_to_delete_for_split", "[operations][split][2D]") REQUIRE(m.is_connectivity_valid()); const Tuple edge = m.edge_tuple_between_v1_v2(1, 2, 0); const int64_t edge_id = m.id(edge, PE); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); - auto executor = m.get_tmoe(edge, hash_accessor); -#else auto executor = m.get_tmoe(edge); -#endif executor.split_edge(); @@ -739,11 +619,7 @@ TEST_CASE("split_edge", "[operations][split][2D]") REQUIRE(m.is_connectivity_valid()); Tuple edge3 = m.edge_tuple_between_v1_v2(4, 7, 6); -#if defined(WMTK_ENABLE_HASH_UPDATE) - REQUIRE(m.is_valid_with_hash(edge3)); -#else REQUIRE(m.is_valid(edge3)); -#endif split(Simplex::edge(m, edge)); REQUIRE(m.is_connectivity_valid()); @@ -794,19 +670,12 @@ TEST_CASE("split_return_tuple", "[operations][split][2D]") REQUIRE(m.is_connectivity_valid()); const Tuple edge = m.edge_tuple_between_v1_v2(1, 2, 0); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); -#endif EdgeSplit split(m); auto res = split(Simplex::edge(m, edge)); REQUIRE(!res.empty()); const Tuple ret = res.front().tuple(); REQUIRE(m.is_connectivity_valid()); -#if defined(WMTK_ENABLE_HASH_UPDATE) - REQUIRE(m.is_valid_with_hash(ret, hash_accessor)); -#else REQUIRE(m.is_valid(ret)); -#endif CHECK(m.id(ret, PV) == 3); CHECK(m.id(m.switch_vertex(ret), PV) == 2); CHECK(m.id(ret, PF) == 2); @@ -817,19 +686,12 @@ TEST_CASE("split_return_tuple", "[operations][split][2D]") REQUIRE(m.is_connectivity_valid()); const Tuple edge = m.edge_tuple_between_v1_v2(2, 1, 0); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); -#endif EdgeSplit split(m); auto res = split(Simplex::edge(m, edge)); REQUIRE(!res.empty()); const Tuple ret = res.front().tuple(); REQUIRE(m.is_connectivity_valid()); -#if defined(WMTK_ENABLE_HASH_UPDATE) - REQUIRE(m.is_valid_with_hash(ret, hash_accessor)); -#else REQUIRE(m.is_valid(ret)); -#endif CHECK(m.id(ret, PV) == 3); CHECK(m.id(m.switch_vertex(ret), PV) == 1); CHECK(m.id(ret, PF) == 2); @@ -840,19 +702,12 @@ TEST_CASE("split_return_tuple", "[operations][split][2D]") REQUIRE(m.is_connectivity_valid()); const Tuple edge = m.edge_tuple_between_v1_v2(2, 1, 1); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); -#endif EdgeSplit split(m); auto res = split(Simplex::edge(m, edge)); REQUIRE(!res.empty()); const Tuple ret = res.front().tuple(); REQUIRE(m.is_connectivity_valid()); -#if defined(WMTK_ENABLE_HASH_UPDATE) - REQUIRE(m.is_valid_with_hash(ret, hash_accessor)); -#else REQUIRE(m.is_valid(ret)); -#endif CHECK(m.id(ret, PV) == 6); CHECK(m.id(m.switch_vertex(ret), PV) == 1); CHECK(m.id(m.switch_vertex(m.switch_edge(ret)), PV) == 0); @@ -864,19 +719,12 @@ TEST_CASE("split_return_tuple", "[operations][split][2D]") REQUIRE(m.is_connectivity_valid()); const Tuple edge = m.edge_tuple_between_v1_v2(2, 1, 3); -#if defined(WMTK_ENABLE_HASH_UPDATE) - wmtk::attribute::Accessor hash_accessor = m.get_cell_hash_accessor(); -#endif EdgeSplit split(m); auto res = split(Simplex::edge(m, edge)); REQUIRE(!res.empty()); const Tuple ret = res.front().tuple(); REQUIRE(m.is_connectivity_valid()); -#if defined(WMTK_ENABLE_HASH_UPDATE) - REQUIRE(m.is_valid_with_hash(ret, hash_accessor)); -#else REQUIRE(m.is_valid(ret)); -#endif CHECK(m.id(ret, PV) == 6); CHECK(m.id(m.switch_vertex(ret), PV) == 1); CHECK(m.id(m.switch_vertex(m.switch_edge(ret)), PV) == 5); @@ -909,11 +757,7 @@ TEST_CASE("split_multiple_edges", "[operations][split][2D]") for (size_t i = 0; i < 5; ++i) { const std::vector edges = mesh.get_all(PE); for (const wmtk::Tuple& e : edges) { -#if defined(WMTK_ENABLE_HASH_UPDATE) - if (!mesh.is_valid_with_hash(e)) { -#else if (!mesh.is_valid(e)) { -#endif continue; } diff --git a/tests/test_example_meshes.cpp b/tests/test_example_meshes.cpp index ef5de06b61..4bc832f291 100644 --- a/tests/test_example_meshes.cpp +++ b/tests/test_example_meshes.cpp @@ -358,12 +358,12 @@ TEST_CASE("test_debug_disk_trimesh") CHECK(n_boundary_vertices == 1); - Tuple v0e1(0, 1, -1, 0, 0); - Tuple v0e2(0, 2, -1, 0, 0); - Tuple v1e0(1, 0, -1, 0, 0); - Tuple v1e2(1, 2, -1, 0, 0); - Tuple v2e0(2, 0, -1, 0, 0); - Tuple v2e1(2, 1, -1, 0, 0); + Tuple v0e1(0, 1, -1, 0); + Tuple v0e2(0, 2, -1, 0); + Tuple v1e0(1, 0, -1, 0); + Tuple v1e2(1, 2, -1, 0); + Tuple v2e0(2, 0, -1, 0); + Tuple v2e1(2, 1, -1, 0); CHECK(m.switch_face(v0e1) == v0e2); From 88fa3c0d7ec8e340b9918261ce8a74418e1047f2 Mon Sep 17 00:00:00 2001 From: Michael Tao Date: Sat, 17 Aug 2024 17:55:11 -0400 Subject: [PATCH 4/6] removing usage of attributescopestack --- CMakeLists.txt | 8 ----- src/wmtk/attribute/Attribute.hpp | 20 ------------ src/wmtk/attribute/AttributeCache.hpp | 10 ------ src/wmtk/attribute/AttributeScope.hpp | 3 -- src/wmtk/attribute/AttributeScopeStack.hpp | 26 ---------------- src/wmtk/attribute/AttributeScopeStack.hxx | 10 ------ src/wmtk/attribute/CMakeLists.txt | 2 -- src/wmtk/attribute/CachingAccessor.hpp | 4 --- src/wmtk/attribute/CachingAccessor.hxx | 4 --- .../PerThreadAttributeScopeStacks.hpp | 31 ------------------- tests/attributes/compound_accessor.cpp | 1 - tests/attributes/test_accessor.cpp | 1 - tests/attributes/tuple_accessor.cpp | 1 - 13 files changed, 121 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d472a7c95d..23cc811b06 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,14 +125,6 @@ if(WMTK_USE_MONOTONIC_ATTRIBUTE_CACHE) endif() -option(WMTK_ENABLE_GENERIC_CHECKPOINTS "Enable checkpoint selection" OFF) -if(WMTK_ENABLE_GENERIC_CHECKPOINTS) - target_compile_definitions(wildmeshing_toolkit PRIVATE WMTK_ENABLE_GENERIC_CHECKPOINTS) -endif() -option(WMTK_ENABLE_MAP_CACHE "Enable checkpoint selection" ON) -if(WMTK_ENABLE_MAP_CACHE) - target_compile_definitions(wildmeshing_toolkit PUBLIC WMTK_ENABLE_MAP_CACHE) -endif() option(WMTK_ENABLE_TRANSACTION_STACK "Enable transaction stack" ON) if(WMTK_ENABLE_TRANSACTION_STACK) diff --git a/src/wmtk/attribute/Attribute.hpp b/src/wmtk/attribute/Attribute.hpp index 6b925b77db..670e54208d 100644 --- a/src/wmtk/attribute/Attribute.hpp +++ b/src/wmtk/attribute/Attribute.hpp @@ -17,8 +17,6 @@ class AccessorBase; template class PerThreadAttributeScopeStacks; -template -class AttributeScopeStack; namespace internal { template class AttributeMapCache; @@ -108,13 +106,8 @@ class Attribute : public wmtk::utils::Hashable void pop_scope(bool apply_updates); void rollback_current_scope(); -#if defined(WMTK_ENABLE_TRANSACTION_STACK) const internal::AttributeTransactionStack& get_local_scope_stack() const; internal::AttributeTransactionStack& get_local_scope_stack(); -#else - const AttributeScopeStack& get_local_scope_stack() const; - AttributeScopeStack& get_local_scope_stack(); -#endif /** * @brief Consolidate the vector, using the new2old map m provided and resizing the vector to @@ -345,7 +338,6 @@ inline const T& Attribute::default_value() const return m_default_value; } -#if defined(WMTK_ENABLE_TRANSACTION_STACK) template inline const internal::AttributeTransactionStack& Attribute::get_local_scope_stack() const { @@ -356,18 +348,6 @@ inline internal::AttributeTransactionStack& Attribute::get_local_scope_sta { return m_scope_stacks.local(); } -#else -template -inline const AttributeScopeStack& Attribute::get_local_scope_stack() const -{ - return m_scope_stacks.local(); -} -template -inline AttributeScopeStack& Attribute::get_local_scope_stack() -{ - return m_scope_stacks.local(); -} -#endif template inline void Attribute::push_scope() diff --git a/src/wmtk/attribute/AttributeCache.hpp b/src/wmtk/attribute/AttributeCache.hpp index d59a959351..4b467ccaed 100644 --- a/src/wmtk/attribute/AttributeCache.hpp +++ b/src/wmtk/attribute/AttributeCache.hpp @@ -1,13 +1,4 @@ #pragma once -#if defined(WMTK_ENABLE_MAP_CACHE) -#include "internal/AttributeMapCache.hpp" - -namespace wmtk::attribute { - - template - using AttributeCache = internal::AttributeMapCache; -} -#else #include "internal/AttributeFlatCache.hpp" namespace wmtk::attribute { @@ -15,4 +6,3 @@ namespace wmtk::attribute { template using AttributeCache = internal::AttributeFlatCache; } -#endif diff --git a/src/wmtk/attribute/AttributeScope.hpp b/src/wmtk/attribute/AttributeScope.hpp index a4fb5b5904..c939574cbf 100644 --- a/src/wmtk/attribute/AttributeScope.hpp +++ b/src/wmtk/attribute/AttributeScope.hpp @@ -9,8 +9,6 @@ namespace wmtk { namespace attribute { -template -class AttributeScopeStack; template class CachingAccessor; @@ -20,7 +18,6 @@ class AttributeScope : public AttributeCache public: template friend class CachingAccessor; - friend class AttributeScopeStack; AttributeScope(); AttributeScope(const AttributeScope&) = delete; AttributeScope& operator=(const AttributeScope&) = delete; diff --git a/src/wmtk/attribute/AttributeScopeStack.hpp b/src/wmtk/attribute/AttributeScopeStack.hpp index 630c6f99b6..2914bb9d43 100644 --- a/src/wmtk/attribute/AttributeScopeStack.hpp +++ b/src/wmtk/attribute/AttributeScopeStack.hpp @@ -17,8 +17,6 @@ template class AttributeScope; class AttributeManager; -#define WMTK_ATTRIBUTE_SCOPE_STACK_CACHE_ACTIVE -// #define WMTK_USE_MAP_CACHE_ITERATOR /** * A stack of changes applied to an Attribute. * The stack consists of AttributeScopes which hold all changes applied inside one scope. Whenever a @@ -97,9 +95,7 @@ class AttributeScopeStack std::vector> m_scopes; typename std::vector>::const_iterator m_active; // typename std::vector>::iterator m_back; -#if defined(WMTK_ATTRIBUTE_SCOPE_STACK_CACHE_ACTIVE) bool m_at_current_scope = true; -#endif // Mesh& m_mesh; // AttributeManager& m_attribute_manager; // MeshAttributeHandle m_handle; @@ -154,27 +150,6 @@ inline auto AttributeScopeStack::const_vector_attribute( assert(m_active >= m_scopes.begin()); assert(m_active < m_scopes.end()); for (auto it = m_active; it < m_scopes.end(); ++it) { -#if defined(WMTK_USE_MAP_CACHE_ITERATOR) -#if defined(WMTK_ENABLE_MAP_CACHE) - if (auto mapit = it->find_value(index); it->is_value(mapit)) { - const auto& d = mapit->second; - auto dat = d.template data_as_const_map(); - return dat; - } -#else - - const auto& indices = it->indices(); - for (auto iit = indices.crbegin(); iit != indices.crend(); ++iit) { - const auto& [global, local] = *iit; - if (global == index) { - const int dim = accessor.dimension(); - auto dat = ConstMapResult(it->buffer().data() + dim * local, dim); - return dat; - } - } - -#endif -#else const int dim = accessor.dimension(); const auto ptr = it->get_value(index, dim); if (ptr != nullptr) { @@ -182,7 +157,6 @@ inline auto AttributeScopeStack::const_vector_attribute( return dat; } -#endif } } return accessor.template const_vector_attribute(index); diff --git a/src/wmtk/attribute/AttributeScopeStack.hxx b/src/wmtk/attribute/AttributeScopeStack.hxx index 55fa417397..6a2fbed556 100644 --- a/src/wmtk/attribute/AttributeScopeStack.hxx +++ b/src/wmtk/attribute/AttributeScopeStack.hxx @@ -88,9 +88,7 @@ inline void AttributeScopeStack::change_to_previous_scope() } else { m_active++; } -#if defined(WMTK_ATTRIBUTE_SCOPE_STACK_CACHE_ACTIVE) m_at_current_scope = (m_active == m_scopes.end()); -#endif } template @@ -100,9 +98,7 @@ inline void AttributeScopeStack::change_to_next_scope() assert(!empty()); assert(m_active == m_scopes.end()); // just making sure the definition doesn't change as // this should be m_scopes.end()-1 -#if defined(WMTK_ATTRIBUTE_SCOPE_STACK_CACHE_ACTIVE) m_at_current_scope = false; -#endif m_active--; } else { m_active--; @@ -111,21 +107,15 @@ inline void AttributeScopeStack::change_to_next_scope() template inline void AttributeScopeStack::change_to_current_scope() { -#if defined(WMTK_ATTRIBUTE_SCOPE_STACK_CACHE_ACTIVE) m_at_current_scope = true; -#endif // m_back = m_scopes.end()-1; m_active = m_scopes.end(); } template inline bool AttributeScopeStack::at_current_scope() const { -#if defined(WMTK_ATTRIBUTE_SCOPE_STACK_CACHE_ACTIVE) assert(m_at_current_scope == (m_active == m_scopes.end())); return m_at_current_scope; -#else - return m_active == m_scopes.end(); -#endif } template inline bool AttributeScopeStack::writing_enabled() const diff --git a/src/wmtk/attribute/CMakeLists.txt b/src/wmtk/attribute/CMakeLists.txt index 0757bfbba2..e2e22c6ba2 100644 --- a/src/wmtk/attribute/CMakeLists.txt +++ b/src/wmtk/attribute/CMakeLists.txt @@ -8,8 +8,6 @@ set(SRC_FILES AttributeScope.hxx MeshAttributes.cpp MeshAttributes.hpp - AttributeScopeStack.hpp - AttributeScopeStack.hxx AttributeManager.hpp AttributeManager.cpp PerThreadAttributeScopeStacks.hpp diff --git a/src/wmtk/attribute/CachingAccessor.hpp b/src/wmtk/attribute/CachingAccessor.hpp index 972c19f058..95c65a1084 100644 --- a/src/wmtk/attribute/CachingAccessor.hpp +++ b/src/wmtk/attribute/CachingAccessor.hpp @@ -87,11 +87,7 @@ class CachingAccessor : public AccessorBase const BaseType& base_type() const { return *this; } private: -#if defined(WMTK_ENABLE_TRANSACTION_STACK) internal::AttributeTransactionStack& m_cache_stack; -#else - AttributeScopeStack& m_cache_stack; -#endif }; } // namespace wmtk::attribute #include "CachingAccessor.hxx" diff --git a/src/wmtk/attribute/CachingAccessor.hxx b/src/wmtk/attribute/CachingAccessor.hxx index cab3ae3e4c..562ac248bb 100644 --- a/src/wmtk/attribute/CachingAccessor.hxx +++ b/src/wmtk/attribute/CachingAccessor.hxx @@ -2,11 +2,7 @@ #include #include "AttributeScope.hpp" -#if defined(WMTK_ENABLE_TRANSACTION_STACK) #include "internal/AttributeTransactionStack.hpp" -#else -#include "AttributeScopeStack.hpp" -#endif #include "CachingAccessor.hpp" namespace wmtk::attribute { diff --git a/src/wmtk/attribute/PerThreadAttributeScopeStacks.hpp b/src/wmtk/attribute/PerThreadAttributeScopeStacks.hpp index d8a636902f..a91425b80a 100644 --- a/src/wmtk/attribute/PerThreadAttributeScopeStacks.hpp +++ b/src/wmtk/attribute/PerThreadAttributeScopeStacks.hpp @@ -1,7 +1,6 @@ #pragma once -#if defined(WMTK_ENABLE_TRANSACTION_STACK) #include "internal/AttributeTransactionStack.hpp" namespace wmtk::attribute { template @@ -30,34 +29,4 @@ inline const internal::AttributeTransactionStack& PerThreadAttributeScopeStac { return m_stack; } -#else -#include "AttributeScopeStack.hpp" -namespace wmtk::attribute { -template -class PerThreadAttributeScopeStacks -{ -public: - PerThreadAttributeScopeStacks() = default; - PerThreadAttributeScopeStacks(PerThreadAttributeScopeStacks&&) = default; - PerThreadAttributeScopeStacks& operator=(PerThreadAttributeScopeStacks&&) = default; - AttributeScopeStack& local(); - const AttributeScopeStack& local() const; - -private: - // single stack so far - mutable AttributeScopeStack m_stack; -}; - - -template -inline AttributeScopeStack& PerThreadAttributeScopeStacks::local() -{ - return m_stack; -} -template -inline const AttributeScopeStack& PerThreadAttributeScopeStacks::local() const -{ - return m_stack; -} -#endif } // namespace wmtk::attribute diff --git a/tests/attributes/compound_accessor.cpp b/tests/attributes/compound_accessor.cpp index 0a19df35f2..017faee620 100644 --- a/tests/attributes/compound_accessor.cpp +++ b/tests/attributes/compound_accessor.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include diff --git a/tests/attributes/test_accessor.cpp b/tests/attributes/test_accessor.cpp index cf7a7314cf..a02980aceb 100644 --- a/tests/attributes/test_accessor.cpp +++ b/tests/attributes/test_accessor.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include "../tools/DEBUG_PointMesh.hpp" #include "../tools/DEBUG_TriMesh.hpp" diff --git a/tests/attributes/tuple_accessor.cpp b/tests/attributes/tuple_accessor.cpp index ef25d3db93..081b83afd7 100644 --- a/tests/attributes/tuple_accessor.cpp +++ b/tests/attributes/tuple_accessor.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include From 5d397a67e5fed982f85c2978138fd145add42b63 Mon Sep 17 00:00:00 2001 From: Michael Tao Date: Sat, 17 Aug 2024 17:55:30 -0400 Subject: [PATCH 5/6] removing unused scope stack code --- src/wmtk/attribute/AttributeScopeStack.hpp | 202 --------------------- src/wmtk/attribute/AttributeScopeStack.hxx | 126 ------------- 2 files changed, 328 deletions(-) delete mode 100644 src/wmtk/attribute/AttributeScopeStack.hpp delete mode 100644 src/wmtk/attribute/AttributeScopeStack.hxx diff --git a/src/wmtk/attribute/AttributeScopeStack.hpp b/src/wmtk/attribute/AttributeScopeStack.hpp deleted file mode 100644 index 2914bb9d43..0000000000 --- a/src/wmtk/attribute/AttributeScopeStack.hpp +++ /dev/null @@ -1,202 +0,0 @@ -#pragma once -#include -#include -#include -#include "AttributeCache.hpp" -#include "AttributeHandle.hpp" -#include "internal/MapTypes.hpp" - -namespace wmtk { -class Mesh; -namespace attribute { -template -class Attribute; -template -class AccessorBase; -template -class AttributeScope; -class AttributeManager; - -/** - * A stack of changes applied to an Attribute. - * The stack consists of AttributeScopes which hold all changes applied inside one scope. Whenever a - * new scope is created, it is pushed to the stack. As soon as an AttributeScopeHandle is - * destructed, `push_scope` of all Attributes is triggered. - */ -template -class AttributeScopeStack -{ -public: - template - using MapResult = internal::MapResult; - template - using ConstMapResult = internal::ConstMapResult; - // stack is implemented by a parent pointing graph, so we track a pointer - // to the leaf - AttributeScopeStack(); - ~AttributeScopeStack(); - AttributeScopeStack(const AttributeScopeStack&) = delete; - AttributeScopeStack& operator=(const AttributeScopeStack&) = delete; - AttributeScopeStack(AttributeScopeStack&&) = default; - AttributeScopeStack& operator=(AttributeScopeStack&&) = default; - - bool empty() const; - int64_t size() const; - - - bool writing_enabled() const; - - - /// default mutable vector access - template - MapResult vector_attribute(AccessorBase& accessor, int64_t index); - /// default immutable vector access - - template - ConstMapResult const_vector_attribute(const AccessorBase& accessor, int64_t index) - const; - /// default mutable scalar access - template - T& scalar_attribute(AccessorBase& accessor, int64_t index); - - /// default immutable scalar access - template - T const_scalar_attribute(const AccessorBase& accessor, int64_t index) const; - - template - /// specialized immutable scalar access useful for topological operations - T const_scalar_attribute(const AccessorBase& accessor, int64_t index, int8_t offset) - const; - - void emplace(); - void pop(Attribute& attribute, bool preserve_changes); - // go to the next most historic scope - void change_to_next_scope(); - void change_to_previous_scope(); - // go to the scope with active data - void change_to_current_scope(); - void rollback_current_scope(Attribute& attr); - - /// checks that we are viewing the active state of the attribute - bool at_current_scope() const; - /// applies the diffs from the last scope to the current attribute -private: - void apply_last_scope(Attribute& attr); - /// apply a particular scope to the current attribute - void apply_scope(const AttributeScope& scope, Attribute& attr); - /// apply a particular scope to a piece of data - void apply_scope(const AttributeScope& scope, const Attribute& attr, std::vector& data) - const; - - - // current scope is - -protected: - std::vector> m_scopes; - typename std::vector>::const_iterator m_active; - // typename std::vector>::iterator m_back; - bool m_at_current_scope = true; - // Mesh& m_mesh; - // AttributeManager& m_attribute_manager; - // MeshAttributeHandle m_handle; -}; -template -inline int64_t AttributeScopeStack::size() const -{ - return m_scopes.size(); -} - -template -inline void AttributeScopeStack::rollback_current_scope(Attribute& attr) -{ - assert(!empty()); - assert(at_current_scope()); - apply_last_scope(attr); -} - -template -template -inline auto AttributeScopeStack::vector_attribute(AccessorBase& accessor, int64_t index) - -> MapResult -{ - assert(writing_enabled()); - - static_assert(D == Eigen::Dynamic || D2 == Eigen::Dynamic || D == D2); - auto data = accessor.template vector_attribute(index); - assert(data.cols() == 1); - if constexpr (D != Eigen::Dynamic) { - assert(data.size() == D); - } - if constexpr (D2 != Eigen::Dynamic) { - assert(data.size() == D2); - } - // we are typically only going to write when caching is enabled so better to optimize for this - if (!empty()) [[unlikely]] { - // assert(m_scopes.back() == *m_back); - m_scopes.back().try_caching(index, data); - // m_back->try_caching(index,data); - } - return data; -} - -template -template -inline auto AttributeScopeStack::const_vector_attribute( - const AccessorBase& accessor, - int64_t index) const -> ConstMapResult -{ - static_assert(D == Eigen::Dynamic || D2 == Eigen::Dynamic || D == D2); - if (!at_current_scope()) [[unlikely]] { - assert(m_active >= m_scopes.begin()); - assert(m_active < m_scopes.end()); - for (auto it = m_active; it < m_scopes.end(); ++it) { - const int dim = accessor.dimension(); - const auto ptr = it->get_value(index, dim); - if (ptr != nullptr) { - auto dat = ConstMapResult(ptr, dim); - return dat; - } - - } - } - return accessor.template const_vector_attribute(index); -} - -template -template -inline auto AttributeScopeStack::scalar_attribute(AccessorBase& accessor, int64_t index) - -> T& -{ - assert(writing_enabled()); - T& value = accessor.scalar_attribute(index); - if (!empty()) { - m_scopes.back().try_caching(index, value); - // m_active->try_caching(index, value); - } - return value; -} - -template -template -inline auto AttributeScopeStack::const_scalar_attribute( - const AccessorBase& accessor, - int64_t index) const -> T -{ - return const_vector_attribute<1>(accessor, index)(0); -} -template -template -inline auto AttributeScopeStack::const_scalar_attribute( - const AccessorBase& accessor, - int64_t index, - int8_t offset) const -> T -{ - if (!at_current_scope()) { - return const_vector_attribute(accessor, index)(offset); - } else { - return accessor.const_scalar_attribute(index, offset); - } -} -} // namespace attribute -} // namespace wmtk -#include "AttributeScopeStack.hxx" diff --git a/src/wmtk/attribute/AttributeScopeStack.hxx b/src/wmtk/attribute/AttributeScopeStack.hxx deleted file mode 100644 index 6a2fbed556..0000000000 --- a/src/wmtk/attribute/AttributeScopeStack.hxx +++ /dev/null @@ -1,126 +0,0 @@ -#include -#include "Attribute.hpp" -#include "AttributeScope.hpp" -#include "AttributeScopeStack.hpp" - -namespace wmtk::attribute { - -template -inline AttributeScopeStack::AttributeScopeStack() -{ - // a random value that's more than 2ish - m_scopes.reserve(5); - m_active = m_scopes.end(); -} -template -inline AttributeScopeStack::~AttributeScopeStack() = default; -template -inline void AttributeScopeStack::emplace() -{ - assert(at_current_scope()); // must only be called on leaf node - - // create a new leaf that points to the active stack and - // - if (m_scopes.size() + 1 >= m_scopes.capacity()) { - m_scopes.reserve(m_scopes.capacity() + 3); - change_to_current_scope(); - } - m_scopes.emplace_back(); - change_to_current_scope(); -} -template -inline void AttributeScopeStack::pop(Attribute& attribute, bool preserve_changes) -{ - assert(at_current_scope()); // must only be called on leaf node - if (!preserve_changes) { - // rollback_current_scope(attribute); - } - - - if (m_scopes.size() >= 2) { - auto it = m_scopes.rbegin(); - auto it2 = it + 1; - it->apply_to(*it2); - } - m_scopes.pop_back(); - - change_to_current_scope(); -} - - -template -inline bool AttributeScopeStack::empty() const -{ - return m_scopes.empty(); -} - - -template -inline void AttributeScopeStack::apply_last_scope(Attribute& attr) -{ - assert(at_current_scope()); - assert(!empty()); - apply_scope(m_scopes.back(), attr); -} -template -inline void AttributeScopeStack::apply_scope(const AttributeScope& scope, Attribute& attr) -{ - scope.apply(attr); -} -template -inline void AttributeScopeStack::apply_scope( - const AttributeScope& scope, - const Attribute& attr, - std::vector& data) const -{ - assert(false); - // scope.apply(attr, data); -} - - -template -inline void AttributeScopeStack::change_to_previous_scope() -{ - // if the previous is a nullptr it's fine - assert(!at_current_scope()); - if (m_active == m_scopes.end()) { - change_to_current_scope(); - } else { - m_active++; - } - m_at_current_scope = (m_active == m_scopes.end()); -} - -template -inline void AttributeScopeStack::change_to_next_scope() -{ - if (at_current_scope()) { - assert(!empty()); - assert(m_active == m_scopes.end()); // just making sure the definition doesn't change as - // this should be m_scopes.end()-1 - m_at_current_scope = false; - m_active--; - } else { - m_active--; - } -} -template -inline void AttributeScopeStack::change_to_current_scope() -{ - m_at_current_scope = true; - // m_back = m_scopes.end()-1; - m_active = m_scopes.end(); -} -template -inline bool AttributeScopeStack::at_current_scope() const -{ - assert(m_at_current_scope == (m_active == m_scopes.end())); - return m_at_current_scope; -} -template -inline bool AttributeScopeStack::writing_enabled() const -{ - return at_current_scope(); -} - -} // namespace wmtk::attribute From 32e7437163e1bc8bbadd1fe0e62b7bea19994d27 Mon Sep 17 00:00:00 2001 From: Michael Tao Date: Sat, 17 Aug 2024 18:22:08 -0400 Subject: [PATCH 6/6] deleting map cache, including a unit test comparing int ot flat cache --- CMakeLists.txt | 8 -- src/wmtk/attribute/Accessor.hpp | 1 - src/wmtk/attribute/Attribute.hpp | 3 - src/wmtk/attribute/CachingAccessor.hpp | 5 - .../attribute/internal/AttributeMapCache.hpp | 78 ---------- .../attribute/internal/AttributeMapCache.hxx | 107 -------------- src/wmtk/attribute/internal/CMakeLists.txt | 2 - tests/attributes/CMakeLists.txt | 1 - tests/attributes/caches.cpp | 136 ------------------ 9 files changed, 341 deletions(-) delete mode 100644 src/wmtk/attribute/internal/AttributeMapCache.hpp delete mode 100644 src/wmtk/attribute/internal/AttributeMapCache.hxx delete mode 100644 tests/attributes/caches.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 23cc811b06..5aa798a5dd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,17 +119,9 @@ target_compile_definitions(wildmeshing_toolkit PUBLIC WMTK_MAX_ATTRIBUTE_DIMENSI -option(WMTK_USE_MONOTONIC_ATTRIBUTE_CACHE "Use monotonic allocator to store the cache buffer" OFF) -if(WMTK_USE_MONOTONIC_ATTRIBUTE_CACHE) - target_compile_definitions(wildmeshing_toolkit PRIVATE WMTK_USE_MONOTONIC_ATTRIBUTE_CACHE) -endif() -option(WMTK_ENABLE_TRANSACTION_STACK "Enable transaction stack" ON) -if(WMTK_ENABLE_TRANSACTION_STACK) - target_compile_definitions(wildmeshing_toolkit PUBLIC WMTK_ENABLE_TRANSACTION_STACK) -endif() diff --git a/src/wmtk/attribute/Accessor.hpp b/src/wmtk/attribute/Accessor.hpp index 706ae9f812..9b395c3579 100644 --- a/src/wmtk/attribute/Accessor.hpp +++ b/src/wmtk/attribute/Accessor.hpp @@ -30,7 +30,6 @@ class Accessor : protected CachingAccessor friend class wmtk::PointMesh; using Scalar = T; - friend class internal::AttributeMapCache; using BaseType = AccessorBase; using CachingBaseType = CachingAccessor; diff --git a/src/wmtk/attribute/Attribute.hpp b/src/wmtk/attribute/Attribute.hpp index 670e54208d..920a3df8d7 100644 --- a/src/wmtk/attribute/Attribute.hpp +++ b/src/wmtk/attribute/Attribute.hpp @@ -19,8 +19,6 @@ template class PerThreadAttributeScopeStacks; namespace internal { template -class AttributeMapCache; -template class AttributeTransactionStack; } // namespace internal @@ -46,7 +44,6 @@ class Attribute : public wmtk::utils::Hashable template friend class AccessorBase; - friend class internal::AttributeMapCache; friend class internal::AttributeTransactionStack; void serialize(const std::string& name, const int dim, MeshWriter& writer) const; diff --git a/src/wmtk/attribute/CachingAccessor.hpp b/src/wmtk/attribute/CachingAccessor.hpp index 95c65a1084..a01e3a90e9 100644 --- a/src/wmtk/attribute/CachingAccessor.hpp +++ b/src/wmtk/attribute/CachingAccessor.hpp @@ -10,10 +10,6 @@ class TriMesh; } // namespace wmtk namespace wmtk::attribute { -namespace internal { -template -class AttributeMapCache; -} /** * An accessor for cached attribute values. This accessor or any of its derivatives should be used @@ -28,7 +24,6 @@ class CachingAccessor : public AccessorBase friend class wmtk::TriMesh; using Scalar = T; - friend class internal::AttributeMapCache; using BaseType = AccessorBase; template diff --git a/src/wmtk/attribute/internal/AttributeMapCache.hpp b/src/wmtk/attribute/internal/AttributeMapCache.hpp deleted file mode 100644 index 10b2e39f99..0000000000 --- a/src/wmtk/attribute/internal/AttributeMapCache.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once -#include -#include -#include -#include "AttributeCacheData.hpp" -#include "MapTypes.hpp" - -#if defined(WMTK_USE_MONOTONIC_ATTRIBUTE_CACHE) -#include -#endif - - -namespace wmtk::attribute { -template -class Attribute; -template -class AccessorBase; -namespace internal { -template -class AttributeMapCache -{ -public: - using Data = AttributeCacheData; - using DataStorage = std::map< - int64_t, - Data, - std::less -#if defined(WMTK_USE_MONOTONIC_ATTRIBUTE_CACHE) - , - std::pmr::polymorphic_allocator> -#endif - >; - - using MapResult = internal::MapResult; - using ConstMapResult = internal::ConstMapResult; - - - AttributeMapCache(); - ~AttributeMapCache(); - AttributeMapCache(const AttributeMapCache&) = delete; - AttributeMapCache& operator=(const AttributeMapCache&) = delete; - AttributeMapCache(AttributeMapCache&&) = default; - AttributeMapCache& operator=(AttributeMapCache&&) = default; - - - template - void try_caching(int64_t index, const Eigen::MatrixBase& value); - void try_caching(int64_t index, const T& value); - - - typename DataStorage::const_iterator find_value(int64_t index) const; - bool is_value(const typename DataStorage::const_iterator& it) const; - const T* get_value(int64_t index, size_t dim) const; - - void clear(); - size_t size() const { return m_data.size(); } - - void apply_to(Attribute& attribute) const; - void apply_to(AttributeMapCache& other) const; - - // applyes to some other buffer that was passed in - void apply_to(const Attribute& attribute, std::vector& other) const; - - - const DataStorage& data() const { return m_data; } - -protected: -#if defined(WMTK_USE_MONOTONIC_ATTRIBUTE_CACHE) - std::vector m_buffer; - std::pmr::monotonic_buffer_resource m_resource; -#endif - DataStorage m_data; -}; - -} // namespace internal -} // namespace wmtk::attribute - -#include "AttributeMapCache.hxx" diff --git a/src/wmtk/attribute/internal/AttributeMapCache.hxx b/src/wmtk/attribute/internal/AttributeMapCache.hxx deleted file mode 100644 index 85ead67fec..0000000000 --- a/src/wmtk/attribute/internal/AttributeMapCache.hxx +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include -#include -#include "AttributeMapCache.hpp" - -namespace wmtk::attribute::internal { - - -template -inline AttributeMapCache::AttributeMapCache() -#if defined(WMTK_USE_MONOTONIC_ATTRIBUTE_CACHE) - : m_buffer(32 * sizeof(typename DataStorage::value_type)) - , m_resource(m_buffer.data(), m_buffer.size()) - , m_data(std::pmr::polymorphic_allocator>{&m_resource}) -#endif -{} //: m_data({m_resource}) {} -template -inline AttributeMapCache::~AttributeMapCache() = default; - -template -inline auto AttributeMapCache::find_value(int64_t index) const -> - typename DataStorage::const_iterator -{ - return m_data.find(index); -} -template -inline bool AttributeMapCache::is_value(const typename DataStorage::const_iterator& it) const -{ - return it != m_data.end(); -} - -template -inline auto AttributeMapCache::get_value(int64_t index, size_t) const -> const T* -{ - if (auto mapit = find_value(index); is_value(mapit)) { - const auto& d = mapit->second; - return d.data.data(); - } - return nullptr; -} - - -template -inline void AttributeMapCache::clear() -{ - m_data.clear(); -} - - -template -template -inline void AttributeMapCache::try_caching( - int64_t index, - const Eigen::MatrixBase& value) -{ - // basically try_emplace but optimizes to avoid accessing the pointed-to value - auto [it, did_insert] = m_data.try_emplace(index, AttributeCacheData{}); - if (did_insert) { - it->second.data = value; - } -} - -template -inline void AttributeMapCache::try_caching(int64_t index, const T& value) -{ - // basically try_emplace but optimizes to avoid accessing the pointed-to value - auto [it, did_insert] = m_data.try_emplace(index, AttributeCacheData{}); - if (did_insert) { - it->second.data = VectorX::Constant(1, value); - } -} - - -template -inline void AttributeMapCache::apply_to(Attribute& attribute) const -{ - for (const auto& [index, data] : m_data) { - { - auto a = attribute.vector_attribute(index); - auto b = data.data; - a = b; - } - } -} -template -inline void AttributeMapCache::apply_to(AttributeMapCache& other) const -{ - auto& o_data = other.m_data; - - for (const auto& [index, data] : m_data) { - { - if (o_data.find(index) == o_data.end()) { - o_data[index] = data; - } - } - } -} - -template -inline void AttributeMapCache::apply_to(const Attribute& attribute, std::vector& other) - const -{ - for (auto& [index, data] : m_data) { - attribute.vector_attribute(index, other) = data.data; - } -} -} // namespace wmtk::attribute::internal diff --git a/src/wmtk/attribute/internal/CMakeLists.txt b/src/wmtk/attribute/internal/CMakeLists.txt index 8d1ebe9b50..22900988ff 100644 --- a/src/wmtk/attribute/internal/CMakeLists.txt +++ b/src/wmtk/attribute/internal/CMakeLists.txt @@ -3,8 +3,6 @@ set(SRC_FILES hash.cpp AttributeCacheData.hpp AttributeCacheData.hxx - AttributeMapCache.hxx - AttributeMapCache.hpp AttributeTransactionStack.hxx AttributeTransactionStack.hpp ) diff --git a/tests/attributes/CMakeLists.txt b/tests/attributes/CMakeLists.txt index 50c6990126..f4f0cacb21 100644 --- a/tests/attributes/CMakeLists.txt +++ b/tests/attributes/CMakeLists.txt @@ -6,7 +6,6 @@ set(TEST_SOURCES hybrid_rational_accessor.cpp performance.cpp - caches.cpp old_wmtk_attributecollection.cpp transaction_stack.cpp diff --git a/tests/attributes/caches.cpp b/tests/attributes/caches.cpp deleted file mode 100644 index 0396d0ff41..0000000000 --- a/tests/attributes/caches.cpp +++ /dev/null @@ -1,136 +0,0 @@ - -#include -#include -//#include - -#include -#include -#include -#include -#include - -#include - -TEST_CASE("attribute_map_cache", "[attributes]") -{ - wmtk::attribute::Attribute vector("vector", 2, 0, 10); - - - wmtk::attribute::Attribute scalar("scalar", 1, 0, 10); - - wmtk::attribute::internal::AttributeMapCache map_cache; - wmtk::attribute::internal::AttributeFlatCache flat_cache; - - - wmtk::attribute::internal::AttributeMapCache child_map_cache; - wmtk::attribute::internal::AttributeFlatCache child_flat_cache; - - - std::vector map_data(10, 0); - std::vector flat_data(10, 0); - - auto clean = [&]() { - std::fill(map_data.begin(), map_data.end(), 0); - std::fill(flat_data.begin(), flat_data.end(), 0); - map_cache.clear(); - flat_cache.clear(); - child_map_cache.clear(); - child_flat_cache.clear(); - }; - - auto cache = [&](int64_t index, const auto& value, bool child = false) { - if (child) { - child_map_cache.try_caching(index, value); - child_flat_cache.try_caching(index, value); - } else { - map_cache.try_caching(index, value); - flat_cache.try_caching(index, value); - } - }; - - auto apply_and_check = [&](const auto& attr) { - map_cache.apply_to(attr, map_data); - flat_cache.apply_to(attr, flat_data); - spdlog::warn("Map: {}", fmt::join(map_data, ",")); - spdlog::warn("Flat: {}", fmt::join(flat_data, ",")); - CHECK(map_data == flat_data); - }; - - auto apply_child_and_check = [&](const auto& attr) { - child_map_cache.apply_to(map_cache); - child_flat_cache.apply_to(flat_cache); - apply_and_check(attr); - }; - - - // try caching some individual values - cache(3, 2); - cache(4, 1); - - // write to a vector to make sure they store the same data - apply_and_check(scalar); - cache(4, 0); - // try adding one more value that overwrites another - apply_and_check(scalar); - - // reset so we can do vector-based experiments - clean(); - - // try writing a few values - cache(2, Eigen::Matrix::Constant(10)); - apply_and_check(vector); - cache(1, Eigen::Matrix::Constant(3)); - apply_and_check(vector); - cache(0, Eigen::Matrix::Constant(3)); - apply_and_check(vector); - - // overwrite an existing value - cache(1, Eigen::Matrix::Constant(2)); - apply_and_check(vector); - - - // cache to the "child cache" - cache(1, Eigen::Matrix::Constant(-3), true); - cache(2, Eigen::Matrix::Constant(4), true); - cache(3, Eigen::Matrix::Constant(-2), true); - cache(3, Eigen::Matrix::Constant(2), true); - cache(1, Eigen::Matrix::Constant(4), true); - - // map the child to the parent, then the parent to the vector data - apply_child_and_check(vector); - - spdlog::info("Flat child buffer: {}", fmt::join(child_flat_cache.buffer(),",")); - spdlog::info("Flat child indices: {}", fmt::join(child_flat_cache.indices(),",")); - for (int j = 0; j < 5; ++j) { - const int64_t* a = child_map_cache.get_value(j,2); - const int64_t* b = child_flat_cache.get_value(j,2); - if(a == nullptr || b == nullptr) { - REQUIRE(a == nullptr); - REQUIRE(b == nullptr); - continue; - } - std::cout << j << ": " << *a << std::endl; - CHECK(*a == *b); - - - // TODO: test get_value function - } - spdlog::info("Flat buffer: {}", fmt::join(flat_cache.buffer(),",")); - spdlog::info("Flat indices: {}", fmt::join(flat_cache.buffer(),",")); - - for (int j = 0; j < 5; ++j) { - const int64_t* a = map_cache.get_value(j,2); - const int64_t* b = flat_cache.get_value(j,2); - if(a == nullptr || b == nullptr) { - REQUIRE(a == nullptr); - REQUIRE(b == nullptr); - continue; - } - std::cout << j << ": " << *a << std::endl; - CHECK(*a == *b); - - - // TODO: test get_value function - } -} -