Wildmeshing Toolkit
from_boundary.cpp
Go to the documentation of this file.
1 #include "from_boundary.hpp"
2 #include <wmtk/Mesh.hpp>
4 #include "from_tag.hpp"
5 
6 
8 
9 
10  std::shared_ptr<Mesh> from_boundary(
11  Mesh& mesh,
12  const PrimitiveType ptype,
13  const std::string& attribute_name,
14  char value,
15  const std::vector<wmtk::attribute::MeshAttributeHandle>& passed_attributes)
16 {
17  auto is_boundary_handle = mesh.register_attribute<char>(attribute_name, ptype, 1);
18  auto is_boundary_accessor = mesh.create_accessor(is_boundary_handle.as<char>());
19 
20  for (const auto& t : mesh.get_all(ptype)) {
21  is_boundary_accessor.scalar_attribute(t) = mesh.is_boundary(ptype, t) ? value : 0;
22  }
23 
24  return from_tag(is_boundary_handle, value, passed_attributes);
25 }
26 
27 } // namespace wmtk::components::multimesh
attribute::MeshAttributeHandle register_attribute(const std::string &name, PrimitiveType type, int64_t size, bool replace=false, T default_value=T(0))
bool is_boundary(const simplex::Simplex &tuple) const
check if a simplex lies on a boundary or not
Definition: Mesh.cpp:106
std::vector< Tuple > get_all(PrimitiveType type) const
Generate a vector of Tuples from global vertex/edge/triangle/tetrahedron index.
Definition: Mesh.cpp:18
attribute::Accessor< T, Mesh, D > create_accessor(const attribute::MeshAttributeHandle &handle)
std::shared_ptr< Mesh > from_tag(const wmtk::attribute::MeshAttributeHandle &handle, const wmtk::attribute::MeshAttributeHandle::ValueVariant &tag_value, const std::vector< wmtk::attribute::MeshAttributeHandle > &passed_attributes)
Definition: from_tag.cpp:28
std::shared_ptr< Mesh > from_boundary(Mesh &mesh, const PrimitiveType ptype, const std::string &attribute_name, char value, const std::vector< wmtk::attribute::MeshAttributeHandle > &passed_attributes)