Wildmeshing Toolkit
CofacesSingleDimensionIterable.cpp
Go to the documentation of this file.
2 
4 #include <wmtk/utils/Logger.hpp>
6 
7 namespace wmtk::simplex {
8 
9 
11  const Mesh& mesh,
12  const Simplex& simplex,
13  const PrimitiveType cofaces_type)
14  : m_mesh(mesh)
15  , m_simplex(simplex)
16  , m_cofaces_type(cofaces_type)
17  , m_tdc_itrbl(mesh, simplex, cofaces_type != mesh.top_simplex_type())
18  , m_it_end(m_tdc_itrbl.end())
19 {
20  assert(cofaces_type >= simplex.primitive_type());
21 }
22 
25  const Tuple& t)
26  : m_container(container)
27  , m_it(container.m_tdc_itrbl, t)
28 {
29  if ((*m_it).is_null()) {
30  return;
31  }
32 
33  init();
34 }
35 
37 {
38  if (m_container.m_simplex.primitive_type() == m_container.m_cofaces_type) {
39  *m_it = Tuple();
40  return *this;
41  }
42 
43  if (depth() == 3) {
44  return step_depth_3();
45  }
46 
47  ++m_it;
48  return *this;
49 }
50 
52 {
53  return *m_it != *other;
54 }
55 
57 {
58  return *m_it;
59 }
60 
62 {
63  return *m_it;
64 }
65 
67 {
68  const Mesh& mesh = m_container.m_mesh;
69  const simplex::Simplex& simplex = m_container.m_simplex;
70  assert(mesh.top_cell_dimension() >= get_primitive_type_id(simplex.primitive_type()));
71  assert(mesh.top_cell_dimension() - get_primitive_type_id(simplex.primitive_type()) < 4);
72 
73  return mesh.top_cell_dimension() - get_primitive_type_id(simplex.primitive_type());
74 }
75 
77 {
78  return m_container.m_mesh.top_cell_dimension() ==
79  get_primitive_type_id(m_container.m_cofaces_type);
80 }
81 
83 {
84  if (depth() == 3 && !is_coface_d0()) {
85  const Mesh& mesh = m_container.m_mesh;
86  const PrimitiveType& cofaces_type = m_container.m_cofaces_type;
87 
88  m_container.m_visited_cofaces.is_visited(mesh.get_id_simplex(*m_it, cofaces_type));
89  }
90 }
91 
93 {
94  const Mesh& mesh = m_container.m_mesh;
95  const simplex::Simplex& simplex = m_container.m_simplex;
96  const PrimitiveType& cofaces_type = m_container.m_cofaces_type;
97  auto& visited = m_container.m_visited_cofaces;
98 
99  if (!is_coface_d0()) {
101  ++m_edge_counter;
102 
103  while (!(*m_it).is_null()) {
104  for (; m_edge_counter < 3; ++m_edge_counter) {
105  if (!visited.is_visited(mesh.get_id_simplex(*m_it, cofaces_type))) {
106  return *this;
107  }
109  }
110 
111  // go to next cell
112  m_edge_counter = 0;
113  ++m_it;
114  }
115  } else {
116  ++m_it;
117  }
118 
119  return *this;
120 }
121 
122 } // namespace wmtk::simplex
Tuple switch_tuples(const Tuple &tuple, const ContainerType &op_sequence) const
Definition: Mesh.hpp:967
int64_t top_cell_dimension() const
Definition: Mesh.hpp:992
simplex::IdSimplex get_id_simplex(const Tuple &tuple, PrimitiveType pt) const
Retrieve the IdSimplex that is represented by the tuple and primitive type.
Definition: Mesh.cpp:28
int64_t depth()
Compute the depth from the mesh and the simplex type.
Iterator & step_depth_3()
Use breadth first search to find all d-simplices, and iterate through all cofaces in a d-simplex.
void init()
Depending on the depth, the iterator must be initialized differently.
Iterator(CofacesSingleDimensionIterable &container, const Tuple &t=Tuple())
bool is_coface_d0()
Check if coface type is the mesh's top simplex type.
This iterator internally uses TopDimensionCofacesIterable.
CofacesSingleDimensionIterable(const Mesh &mesh, const Simplex &simplex, const PrimitiveType cofaces_type)
PrimitiveType primitive_type() const
Definition: Simplex.hpp:51
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.