diff --git a/src/amdis/functions/GlobalIdSet.hpp b/src/amdis/functions/GlobalIdSet.hpp index eb036a6e5b1f95cc37eb75a3badb3a7276adb12e..fb9c6a6e8636845588505f4973b5bb43dbb299a1 100644 --- a/src/amdis/functions/GlobalIdSet.hpp +++ b/src/amdis/functions/GlobalIdSet.hpp @@ -13,6 +13,7 @@ #include <amdis/Output.hpp> #include <amdis/common/Apply.hpp> +#include <amdis/common/ConceptsBase.hpp> #include <amdis/common/ForEach.hpp> #include <amdis/common/TupleUtility.hpp> #include <amdis/functions/Nodes.hpp> @@ -23,15 +24,6 @@ namespace Dune namespace Functions { // forward declarations... - template <class RB, class TP> - class SubspaceBasis; - - template <class MI, class IMS, class... SPB> - class CompositePreBasis; - - template <class MI, class IMS, class SPB, std::size_t C> - class PowerPreBasis; - template <class GV, int k, class MI> class LagrangeDGPreBasis; @@ -44,7 +36,7 @@ namespace Dune namespace AMDiS { // forward declaration - template <class PreBasis, class TP> + template <class PreBasis, class TP, class = void> class NodeIdSet; /// \brief Provide global ids for all DOFs in a global basis @@ -68,7 +60,7 @@ namespace AMDiS * ``` * **/ - template <class GB> + template <class GB, class = void> class GlobalBasisIdSet { public: @@ -180,18 +172,19 @@ namespace AMDiS }; - template <class RB, class TP> - class GlobalBasisIdSet<Dune::Functions::SubspaceBasis<RB,TP>> - : public GlobalBasisIdSet<RB> + // Specialization for SubspaceBasis + template <class Basis> + class GlobalBasisIdSet<Basis, void_t<typename Basis::RootBasis>> + : public GlobalBasisIdSet<typename Basis::RootBasis> { public: - GlobalBasisIdSet(Dune::Functions::SubspaceBasis<RB,TP> const& basis) - : GlobalBasisIdSet<RB>(basis.rootBasis()) + GlobalBasisIdSet(Basis const& basis) + : GlobalBasisIdSet<typename Basis::RootBasis>(basis.rootBasis()) {} }; - template <class PB, class TP> + template <class PB, class TP, class> class NodeIdSet { public: @@ -240,10 +233,10 @@ namespace AMDiS } /// \brief Maps from subtree index set [0..size-1] to a globally unique id in global basis - // [[expects: node_ != nullptr]] template <class Twist, class It> It fillIn(Twist const& twist, It it, size_type shift = 0) const { + assert(node_ != nullptr); const auto& gridIdSet = gridView_.grid().globalIdSet(); for (size_type i = 0; i < size_ ; ++i, ++it) { @@ -271,11 +264,11 @@ namespace AMDiS }; - template <class MI, class IMS, class SPB, std::size_t C, class TP> - class NodeIdSet<Dune::Functions::PowerPreBasis<MI,IMS,SPB,C>, TP> + // Specialization for PowerBasis + template <class PreBasis, class TP> + class NodeIdSet<PreBasis, TP, void_t<typename PreBasis::SubPreBasis>> { public: - using PreBasis = Dune::Functions::PowerPreBasis<MI,IMS,SPB,C>; using Node = Node_t<PreBasis,TP>; using GridView = typename PreBasis::GridView; using size_type = std::size_t; @@ -284,7 +277,7 @@ namespace AMDiS using SubPreBasis = typename PreBasis::SubPreBasis; using SubTreePath = decltype(Dune::TypeTree::push_back(std::declval<TP>(), std::size_t(0))); using SubNodeIdSet = NodeIdSet<SubPreBasis, SubTreePath>; - static const std::size_t children = C; + static const std::size_t children = Node::CHILDREN; public: NodeIdSet(GridView const& gridView) @@ -312,10 +305,10 @@ namespace AMDiS } /// \brief Maps from subtree index set [0..size-1] to a globally unique id in global basis - // [[expects: node_ != nullptr]] template <class Twist, class It> It fillIn(Twist const& twist, It it, size_type shift = 0) const { + assert(node_ != nullptr); for (std::size_t child = 0; child < children; ++child) { size_type subTreeSize = subIds_.size(); @@ -331,17 +324,17 @@ namespace AMDiS }; - template <class MI, class IMS, class... SPB, class TP> - class NodeIdSet<Dune::Functions::CompositePreBasis<MI,IMS,SPB...>, TP> + // Specialization for CompositePreBasis + template <class PreBasis, class TP> + class NodeIdSet<PreBasis, TP, void_t<typename PreBasis::SubPreBases>> { public: - using PreBasis = Dune::Functions::CompositePreBasis<MI,IMS,SPB...>; using Node = Node_t<PreBasis,TP>; using GridView = typename PreBasis::GridView; using size_type = std::size_t; protected: - static const std::size_t children = sizeof...(SPB); + static const std::size_t children = Node::CHILDREN; using ChildIndices = std::make_index_sequence<children>; // The I'th SubPreBasis @@ -389,10 +382,10 @@ namespace AMDiS } /// \brief Maps from subtree index set [0..size-1] to a globally unique id in global basis - // [[expects: node_ != nullptr]] template <class Twist, class It> It fillIn(Twist const& twist, It it, size_type shift = 0) const { + assert(node_ != nullptr); Tools::for_each(idsTuple_, [&](auto const& ids) { size_type subTreeSize = ids.size(); @@ -462,10 +455,10 @@ namespace AMDiS } /// \brief Maps from subtree index set [0..size-1] to a globally unique id in global basis - // [[expects: node_ != nullptr]] template <class Twist, class It> It fillIn(Twist const& twist, It it, size_type shift = 0) const { + assert(node_ != nullptr); for (int child = 0; child < dow; ++child) { size_type subTreeSize = pq2NodeIdSet_.size(); it = pq2NodeIdSet_.fillIn(twist, it, shift); @@ -515,10 +508,10 @@ namespace AMDiS } /// \brief Maps from subtree index set [0..size-1] to a globally unique id in global basis - // [[expects: node_ != nullptr]] template <class Twist, class It> It fillIn(Twist const& /*twist*/, It it, size_type shift = 0) const { + assert(node_ != nullptr); const auto& gridIdSet = gridView_.grid().globalIdSet(); auto elementId = gridIdSet.id(node_->element());