22Tuple find_valid_tuple(
30 return facet_data->get_alternative(my_mesh.top_simplex_type(), tuple, primitive_type);
43 for (
size_t i = 0; i <
children.size(); ++i) {
46 children[i].mesh->top_simplex_type());
51 for (
size_t i = 0; i <
children.size(); ++i) {
52 children[i].mesh->m_multi_mesh_manager.m_child_id = i;
76 std::vector<int64_t> gids;
79 for (
auto& child_data :
children()) {
80 auto& child_mesh = *child_data.mesh;
82 if (child_mesh.top_simplex_type() != primitive_type) {
91 auto& [parent_to_child_accessor, child_to_parent_accessor] = maps;
93 auto child_flag_accessor = child_mesh.get_const_flag_accessor(primitive_type);
96 for (
const auto& gid : gids) {
97 const bool parent_exists = !my_mesh.
is_removed(gid);
99 logger().debug(
"parent doesnt exist, skip!");
103 auto parent_to_child_data =
109 Tuple parent_tuple, child_tuple;
110 std::tie(parent_tuple, child_tuple) =
125 const bool child_exists = !child_mesh.is_removed(child_tuple);
127 logger().debug(
"child doesnt exist, skip!");
132 parent_tuple = wmtk::multimesh::find_valid_tuple(
140 parent_to_child_accessor,
141 child_to_parent_accessor,
151 const std::vector<std::tuple<int64_t, std::vector<Tuple>>>& simplices_to_update,
152 const std::vector<std::tuple<int64_t, std::array<int64_t, 2>>>& split_cell_maps)
177 for (
auto& child_data :
children()) {
178 auto& child_mesh = *child_data.mesh;
180 if (child_mesh.top_simplex_type() != primitive_type) {
189 auto& [parent_to_child_accessor, child_to_parent_accessor] = maps;
191 auto child_flag_accessor = child_mesh.get_const_flag_accessor(primitive_type);
194 for (
const auto& [original_parent_gid, equivalent_parent_tuples] : simplices_to_update) {
202 .const_vector_attribute(original_parent_gid);
206 Tuple parent_tuple, child_tuple;
207 std::tie(parent_tuple, child_tuple) =
220 if (child_mesh.is_removed(child_tuple)) {
230 equivalent_parent_tuples,
233 if (!old_tuple_opt.has_value()) {
237 [&] {
return simplex::Simplex(my_mesh, primitive_type, old_tuple_opt.value()); });
243 equivalent_parent_tuples,
247 if (!new_parent_shared_opt.has_value()) {
253 Tuple new_parent_tuple_shared = new_parent_shared_opt.value();
259 new_parent_tuple_shared,
261 assert(my_mesh.
is_valid(parent_tuple));
262 assert(child_mesh.is_valid(child_tuple));
266 parent_to_child_accessor,
267 child_to_parent_accessor,
276 const int64_t old_gid,
277 const std::vector<Tuple>& equivalent_parent_tuples,
278 const std::vector<std::tuple<int64_t, std::array<int64_t, 2>>>& split_cell_maps)
const
287 equivalent_parent_tuples,
289 if (!split_attempt.has_value()) {
293 equivalent_parent_tuples);
296 return split_attempt;
303 const std::vector<Tuple>& tuple_alternatives)
const
307 auto it = std::find_if(
308 tuple_alternatives.begin(),
309 tuple_alternatives.end(),
310 [&](
const Tuple& t) ->
bool { return !my_mesh.is_removed(t); });
311 if (it != tuple_alternatives.end()) {
314 return std::optional<Tuple>{};
321 const int64_t old_simplex_gid,
322 const std::vector<Tuple>& tuple_alternatives,
323 const std::vector<std::tuple<int64_t, std::array<int64_t, 2>>>& split_cell_maps)
const
328 for (
const auto& [old_cid, new_cids] : split_cell_maps) {
336 if (!(old_tuple_opt.has_value())) {
337 return std::optional<Tuple>{};
340 const Tuple& old_cid_tuple = old_tuple_opt.value();
341 for (
const int64_t new_cid : new_cids) {
350 old_simplex_gid == my_mesh.
id(tuple, primitive_type)) {
355 return std::optional<Tuple>{};
361 const std::vector<Tuple>& tuples,
366 auto it = std::find_if(tuples.begin(), tuples.end(), [&](
const Tuple& t) ->
bool {
367 return (gid == my_mesh.id(t, primitive_type));
369 if (it == tuples.end()) {
371 return std::optional<Tuple>{};
385 .vector_attribute(parent_gid)(
386 wmtk::multimesh::utils::TUPLE_SIZE + wmtk::multimesh::utils::GLOBAL_ID_INDEX);
396 .vector_attribute(child_gid)(
397 wmtk::multimesh::utils::TUPLE_SIZE + wmtk::multimesh::utils::GLOBAL_ID_INDEX);
405#if defined WMTK_DISABLE_COMPRESSED_MULTIMESH_TUPLE
408 .vector_attribute(child_gid)(wmtk::multimesh::utils::TUPLE_SIZE + 2);
413 .vector_attribute(child_gid)(
414 wmtk::multimesh::utils::TUPLE_SIZE + (1 - wmtk::multimesh::utils::GLOBAL_ID_INDEX));
415 auto vptr =
reinterpret_cast<const int8_t*
>(&v);
static auto & get_index_access(attribute::Accessor< T, MeshType > &attr)
attribute::TypedAttributeHandle< T > get_attribute_handle_typed(const std::string &name, const PrimitiveType ptype) const
int64_t id(const Tuple &tuple, PrimitiveType type) const
return the global id of the Tuple of the given dimension
multimesh::MultiMeshManager m_multi_mesh_manager
virtual bool is_valid(const Tuple &tuple) const
check validity of tuple including its hash
PrimitiveType top_simplex_type() const
decltype(auto) parent_scope(Functor &&f, Args &&... args) const
Evaluate the passed in function inside the parent scope.
const attribute::FlagAccessor< Mesh > get_const_flag_accessor(PrimitiveType type) const
bool is_removed(const Tuple &tuple) const
attribute::AttributeManager m_attribute_manager
The Tuple is the basic navigation tool in our mesh data structure.
bool is_null() const
Checks if a tuple is "null". This merely implies the global index is -1.
int64_t global_cid() const
A CachingAccessor that uses tuples for accessing attributes instead of indices.
void set_name(const TypedAttributeHandle< T > &attr, const std::string &name)
Implementation details for how the Mesh class implements multiple meshes.
static int64_t child_global_cid(const wmtk::attribute::Accessor< int64_t > &parent_to_child, int64_t parent_gid)
static int64_t parent_local_fid(const wmtk::attribute::Accessor< int64_t > &child_to_parent, int64_t child_gid)
std::vector< ChildData > m_children
std::optional< Tuple > find_valid_tuple_from_alternatives(Mesh &my_mesh, PrimitiveType primitive_type, const std::vector< Tuple > &tuple_alternatives) const
std::optional< Tuple > find_valid_tuple_from_split(Mesh &my_mesh, const simplex::Simplex &old_simplex, const int64_t old_gid, const std::vector< Tuple > &tuple_alternatives, const std::vector< std::tuple< int64_t, std::array< int64_t, 2 > > > &split_cell_maps) const
static int64_t parent_global_cid(const wmtk::attribute::Accessor< int64_t > &child_to_parent, int64_t child_gid)
std::optional< Tuple > find_valid_tuple(Mesh &my_mesh, const simplex::Simplex &old_simplex, const int64_t old_gid, const std::vector< Tuple > &tuple_alternatives, const std::vector< std::tuple< int64_t, std::array< int64_t, 2 > > > &split_cell_maps={}) const
static std::string parent_to_child_map_attribute_name(int64_t index)
void update_map_tuple_hashes(Mesh &my_mesh, PrimitiveType primitive_type, const std::vector< std::tuple< int64_t, std::vector< Tuple > > > &simplices_to_update, const std::vector< std::tuple< int64_t, std::array< int64_t, 2 > > > &split_cell_maps={})
void update_child_handles(Mesh &my_mesh)
Clean up child data after deleting attributes.
std::array< wmtk::attribute::Accessor< int64_t >, 2 > get_map_accessors(Mesh &my_mesh, ChildData &c)
const std::vector< ChildData > & children() const
static std::optional< Tuple > find_tuple_from_gid(const Mesh &my_mesh, PrimitiveType primitive_type, const std::vector< Tuple > &tuples, int64_t gid)
void update_maps_from_edge_operation(Mesh &my_mesh, PrimitiveType primitive_type, const operations::EdgeOperationData &operation_data)
std::variant< std::unique_ptr< internal::SplitAlternateFacetData >, std::unique_ptr< internal::CollapseAlternateFacetData > > m_op_data
const Tuple & tuple() const
PrimitiveType primitive_type() const
std::tuple< Tuple, Tuple > vectors_to_tuples(const Eigen::Ref< const TwoTupleVector > &v)
Tuple transport_tuple(const Tuple &base_source, const Tuple &base_target, PrimitiveType base_primitive_type, const Tuple &source, PrimitiveType primitive_type)
void symmetric_write_tuple_map_attributes(wmtk::attribute::Accessor< int64_t, MeshA > &a_to_b, wmtk::attribute::Accessor< int64_t, MeshB > &b_to_a, const Tuple &a_tuple, const Tuple &b_tuple)
spdlog::logger & logger()
Retrieves the current logger.
std::shared_ptr< Mesh > mesh