Wildmeshing Toolkit
Loading...
Searching...
No Matches
Mesh.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
4
5#include <initializer_list>
6
7#include <memory>
8#include <tuple>
9// just includes function prorotypes to befriend
10//#include <wmtk/multimesh/utils/extract_child_mesh_from_tag.hpp>
11
12
13// need to return this header
15
16// is a member of the Mesh class
17#include "MultiMeshManager.hpp"
18
19// basic data for the class
21#include "Tuple.hpp"
22#include "Types.hpp"
24#include "attribute/AttributeScopeHandle.hpp"
29
31
32#include "simplex/IdSimplex.hpp"
35
36
37// if we have concepts then switch_tuples uses forward_iterator concept
38#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
39#include <ranges>
40#endif
41
42
43namespace wmtk {
44namespace tests {
45class DEBUG_Mesh;
46} // namespace tests
47// thread management tool that we will PImpl
48namespace attribute {
49class AttributeManager;
50template <typename T, typename MeshType, int Dim>
51class Accessor;
52
53} // namespace attribute
54namespace operations {
55class Operation;
56class EdgeCollapse;
57class EdgeSplit;
58class EdgeOperationData;
59namespace internal {
61}
62namespace utils {
63class UpdateEdgeOperationMultiMeshMapFunctor;
64}
65} // namespace operations
66
67namespace io {
68class ParaviewWriter;
69}
70namespace multimesh {
71template <int64_t cell_dimension, typename NodeFunctor>
73template <typename NodeFunctor>
75template <typename Visitor>
77template <typename Visitor>
79
80namespace utils {
81class MapValidator;
82namespace internal {
83class TupleTag;
84}
85} // namespace utils
86} // namespace multimesh
87
88
89// NOTE: the implementation of this class is split into several files to improve clang-format
90// performance
91// * Mesh.cpp
92// * Mesh_attributes.cpp
93// * Mesh_construction.cpp
94class Mesh : public std::enable_shared_from_this<Mesh>, public wmtk::utils::MerkleTreeInteriorNode
95{
96public:
97 friend class tests::DEBUG_Mesh;
98 template <typename T, int Dim>
100 template <typename T, typename MeshType, int Dim>
102 friend class io::ParaviewWriter;
103 friend class HDF5Reader;
107 template <int64_t cell_dimension, typename NodeFunctor>
109 template <typename Visitor>
111 template <typename NodeFunctor>
114 template <typename Visitor>
124
125
126 int64_t top_cell_dimension() const;
128 bool is_free() const;
129
130 // attribute directly hashes its "children" components so it overrides "child_hashes"
131 std::map<std::string, const wmtk::utils::Hashable*> child_hashables() const override;
132 std::map<std::string, std::size_t> child_hashes() const override;
133
134 // dimension is the dimension of the top level simplex in this mesh
135 // That is, a TriMesh is a 2, a TetMesh is a 3
136 Mesh(const int64_t& dimension);
137 // maximum primitive type id for supported attribute primitive locations
138 Mesh(const int64_t& dimension, const int64_t& max_primitive_type_id, PrimitiveType hash_type);
139 Mesh(Mesh&& other);
140 Mesh(const Mesh& other) = delete;
141 Mesh& operator=(const Mesh& other) = delete;
142 Mesh& operator=(Mesh&& other);
143 virtual ~Mesh();
144
145 void serialize(MeshWriter& writer, const Mesh* local_root = nullptr) const;
146
152 std::vector<Tuple> get_all(PrimitiveType type) const;
153
154 std::vector<simplex::IdSimplex> get_all_id_simplex(PrimitiveType type) const;
159
161
166
168
173 virtual std::tuple<std::vector<std::vector<int64_t>>, std::vector<std::vector<int64_t>>>
174 consolidate();
175
181 virtual std::vector<std::vector<TypedAttributeHandle<int64_t>>> connectivity_attributes()
182 const = 0;
183
184
185 std::vector<attribute::MeshAttributeHandle::HandleVariant> builtin_attributes() const;
186 std::vector<attribute::MeshAttributeHandle::HandleVariant> custom_attributes() const;
187
188
189 /* @brief registers an attribute without assuming the mesh exists */
190 template <typename T>
192 const std::string& name,
193 PrimitiveType type,
194 int64_t size,
195 bool replace = false,
196 T default_value = T(0));
197
198 /* @brief registers an attribute without assuming the mesh exists, returns a typed attribute */
199 template <typename T>
201 const std::string& name,
202 PrimitiveType type,
203 int64_t size,
204 bool replace = false,
205 T default_value = T(0));
206
207
208public:
209 template <typename T>
210 bool has_attribute(
211 const std::string& name,
212 const PrimitiveType ptype) const; // block standard topology tools
213
214 template <typename T>
216 const std::string& name,
217 const PrimitiveType ptype) const; // block standard topology tools
218
219 template <typename T>
221 const std::string& name,
222 const PrimitiveType ptype) const; // block standard topology tools
223
224
225 template <typename T, int D = Eigen::Dynamic>
227
228
229 template <typename T, int D = Eigen::Dynamic>
231 const attribute::MeshAttributeHandle& handle) const;
232
233 template <typename T, int D = Eigen::Dynamic>
235
236 template <typename T, int D = Eigen::Dynamic>
238 const TypedAttributeHandle<T>& handle) const;
239
240 template <typename T>
241 int64_t get_attribute_dimension(const TypedAttributeHandle<T>& handle) const;
242
243 template <typename T>
244 const T& get_attribute_default_value(const TypedAttributeHandle<T>& handle) const;
245
246 template <typename T>
247 std::string get_attribute_name(const TypedAttributeHandle<T>& handle) const;
248
249 std::string get_attribute_name(
251
257 void clear_attributes(
258 const std::vector<attribute::MeshAttributeHandle::HandleVariant>& keep_attributes);
259 void clear_attributes();
260 void clear_attributes(const std::vector<attribute::MeshAttributeHandle>& keep_attributes);
263
264
265 // creates a scope as int64_t as the AttributeScopeHandle exists
267
268
277 template <typename Functor, typename... Args>
278 decltype(auto) parent_scope(Functor&& f, Args&&... args) const;
279
280
283
284
285 bool operator==(const Mesh& other) const;
286
287 void assert_capacity_valid() const;
288 virtual bool is_connectivity_valid() const = 0;
289
290 virtual std::vector<Tuple> orient_vertices(const Tuple& t) const = 0;
291
292protected: // member functions
294
295
296protected:
304 virtual Tuple tuple_from_id(const PrimitiveType type, const int64_t gid) const = 0;
305 simplex::NavigatableSimplex simplex_from_id(const PrimitiveType type, const int64_t gid) const;
306 std::vector<std::vector<int64_t>> simplices_to_gids(
307 const std::vector<std::vector<simplex::Simplex>>& simplices) const;
314 void reserve_attributes(PrimitiveType type, int64_t size);
315 void reserve_attributes(int64_t dimension, int64_t size);
316
317
318 // specifies the number of simplices of each type and resizes attributes appropritely
319 void set_capacities(std::vector<int64_t> capacities);
320
321 // reserves extra attributes than necessary right now
322 void reserve_more_attributes(PrimitiveType type, int64_t size);
323 // reserves extra attributes than necessary right now, does not pay attention
324 void reserve_more_attributes(const std::vector<int64_t>& sizes);
325
326 // makes sure that there are at least `size` simples of type `type` avialable
327 void guarantee_more_attributes(PrimitiveType type, int64_t size);
328 // makes sure that there are at least `size` simplices avialable at every dimension
329 void guarantee_more_attributes(const std::vector<int64_t>& sizes);
330
331 // makes sure that there are at least `size` simples of type `type` avialable
332 void guarantee_at_least_attributes(PrimitiveType type, int64_t size);
333 // makes sure that there are at least `size` simplices avialable at every dimension
334 void guarantee_at_least_attributes(const std::vector<int64_t>& sizes);
335
336 // provides new simplices - should ONLY be called in our atomic topological operations
337 // all returned simplices are active (i.e their flags say they exist)
338 [[nodiscard]] std::vector<int64_t> request_simplex_indices(PrimitiveType type, int64_t count);
339
340public:
351 virtual Tuple switch_tuple(const Tuple& tuple, PrimitiveType type) const = 0;
352
353 // NOTE: adding per-simplex utility functions here is _wrong_ and will be removed
354
355
356 // Performs a sequence of switch_tuple operations in the order specified in op_sequence.
357 // in debug mode this will assert a failure, in release this will return a null tuple
358#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
359 template <std::ranges::forward_range ContainerType>
360#else
361 template <typename ContainerType>
362#endif
363 Tuple switch_tuples(const Tuple& tuple, const ContainerType& op_sequence) const;
364 // annoying initializer list prototype to catch switch_tuples(t, {PV,PE})
365 Tuple switch_tuples(const Tuple& tuple, const std::initializer_list<PrimitiveType>& op_sequence)
366 const;
367
368 // Performs a sequence of switch_tuple operations in the order specified in op_sequence.
369#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
370 template <std::ranges::forward_range ContainerType>
371#else
372 template <typename ContainerType>
373#endif
374 Tuple switch_tuples_unsafe(const Tuple& tuple, const ContainerType& op_sequence) const;
375 // annoying initializer list prototype to catch switch_tuples(t, {PV,PE})
377 const Tuple& tuple,
378 const std::initializer_list<PrimitiveType>& op_sequence) const;
379
388 int64_t capacity(PrimitiveType type) const;
389
397 virtual bool is_ccw(const Tuple& tuple) const = 0;
398
406 bool is_boundary(const simplex::Simplex& tuple) const;
414 virtual bool is_boundary(PrimitiveType, const Tuple& tuple) const = 0;
415
416
417 bool is_hash_valid(const Tuple& tuple, const attribute::Accessor<int64_t>& hash_accessor) const;
418 bool is_hash_valid(const Tuple& tuple) const;
419
429 virtual bool is_valid(const Tuple& tuple) const;
430
431 // whether the tuple refers to a removed / invalid dart in the mesh
432 bool is_removed(const Tuple& tuple) const;
433 // whether the tuple refers to a removed / invalid simplex in the mesh
434 bool is_removed(const Tuple& tuple, PrimitiveType pt) const;
435
436protected:
437 // whether the tuple refers to a removed / invalid facet
438 bool is_removed(int64_t index) const;
439 // whether the tuple refers to a removed / invalid simplex
440 bool is_removed(int64_t index, PrimitiveType pt) const;
441
442public:
446 bool is_valid(const simplex::Simplex& s) const;
447
448
449 //============================
450 // MultiMesh interface
451 //============================
452 //
456 bool is_multi_mesh_root() const;
464 const Mesh& get_multi_mesh_root() const;
465
466 Mesh& get_multi_mesh_mesh(const std::vector<int64_t>& absolute_id);
467 const Mesh& get_multi_mesh_mesh(const std::vector<int64_t>& absolute_id) const;
468
469
470 Mesh& get_multi_mesh_child_mesh(const std::vector<int64_t>& relative_id);
471 const Mesh& get_multi_mesh_child_mesh(const std::vector<int64_t>& relative_id) const;
472
476 std::vector<std::shared_ptr<Mesh>> get_child_meshes() const;
477
481 std::vector<std::shared_ptr<Mesh>> get_all_child_meshes() const;
482
486 std::vector<std::shared_ptr<const Mesh>> get_all_meshes() const;
487
488
497 std::vector<int64_t> absolute_multi_mesh_id() const;
498
499
513 const std::shared_ptr<Mesh>& child_mesh_ptr,
514 const std::vector<std::array<Tuple, 2>>& map_tuples);
515
523 void deregister_child_mesh(const std::shared_ptr<Mesh>& child_mesh_ptr);
524
525
526private:
531
532public:
550 std::vector<simplex::Simplex> map(const Mesh& other_mesh, const simplex::Simplex& my_simplex)
551 const;
552
553
554 /*
555 * @brief map a collection of simplices to another mesh
556 *
557 * @param mesh the mesh the simplices should be mapped to
558 * @param simplices the simplices being mapped to the child mesh
559 * @returns every simplex that corresponds to the passed simplices
560 * */
561 std::vector<simplex::Simplex> map(
562 const Mesh& other_mesh,
563 const std::vector<simplex::Simplex>& my_simplices) const;
564
576 std::vector<simplex::Simplex> lub_map(
577 const Mesh& other_mesh,
578 const simplex::Simplex& my_simplex) const;
579
580
581 /*
582 * @brief maps a collection of simplices from this mesh to any other mesh using LUB mesh as root
583 *
584 * Satisfies the same properties of standard map, but uses a the LUB as the root
585 *
586 * @param mesh the mesh the simplices should be mapped to
587 * @param simplices the simplices being mapped to the child mesh
588 * @returns every simplex that corresponds to the passed simplices
589 * */
590 std::vector<simplex::Simplex> lub_map(
591 const Mesh& other_mesh,
592 const std::vector<simplex::Simplex>& my_simplices) const;
593
606 simplex::Simplex map_to_parent(const simplex::Simplex& my_simplex) const;
607
616 simplex::Simplex map_to_root(const simplex::Simplex& my_simplex) const;
617
627 std::vector<simplex::Simplex> map_to_child(
628 const Mesh& child_mesh,
629 const simplex::Simplex& my_simplex) const;
630
631
649 std::vector<Tuple> map_tuples(const Mesh& other_mesh, const simplex::Simplex& my_simplex) const;
650
651 /*
652 * @brief map a collection of homogeneous simplices to another mesh
653 *
654 * @param mesh the mesh the simplices should be mapped to
655 * @param primitive_type the type of primitive the simplices are
656 * @param tuples the tuples used to represent the simplices
657 * @returns every simplex that corresponds to the passed simplices
658 * */
659 std::vector<Tuple> map_tuples(
660 const Mesh& other_mesh,
661 PrimitiveType pt,
662 const std::vector<Tuple>& my_simplices) const;
663
675 std::vector<Tuple> lub_map_tuples(const Mesh& other_mesh, const simplex::Simplex& my_simplex)
676 const;
677
678
679 /*
680 * @brief maps a collection of simplices from this mesh to any other mesh using LUB mesh as root
681 *
682 * Satisfies the same properties of standard map_tuples, but uses a the LUB as the root
683 *
684 * @param mesh the mesh the simplices should be mapped to
685 * @param simplices the simplices being mapped to the child mesh
686 * @returns every simplex that corresponds to the passed simplices
687 * */
688 std::vector<Tuple> lub_map_tuples(
689 const Mesh& other_mesh,
690 PrimitiveType pt,
691 const std::vector<Tuple>& my_simplices) const;
692
706 Tuple map_to_parent_tuple(const simplex::Simplex& my_simplex) const;
707
717 Tuple map_to_root_tuple(const simplex::Simplex& my_simplex) const;
718
729 std::vector<Tuple> map_to_child_tuples(
730 const Mesh& child_mesh,
731 const simplex::Simplex& my_simplex) const;
732
733
734 /*
735 * @brief identifies if this simplex can be mapped to another mesh
736 *
737 * This tries to map a simplex to another mesh and wil return true if a simplex is found.
738 * Note that the cost of this is almost hte same as mapping, so it is more efficient to map and
739 * check if the returned vector is empty rather than call this function.
740 */
741 bool can_map(const Mesh& other_mesh, const simplex::Simplex& my_simplex) const;
742
751 const Tuple& vertex,
752 attribute::Accessor<int64_t>& hash_accessor);
753
754
762 bool has_child_mesh_in_dimension(int64_t dimension) const
763 {
765 }
766
768
769 /*
770 * @brief returns if the other mesh is part of the same multi-mesh structure
771 * @param other the other being mesh being checked
772 * @returns true if they are part of the same structure
773 **/
774 bool is_from_same_multi_mesh_structure(const Mesh& other) const;
775
776protected:
777 // creates a scope as int64_t as the AttributeScopeHandle exists
779
780public:
793 int64_t id(const Tuple& tuple, PrimitiveType type) const;
794
795 int64_t id(const simplex::NavigatableSimplex& s) const { return s.index(); }
796 int64_t id(const simplex::IdSimplex& s) const { return s.index(); }
797
799 virtual int64_t id(const simplex::Simplex& s) const = 0;
800
801protected:
805 virtual int64_t id_virtual(const Tuple& tuple, PrimitiveType type) const = 0;
806
807
808 template <typename T, typename MeshType>
810 {
811 return attr.index_access();
812 }
813 template <typename T, typename MeshType>
815 {
816 return attr.index_access();
817 }
818
819
820 // std::shared_ptr<AccessorCache> request_accesor_cache();
821 //[[nodiscard]] AccessorScopeHandle push_accesor_scope();
822
823protected: // THese are protected so unit tests can access - do not use manually in other derived
824 // classes?
826
828
830
831 // assumes no adjacency data exists
832 bool m_is_free = false;
833
834private:
835 // PImpl'd manager of per-thread update stacks
836 // Every time a new access scope is requested the manager creates another level of indirection
837 // for updates
838 // std::unique_ptr<AttributeScopeManager> m_attribute_scope_manager;
839
840 //=========================================================
841 // simplex::Simplex Attribute
842 //=========================================================
843
844
850 std::vector<TypedAttributeHandle<char>> m_flag_handles;
851
852 // hashes for top level simplices (i.e cells) to identify whether tuples
853 // are invalid or not
855
856
863 std::vector<Tuple> get_all(PrimitiveType type, const bool include_deleted) const;
864 std::vector<simplex::IdSimplex> get_all_id_simplex(
865 PrimitiveType type,
866 const bool include_deleted) const;
867};
868
869
870template <typename T, int D>
873{
874 return attribute::Accessor<T, Mesh, D>(*this, handle);
875}
876template <typename T, int D>
879{
880 return attribute::Accessor<T, Mesh, D>(*this, handle);
881}
882
883template <typename T, int D>
886{
887 assert(&handle.mesh() == this);
888 assert(handle.holds<T>());
889 return create_accessor<T, D>(handle.as<T>());
890}
891
892
893template <typename T, int D>
896{
897 assert(&handle.mesh() == this);
898 assert(handle.holds<T>());
899 return create_const_accessor<T, D>(handle.as<T>());
900}
901
902template <typename T>
904 const std::string& name,
905 const PrimitiveType ptype) const
906{
908 *const_cast<Mesh*>(this),
909 get_attribute_handle_typed<T>(name, ptype));
910}
911
912template <typename T>
914 const std::string& name,
915 const PrimitiveType ptype) const
916{
918 h.m_base_handle = m_attribute_manager.get<T>(ptype).attribute_handle(name);
919 h.m_primitive_type = ptype;
920 return h;
921}
922template <typename T>
923inline bool Mesh::has_attribute(const std::string& name, const PrimitiveType ptype) const
924{
925 return m_attribute_manager.get<T>(ptype).has_attribute(name);
926}
927
928template <typename T>
930{
932}
933
934template <typename T>
935inline std::string Mesh::get_attribute_name(const TypedAttributeHandle<T>& handle) const
936{
937 return m_attribute_manager.get_name(handle);
938}
939
940template <typename Functor, typename... Args>
941inline decltype(auto) Mesh::parent_scope(Functor&& f, Args&&... args) const
942{
943 multimesh::attribute::UseParentScopeRAII raii(const_cast<Mesh&>(*this));
944
945 return std::invoke(std::forward<Functor>(f), std::forward<Args>(args)...);
946}
947
948#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
949template <std::ranges::forward_range ContainerType>
950#else
951template <typename ContainerType>
952#endif
953inline Tuple Mesh::switch_tuples(const Tuple& tuple, const ContainerType& sequence) const
954{
955 static_assert(std::is_same_v<typename ContainerType::value_type, PrimitiveType>);
956 Tuple r = tuple;
957 const PrimitiveType top_type = top_simplex_type();
958
959 const int64_t boundary_dim = top_cell_dimension() - 1;
960 const PrimitiveType boundary_pt = static_cast<PrimitiveType>(boundary_dim);
961
962 for (const PrimitiveType primitive : sequence) {
963 // for top level simplices we cannot navigate across boundaries
964 if (primitive == top_type && is_boundary(boundary_pt, r)) {
965 assert(!is_boundary(boundary_pt, r));
966 r = {};
967 return r;
968 }
969 r = switch_tuple(r, primitive);
970 }
971 return r;
972}
973inline bool Mesh::is_free() const
974{
975 return m_is_free;
976}
977
978inline int64_t Mesh::top_cell_dimension() const
979{
981}
983{
984 int64_t dimension = top_cell_dimension();
985 assert(dimension >= 0);
986 assert(dimension < 4);
987 return static_cast<PrimitiveType>(dimension);
988}
989
990
991#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
992template <std::ranges::forward_range ContainerType>
993#else
994template <typename ContainerType>
995#endif
996inline Tuple Mesh::switch_tuples_unsafe(const Tuple& tuple, const ContainerType& sequence) const
997{
998 static_assert(std::is_same_v<typename ContainerType::value_type, PrimitiveType>);
999 Tuple r = tuple;
1000 for (const PrimitiveType primitive : sequence) {
1001 r = switch_tuple(r, primitive);
1002 }
1003 return r;
1004}
1005
1006inline int64_t Mesh::id(const Tuple& tuple, PrimitiveType type) const
1007{
1008 return id_virtual(tuple, type);
1009}
1010} // namespace wmtk
bool m_is_free
Definition Mesh.hpp:832
void set_capacities(std::vector< int64_t > capacities)
Tuple switch_tuples_unsafe(const Tuple &tuple, const ContainerType &op_sequence) const
Definition Mesh.hpp:996
int64_t id(const simplex::IdSimplex &s) const
Definition Mesh.hpp:796
void update_vertex_operation_hashes(const Tuple &vertex, attribute::Accessor< int64_t > &hash_accessor)
wrapper function to update hashes (for parent mesh *this and its child meshes) after vertex operation...
void clear_attributes()
int64_t id(const simplex::NavigatableSimplex &s) const
Definition Mesh.hpp:795
Mesh(const Mesh &other)=delete
attribute::Accessor< T, Mesh, D > create_accessor(const TypedAttributeHandle< T > &handle)
simplex::Simplex get_simplex(const simplex::IdSimplex &s) const
Convert an IdSimplex into a Simplex.
Definition Mesh.cpp:38
std::vector< attribute::MeshAttributeHandle::HandleVariant > builtin_attributes() const
std::vector< attribute::MeshAttributeHandle::HandleVariant > custom_attributes() const
static auto & get_index_access(attribute::Accessor< T, MeshType > &attr)
Definition Mesh.hpp:809
std::vector< int64_t > absolute_multi_mesh_id() const
returns a unique identifier for this mesh within a single multimesh structure
virtual bool is_boundary(PrimitiveType, const Tuple &tuple) const =0
check if a simplex (encoded as a tuple/primitive pair) lies on a boundary or not
attribute::MeshAttributeHandle register_attribute(const std::string &name, PrimitiveType type, int64_t size, bool replace=false, T default_value=T(0))
void serialize(MeshWriter &writer, const Mesh *local_root=nullptr) const
Definition Mesh.cpp:93
attribute::MeshAttributeHandle get_attribute_handle(const std::string &name, const PrimitiveType ptype) const
Definition Mesh.hpp:903
std::vector< std::vector< int64_t > > simplices_to_gids(const std::vector< std::vector< simplex::Simplex > > &simplices) const
Definition Mesh.cpp:189
const attribute::Accessor< T, Mesh, D > create_const_accessor(const attribute::MeshAttributeHandle &handle) const
int64_t capacity(PrimitiveType type) const
read in the m_capacities return the upper bound for the number of entities of the given dimension
attribute::TypedAttributeHandle< T > register_attribute_typed(const std::string &name, PrimitiveType type, int64_t size, bool replace=false, T default_value=T(0))
std::vector< simplex::Simplex > lub_map(const Mesh &other_mesh, const simplex::Simplex &my_simplex) const
maps a simplex from this mesh to any other mesh using LUB mesh as root
std::vector< TypedAttributeHandle< char > > m_flag_handles
0x1 == true = simplex is active (simplex exists) all flag default to 0
Definition Mesh.hpp:850
void guarantee_more_attributes(PrimitiveType type, int64_t size)
std::map< std::string, std::size_t > child_hashes() const override
Definition Mesh_hash.cpp:12
void reserve_more_attributes(PrimitiveType type, int64_t size)
simplex::NavigatableSimplex simplex_from_id(const PrimitiveType type, const int64_t gid) const
Definition Mesh.cpp:130
void update_child_handles()
Update the child handles after clearing attributes.
Mesh & get_multi_mesh_child_mesh(const std::vector< int64_t > &relative_id)
int64_t get_attribute_dimension(const TypedAttributeHandle< T > &handle) const
Definition Mesh.hpp:929
Tuple map_to_root_tuple(const simplex::Simplex &my_simplex) const
maps a simplex from this mesh to the root mesh
attribute::TypedAttributeHandle< T > get_attribute_handle_typed(const std::string &name, const PrimitiveType ptype) const
Definition Mesh.hpp:913
bool is_free() const
Definition Mesh.hpp:973
virtual bool is_ccw(const Tuple &tuple) const =0
TODO this needs dimension?
int64_t id(const Tuple &tuple, PrimitiveType type) const
return the global id of the Tuple of the given dimension
Definition Mesh.hpp:1006
bool is_boundary(const simplex::Simplex &tuple) const
check if a simplex lies on a boundary or not
Definition Mesh.cpp:107
void guarantee_at_least_attributes(PrimitiveType type, int64_t size)
attribute::Accessor< T, Mesh, D > create_accessor(const attribute::MeshAttributeHandle &handle)
virtual Tuple tuple_from_id(const PrimitiveType type, const int64_t gid) const =0
internal function that returns the tuple of requested type, and has the global index cid
void assert_capacity_valid() const
Definition Mesh.cpp:220
std::vector< std::shared_ptr< Mesh > > get_all_child_meshes() const
returns all multimesh child meshes
std::vector< Tuple > get_all(PrimitiveType type) const
Generate a vector of Tuples from global vertex/edge/triangle/tetrahedron index.
Definition Mesh.cpp:18
virtual int64_t id_virtual(const Tuple &tuple, PrimitiveType type) const =0
Internal utility to allow id to be virtual with a non-virtual overload in derived -Mesh classes.
multimesh::MultiMeshManager m_multi_mesh_manager
Definition Mesh.hpp:827
multimesh::attribute::AttributeScopeHandle create_scope()
std::vector< simplex::IdSimplex > get_all_id_simplex(PrimitiveType type) const
Definition Mesh.cpp:23
Tuple switch_tuples(const Tuple &tuple, const ContainerType &op_sequence) const
Definition Mesh.hpp:953
std::vector< Tuple > map_tuples(const Mesh &other_mesh, const simplex::Simplex &my_simplex) const
maps a simplex from this mesh to any other mesh
Mesh & operator=(const Mesh &other)=delete
bool has_attribute(const std::string &name, const PrimitiveType ptype) const
Definition Mesh.hpp:923
bool is_hash_valid(const Tuple &tuple) const
std::map< std::string, const wmtk::utils::Hashable * > child_hashables() const override
Definition Mesh_hash.cpp:5
void register_child_mesh(const std::shared_ptr< Mesh > &child_mesh_ptr, const std::vector< std::array< Tuple, 2 > > &map_tuples)
register a mesh as the child of this mesh
virtual bool is_valid(const Tuple &tuple) const
check validity of tuple including its hash
Definition Mesh.cpp:113
void set_capacities_from_flags()
Definition Mesh.cpp:175
virtual int64_t id(const simplex::Simplex &s) const =0
Forwarding version of id on simplices that does id caching.
const attribute::Accessor< T, Mesh, D > create_const_accessor(const TypedAttributeHandle< T > &handle) const
bool is_multi_mesh_root() const
return true if this mesh is the root of a multimesh tree
int64_t top_cell_dimension() const
Definition Mesh.hpp:978
bool operator==(const Mesh &other) const
Definition Mesh.cpp:183
virtual Tuple switch_tuple(const Tuple &tuple, PrimitiveType type) const =0
switch the orientation of the Tuple of the given dimension
Tuple map_to_parent_tuple(const simplex::Simplex &my_simplex) const
optimized map from a simplex from this mesh to its direct parent
void reserve_attributes_to_fit()
reserve space for all attributes data types for all dimensional simplices
attribute::AttributeScopeHandle create_single_mesh_scope()
std::string get_attribute_name(const TypedAttributeHandle< T > &handle) const
Definition Mesh.hpp:935
simplex::Simplex map_to_root(const simplex::Simplex &my_simplex) const
maps a simplex from this mesh to the root mesh
virtual std::vector< std::vector< TypedAttributeHandle< int64_t > > > connectivity_attributes() const =0
Returns a vector of vectors of attribute handles.
Mesh & get_multi_mesh_root()
returns a reference to the root of a multimesh tree
bool is_hash_valid(const Tuple &tuple, const attribute::Accessor< int64_t > &hash_accessor) const
simplex::IdSimplex get_id_simplex(const Tuple &tuple, PrimitiveType pt) const
Retrieve the IdSimplex that is represented by the tuple and primitive type.
Definition Mesh.cpp:28
friend class tests::DEBUG_Mesh
Definition Mesh.hpp:97
void delete_attribute(const attribute::MeshAttributeHandle &to_delete)
int64_t m_top_cell_dimension
Definition Mesh.hpp:829
virtual std::vector< Tuple > orient_vertices(const Tuple &t) const =0
std::vector< std::shared_ptr< const Mesh > > get_all_meshes() const
returns all meshes in multimesh
PrimitiveType top_simplex_type() const
Definition Mesh.hpp:982
virtual std::tuple< std::vector< std::vector< int64_t > >, std::vector< std::vector< int64_t > > > consolidate()
Consolidate the attributes, moving all valid simplexes at the beginning of the corresponding vector.
simplex::Simplex map_to_parent(const simplex::Simplex &my_simplex) const
optimized map from a simplex from this mesh to its direct parent
Tuple get_tuple_from_id_simplex(const simplex::IdSimplex &s) const
Definition Mesh.cpp:44
std::vector< simplex::Simplex > map(const Mesh &other_mesh, const simplex::Simplex &my_simplex) const
maps a simplex from this mesh to any other mesh
virtual bool is_connectivity_valid() const =0
std::vector< int64_t > request_simplex_indices(PrimitiveType type, int64_t count)
Mesh & get_multi_mesh_mesh(const std::vector< int64_t > &absolute_id)
TypedAttributeHandle< int64_t > m_cell_hash_handle
Definition Mesh.hpp:854
decltype(auto) parent_scope(Functor &&f, Args &&... args) const
Evaluate the passed in function inside the parent scope.
Definition Mesh.hpp:941
bool can_map(const Mesh &other_mesh, const simplex::Simplex &my_simplex) const
const attribute::FlagAccessor< Mesh > get_const_flag_accessor(PrimitiveType type) const
Definition Mesh.cpp:163
bool is_from_same_multi_mesh_structure(const Mesh &other) const
void deregister_child_mesh(const std::shared_ptr< Mesh > &child_mesh_ptr)
Deregister a child mesh.
bool has_child_mesh() const
Definition Mesh.hpp:767
bool is_removed(const Tuple &tuple) const
Definition Mesh.cpp:118
std::vector< Tuple > map_to_child_tuples(const Mesh &child_mesh, const simplex::Simplex &my_simplex) const
optimized map fromsimplex from this mesh to one of its direct children
const attribute::FlagAccessor< Mesh > get_flag_accessor(PrimitiveType type) const
Definition Mesh.cpp:159
std::vector< simplex::Simplex > map_to_child(const Mesh &child_mesh, const simplex::Simplex &my_simplex) const
optimized map fromsimplex from this mesh to one of its direct children
std::vector< std::shared_ptr< Mesh > > get_child_meshes() const
returns the direct multimesh child meshes for the current mesh
void reserve_attributes(PrimitiveType type, int64_t size)
attribute::AttributeManager m_attribute_manager
Definition Mesh.hpp:825
bool has_child_mesh_in_dimension(int64_t dimension) const
returns if the mesh has a child mesh in the given dimension
Definition Mesh.hpp:762
const T & get_attribute_default_value(const TypedAttributeHandle< T > &handle) const
std::vector< Tuple > lub_map_tuples(const Mesh &other_mesh, const simplex::Simplex &my_simplex) const
maps a simplex from this mesh to any other mesh using LUB mesh as root
static auto & get_index_access(const attribute::Accessor< T, MeshType > &attr)
Definition Mesh.hpp:814
void reserve_attributes(int64_t dimension, int64_t size)
The Tuple is the basic navigation tool in our mesh data structure.
Definition Tuple.hpp:19
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition Accessor.hpp:28
CachingBaseType & index_access()
Definition Accessor.hpp:97
int64_t get_attribute_dimension(const TypedAttributeHandle< T > &handle) const
std::vector< MeshAttributes< T > > & get()
std::string get_name(const TypedAttributeHandle< T > &attr) const
This handle is a wrapper for the MeshManager scope funtions.
std::variant< TypedAttributeHandle< char >, TypedAttributeHandle< int64_t >, TypedAttributeHandle< double >, TypedAttributeHandle< wmtk::Rational > > HandleVariant
Handle that represents attributes for some mesh.
wmtk::attribute::AttributeHandle m_base_handle
Implementation details for how the Mesh class implements multiple meshes.
bool has_child_mesh_in_dimension(int64_t dimension) const
TupleTag is a util helper class for tagging edges in a triangle mesh.
Definition TupleTag.hpp:17
int64_t index() const
Definition IdSimplex.hpp:30