5 #include <initializer_list>
24 #include "attribute/AttributeScopeHandle.hpp"
38 #if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
54 class AttributeManager;
55 template <
typename T,
typename MeshType,
int Dim>
59 namespace operations {
63 class EdgeOperationData;
68 class UpdateEdgeOperationMultiMeshMapFunctor;
83 template <
int64_t cell_dimension,
typename NodeFunctor>
85 template <
typename NodeFunctor>
87 template <
typename Visitor>
89 template <
typename Visitor>
111 template <
typename T,
int Dim>
113 template <
typename T,
typename MeshType,
int Dim>
120 template <
int64_t cell_dimension,
typename NodeFunctor>
122 template <
typename Visitor>
124 template <
typename NodeFunctor>
127 template <
typename Visitor>
149 std::map<std::string, const wmtk::utils::Hashable*>
child_hashables()
const override;
150 std::map<std::string, std::size_t>
child_hashes()
const override;
154 Mesh(
const int64_t& dimension);
156 Mesh(
const int64_t& dimension,
const int64_t& max_primitive_type_id,
PrimitiveType hash_type);
191 virtual std::tuple<std::vector<std::vector<int64_t>>, std::vector<std::vector<int64_t>>>
203 std::vector<attribute::MeshAttributeHandle::HandleVariant>
builtin_attributes()
const;
204 std::vector<attribute::MeshAttributeHandle::HandleVariant>
custom_attributes()
const;
208 template <
typename T>
210 const std::string& name,
213 bool replace =
false,
214 T default_value = T(0));
217 template <
typename T>
219 const std::string& name,
222 bool replace =
false,
223 T default_value = T(0));
227 template <
typename T>
229 const std::string& name,
232 template <
typename T>
234 const std::string& name,
237 template <
typename T>
239 const std::string& name,
243 template <
typename T,
int D = Eigen::Dynamic>
247 template <
typename T,
int D = Eigen::Dynamic>
251 template <
typename T,
int D = Eigen::Dynamic>
254 template <
typename T,
int D = Eigen::Dynamic>
258 template <
typename T>
261 template <
typename T>
264 template <
typename T>
276 const std::vector<attribute::MeshAttributeHandle::HandleVariant>& keep_attributes);
278 void clear_attributes(
const std::vector<attribute::MeshAttributeHandle>& keep_attributes);
295 template <
typename Functor,
typename... Args>
303 bool operator==(const
Mesh& other) const;
325 const
std::vector<
std::vector<simplex::Simplex>>& simplices) const;
376 #if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
377 template <std::ranges::forward_range ContainerType>
379 template <
typename ContainerType>
387 #if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
388 template <std::ranges::forward_range ContainerType>
390 template <
typename ContainerType>
396 const std::initializer_list<PrimitiveType>& op_sequence)
const;
531 const std::shared_ptr<Mesh>& child_mesh_ptr,
532 const std::vector<std::array<Tuple, 2>>&
map_tuples);
579 std::vector<simplex::Simplex>
map(
580 const Mesh& other_mesh,
581 const std::vector<simplex::Simplex>& my_simplices)
const;
594 std::vector<simplex::Simplex>
lub_map(
595 const Mesh& other_mesh,
608 std::vector<simplex::Simplex>
lub_map(
609 const Mesh& other_mesh,
610 const std::vector<simplex::Simplex>& my_simplices)
const;
646 const Mesh& child_mesh,
678 const Mesh& other_mesh,
680 const std::vector<Tuple>& my_simplices)
const;
707 const Mesh& other_mesh,
709 const std::vector<Tuple>& my_simplices)
const;
748 const Mesh& child_mesh,
823 template <
typename T,
typename MeshType>
828 template <
typename T,
typename MeshType>
881 const bool include_deleted)
const;
885 template <
typename T,
int D>
891 template <
typename T,
int D>
898 template <
typename T,
int D>
902 assert(&handle.mesh() ==
this);
903 assert(handle.holds<T>());
904 return create_accessor<T, D>(handle.as<T>());
908 template <
typename T,
int D>
912 assert(&handle.mesh() ==
this);
913 assert(handle.holds<T>());
914 return create_const_accessor<T, D>(handle.as<T>());
917 template <
typename T>
919 const std::string& name,
923 *
const_cast<Mesh*
>(
this),
924 get_attribute_handle_typed<T>(name, ptype));
927 template <
typename T>
929 const std::string& name,
937 template <
typename T>
943 template <
typename T>
949 template <
typename T>
955 template <
typename Functor,
typename... Args>
956 inline decltype(
auto)
Mesh::parent_scope(Functor&& f, Args&&... args)
const
960 return std::invoke(std::forward<Functor>(f), std::forward<Args>(args)...);
963 #if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
964 template <std::ranges::forward_range ContainerType>
966 template <
typename ContainerType>
970 static_assert(std::is_same_v<typename ContainerType::value_type, PrimitiveType>);
979 if (primitive == top_type &&
is_boundary(boundary_pt, r)) {
1000 assert(dimension >= 0);
1001 assert(dimension < 4);
1006 #if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
1007 template <std::ranges::forward_range ContainerType>
1009 template <
typename ContainerType>
1013 static_assert(std::is_same_v<typename ContainerType::value_type, PrimitiveType>);
void set_capacities(std::vector< int64_t > capacities)
Tuple switch_tuples_unsafe(const Tuple &tuple, const ContainerType &op_sequence) const
Mesh(const int64_t &dimension)
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...
virtual std::vector< Tuple > orient_vertices(const Tuple &t) const =0
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
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))
static auto & get_index_access(const attribute::Accessor< T, MeshType > &attr)
void serialize(MeshWriter &writer, const Mesh *local_root=nullptr) const
attribute::MeshAttributeHandle get_attribute_handle(const std::string &name, const PrimitiveType ptype) 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
const attribute::Accessor< T, Mesh, D > create_const_accessor(const attribute::MeshAttributeHandle &handle) 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)
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
static auto & get_index_access(attribute::Accessor< T, MeshType > &attr)
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.
multimesh::MultiMeshManager m_multi_mesh_manager
multimesh::attribute::AttributeScopeHandle create_scope()
std::vector< std::vector< int64_t > > simplices_to_gids(const std::vector< std::vector< simplex::Simplex >> &simplices) const
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
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
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
Mesh & operator=(const Mesh &other)=delete
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
attribute::Accessor< T, Mesh, D > create_accessor(const attribute::MeshAttributeHandle &handle)
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.
virtual std::vector< std::vector< TypedAttributeHandle< int64_t > > > connectivity_attributes() const =0
Returns a vector of vectors of attribute handles.
friend class tests::DEBUG_Mesh
void delete_attribute(const attribute::MeshAttributeHandle &to_delete)
int64_t m_top_cell_dimension
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
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
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
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
const attribute::Accessor< T, Mesh, D > create_const_accessor(const TypedAttributeHandle< T > &handle) const
void deregister_child_mesh(const std::shared_ptr< Mesh > &child_mesh_ptr)
Deregister a child mesh.
bool has_child_mesh() const
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
friend class tests::tools::TestTools
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
attribute::Accessor< T, Mesh, D > create_accessor(const TypedAttributeHandle< T > &handle)
A CachingAccessor that uses tuples for accessing attributes instead of indices.
CachingBaseType & index_access()
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
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.
A meshless implementation of the simplex that just stores an array of ids.
std::pair< std::shared_ptr< Mesh >, std::shared_ptr< Mesh > > multimesh(const MultiMeshType &type, Mesh &parent, std::shared_ptr< Mesh > child, const attribute::MeshAttributeHandle parent_position_handle, const std::string &tag_name, const int64_t tag_value, const int64_t primitive)