Wildmeshing Toolkit
Loading...
Searching...
No Matches
SplitAlternateFacetData.cpp
Go to the documentation of this file.
2#include <algorithm>
3#include <array>
4#include <cassert>
5#include <vector>
6#include <wmtk/Mesh.hpp>
9#include "ear_actions.hpp"
11namespace {
12auto sort_op = [](const SplitAlternateFacetData::Data& a,
13 const SplitAlternateFacetData::Data& b) -> bool {
14 return a.input.global_id() < b.input.global_id();
15};
16
17auto sort_int_op = [](const SplitAlternateFacetData::Data& value, const int64_t& facet_id) -> bool {
18 return value.input.global_id() < facet_id;
19};
20} // namespace
21
23{
24 std::sort(m_facet_maps.begin(), m_facet_maps.end(), sort_op);
25}
26
27// assumes the split cell map has been sorted
28auto SplitAlternateFacetData::get_alternative_facets_it(const int64_t& input_cell) const
29 -> AltData::const_iterator
30{
31 assert(std::is_sorted(m_facet_maps.begin(), m_facet_maps.end(), sort_op));
32
33
34 auto it = std::lower_bound(m_facet_maps.begin(), m_facet_maps.end(), input_cell, sort_int_op);
35 auto end = m_facet_maps.cend();
36 // fix case where the lower bound was not the target value
37 if (it != end && it->input.global_id() != input_cell) {
38 it = end;
39 }
40 return it;
41}
43 -> const Data&
44{
45 const PrimitiveType pt = mesh.top_simplex_type();
46 const std::vector<int64_t> new_eids = EdgeOperationData::request_simplex_indices(mesh, pt, 2);
47 std::array<int64_t, 2> dat;
48 std::copy(new_eids.begin(), new_eids.end(), dat.begin());
49 return add_facet(mesh, edge_tuple, dat);
50}
52 const wmtk::Mesh& mesh,
53 const wmtk::Tuple& edge_tuple,
54 const std::array<int64_t, 2>& nfa) -> const Data&
55{
56 const PrimitiveType mesh_pt = mesh.top_simplex_type();
57 const auto& sd = wmtk::autogen::SimplexDart::get_singleton(mesh_pt);
58 return m_facet_maps.emplace_back(sd.dart_from_tuple(edge_tuple), nfa);
59}
60
61auto SplitAlternateFacetData::get_alternative_facets(const int64_t& input_cell) const
62 -> const std::array<int64_t, 2>&
63{
64 auto it = get_alternative_facets_it(input_cell);
65 assert(it != m_facet_maps.cend());
66 return it->new_facet_indices;
67}
69 const PrimitiveType mesh_pt,
70 const Tuple& t,
71 const PrimitiveType simplex_dimension) const -> Tuple
72{
73 assert(mesh_pt > PrimitiveType::Vertex);
74 const auto alts_it = get_alternative_facets_it(t.global_cid());
75 assert(alts_it != m_facet_maps.end());
76
77 const auto& sd = wmtk::autogen::SimplexDart::get_singleton(mesh_pt);
78
79 int64_t new_global_cid = alts_it->new_gid(mesh_pt, sd.valid_index_from_tuple(t));
80
81
82 return {t.local_vid(), t.local_eid(), t.local_fid(), new_global_cid};
83}
84} // 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)
static std::vector< int64_t > request_simplex_indices(Mesh &mesh, const PrimitiveType type, int64_t count)
Tuple get_alternative(const PrimitiveType mesh_pt, const Tuple &t, const PrimitiveType simplex_dimension) const
const Data & add_facet(const wmtk::Mesh &mesh, const wmtk::Tuple &edge_tuple, const std::array< int64_t, 2 > &new_facet_indices)
const std::array< int64_t, 2 > & get_alternative_facets(const int64_t &input_facet) const
AltData::const_iterator get_alternative_facets_it(const int64_t &input_facet) const