5#include <initializer_list>
24#include "attribute/AttributeScopeHandle.hpp"
38#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
49class AttributeManager;
50template <
typename T,
typename MeshType,
typename AttributeType,
int Dim>
58class EdgeOperationData;
63class UpdateEdgeOperationMultiMeshMapFunctor;
71template <
int64_t cell_dimension,
typename NodeFunctor>
73template <
typename NodeFunctor>
75template <
typename Visitor>
77template <
typename Visitor>
98 template <
typename T,
typename MeshType,
typename AttributeType,
int Dim>
105 template <
int64_t cell_dimension,
typename NodeFunctor>
107 template <
typename Visitor>
109 template <
typename NodeFunctor>
112 template <
typename Visitor>
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;
134 Mesh(
const int64_t& dimension);
136 Mesh(
const int64_t& dimension,
const int64_t& max_primitive_type_id);
171 virtual std::tuple<std::vector<std::vector<int64_t>>, std::vector<std::vector<int64_t>>>
183 std::vector<attribute::MeshAttributeHandle::HandleVariant>
builtin_attributes()
const;
184 std::vector<attribute::MeshAttributeHandle::HandleVariant>
custom_attributes()
const;
188 template <
typename T>
190 const std::string& name,
193 bool replace =
false,
194 T default_value = T(0));
197 template <
typename T>
199 const std::string& name,
202 bool replace =
false,
203 T default_value = T(0));
207 template <
typename T>
209 const std::string& name,
212 template <
typename T>
214 const std::string& name,
217 template <
typename T>
219 const std::string& name,
223 template <
typename T,
int D = Eigen::Dynamic>
227 template <
typename T,
int D = Eigen::Dynamic>
231 template <
typename T,
int D = Eigen::Dynamic>
234 template <
typename T,
int D = Eigen::Dynamic>
238 template <
typename T>
241 template <
typename T>
244 template <
typename T>
256 const std::vector<attribute::MeshAttributeHandle::HandleVariant>& keep_attributes);
258 void clear_attributes(
const std::vector<attribute::MeshAttributeHandle>& keep_attributes);
275 template <
typename Functor,
typename... Args>
276 decltype(
auto)
parent_scope(Functor&& f, Args&&... args)
const;
305 const std::vector<std::vector<simplex::Simplex>>& simplices)
const;
356#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
357 template <std::ranges::forward_range ContainerType>
359 template <
typename ContainerType>
367#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
368 template <std::ranges::forward_range ContainerType>
370 template <
typename ContainerType>
376 const std::initializer_list<PrimitiveType>& op_sequence)
const;
448 template <
typename T>
515 const std::shared_ptr<Mesh>& child_mesh_ptr,
516 const std::vector<std::array<Tuple, 2>>&
map_tuples);
563 std::vector<simplex::Simplex>
map(
564 const Mesh& other_mesh,
565 const std::vector<simplex::Simplex>& my_simplices)
const;
578 std::vector<simplex::Simplex>
lub_map(
579 const Mesh& other_mesh,
592 std::vector<simplex::Simplex>
lub_map(
593 const Mesh& other_mesh,
594 const std::vector<simplex::Simplex>& my_simplices)
const;
630 const Mesh& child_mesh,
662 const Mesh& other_mesh,
664 const std::vector<Tuple>& my_simplices)
const;
691 const Mesh& other_mesh,
693 const std::vector<Tuple>& my_simplices)
const;
732 const Mesh& child_mesh,
810 template <
typename T,
typename MeshType>
815 template <
typename T,
typename MeshType>
864 const bool include_deleted)
const;
868template <
typename T,
int D>
874template <
typename T,
int D>
881template <
typename T,
int D>
885 assert(&handle.mesh() ==
this);
886 assert(handle.holds<T>());
887 return create_accessor<T, D>(handle.as<T>());
891template <
typename T,
int D>
895 assert(&handle.mesh() ==
this);
896 assert(handle.holds<T>());
897 return create_const_accessor<T, D>(handle.as<T>());
902 const std::string& name,
906 *
const_cast<Mesh*
>(
this),
907 get_attribute_handle_typed<T>(name, ptype));
912 const std::string& name,
938template <
typename Functor,
typename... Args>
943 return std::invoke(std::forward<Functor>(f), std::forward<Args>(args)...);
946#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
947template <std::ranges::forward_range ContainerType>
949template <
typename ContainerType>
953 static_assert(std::is_same_v<typename ContainerType::value_type, PrimitiveType>);
962 if (primitive == top_type &&
is_boundary(boundary_pt, r)) {
983 assert(dimension >= 0);
984 assert(dimension < 4);
989#if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
990template <std::ranges::forward_range ContainerType>
992template <
typename ContainerType>
996 static_assert(std::is_same_v<typename ContainerType::value_type, PrimitiveType>);
1004template <
typename T>
void set_capacities(std::vector< int64_t > capacities)
Tuple switch_tuples_unsafe(const Tuple &tuple, const ContainerType &op_sequence) const
int64_t id(const simplex::IdSimplex &s) const
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...
int64_t id(const simplex::NavigatableSimplex &s) const
Mesh(const Mesh &other)=delete
simplex::Simplex get_simplex(const simplex::IdSimplex &s) const
Convert an IdSimplex into a Simplex.
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)
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
attribute::MeshAttributeHandle get_attribute_handle(const std::string &name, const PrimitiveType ptype) const
std::vector< std::vector< int64_t > > simplices_to_gids(const std::vector< std::vector< simplex::Simplex > > &simplices) 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
void guarantee_more_attributes(PrimitiveType type, int64_t size)
std::map< std::string, std::size_t > child_hashes() const override
void reserve_more_attributes(PrimitiveType type, int64_t size)
simplex::NavigatableSimplex simplex_from_id(const PrimitiveType type, const int64_t gid) const
bool validate_attributes() const
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
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
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
bool is_boundary(const simplex::Simplex &tuple) const
check if a simplex lies on a boundary or not
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
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.
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
multimesh::MultiMeshManager m_multi_mesh_manager
multimesh::attribute::AttributeScopeHandle create_scope()
std::vector< simplex::IdSimplex > get_all_id_simplex(PrimitiveType type) const
Tuple switch_tuples(const Tuple &tuple, const ContainerType &op_sequence) const
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
bool is_hash_valid(const Tuple &tuple) const
std::map< std::string, const wmtk::utils::Hashable * > child_hashables() const override
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
void set_capacities_from_flags()
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
bool operator==(const Mesh &other) const
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
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.
friend class tests::DEBUG_Mesh
void delete_attribute(const attribute::MeshAttributeHandle &to_delete)
int64_t m_top_cell_dimension
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
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
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.
bool can_map(const Mesh &other_mesh, const simplex::Simplex &my_simplex) const
const attribute::FlagAccessor< Mesh > get_const_flag_accessor(PrimitiveType type) const
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
attribute::Accessor< T, Mesh, attribute::CachingAttribute< T >, D > create_accessor(const attribute::MeshAttributeHandle &handle)
bool is_removed(const Tuple &tuple) const
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
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
bool has_child_mesh_in_dimension(int64_t dimension) const
returns if the mesh has a child mesh in the given dimension
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)
void reserve_attributes(int64_t dimension, int64_t size)
The Tuple is the basic navigation tool in our mesh data structure.
An Accessor that uses tuples for accessing attributes instead of indices.
AttributeType & index_access()
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
wmtk::PrimitiveType m_primitive_type
Implementation details for how the Mesh class implements multiple meshes.
bool has_child_mesh_in_dimension(int64_t dimension) const
bool has_child_mesh() const
TupleTag is a util helper class for tagging edges in a triangle mesh.