5 #include <initializer_list>
24 #include "attribute/AttributeScopeHandle.hpp"
37 #if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
53 class AttributeManager;
54 template <
typename T,
typename MeshType,
int Dim>
58 namespace operations {
62 class EdgeOperationData;
67 class UpdateEdgeOperationMultiMeshMapFunctor;
82 template <
int64_t cell_dimension,
typename NodeFunctor>
84 template <
typename NodeFunctor>
86 template <
typename Visitor>
88 template <
typename Visitor>
110 template <
typename T,
int Dim>
112 template <
typename T,
typename MeshType,
int Dim>
119 template <
int64_t cell_dimension,
typename NodeFunctor>
121 template <
typename Visitor>
123 template <
typename NodeFunctor>
126 template <
typename Visitor>
148 std::map<std::string, const wmtk::utils::Hashable*>
child_hashables()
const override;
149 std::map<std::string, std::size_t>
child_hashes()
const override;
153 Mesh(
const int64_t& dimension);
155 Mesh(
const int64_t& dimension,
const int64_t& max_primitive_type_id,
PrimitiveType hash_type);
190 virtual std::tuple<std::vector<std::vector<int64_t>>, std::vector<std::vector<int64_t>>>
202 std::vector<attribute::MeshAttributeHandle::HandleVariant>
builtin_attributes()
const;
203 std::vector<attribute::MeshAttributeHandle::HandleVariant>
custom_attributes()
const;
207 template <
typename T>
209 const std::string& name,
212 bool replace =
false,
213 T default_value = T(0));
216 template <
typename T>
218 const std::string& name,
221 bool replace =
false,
222 T default_value = T(0));
226 template <
typename T>
228 const std::string& name,
231 template <
typename T>
233 const std::string& name,
236 template <
typename T>
238 const std::string& name,
242 template <
typename T,
int D = Eigen::Dynamic>
246 template <
typename T,
int D = Eigen::Dynamic>
250 template <
typename T,
int D = Eigen::Dynamic>
253 template <
typename T,
int D = Eigen::Dynamic>
257 template <
typename T>
260 template <
typename T>
263 template <
typename T>
275 const std::vector<attribute::MeshAttributeHandle::HandleVariant>& keep_attributes);
277 void clear_attributes(
const std::vector<attribute::MeshAttributeHandle>& keep_attributes);
294 template <
typename Functor,
typename... Args>
302 bool operator==(const
Mesh& other) const;
324 const
std::vector<
std::vector<simplex::Simplex>>& simplices) const;
375 #if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
376 template <std::ranges::forward_range ContainerType>
378 template <
typename ContainerType>
386 #if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
387 template <std::ranges::forward_range ContainerType>
389 template <
typename ContainerType>
395 const std::initializer_list<PrimitiveType>& op_sequence)
const;
530 const std::shared_ptr<Mesh>& child_mesh_ptr,
531 const std::vector<std::array<Tuple, 2>>&
map_tuples);
578 std::vector<simplex::Simplex>
map(
579 const Mesh& other_mesh,
580 const std::vector<simplex::Simplex>& my_simplices)
const;
593 std::vector<simplex::Simplex>
lub_map(
594 const Mesh& other_mesh,
607 std::vector<simplex::Simplex>
lub_map(
608 const Mesh& other_mesh,
609 const std::vector<simplex::Simplex>& my_simplices)
const;
645 const Mesh& child_mesh,
677 const Mesh& other_mesh,
679 const std::vector<Tuple>& my_simplices)
const;
706 const Mesh& other_mesh,
708 const std::vector<Tuple>& my_simplices)
const;
747 const Mesh& child_mesh,
822 template <
typename T,
typename MeshType>
827 template <
typename T,
typename MeshType>
880 const bool include_deleted)
const;
884 template <
typename T,
int D>
890 template <
typename T,
int D>
897 template <
typename T,
int D>
901 assert(&handle.mesh() ==
this);
902 assert(handle.holds<T>());
903 return create_accessor<T, D>(handle.as<T>());
907 template <
typename T,
int D>
911 assert(&handle.mesh() ==
this);
912 assert(handle.holds<T>());
913 return create_const_accessor<T, D>(handle.as<T>());
916 template <
typename T>
918 const std::string& name,
922 *
const_cast<Mesh*
>(
this),
923 get_attribute_handle_typed<T>(name, ptype));
926 template <
typename T>
928 const std::string& name,
936 template <
typename T>
942 template <
typename T>
948 template <
typename T>
954 template <
typename Functor,
typename... Args>
955 inline decltype(
auto)
Mesh::parent_scope(Functor&& f, Args&&... args)
const
959 return std::invoke(std::forward<Functor>(f), std::forward<Args>(args)...);
962 #if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
963 template <std::ranges::forward_range ContainerType>
965 template <
typename ContainerType>
969 static_assert(std::is_same_v<typename ContainerType::value_type, PrimitiveType>);
978 if (primitive == top_type &&
is_boundary(boundary_pt, r)) {
999 assert(dimension >= 0);
1000 assert(dimension < 4);
1005 #if defined(__cpp_concepts) && defined(__cpp_lib_ranges)
1006 template <std::ranges::forward_range ContainerType>
1008 template <
typename ContainerType>
1012 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.
const attribute::Accessor< char > get_const_flag_accessor(PrimitiveType type) const
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
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
const attribute::Accessor< char > get_flag_accessor(PrimitiveType type) 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
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)