23 Tuple find_valid_tuple(
31 return facet_data->get_alternative(my_mesh.top_simplex_type(), tuple, primitive_type);
44 for (
size_t i = 0; i <
children.size(); ++i) {
47 children[i].mesh->top_simplex_type());
52 for (
size_t i = 0; i <
children.size(); ++i) {
53 children[i].mesh->m_multi_mesh_manager.m_child_id = i;
77 std::vector<int64_t> gids;
80 for (
auto& child_data :
children()) {
81 auto& child_mesh = *child_data.mesh;
83 if (child_mesh.top_simplex_type() != primitive_type) {
92 auto& [parent_to_child_accessor, child_to_parent_accessor] = maps;
94 auto child_flag_accessor = child_mesh.get_const_flag_accessor(primitive_type);
97 for (
const auto& gid : gids) {
98 const bool parent_exists = !my_mesh.
is_removed(gid);
100 logger().debug(
"parent doesnt exist, skip!");
104 auto parent_to_child_data =
110 Tuple parent_tuple, child_tuple;
111 std::tie(parent_tuple, child_tuple) =
126 const bool child_exists = !child_mesh.is_removed(child_tuple);
128 logger().debug(
"child doesnt exist, skip!");
133 parent_tuple = wmtk::multimesh::find_valid_tuple(
141 parent_to_child_accessor,
142 child_to_parent_accessor,
152 const std::vector<std::tuple<int64_t, std::vector<Tuple>>>& simplices_to_update,
153 const std::vector<std::tuple<int64_t, std::array<int64_t, 2>>>& split_cell_maps)
178 for (
auto& child_data :
children()) {
179 auto& child_mesh = *child_data.mesh;
181 if (child_mesh.top_simplex_type() != primitive_type) {
190 auto& [parent_to_child_accessor, child_to_parent_accessor] = maps;
192 auto child_flag_accessor = child_mesh.get_const_flag_accessor(primitive_type);
195 for (
const auto& [original_parent_gid, equivalent_parent_tuples] : simplices_to_update) {
203 .const_vector_attribute(original_parent_gid);
207 Tuple parent_tuple, child_tuple;
208 std::tie(parent_tuple, child_tuple) =
221 if (child_mesh.is_removed(child_tuple)) {
234 equivalent_parent_tuples,
237 if (!old_tuple_opt.has_value()) {
241 [&] {
return simplex::Simplex(my_mesh, primitive_type, old_tuple_opt.value()); });
247 equivalent_parent_tuples,
251 if (!new_parent_shared_opt.has_value()) {
257 Tuple new_parent_tuple_shared = new_parent_shared_opt.value();
268 new_parent_tuple_shared,
270 assert(my_mesh.
is_valid(parent_tuple));
271 assert(child_mesh.is_valid(child_tuple));
275 parent_to_child_accessor,
276 child_to_parent_accessor,
285 const int64_t old_gid,
286 const std::vector<Tuple>& equivalent_parent_tuples,
287 const std::vector<std::tuple<int64_t, std::array<int64_t, 2>>>& split_cell_maps)
const
296 equivalent_parent_tuples,
298 if (!split_attempt.has_value()) {
302 equivalent_parent_tuples);
305 return split_attempt;
312 const std::vector<Tuple>& tuple_alternatives)
const
316 auto it = std::find_if(
317 tuple_alternatives.begin(),
318 tuple_alternatives.end(),
319 [&](
const Tuple& t) ->
bool { return !my_mesh.is_removed(t); });
320 if (it != tuple_alternatives.end()) {
323 return std::optional<Tuple>{};
330 const int64_t old_simplex_gid,
331 const std::vector<Tuple>& tuple_alternatives,
332 const std::vector<std::tuple<int64_t, std::array<int64_t, 2>>>& split_cell_maps)
const
337 for (
const auto& [old_cid, new_cids] : split_cell_maps) {
345 if (!(old_tuple_opt.has_value())) {
346 return std::optional<Tuple>{};
349 const Tuple& old_cid_tuple = old_tuple_opt.value();
350 for (
const int64_t new_cid : new_cids) {
359 old_simplex_gid == my_mesh.
id(tuple, primitive_type)) {
364 return std::optional<Tuple>{};
370 const std::vector<Tuple>& tuples,
375 auto it = std::find_if(tuples.begin(), tuples.end(), [&](
const Tuple& t) ->
bool {
376 return (gid == my_mesh.id(t, primitive_type));
378 if (it == tuples.end()) {
380 return std::optional<Tuple>{};
394 .vector_attribute(parent_gid)(
395 wmtk::multimesh::utils::TUPLE_SIZE + wmtk::multimesh::utils::GLOBAL_ID_INDEX);
405 .vector_attribute(child_gid)(
406 wmtk::multimesh::utils::TUPLE_SIZE + wmtk::multimesh::utils::GLOBAL_ID_INDEX);
414 #if defined WMTK_DISABLE_COMPRESSED_MULTIMESH_TUPLE
417 .vector_attribute(child_gid)(wmtk::multimesh::utils::TUPLE_SIZE + 2);
422 .vector_attribute(child_gid)(
423 wmtk::multimesh::utils::TUPLE_SIZE + (1 - wmtk::multimesh::utils::GLOBAL_ID_INDEX));
424 auto vptr =
reinterpret_cast<const int8_t*
>(&v);
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
static auto & get_index_access(attribute::Accessor< T, MeshType > &attr)
const attribute::Accessor< char > get_const_flag_accessor(PrimitiveType type) const
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.
bool is_removed(const Tuple &tuple) const
attribute::AttributeManager m_attribute_manager
bool is_null() const
Checks if a tuple is "null". This merely implies the global index is -1.
void set_name(const TypedAttributeHandle< T > &attr, const std::string &name)
Implementation details for how the Mesh class implements multiple meshes.
const std::vector< ChildData > & children() const
static int64_t child_global_cid(const wmtk::attribute::Accessor< int64_t > &parent_to_child, int64_t parent_gid)
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_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
static int64_t parent_global_cid(const wmtk::attribute::Accessor< int64_t > &child_to_parent, int64_t child_gid)
static std::string parent_to_child_map_attribute_name(int64_t index)
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)
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={})
static std::optional< Tuple > find_tuple_from_gid(const Mesh &my_mesh, PrimitiveType primitive_type, const std::vector< Tuple > &tuples, int64_t 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
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.