Wildmeshing Toolkit
tuple_map_attribute_io.hpp
Go to the documentation of this file.
1 #include <wmtk/Types.hpp>
3 
4 // #define WMTK_DISABLE_COMPRESSED_MULTIMESH_TUPLE
5 namespace wmtk::multimesh::utils {
6 #if defined WMTK_DISABLE_COMPRESSED_MULTIMESH_TUPLE
7 constexpr static int64_t TUPLE_SIZE = 4; // in terms of int64_t
8 constexpr static int64_t GLOBAL_ID_INDEX = 3;
9 #else
10 constexpr static int64_t TUPLE_SIZE = 2; // in terms of int64_t
11 constexpr static int64_t GLOBAL_ID_INDEX = 0;
12 #endif
13 constexpr static int64_t DEFAULT_TUPLES_VALUES = -1;
14 constexpr static int64_t TWO_TUPLE_SIZE = TUPLE_SIZE * 2; // in terms of int64_t
17 
18 
20 Tuple vector_to_tuple(const Eigen::Ref<const TupleVector>& v);
21 
22 std::tuple<Tuple, Tuple> vectors_to_tuples(const Eigen::Ref<const TwoTupleVector>& v);
23 TwoTupleVector tuples_to_vectors(const Tuple& a, const Tuple& b);
24 
25 // utility functions to simplify how we encode 2-Tuple attributes as 10-int64_t attribute
26 template <typename MeshType>
29  const Tuple& source_tuple,
30  const Tuple& target_tuple);
31 
32 template <typename MeshType>
33 std::tuple<Tuple, Tuple> read_tuple_map_attribute(
35  const Tuple& source_tuple);
36 
37 
38 template <typename MeshA, typename MeshB>
42  const Tuple& a_tuple,
43  const Tuple& b_tuple)
44 {
45  write_tuple_map_attribute(a_to_b, a_tuple, b_tuple);
46  write_tuple_map_attribute(b_to_a, b_tuple, a_tuple);
47 }
49  Mesh& source_mesh,
51  const Tuple& source_tuple,
52  const Tuple& target_tuple);
53 
54 
55 std::tuple<Tuple, Tuple> read_tuple_map_attribute_slow(
56  const Mesh& source_mesh,
58  const Tuple& source_tuple);
59 } // namespace wmtk::multimesh::utils
Handle that represents attributes for some mesh.
Vector< int64_t, TUPLE_SIZE > tuple_to_vector(const Tuple &t)
std::tuple< Tuple, Tuple > vectors_to_tuples(const Eigen::Ref< const TwoTupleVector > &v)
std::tuple< Tuple, Tuple > read_tuple_map_attribute(const wmtk::attribute::Accessor< int64_t, MeshType > &accessor, const Tuple &source_tuple)
TwoTupleVector tuples_to_vectors(const Tuple &a, const Tuple &b)
void write_tuple_map_attribute(wmtk::attribute::Accessor< int64_t, MeshType > &map_accessor, const Tuple &source_tuple, const Tuple &target_tuple)
void symmetric_write_tuple_map_attributes(wmtk::attribute::Accessor< int64_t, MeshA > &a_to_b, wmtk::attribute::Accessor< int64_t, MeshB > &b_to_a, const Tuple &a_tuple, const Tuple &b_tuple)
void write_tuple_map_attribute_slow(Mesh &source_mesh, TypedAttributeHandle< int64_t > map_handle, const Tuple &source_tuple, const Tuple &target_tuple)
Vector< int64_t, TUPLE_SIZE > TupleVector
Vector< int64_t, TWO_TUPLE_SIZE > TwoTupleVector
std::tuple< Tuple, Tuple > read_tuple_map_attribute_slow(const Mesh &source_mesh, TypedAttributeHandle< int64_t > map_handle, const Tuple &source_tuple)
Tuple vector_to_tuple(const Eigen::Ref< const TupleVector > &v)
Eigen::Matrix< T, R, 1 > Vector
Definition: Types.hpp:17