Wildmeshing Toolkit
VertexLaplacianSmooth.cpp
Go to the documentation of this file.
2 
3 #include <wmtk/Mesh.hpp>
4 #include <wmtk/simplex/link.hpp>
5 
6 
7 namespace wmtk::operations {
8 
10  : m_attibute_handle(handle)
11 {
12 #if !defined(NDEBUG) // pragma to make sure this heldtype isn't useful
14  assert(
15  handle.held_type() == HeldType::Double);
16 #endif
17 }
18 
19 
21 {
22  const std::vector<simplex::Simplex> one_ring =
24 
25  std::visit(
26  [&](const auto& handle) {
27  using T = typename std::decay_t<decltype(handle)>::value_type;
29  constexpr static HeldType ht =
30  attribute::MeshAttributeHandle::held_type_from_primitive<T>();
31 
32  auto run = [&](auto& accessor) {
33  auto p_mid = accessor.vector_attribute(simplex.tuple());
34  p_mid.setZero();
35  for (const simplex::Simplex& s : one_ring) {
36  p_mid = p_mid + accessor.vector_attribute(s.tuple());
37  }
38  p_mid = p_mid / one_ring.size();
39  };
40 
41  if constexpr (ht == HeldType::Double) {
42  auto accessor = mesh.create_accessor<double>(handle);
43  // run on double data
44  run(accessor);
45  }
46  },
48 
49  return true;
50 }
51 
52 } // namespace wmtk::operations
attribute::Accessor< T, Mesh, D > create_accessor(const attribute::MeshAttributeHandle &handle)
virtual bool operator()(Mesh &m, const simplex::Simplex &s)
attribute::MeshAttributeHandle m_attibute_handle
VertexLaplacianSmooth(const attribute::MeshAttributeHandle &handle)
const std::vector< Simplex > & simplex_vector() const
Return const reference to the simplex vector.
const Tuple & tuple() const
Definition: Simplex.hpp:53
SimplexCollection link(const Mesh &mesh, const simplex::Simplex &simplex, const bool sort_and_clean)
Definition: link.cpp:84