22Tuple find_valid_tuple(
30 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;
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;
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)) {
231 equivalent_parent_tuples,
234 if (!old_tuple_opt.has_value()) {
238 [&] {
return simplex::Simplex(my_mesh, primitive_type, old_tuple_opt.value()); });
244 equivalent_parent_tuples,
248 if (!new_parent_shared_opt.has_value()) {
254 Tuple new_parent_tuple_shared = new_parent_shared_opt.value();
260 new_parent_tuple_shared,
262 assert(my_mesh.
is_valid(parent_tuple));
263 assert(child_mesh.is_valid(child_tuple));
267 parent_to_child_accessor,
268 child_to_parent_accessor,
277 const int64_t old_gid,
278 const std::vector<Tuple>& equivalent_parent_tuples,
279 const std::vector<std::tuple<int64_t, std::array<int64_t, 2>>>& split_cell_maps)
const
288 equivalent_parent_tuples,
290 if (!split_attempt.has_value()) {
294 equivalent_parent_tuples);
297 return split_attempt;
304 const std::vector<Tuple>& tuple_alternatives)
const
308 auto it = std::find_if(
309 tuple_alternatives.begin(),
310 tuple_alternatives.end(),
311 [&](
const Tuple& t) ->
bool { return !my_mesh.is_removed(t); });
312 if (it != tuple_alternatives.end()) {
315 return std::optional<Tuple>{};
322 const int64_t old_simplex_gid,
323 const std::vector<Tuple>& tuple_alternatives,
324 const std::vector<std::tuple<int64_t, std::array<int64_t, 2>>>& split_cell_maps)
const
329 for (
const auto& [old_cid, new_cids] : split_cell_maps) {
337 if (!(old_tuple_opt.has_value())) {
338 return std::optional<Tuple>{};
341 const Tuple& old_cid_tuple = old_tuple_opt.value();
342 for (
const int64_t new_cid : new_cids) {
351 old_simplex_gid == my_mesh.
id(tuple, primitive_type)) {
356 return std::optional<Tuple>{};
362 const std::vector<Tuple>& tuples,
367 auto it = std::find_if(tuples.begin(), tuples.end(), [&](
const Tuple& t) ->
bool {
368 return (gid == my_mesh.id(t, primitive_type));
370 if (it == tuples.end()) {
372 return std::optional<Tuple>{};
386 .const_vector_attribute(parent_gid)(
387 wmtk::multimesh::utils::TUPLE_SIZE + wmtk::multimesh::utils::GLOBAL_ID_INDEX);
397 .const_vector_attribute(child_gid)(
398 wmtk::multimesh::utils::TUPLE_SIZE + wmtk::multimesh::utils::GLOBAL_ID_INDEX);
406#if defined WMTK_DISABLE_COMPRESSED_MULTIMESH_TUPLE
409 .const_vector_attribute(child_gid)(wmtk::multimesh::utils::TUPLE_SIZE + 2);
414 .const_vector_attribute(child_gid)(
415 wmtk::multimesh::utils::TUPLE_SIZE + (1 - wmtk::multimesh::utils::GLOBAL_ID_INDEX));
416 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.
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
An Accessor 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