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
18
19// basic data for the class
21#include "Tuple.hpp"
22#include "Types.hpp"
24#include "attribute/AttributeScopeHandle.hpp"
28
30
31#include "simplex/IdSimplex.hpp"
33#include "simplex/Simplex.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, typename AttributeType, 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, typename MeshType, typename AttributeType, int Dim>
99 friend class attribute::Accessor;
100 friend class io::ParaviewWriter;
101 friend class HDF5Reader;
105 template <int64_t cell_dimension, typename NodeFunctor>
107 template <typename Visitor>
109 template <typename NodeFunctor>
112 template <typename Visitor>
122
123
124 int64_t top_cell_dimension() const;
126 bool is_free() const;
127
128 // attribute directly hashes its "children" components so it overrides "child_hashes"
129 std::map<std::string, const wmtk::utils::Hashable*> child_hashables() const override;
130 std::map<std::string, std::size_t> child_hashes() const override;
131
132 // dimension is the dimension of the top level simplex in this mesh
133 // That is, a TriMesh is a 2, a TetMesh is a 3
134 Mesh(const int64_t& dimension);
135 // maximum primitive type id for supported attribute primitive locations
136 Mesh(const int64_t& dimension, const int64_t& max_primitive_type_id);
137 Mesh(Mesh&& other);
138 Mesh(const Mesh& other) = delete;
139 Mesh& operator=(const Mesh& other) = delete;
140 Mesh& operator=(Mesh&& other);
141 virtual ~Mesh();
142
143 void serialize(MeshWriter& writer, const Mesh* local_root = nullptr) const;
144
150 std::vector<Tuple> get_all(PrimitiveType type) const;
151
152 std::vector<simplex::IdSimplex> get_all_id_simplex(PrimitiveType type) const;
157
159
164
166
171 virtual std::tuple<std::vector<std::vector<int64_t>>, std::vector<std::vector<int64_t>>>
172 consolidate();
173
179 virtual std::vector<std::vector<TypedAttributeHandle<int64_t>>> connectivity_attributes()
180 const = 0;
181
182
183 std::vector<attribute::MeshAttributeHandle::HandleVariant> builtin_attributes() const;
184 std::vector<attribute::MeshAttributeHandle::HandleVariant> custom_attributes() const;
185
186
187 /* @brief registers an attribute without assuming the mesh exists */
188 template <typename T>
190 const std::string& name,
191 PrimitiveType type,
192 int64_t size,
193 bool replace = false,
194 T default_value = T(0));
195
196 /* @brief registers an attribute without assuming the mesh exists, returns a typed attribute */
197 template <typename T>
199 const std::string& name,
200 PrimitiveType type,
201 int64_t size,
202 bool replace = false,
203 T default_value = T(0));
204
205
206public:
207 template <typename T>
208 bool has_attribute(
209 const std::string& name,
210 const PrimitiveType ptype) const; // block standard topology tools
211
212 template <typename T>
214 const std::string& name,
215 const PrimitiveType ptype) const; // block standard topology tools
216
217 template <typename T>
219 const std::string& name,
220 const PrimitiveType ptype) const; // block standard topology tools
221
222
223 template <typename T, int D = Eigen::Dynamic>
225
226
227 template <typename T, int D = Eigen::Dynamic>
229 const attribute::MeshAttributeHandle& handle) const;
230
231 template <typename T, int D = Eigen::Dynamic>
233
234 template <typename T, int D = Eigen::Dynamic>
236 const TypedAttributeHandle<T>& handle) const;
237
238 template <typename T>
239 int64_t get_attribute_dimension(const TypedAttributeHandle<T>& handle) const;
240
241 template <typename T>
242 const T& get_attribute_default_value(const TypedAttributeHandle<T>& handle) const;
243
244 template <typename T>
245 std::string get_attribute_name(const TypedAttributeHandle<T>& handle) const;
246
247 std::string get_attribute_name(
249
255 void clear_attributes(
256 const std::vector<attribute::MeshAttributeHandle::HandleVariant>& keep_attributes);
257 void clear_attributes();
258 void clear_attributes(const std::vector<attribute::MeshAttributeHandle>& keep_attributes);
261
262
263 // creates a scope as int64_t as the AttributeScopeHandle exists
265
266
275 template <typename Functor, typename... Args>
276 decltype(auto) parent_scope(Functor&& f, Args&&... args) const;
277
278
281
282
283 bool operator==(const Mesh& other) const;
284
285 void assert_capacity_valid() const;
286 virtual bool is_connectivity_valid() const = 0;
287
288 virtual std::vector<Tuple> orient_vertices(const Tuple& t) const = 0;
289
290protected: // member functions
292
293
294protected:
302 virtual Tuple tuple_from_id(const PrimitiveType type, const int64_t gid) const = 0;
303 simplex::NavigatableSimplex simplex_from_id(const PrimitiveType type, const int64_t gid) const;
304 std::vector<std::vector<int64_t>> simplices_to_gids(
305 const std::vector<std::vector<simplex::Simplex>>& simplices) const;
312 void reserve_attributes(PrimitiveType type, int64_t size);
313 void reserve_attributes(int64_t dimension, int64_t size);
314
315
316 // specifies the number of simplices of each type and resizes attributes appropritely
317 void set_capacities(std::vector<int64_t> capacities);
318
319 // reserves extra attributes than necessary right now
320 void reserve_more_attributes(PrimitiveType type, int64_t size);
321 // reserves extra attributes than necessary right now, does not pay attention
322 void reserve_more_attributes(const std::vector<int64_t>& sizes);
323
324 // makes sure that there are at least `size` simples of type `type` avialable
325 void guarantee_more_attributes(PrimitiveType type, int64_t size);
326 // makes sure that there are at least `size` simplices avialable at every dimension
327 void guarantee_more_attributes(const std::vector<int64_t>& sizes);
328
329 // makes sure that there are at least `size` simples of type `type` avialable
330 void guarantee_at_least_attributes(PrimitiveType type, int64_t size);
331 // makes sure that there are at least `size` simplices avialable at every dimension
332 void guarantee_at_least_attributes(const std::vector<int64_t>& sizes);
333
334 // provides new simplices - should ONLY be called in our atomic topological operations
335 // all returned simplices are active (i.e their flags say they exist)
336 [[nodiscard]] std::vector<int64_t> request_simplex_indices(PrimitiveType type, int64_t count);
337
338public:
349 virtual Tuple switch_tuple(const Tuple& tuple, PrimitiveType type) const = 0;
350
351 // NOTE: adding per-simplex utility functions here is _wrong_ and will be removed
352
353
354 // Performs a sequence of switch_tuple operations in the order specified in op_sequence.
355 // in debug mode this will assert a failure, in release this will return a null tuple
356#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
357 template <std::ranges::forward_range ContainerType>
358#else
359 template <typename ContainerType>
360#endif
361 Tuple switch_tuples(const Tuple& tuple, const ContainerType& op_sequence) const;
362 // annoying initializer list prototype to catch switch_tuples(t, {PV,PE})
363 Tuple switch_tuples(const Tuple& tuple, const std::initializer_list<PrimitiveType>& op_sequence)
364 const;
365
366 // Performs a sequence of switch_tuple operations in the order specified in op_sequence.
367#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
368 template <std::ranges::forward_range ContainerType>
369#else
370 template <typename ContainerType>
371#endif
372 Tuple switch_tuples_unsafe(const Tuple& tuple, const ContainerType& op_sequence) const;
373 // annoying initializer list prototype to catch switch_tuples(t, {PV,PE})
375 const Tuple& tuple,
376 const std::initializer_list<PrimitiveType>& op_sequence) const;
377
386 int64_t capacity(PrimitiveType type) const;
387
395 virtual bool is_ccw(const Tuple& tuple) const = 0;
396
404 bool is_boundary(const simplex::Simplex& tuple) const;
412 virtual bool is_boundary(PrimitiveType, const Tuple& tuple) const = 0;
413
414
415 bool is_hash_valid(const Tuple& tuple, const attribute::Accessor<int64_t>& hash_accessor) const;
416 bool is_hash_valid(const Tuple& tuple) const;
417
427 virtual bool is_valid(const Tuple& tuple) const;
428
429 // whether the tuple refers to a removed / invalid dart in the mesh
430 bool is_removed(const Tuple& tuple) const;
431 // whether the tuple refers to a removed / invalid simplex in the mesh
432 bool is_removed(const Tuple& tuple, PrimitiveType pt) const;
433
434protected:
435 // whether the tuple refers to a removed / invalid facet
436 bool is_removed(int64_t index) const;
437 // whether the tuple refers to a removed / invalid simplex
438 bool is_removed(int64_t index, PrimitiveType pt) const;
439
440public:
444 bool is_valid(const simplex::Simplex& s) const;
445
446 bool validate_attributes() const;
447
448 template <typename T>
449 bool validate_handle(const TypedAttributeHandle<T>& handle) const;
450
451 //============================
452 // MultiMesh interface
453 //============================
454 //
458 bool is_multi_mesh_root() const;
466 const Mesh& get_multi_mesh_root() const;
467
468 Mesh& get_multi_mesh_mesh(const std::vector<int64_t>& absolute_id);
469 const Mesh& get_multi_mesh_mesh(const std::vector<int64_t>& absolute_id) const;
470
471
472 Mesh& get_multi_mesh_child_mesh(const std::vector<int64_t>& relative_id);
473 const Mesh& get_multi_mesh_child_mesh(const std::vector<int64_t>& relative_id) const;
474
478 std::vector<std::shared_ptr<Mesh>> get_child_meshes() const;
479
483 std::vector<std::shared_ptr<Mesh>> get_all_child_meshes() const;
484
488 std::vector<std::shared_ptr<const Mesh>> get_all_meshes() const;
489
490
499 std::vector<int64_t> absolute_multi_mesh_id() const;
500
501
515 const std::shared_ptr<Mesh>& child_mesh_ptr,
516 const std::vector<std::array<Tuple, 2>>& map_tuples);
517
525 void deregister_child_mesh(const std::shared_ptr<Mesh>& child_mesh_ptr);
526
527
528private:
533
534public:
552 std::vector<simplex::Simplex> map(const Mesh& other_mesh, const simplex::Simplex& my_simplex)
553 const;
554
555
556 /*
557 * @brief map a collection of simplices to another mesh
558 *
559 * @param mesh the mesh the simplices should be mapped to
560 * @param simplices the simplices being mapped to the child mesh
561 * @returns every simplex that corresponds to the passed simplices
562 * */
563 std::vector<simplex::Simplex> map(
564 const Mesh& other_mesh,
565 const std::vector<simplex::Simplex>& my_simplices) const;
566
578 std::vector<simplex::Simplex> lub_map(
579 const Mesh& other_mesh,
580 const simplex::Simplex& my_simplex) const;
581
582
583 /*
584 * @brief maps a collection of simplices from this mesh to any other mesh using LUB mesh as root
585 *
586 * Satisfies the same properties of standard map, but uses a the LUB as the root
587 *
588 * @param mesh the mesh the simplices should be mapped to
589 * @param simplices the simplices being mapped to the child mesh
590 * @returns every simplex that corresponds to the passed simplices
591 * */
592 std::vector<simplex::Simplex> lub_map(
593 const Mesh& other_mesh,
594 const std::vector<simplex::Simplex>& my_simplices) const;
595
608 simplex::Simplex map_to_parent(const simplex::Simplex& my_simplex) const;
609
618 simplex::Simplex map_to_root(const simplex::Simplex& my_simplex) const;
619
629 std::vector<simplex::Simplex> map_to_child(
630 const Mesh& child_mesh,
631 const simplex::Simplex& my_simplex) const;
632
633
651 std::vector<Tuple> map_tuples(const Mesh& other_mesh, const simplex::Simplex& my_simplex) const;
652
653 /*
654 * @brief map a collection of homogeneous simplices to another mesh
655 *
656 * @param mesh the mesh the simplices should be mapped to
657 * @param primitive_type the type of primitive the simplices are
658 * @param tuples the tuples used to represent the simplices
659 * @returns every simplex that corresponds to the passed simplices
660 * */
661 std::vector<Tuple> map_tuples(
662 const Mesh& other_mesh,
663 PrimitiveType pt,
664 const std::vector<Tuple>& my_simplices) const;
665
677 std::vector<Tuple> lub_map_tuples(const Mesh& other_mesh, const simplex::Simplex& my_simplex)
678 const;
679
680
681 /*
682 * @brief maps a collection of simplices from this mesh to any other mesh using LUB mesh as root
683 *
684 * Satisfies the same properties of standard map_tuples, but uses a the LUB as the root
685 *
686 * @param mesh the mesh the simplices should be mapped to
687 * @param simplices the simplices being mapped to the child mesh
688 * @returns every simplex that corresponds to the passed simplices
689 * */
690 std::vector<Tuple> lub_map_tuples(
691 const Mesh& other_mesh,
692 PrimitiveType pt,
693 const std::vector<Tuple>& my_simplices) const;
694
708 Tuple map_to_parent_tuple(const simplex::Simplex& my_simplex) const;
709
719 Tuple map_to_root_tuple(const simplex::Simplex& my_simplex) const;
720
731 std::vector<Tuple> map_to_child_tuples(
732 const Mesh& child_mesh,
733 const simplex::Simplex& my_simplex) const;
734
735
736 /*
737 * @brief identifies if this simplex can be mapped to another mesh
738 *
739 * This tries to map a simplex to another mesh and wil return true if a simplex is found.
740 * Note that the cost of this is almost hte same as mapping, so it is more efficient to map and
741 * check if the returned vector is empty rather than call this function.
742 */
743 bool can_map(const Mesh& other_mesh, const simplex::Simplex& my_simplex) const;
744
753 const Tuple& vertex,
754 attribute::Accessor<int64_t>& hash_accessor);
755
756
764 bool has_child_mesh_in_dimension(int64_t dimension) const
765 {
767 }
768
770
771 /*
772 * @brief returns if the other mesh is part of the same multi-mesh structure
773 * @param other the other being mesh being checked
774 * @returns true if they are part of the same structure
775 **/
776 bool is_from_same_multi_mesh_structure(const Mesh& other) const;
777
778protected:
779 // creates a scope as int64_t as the AttributeScopeHandle exists
781
782public:
795 int64_t id(const Tuple& tuple, PrimitiveType type) const;
796
797 int64_t id(const simplex::NavigatableSimplex& s) const { return s.index(); }
798 int64_t id(const simplex::IdSimplex& s) const { return s.index(); }
799
801 virtual int64_t id(const simplex::Simplex& s) const = 0;
802
803protected:
807 virtual int64_t id_virtual(const Tuple& tuple, PrimitiveType type) const = 0;
808
809
810 template <typename T, typename MeshType>
812 {
813 return attr.index_access();
814 }
815 template <typename T, typename MeshType>
817 {
818 return attr.index_access();
819 }
820
821
822 // std::shared_ptr<AccessorCache> request_accesor_cache();
823 //[[nodiscard]] AccessorScopeHandle push_accesor_scope();
824
825protected: // THese are protected so unit tests can access - do not use manually in other derived
826 // classes?
828
830
832
833 // assumes no adjacency data exists
834 bool m_is_free = false;
835
836private:
837 // PImpl'd manager of per-thread update stacks
838 // Every time a new access scope is requested the manager creates another level of indirection
839 // for updates
840 // std::unique_ptr<AttributeScopeManager> m_attribute_scope_manager;
841
842 //=========================================================
843 // simplex::Simplex Attribute
844 //=========================================================
845
846
852 std::vector<TypedAttributeHandle<char>> m_flag_handles;
853
854
861 std::vector<Tuple> get_all(PrimitiveType type, const bool include_deleted) const;
862 std::vector<simplex::IdSimplex> get_all_id_simplex(
863 PrimitiveType type,
864 const bool include_deleted) const;
865};
866
867
868template <typename T, int D>
874template <typename T, int D>
880
881template <typename T, int D>
884{
885 assert(&handle.mesh() == this);
886 assert(handle.holds<T>());
887 return create_accessor<T, D>(handle.as<T>());
888}
889
890
891template <typename T, int D>
894{
895 assert(&handle.mesh() == this);
896 assert(handle.holds<T>());
897 return create_const_accessor<T, D>(handle.as<T>());
898}
899
900template <typename T>
902 const std::string& name,
903 const PrimitiveType ptype) const
904{
906 *const_cast<Mesh*>(this),
907 get_attribute_handle_typed<T>(name, ptype));
908}
909
910template <typename T>
912 const std::string& name,
913 const PrimitiveType ptype) const
914{
916 h.m_base_handle = m_attribute_manager.get<T>(ptype).attribute_handle(name);
917 h.m_primitive_type = ptype;
918 return h;
919}
920template <typename T>
921inline bool Mesh::has_attribute(const std::string& name, const PrimitiveType ptype) const
922{
923 return m_attribute_manager.get<T>(ptype).has_attribute(name);
924}
925
926template <typename T>
928{
930}
931
932template <typename T>
933inline std::string Mesh::get_attribute_name(const TypedAttributeHandle<T>& handle) const
934{
935 return m_attribute_manager.get_name(handle);
936}
937
938template <typename Functor, typename... Args>
939inline decltype(auto) Mesh::parent_scope(Functor&& f, Args&&... args) const
940{
941 multimesh::attribute::UseParentScopeRAII raii(const_cast<Mesh&>(*this));
942
943 return std::invoke(std::forward<Functor>(f), std::forward<Args>(args)...);
944}
945
946#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
947template <std::ranges::forward_range ContainerType>
948#else
949template <typename ContainerType>
950#endif
951inline Tuple Mesh::switch_tuples(const Tuple& tuple, const ContainerType& sequence) const
952{
953 static_assert(std::is_same_v<typename ContainerType::value_type, PrimitiveType>);
954 Tuple r = tuple;
955 const PrimitiveType top_type = top_simplex_type();
956
957 const int64_t boundary_dim = top_cell_dimension() - 1;
958 const PrimitiveType boundary_pt = static_cast<PrimitiveType>(boundary_dim);
959
960 for (const PrimitiveType primitive : sequence) {
961 // for top level simplices we cannot navigate across boundaries
962 if (primitive == top_type && is_boundary(boundary_pt, r)) {
963 assert(!is_boundary(boundary_pt, r));
964 r = {};
965 return r;
966 }
967 r = switch_tuple(r, primitive);
968 }
969 return r;
970}
971inline bool Mesh::is_free() const
972{
973 return m_is_free;
974}
975
976inline int64_t Mesh::top_cell_dimension() const
977{
979}
981{
982 int64_t dimension = top_cell_dimension();
983 assert(dimension >= 0);
984 assert(dimension < 4);
985 return static_cast<PrimitiveType>(dimension);
986}
987
988
989#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
990template <std::ranges::forward_range ContainerType>
991#else
992template <typename ContainerType>
993#endif
994inline Tuple Mesh::switch_tuples_unsafe(const Tuple& tuple, const ContainerType& sequence) const
995{
996 static_assert(std::is_same_v<typename ContainerType::value_type, PrimitiveType>);
997 Tuple r = tuple;
998 for (const PrimitiveType primitive : sequence) {
999 r = switch_tuple(r, primitive);
1000 }
1001 return r;
1002}
1003
1004template <typename T>
1005inline bool Mesh::validate_handle(const TypedAttributeHandle<T>& handle) const
1006{
1007 return m_attribute_manager.validate_handle(handle);
1008}
1009
1010inline int64_t Mesh::id(const Tuple& tuple, PrimitiveType type) const
1011{
1012 return id_virtual(tuple, type);
1013}
1014} // namespace wmtk
bool m_is_free
Definition Mesh.hpp:834
void set_capacities(std::vector< int64_t > capacities)
Tuple switch_tuples_unsafe(const Tuple &tuple, const ContainerType &op_sequence) const
Definition Mesh.hpp:994
int64_t id(const simplex::IdSimplex &s) const
Definition Mesh.hpp:798
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:797
Mesh(const Mesh &other)=delete
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:811
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::Accessor< T, Mesh, attribute::CachingAttribute< T >, D > create_accessor(const TypedAttributeHandle< T > &handle)
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:901
std::vector< std::vector< int64_t > > simplices_to_gids(const std::vector< std::vector< simplex::Simplex > > &simplices) const
Definition Mesh.cpp:203
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:852
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:139
bool validate_attributes() const
Definition Mesh.cpp:167
void update_child_handles()
Update the child handles after clearing attributes.
Mesh & get_multi_mesh_child_mesh(const std::vector< int64_t > &relative_id)
const attribute::Accessor< T, Mesh, attribute::CachingAttribute< T >, D > create_const_accessor(const attribute::MeshAttributeHandle &handle) const
const attribute::Accessor< T, Mesh, attribute::CachingAttribute< T >, D > create_const_accessor(const TypedAttributeHandle< T > &handle) const
int64_t get_attribute_dimension(const TypedAttributeHandle< T > &handle) const
Definition Mesh.hpp:927
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:911
bool is_free() const
Definition Mesh.hpp:971
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:1010
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)
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:234
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.
bool validate_handle(const TypedAttributeHandle< T > &handle) const
Definition Mesh.hpp:1005
multimesh::MultiMeshManager m_multi_mesh_manager
Definition Mesh.hpp:829
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:951
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:921
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:189
virtual int64_t id(const simplex::Simplex &s) const =0
Forwarding version of id on simplices that does id caching.
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:976
bool operator==(const Mesh &other) const
Definition Mesh.cpp:197
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:933
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:831
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:980
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)
decltype(auto) parent_scope(Functor &&f, Args &&... args) const
Evaluate the passed in function inside the parent scope.
Definition Mesh.hpp:939
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:177
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:769
attribute::Accessor< T, Mesh, attribute::CachingAttribute< T >, D > create_accessor(const attribute::MeshAttributeHandle &handle)
bool is_removed(const Tuple &tuple) const
Definition Mesh.cpp:127
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:173
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:827
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:764
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:816
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
An Accessor that uses tuples for accessing attributes instead of indices.
Definition Accessor.hpp:28
AttributeType & index_access()
Definition Accessor.hpp:106
std::vector< TypedAttributeManager< T > > & get()
bool validate_handle(const TypedAttributeHandle< T > &handle) const
int64_t get_attribute_dimension(const TypedAttributeHandle< T > &handle) const
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