Skip to content

Commit

Permalink
Merge pull request #409 from mtao/mtao/parent_mesh_refactor
Browse files Browse the repository at this point in the history
MultiMesh Refactor
  • Loading branch information
mtao authored Oct 7, 2023
2 parents 85ea95d + ac0b795 commit 19ec160
Show file tree
Hide file tree
Showing 46 changed files with 1,498 additions and 445 deletions.
1 change: 1 addition & 0 deletions src/wmtk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ add_subdirectory(simplex)
add_subdirectory(operations)
add_subdirectory(autogen)
add_subdirectory(invariants)
add_subdirectory(multimesh)

41 changes: 41 additions & 0 deletions src/wmtk/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ attribute::AttributeScopeHandle Mesh::create_scope()
return m_attribute_manager.create_scope(*this);
}


template MeshAttributeHandle<char>
Mesh::register_attribute(const std::string&, PrimitiveType, long, bool, char);
template MeshAttributeHandle<long>
Expand All @@ -269,4 +270,44 @@ Tuple Mesh::switch_tuples_unsafe(
return switch_tuples_unsafe<std::initializer_list<PrimitiveType>>(tuple, op_sequence);
}


std::vector<long> Mesh::absolute_multi_mesh_id() const
{
return m_multi_mesh_manager.absolute_id();
}
void Mesh::register_child_mesh(
const std::shared_ptr<Mesh>& child_mesh_ptr,
const std::vector<std::array<Tuple, 2>>& map_tuples)
{
m_multi_mesh_manager.register_child_mesh(*this,child_mesh_ptr, map_tuples);
}


std::vector<Simplex> Mesh::map(const Mesh& other_mesh, const Simplex& my_simplex) const
{
return m_multi_mesh_manager.map(*this, other_mesh, my_simplex);
}
Simplex Mesh::map_to_parent(const Simplex& my_simplex) const
{
return m_multi_mesh_manager.map_to_parent(*this, my_simplex);
}
std::vector<Simplex> Mesh::map_to_child(const Mesh& child_mesh, const Simplex& my_simplex) const
{
return m_multi_mesh_manager.map_to_child(*this, child_mesh, my_simplex);
}

std::vector<Tuple> Mesh::map_tuples(const Mesh& other_mesh, const Simplex& my_simplex) const
{
return m_multi_mesh_manager.map_tuples(*this, other_mesh, my_simplex);
}
Tuple Mesh::map_to_parent_tuple(const Simplex& my_simplex) const
{
return m_multi_mesh_manager.map_to_parent_tuple(*this, my_simplex);
}
std::vector<Tuple> Mesh::map_to_child_tuples(const Mesh& child_mesh, const Simplex& my_simplex)
const
{
return m_multi_mesh_manager.map_to_child_tuples(*this, child_mesh, my_simplex);
}

} // namespace wmtk
47 changes: 43 additions & 4 deletions src/wmtk/Mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class Mesh : public std::enable_shared_from_this<Mesh>
friend class MultiMeshManager;

virtual PrimitiveType top_simplex_type() const = 0;
MultiMeshManager multi_mesh_manager;

friend class operations::Operation;

Expand Down Expand Up @@ -100,8 +99,12 @@ class Mesh : public std::enable_shared_from_this<Mesh>
PrimitiveType type,
long size,
bool replace = false,
T default_value = T(0)
);
T default_value = T(0));

template <typename T>
bool has_attribute(
const std::string& name,
const PrimitiveType ptype) const; // block standard topology tools

template <typename T>
MeshAttributeHandle<T> get_attribute_handle(
Expand Down Expand Up @@ -315,6 +318,31 @@ class Mesh : public std::enable_shared_from_this<Mesh>

bool simplex_is_less(const Simplex& s0, const Simplex& s1) const;


//============================
// MultiMesh interface
//============================
std::vector<long> absolute_multi_mesh_id() const;
void register_child_mesh(
const std::shared_ptr<Mesh>& child_mesh,
const std::vector<std::array<Tuple, 2>>& map_tuples);

// a generic map interface between pairs of mesh in a single multi-mesh structure
std::vector<Simplex> map(const Mesh& other_mesh, const Simplex& my_simplex) const;
// map to just the parent
Simplex map_to_parent(const Simplex& my_simplex) const;
// map to just a child
std::vector<Simplex> map_to_child(const Mesh& child_mesh, const Simplex& my_simplex) const;

// a generic map interface between pairs of mesh in a single multi-mesh structure but returns
// tuples Each tuple partial encodes a Simplex, whose dimension is the same as my_simplex
std::vector<Tuple> map_tuples(const Mesh& other_mesh, const Simplex& my_simplex) const;
// map to just the parent
Tuple map_to_parent_tuple(const Simplex& my_simplex) const;
// map to just a child
std::vector<Tuple> map_to_child_tuples(const Mesh& child_mesh, const Simplex& my_simplex) const;


protected:
/**
* @brief return the global id of the Tuple of the given dimension
Expand All @@ -336,9 +364,13 @@ class Mesh : public std::enable_shared_from_this<Mesh>
// std::shared_ptr<AccessorCache> request_accesor_cache();
//[[nodiscard]] AccessorScopeHandle push_accesor_scope();

private: // members
protected: // THese are protected so unit tests can access - do not use manually in other derived
// classes?
attribute::AttributeManager m_attribute_manager;

MultiMeshManager m_multi_mesh_manager;

private:
// PImpl'd manager of per-thread update stacks
// Every time a new access scope is requested the manager creates another level of indirection
// for updates
Expand Down Expand Up @@ -388,6 +420,13 @@ MeshAttributeHandle<T> Mesh::get_attribute_handle(
r.m_primitive_type = ptype;
return r;
}

template <typename T>
bool Mesh::has_attribute(const std::string& name, const PrimitiveType ptype) const
{
return m_attribute_manager.get<T>(ptype).has_attribute(name);
}

template <typename T>
long Mesh::get_attribute_dimension(const MeshAttributeHandle<T>& handle) const
{
Expand Down
Loading

0 comments on commit 19ec160

Please sign in to comment.