Wildmeshing Toolkit
Loading...
Searching...
No Matches
CollapseAlternateFacetData.cpp
Go to the documentation of this file.
2#include <array>
3#include <vector>
4#include <wmtk/Mesh.hpp>
12
14namespace {
15constexpr auto sort_op = [](const CollapseAlternateFacetData::Data& a,
16 const CollapseAlternateFacetData::Data& b) -> bool {
17 return a.input.global_id() < b.input.global_id();
18};
19constexpr auto sort_int_op = [](const CollapseAlternateFacetData::Data& value,
20 const int64_t& facet_id) -> bool {
21 return value.input.global_id() < facet_id;
22};
23} // namespace
24
25void CollapseAlternateFacetData::add(const Mesh& m, const Tuple& input_tuple)
26{
27 m_data.emplace_back(m, input_tuple);
28 // first tuple is different from the input by switching everything but vertex
29 // second one is switch everything
30}
31
33{
34 std::sort(m_data.begin(), m_data.end(), sort_op);
35}
36
37
40
41auto CollapseAlternateFacetData::get_alternative_data_it(const int64_t& input_facet) const
42 -> AltData::const_iterator
43{
44 assert(std::is_sorted(m_data.begin(), m_data.end(), sort_op));
45 auto it = std::lower_bound(m_data.begin(), m_data.end(), input_facet, sort_int_op);
46 auto end = m_data.cend();
47
48 // if we found
49
50 // fix case where the lower bound was not the target value
51 if (it != end && it->input.global_id() != input_facet) {
52 it = end;
53 }
54 return it;
55}
57{
58 auto it = get_alternative_data_it(t.global_cid());
59 assert(it != m_data.cend());
60 return *it;
61}
63 const PrimitiveType mesh_pt,
64 const Tuple& t,
65 const PrimitiveType simplex_dimension) const
66{
67 const auto& data = get_alternatives_data(t);
68
70 const wmtk::autogen::Dart t_dart = sd.dart_from_tuple(t);
71
72 const int8_t action =
73 wmtk::multimesh::utils::find_local_dart_action(mesh_pt, t_dart, data.input);
74 auto map = [&data](const size_t index) -> Tuple {
75 const wmtk::autogen::Dart& transform = data.alts[index];
76 const int8_t& local_boundary_index = data.local_boundary_indices[index];
77 // const PrimitiveType mappable_dart_dimension = a;
78 // if (transform.is_null() || mappable_dart_dimension < simplex_dimension) {
79 // return {};
80 // } else {
81 // int8_t projected_subdart = sd.convert(action, , mesh_pt - 1);
82 // int8_t mapped_dart = sd.product(tup.local_orientation(), action);
83 // const wmtk::autogen::Dart d(tup.global_id(), mapped_dart);
84 // return sd.tuple_from_dart(d);
85 // }
86 return {};
87 };
88
89 std::array<Tuple, 2> r{{map(0), map(1)}};
90
91 return r;
92}
94 const PrimitiveType mesh_pt,
95 const Tuple& t,
96 const PrimitiveType pt) const
97{
98 // TODO: map to a valid face
99
100
101 auto alts = get_alternatives(mesh_pt, t, pt);
102 assert(!alts[0].is_null() || !alts[1].is_null());
103 if (!alts[0].is_null()) {
104 return alts[0];
105 } else {
106 return alts[1];
107 }
108 return {};
109 //
110}
111} // namespace wmtk::operations::internal
The Tuple is the basic navigation tool in our mesh data structure.
Definition Tuple.hpp:19
static const SimplexDart & get_singleton(wmtk::PrimitiveType simplex_type)
Dart dart_from_tuple(const wmtk::Tuple &t) const
AltData::const_iterator get_alternative_data_it(const int64_t &input_facet) const
std::array< Tuple, 2 > get_alternatives(const PrimitiveType mesh_pt, const Tuple &t, const PrimitiveType simplex_dimension) const
Tuple get_alternative(const PrimitiveType mesh_pt, const Tuple &t, const PrimitiveType simplex_dimension) const
int8_t find_local_dart_action(PrimitiveType pt, const Tuple &source, const Tuple &target)