Wildmeshing Toolkit
Loading...
Searching...
No Matches
SplitAlternateFacetOptionData.cpp
Go to the documentation of this file.
4
5
7namespace {
8// hi!
9
10using Pair = std::array<int8_t, 2>;
11using PairPair = std::array<Pair, 2>;
12template <int8_t Dim>
13auto make_inds()
14{
15 auto run = [](auto size_const) {
16 using T = decltype(size_const);
17 constexpr static size_t C = T::value;
18 std::array<PairPair, C> ret = {};
19 const auto& sd = wmtk::autogen::SimplexDart(PrimitiveType(Dim));
20 const auto boundary_type = PrimitiveType(Dim - 1);
21 for (size_t j = 0; j < ret.size(); ++j) {
22 auto& r = ret[j];
23 auto& main = std::get<0>(r);
24 auto& dual = std::get<1>(r);
25 const int8_t edge_index = j;
26
27 for (int8_t k = 0; k < sd.size(); ++k) {
28 if (sd.simplex_index(k, wmtk::PrimitiveType::Edge) == edge_index) {
29 const int8_t left = sd.product(left_ear_action(sd.simplex_type()), k);
30 const int8_t right = sd.product(right_ear_action(sd.simplex_type()), k);
31 main[0] = sd.simplex_index(left, boundary_type);
32 main[1] = sd.simplex_index(right, boundary_type);
33 break;
34 }
35 }
36
37
38 dual[1] = main[0];
39 dual[0] = main[1];
40 }
41 return ret;
42 };
43 if constexpr (Dim == 1) {
44 return run(std::integral_constant<size_t, 1>{});
45 } else if constexpr (Dim == 2) {
46 return run(std::integral_constant<size_t, 3>{});
47 } else if constexpr (Dim == 3) {
48 return run(std::integral_constant<size_t, 6>{});
49 }
50}
51template <size_t ArrSize>
52const std::array<int8_t, 2>& boundary_indices_(
54 int8_t o,
55 const std::array<PairPair, ArrSize>& arr)
56{
57 const int8_t edge_index = sd.simplex_index(o, wmtk::PrimitiveType::Edge);
58 const int8_t boundary_index =
59 sd.simplex_index(sd.product(sd.opposite(), o), sd.simplex_type() - 1);
60 const PairPair& pairpair = arr.at(edge_index);
61 const Pair& pair = std::get<0>(pairpair);
62 static_assert(std::tuple_size_v<Pair> == 2);
63 if (boundary_index == std::get<1>(pair)) {
64 return pairpair[0];
65 } else {
66 return pairpair[1];
67 }
68}
69
70const std::array<int8_t, 2>& boundary_indices_(
72 int8_t orientation)
73{
74 const static std::array<PairPair, 1> edge_inds = make_inds<1>();
75 const static std::array<PairPair, 3> tri_inds = make_inds<2>();
76 const static std::array<PairPair, 6> tet_inds = make_inds<3>();
77
78
79 switch (sd.simplex_type()) {
80 case PrimitiveType::Tetrahedron: return boundary_indices_(sd, orientation, tet_inds);
81 case PrimitiveType::Triangle: return boundary_indices_(sd, orientation, tri_inds);
82 case PrimitiveType::Edge: return boundary_indices_(sd, orientation, edge_inds);
84 default: break;
85 }
86 constexpr static Pair empty = {};
87 assert(false);
88 return empty;
89}
90} // namespace
92 -> const std::array<int8_t, 2>&
93{
94 const auto& sd = wmtk::autogen::SimplexDart::get_singleton(mesh_type);
95 const auto& boundary_inds = boundary_indices_(sd, input.local_orientation());
96 return boundary_inds;
97}
98
100 const Dart& i,
101 const std::array<int64_t, 2>& n)
102 : input(i)
103 , new_facet_indices(n)
104{}
105
106
107auto SplitAlternateFacetOptionData::new_gid(PrimitiveType mesh_type, int8_t orientation) const
108 -> int64_t
109{
110 const auto& sd = wmtk::autogen::SimplexDart::get_singleton(mesh_type);
111 const auto& boundary_simplex_indices = boundary_indices(mesh_type);
112
113
114 const PrimitiveType boundary_type = mesh_type - 1;
115 // the local indices of the ears of faces
116
117 auto get_size = [&](size_t index) {
119 mesh_type,
120 orientation,
121 boundary_type,
122 boundary_simplex_indices[index]);
123 };
124 const std::array<int8_t, 2> sizes{{get_size(0), get_size(1)}};
125 if (sizes[0] >= sizes[1]) {
126 return new_facet_indices[0];
127 } else {
128 return new_facet_indices[1];
129 }
130}
131
132
133} // namespace wmtk::operations::internal
int8_t simplex_index(const int8_t valid_index, PrimitiveType simplex_type) const
static const SimplexDart & get_singleton(wmtk::PrimitiveType simplex_type)
wmtk::PrimitiveType simplex_type() const
int8_t product(int8_t a, int8_t b) const
int64_t new_gid(PrimitiveType primitive_type, int8_t index) const
SplitAlternateFacetOptionData(const Dart &input_tuple, const std::array< int64_t, 2 > &new_facet_indices)
const std::array< int8_t, 2 > & boundary_indices(PrimitiveType pt) const
auto largest_shared_subdart_size(PrimitiveType mesh_type, int8_t dart_index, int8_t simplex_dimension, int8_t simplex_index) -> int8_t
int8_t right_ear_action(PrimitiveType mesh_type)
int8_t left_ear_action(PrimitiveType mesh_type)