Wildmeshing Toolkit
Loading...
Searching...
No Matches
SimplexDart.cpp
Go to the documentation of this file.
1#include "SimplexDart.hpp"
2#include <cassert>
11
12namespace wmtk::autogen {
13namespace {
14
15
16/*
17int8_t empty_binary(int8_t,int8_t){
18 assert(false);
19}
20
21int8_t empty_unary(int8_t){
22 assert(false);
23}
24int8_t empty_unary(){
25 assert(false);
26}
27
28template <typename T>
29 void f();
30
31template <typename
32 */
33
34
35#define GET_OP(NAME, RETTYPE) \
36 auto get_##NAME(PrimitiveType pt)->SimplexDart::RETTYPE \
37 { \
38 switch (pt) { \
39 case PrimitiveType::Edge: return &edge_mesh::SimplexDart::NAME; \
40 case PrimitiveType::Triangle: return &tri_mesh::SimplexDart::NAME; \
41 case PrimitiveType::Tetrahedron: return &tet_mesh::SimplexDart::NAME; \
42 case PrimitiveType::Vertex: return &point_mesh::SimplexDart::NAME; \
43 default: assert(false); \
44 } \
45 return nullptr; \
46 }
47GET_OP(product, binary_op_type)
48GET_OP(inverse, unary_op_type)
49GET_OP(primitive_to_index, primitive_to_index_type)
50GET_OP(identity, nullary_op_type)
51GET_OP(opposite, nullary_op_type)
52} // namespace
53
54#define FORWARD_OP(NAME, OP, RETTYPE, DEFAULT) \
55 auto SimplexDart::NAME() const->RETTYPE \
56 { \
57 switch (m_simplex_type) { \
58 case PrimitiveType::Edge: return edge_mesh::SimplexDart::OP(); \
59 case PrimitiveType::Triangle: return tri_mesh::SimplexDart::OP(); \
60 case PrimitiveType::Tetrahedron: return tet_mesh::SimplexDart::OP(); \
61 case PrimitiveType::Vertex: return point_mesh::SimplexDart::OP(); \
62 default: assert(false); \
63 } \
64 return DEFAULT; \
65 }
66
67FORWARD_OP(size, size, size_t, {})
69namespace {
70const static DynamicIntMap nullmap = DynamicIntMap(nullptr, 0);
71}
72FORWARD_OP(valid_indices, valid_indices_dynamic, DynamicIntMap, nullmap)
73
75 : m_simplex_type(simplex_type)
76 , m_product(get_product(simplex_type))
77 , m_inverse(get_inverse(simplex_type))
78 , m_primitive_to_index(get_primitive_to_index(simplex_type))
79 , m_identity(get_identity(simplex_type))
80 , m_opposite(get_opposite(simplex_type))
81{}
91
92int8_t SimplexDart::product(int8_t a, int8_t b) const
93{
94 return m_product(a, b);
95}
96int8_t SimplexDart::inverse(int8_t a) const
97{
98 return m_inverse(a);
99}
100Dart SimplexDart::act(const Dart& d, int8_t action) const
101{
102 return Dart(d.global_id(), product(action, d.local_orientation()));
103}
104
110{
111 return m_identity();
112}
114{
115 return m_opposite();
116}
117wmtk::Tuple SimplexDart::tuple_from_valid_index(int64_t gid, int8_t index) const
118{
120}
129
130int8_t SimplexDart::convert(int8_t valid_index, const SimplexDart& target) const
131{
133 return 0;
135 return target.identity();
136 } else {
137 return subgroup::convert(m_simplex_type, target.m_simplex_type, valid_index);
138 }
139}
140
149
150int8_t SimplexDart::simplex_index(const Dart& dart, PrimitiveType simplex_type) const
151{
153}
154int8_t SimplexDart::simplex_index(const int8_t valid_index, PrimitiveType simplex_type) const
155{
157}
158} // namespace wmtk::autogen
#define GET_OP(NAME, RETTYPE)
#define FORWARD_OP(NAME, OP, RETTYPE, DEFAULT)
The Tuple is the basic navigation tool in our mesh data structure.
Definition Tuple.hpp:19
int64_t global_cid() const
Definition Tuple.hxx:47
int64_t & global_id()
Definition Dart.hpp:15
int8_t & local_orientation()
Definition Dart.hpp:18
const nullary_op_type m_identity
wmtk::Tuple tuple_from_dart(const Dart &dart) const
int8_t simplex_index(const int8_t valid_index, PrimitiveType simplex_type) const
int8_t valid_index_from_tuple(const wmtk::Tuple &t) const
const wmtk::PrimitiveType m_simplex_type
static const SimplexDart & get_singleton(wmtk::PrimitiveType simplex_type)
const unary_op_type m_inverse
wmtk::Tuple update_tuple_from_valid_index(const Tuple &t, int8_t valid_index) const
wmtk::PrimitiveType simplex_type() const
const primitive_to_index_type m_primitive_to_index
const binary_op_type m_product
int8_t primitive_as_index(wmtk::PrimitiveType pt) const
int8_t inverse(int8_t a) const
int8_t product(int8_t a, int8_t b) const
const nullary_op_type m_opposite
Dart act(const Dart &d, int8_t action) const
Dart dart_from_tuple(const wmtk::Tuple &t) const
int8_t convert(int8_t valid_index, const SimplexDart &target) const
wmtk::Tuple tuple_from_valid_index(int64_t gid, int8_t valid_index) const
int8_t convert(PrimitiveType from, PrimitiveType to, int8_t source)
Definition convert.hxx:8
int8_t simplex_index_from_valid_index(PrimitiveType mesh_type, int8_t valid_tuple_index, PrimitiveType simplex_type)
int8_t valid_index_from_tuple(PrimitiveType mesh_type, const Tuple &t)
Tuple tuple_from_valid_index(PrimitiveType mesh_type, const int64_t global_cid, int8_t valid_tuple_index)
VectorX< int8_t >::ConstMapType DynamicIntMap
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.
Vector< T, Eigen::Dynamic > VectorX
Definition Types.hpp:19