15 std::pair<std::shared_ptr<Mesh>, std::shared_ptr<Mesh>>
multimesh(
18 std::shared_ptr<Mesh> child,
20 const std::string& tag_name,
21 const int64_t tag_value,
22 const int64_t primitive)
27 child->capacity(child->top_simplex_type())) {
28 #if defined(USE_NEW_IMPL_MM)
36 return std::make_pair(parent.shared_from_this(), child);
38 throw std::runtime_error(
"unsupported multimesh mapping");
48 bool use_rational_position = parent_position_handle.
held_type() ==
56 #if defined(USE_NEW_IMPL_MM)
60 auto is_boundary_accessor = parent.
create_accessor(is_boundary_handle.as<int64_t>());
62 for (
const auto& t : parent.
get_all(ptype)) {
63 is_boundary_accessor.scalar_attribute(t) = parent.
is_boundary(ptype, t) ? value : 0;
72 #if defined(USE_NEW_IMPL_MM)
89 if (!use_rational_position) {
90 auto child_position_handle = child->register_attribute<
double>(
95 auto propagate_to_child_position = [](
const Eigen::MatrixXd& P) -> Eigen::VectorXd {
98 auto update_child_positon =
99 std::make_shared<wmtk::operations::SingleAttributeTransferStrategy<double, double>>(
100 child_position_handle,
101 parent_position_handle,
102 propagate_to_child_position);
103 update_child_positon->run_on_all();
105 auto child_position_handle = child->register_attribute<
Rational>(
110 auto propagate_to_child_position =
111 [](
const Eigen::MatrixX<Rational>& P) -> Eigen::VectorX<Rational> {
return P; };
112 auto update_child_positon = std::make_shared<
114 child_position_handle,
115 parent_position_handle,
116 propagate_to_child_position);
120 return std::make_pair(parent.shared_from_this(), child);
123 throw std::runtime_error(
"unsupported multimesh type");
attribute::MeshAttributeHandle register_attribute(const std::string &name, PrimitiveType type, int64_t size, bool replace=false, T default_value=T(0))
int64_t capacity(PrimitiveType type) const
read in the m_capacities return the upper bound for the number of entities of the given dimension
bool is_boundary(const simplex::Simplex &tuple) const
check if a simplex lies on a boundary or not
std::vector< Tuple > get_all(PrimitiveType type) const
Generate a vector of Tuples from global vertex/edge/triangle/tetrahedron index.
int64_t top_cell_dimension() const
attribute::Accessor< T, Mesh, D > create_accessor(const attribute::MeshAttributeHandle &handle)
PrimitiveType top_simplex_type() const
void register_child_mesh(const std::shared_ptr< Mesh > &child_mesh_ptr, const std::vector< std::array< Tuple, 2 >> &map_tuples)
register a mesh as the child of this mesh
HeldType held_type() const
int64_t dimension() const
void from_facet_bijection(Mesh &parent, Mesh &child)
std::pair< std::shared_ptr< Mesh >, std::shared_ptr< Mesh > > multimesh(const MultiMeshType &type, Mesh &parent, std::shared_ptr< Mesh > child, const attribute::MeshAttributeHandle parent_position_handle, const std::string &tag_name, const int64_t tag_value, const int64_t primitive)
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)
std::shared_ptr< Mesh > extract_and_register_child_mesh_from_tag(Mesh &m, const std::string &tag, const int64_t tag_value, const PrimitiveType pt, bool child_is_free)
extract a child mesh based on the given tag and tag value, and register it to the input (parent) mesh
std::vector< std::array< Tuple, 2 > > same_simplex_dimension_bijection(const Mesh &parent, const Mesh &child)
constexpr PrimitiveType get_primitive_type_from_id(int8_t id)
Get the primitive type corresponding to its unique integer id.