19 #define WMTK_MESH_VISITOR_ONLY_SUPPORTS_NONCONST_REFERENCE
24 template <
typename MMVisitor>
25 class MultiMeshVisitorExecutor;
27 template <
typename NodeFunctor_>
35 ReferenceWrappedFunctorReturnCache<NodeFunctor, MeshVariantTraits>;
38 using TypeHelper = wmtk::utils::metaprogramming::detail::
39 ReferenceWrappedFunctorReturnType<NodeFunctor, MeshVariantTraits::AllReferenceTuple>;
51 template <
typename MMVisitor_>
62 template <
typename MeshType>
66 !std::is_same_v<std::decay_t<MeshType>,
Mesh>,
67 "Don't pass in a mesh, use variant/visitor to get its derived type");
69 exec.
execute(std::forward<MeshType>(mesh));
85 std::visit([&](
auto&& root) {
execute_mesh(root.get()); }, mesh_root_variant);
94 template <
typename MMVisitor>
114 template <
typename MeshType>
117 static_assert(std::is_base_of_v<
Mesh, std::decay_t<MeshType>>);
118 run(std::forward<MeshType>(mesh));
127 template <
typename MeshType_>
128 void run(MeshType_&& current_mesh)
130 using MeshType = std::decay_t<MeshType_>;
134 constexpr
static int64_t MeshDim = wmtk::utils::metaprogramming::cell_dimension_v<MeshType>;
139 auto& child_datas = current_mesh.m_multi_mesh_manager.children();
143 for (
size_t child_index = 0; child_index < child_datas.size(); ++child_index) {
144 auto&& child_data = child_datas[child_index];
145 Mesh& child_mesh_base = *child_data.mesh;
148 auto child_mesh_variant =
151 [&](
auto&& child_mesh_) noexcept {
152 auto&& child_mesh = child_mesh_.get();
153 using ChildType = std::decay_t<decltype(child_mesh)>;
155 constexpr
static int64_t ChildDim =
156 wmtk::utils::metaprogramming::cell_dimension_v<ChildType>;
164 assert(MeshDim >= ChildDim);
166 if constexpr (MeshDim >= ChildDim) {
173 visitor.m_node_functor(current_mesh);
178 template <
typename NodeFunctor>
Mesh & get_multi_mesh_root()
returns a reference to the root of a multimesh tree
MultiMeshVisitorExecutor(const MMVisitor &v)
void run(MeshType_ &¤t_mesh)
typename MMVisitor::NodeFunctor NodeFunctor
void execute(MeshType &&mesh)
const MMVisitor & visitor
NodeFunctor m_node_functor
void execute_from_root(Mesh &mesh)
wmtk::utils::metaprogramming::ReferenceWrappedFunctorReturnCache< NodeFunctor, MeshVariantTraits > ReturnDataType
MultiMeshVisitor(NodeFunctor &&f)
void execute_mesh(MeshType &&mesh)
MultiMeshVisitor(NodeFunctor &&) -> MultiMeshVisitor< NodeFunctor >