Wildmeshing Toolkit
FusionEdgeInvariant.cpp
Go to the documentation of this file.
2 #include <wmtk/Mesh.hpp>
4 
5 namespace wmtk::invariants {
6 FusionEdgeInvariant::FusionEdgeInvariant(const Mesh& position_mesh, const Mesh& periodic_mesh)
7  : Invariant(position_mesh)
8  , m_periodic_mesh(periodic_mesh)
9 {}
10 
12 {
13  if (!mesh().is_boundary(PrimitiveType::Edge, s.tuple())) {
14  // non boundary edge, check boundary vertrex
15  // if any one of the vertex is on boundary, return false
16  if (mesh().is_boundary(PrimitiveType::Vertex, s.tuple()) ||
17  mesh().is_boundary(
19  mesh().switch_tuple(s.tuple(), PrimitiveType::Vertex))) {
20  return false;
21  } else {
22  return true;
23  }
24  } else {
25  std::array<wmtk::simplex::Simplex, 2> periodic_v = {
28  mesh(),
29  mesh().switch_tuple(s.tuple(), PrimitiveType::Vertex)))}};
30 
31  // check periodic vertex is on the the periodic mesh boundary, if is, return false
32  // only allow operation on edges that are not on the boudnary of the periodic mesh
33  if (m_periodic_mesh.is_boundary(PrimitiveType::Vertex, periodic_v[0].tuple()) ||
34  m_periodic_mesh.is_boundary(PrimitiveType::Vertex, periodic_v[1].tuple())) {
35  return false;
36  }
37 
38  // check periodic vertex can be mapped to more than 2 vertieces in position mesh
39  // check corner
40  if (m_periodic_mesh.map_to_child(mesh(), periodic_v[0]).size() > 2 ||
41  m_periodic_mesh.map_to_child(mesh(), periodic_v[1]).size() > 2) {
42  return false;
43  }
44 
45  return true;
46  }
47 
48  // TODO: add code for 3d
49 }
50 
51 
52 } // namespace wmtk::invariants
bool is_boundary(const simplex::Simplex &tuple) const
check if a simplex lies on a boundary or not
Definition: Mesh.cpp:106
simplex::Simplex map_to_parent(const simplex::Simplex &my_simplex) const
optimized map from a simplex from this mesh to its direct parent
std::vector< simplex::Simplex > map_to_child(const Mesh &child_mesh, const simplex::Simplex &my_simplex) const
optimized map fromsimplex from this mesh to one of its direct children
FusionEdgeInvariant(const Mesh &position_mesh, const Mesh &periodic_mesh)
bool before(const simplex::Simplex &s) const override
const Mesh & mesh() const
Definition: Invariant.cpp:35
const Tuple & tuple() const
Definition: Simplex.hpp:53
static Simplex vertex(const Mesh &m, const Tuple &t)
Definition: Simplex.hpp:56