Commit 79e896af authored by Felix Gruber's avatar Felix Gruber

make our function space bases work with dune-functions 2.7

dune-functions recently removed the tree path template parameter. Remove
it from our bases to make sure that they keep working with
dune-functions 2.7.
parent bbf245c7
Pipeline #15417 passed with stage
in 20 minutes and 24 seconds
......@@ -5,6 +5,7 @@
#include <dune/common/concept.hh>
#include <dune/common/version.hh>
#include <dune/functions/common/utility.hh>
......@@ -46,7 +47,9 @@ struct ConstrainedNodeIndexSet
template<class GridView>
struct ConstrainedPreBasis
{
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
using RootTreePath = decltype(TypeTree::hybridTreePath());
#endif
template<class F>
auto require(const F& factory) -> decltype(
......@@ -54,19 +57,34 @@ struct ConstrainedPreBasis
requireType<typename F::size_type>(),
requireType<typename F::MultiIndex>(),
requireType<typename F::SizePrefix>(),
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
requireType<typename F::Node>(),
requireType<typename F::IndexSet>(),
#else
requireType<typename F::template Node<RootTreePath>>(),
requireType<typename F::template IndexSet<RootTreePath>>(),
#endif
requireSameType<typename F::GridView, GridView>(),
const_cast<F&>(factory).initializeIndices(),
requireConvertible<typename F::GridView>(factory.gridView()),
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
requireConvertible<typename F::Node>(factory.makeNode()),
requireConvertible<typename F::IndexSet>(factory.makeIndexSet()),
#else
requireConvertible<typename F::template Node<RootTreePath>>(factory.node(RootTreePath())),
requireConvertible<typename F::template IndexSet<RootTreePath>>(factory.template indexSet<RootTreePath>()),
#endif
requireConvertible<typename F::size_type>(factory.size()),
requireConvertible<typename F::size_type>(factory.size(std::declval<typename F::SizePrefix>())),
requireConvertible<typename F::size_type>(factory.dimension()),
requireConvertible<typename F::size_type>(factory.maxNodeSize()),
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
requireConcept<BasisTree<typename F::GridView>>(factory.makeNode()),
requireConcept<ConstrainedNodeIndexSet<F>>(factory.makeIndexSet())
#else
requireConcept<BasisTree<typename F::GridView>>(factory.node(RootTreePath())),
requireConcept<ConstrainedNodeIndexSet<F>>(factory.template indexSet<RootTreePath>())
#endif
);
};
......
......@@ -6,6 +6,7 @@
#include <array>
#include <dune/common/exceptions.hh>
#include <dune/common/power.hh>
#include <dune/common/version.hh>
#include <dune/localfunctions/bernstein/pqkfactory.hh>
......@@ -33,11 +34,19 @@ namespace Functions {
// set and can be used without a global basis.
// *****************************************************************************
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV, int k>
class BernsteinNode;
template<typename GV, int k, class MI>
class BernsteinNodeIndexSet;
#else
template<typename GV, int k, typename TP>
class BernsteinNode;
template<typename GV, int k, class MI, class TP>
class BernsteinNodeIndexSet;
#endif
template<typename GV, int k, class MI>
class BernsteinPreBasis;
......@@ -70,7 +79,11 @@ public:
private:
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename, int, class>
#else
template<typename, int, class, class>
#endif
friend class BernsteinNodeIndexSet;
// Precompute the number of dofs per entity type
......@@ -93,6 +106,11 @@ private:
public:
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
using Node = BernsteinNode<GV, k>;
using IndexSet = BernsteinNodeIndexSet<GV, k, MI>;
#else
//! Template mapping root tree path to type of created tree node
template<class TP>
using Node = BernsteinNode<GV, k, TP>;
......@@ -100,6 +118,7 @@ public:
//! Template mapping root tree path to type of created tree node index set
template<class TP>
using IndexSet = BernsteinNodeIndexSet<GV, k, MI, TP>;
#endif
//! Type used for global numbering of the basis vectors
using MultiIndex = MI;
......@@ -144,6 +163,26 @@ public:
gridView_ = gv;
}
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
/**
* \brief Create tree node
*/
Node makeNode() const
{
return Node{};
}
/**
* \brief Create tree node index set
*
* Create an index set suitable for the tree node obtained
* by makeNode().
*/
IndexSet makeIndexSet() const
{
return IndexSet{*this};
}
#else
/**
* \brief Create tree node with given root tree path
*
......@@ -174,6 +213,7 @@ public:
{
return IndexSet<TP>{*this};
}
#endif
//! Same as size(prefix) with empty prefix
size_type size() const
......@@ -240,25 +280,39 @@ protected:
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV, int k>
class BernsteinNode :
public LeafBasisNode
#else
template<typename GV, int k, typename TP>
class BernsteinNode :
public LeafBasisNode<std::size_t, TP>
#endif
{
static constexpr int dim = GV::dimension;
static const int maxSize = StaticPower<(k+1),GV::dimension>::power;
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
using Base = LeafBasisNode<std::size_t,TP>;
#endif
using FiniteElementCache = typename Dune::BernsteinLocalFiniteElementCache<typename GV::ctype, double, dim, k>;
public:
using size_type = std::size_t;
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
using TreePath = TP;
#endif
using Element = typename GV::template Codim<0>::Entity;
using FiniteElement = typename FiniteElementCache::FiniteElementType;
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
BernsteinNode() :
#else
BernsteinNode(const TreePath& treePath) :
Base(treePath),
#endif
finiteElement_(nullptr),
element_(nullptr)
{}
......@@ -295,7 +349,11 @@ protected:
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV, int k, class MI>
#else
template<typename GV, int k, class MI, class TP>
#endif
class BernsteinNodeIndexSet
{
enum {dim = GV::dimension};
......@@ -309,7 +367,11 @@ public:
using PreBasis = BernsteinPreBasis<GV, k, MI>;
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
using Node = typename PreBasis::Node;
#else
using Node = typename PreBasis::template Node<TP>;
#endif
BernsteinNodeIndexSet(const PreBasis& preBasis) :
preBasis_(&preBasis),
......
......@@ -6,6 +6,7 @@
#include <array>
#include <dune/common/exceptions.hh>
#include <dune/common/power.hh>
#include <dune/common/version.hh>
#include <dune/functions/functionspacebases/nodes.hh>
#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
......@@ -32,11 +33,19 @@ namespace Functions {
// set and can be used without a global basis.
// *****************************************************************************
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV, int k>
using BernsteinDGNode = BernsteinNode<GV, k>;
template<typename GV, int k, class MI>
class BernsteinDGNodeIndexSet;
#else
template<typename GV, int k, typename TP>
using BernsteinDGNode = BernsteinNode<GV, k, TP>;
template<typename GV, int k, class MI, class TP>
class BernsteinDGNodeIndexSet;
#endif
template<typename GV, int k, class MI>
......@@ -61,11 +70,17 @@ public:
constexpr static int dofsPerPyramid = (k+1)*(k+2)*(2*k+3)/6;
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
using Node = BernsteinDGNode<GV, k>;
using IndexSet = BernsteinDGNodeIndexSet<GV, k, MI>;
#else
template<class TP>
using Node = BernsteinDGNode<GV, k, TP>;
template<class TP>
using IndexSet = BernsteinDGNodeIndexSet<GV, k, MI, TP>;
#endif
/** \brief Type used for global numbering of the basis vectors */
using MultiIndex = MI;
......@@ -115,6 +130,17 @@ public:
gridView_ = gv;
}
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
Node makeNode() const
{
return Node{};
}
IndexSet makeIndexSet() const
{
return IndexSet{*this};
}
#else
template<class TP>
Node<TP> node(const TP& tp) const
{
......@@ -126,6 +152,7 @@ public:
{
return IndexSet<TP>{*this};
}
#endif
size_type size() const
{
......@@ -177,7 +204,11 @@ public:
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV, int k, class MI>
#else
template<typename GV, int k, class MI, class TP>
#endif
class BernsteinDGNodeIndexSet
{
// Cannot be an enum -- otherwise the switch statement below produces compiler warnings
......@@ -192,7 +223,11 @@ public:
using PreBasis = BernsteinDGPreBasis<GV, k, MI>;
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
using Node = typename PreBasis::Node;
#else
using Node = typename PreBasis::template Node<TP>;
#endif
BernsteinDGNodeIndexSet(const PreBasis& preBasis) :
preBasis_(&preBasis)
......
......@@ -6,6 +6,7 @@
#include <array>
#include <dune/common/exceptions.hh>
#include <dune/common/power.hh>
#include <dune/common/version.hh>
#include <dune/localfunctions/bernstein/pqkfactory.hh>
......@@ -35,11 +36,19 @@ namespace Functions {
// set and can be used without a global basis.
// *****************************************************************************
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV, int level, int k>
class BernsteinDGRefinedDGNode;
template<typename GV, int level, int k, class MI>
class BernsteinDGRefinedDGNodeIndexSet;
#else
template<typename GV, int level, int k, typename TP>
class BernsteinDGRefinedDGNode;
template<typename GV, int level, int k, class MI, class TP>
class BernsteinDGRefinedDGNodeIndexSet;
#endif
template<typename GV, int level, int k, class MI>
......@@ -68,11 +77,17 @@ public:
* RefinementConstants::dofsPerSubQuad;
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
using Node = BernsteinDGRefinedDGNode<GV, level, k>;
using IndexSet = BernsteinDGRefinedDGNodeIndexSet<GV, level, k, MI>;
#else
template<class TP>
using Node = BernsteinDGRefinedDGNode<GV, level, k, TP>;
template<class TP>
using IndexSet = BernsteinDGRefinedDGNodeIndexSet<GV, level, k, MI, TP>;
#endif
/** \brief Type used for global numbering of the basis vectors */
using MultiIndex = MI;
......@@ -119,6 +134,17 @@ public:
gridView_ = gv;
}
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
Node makeNode() const
{
return Node{};
}
IndexSet makeIndexSet() const
{
return IndexSet{*this};
}
#else
template<class TP>
Node<TP> node(const TP& tp) const
{
......@@ -130,6 +156,7 @@ public:
{
return IndexSet<TP>{*this};
}
#endif
size_type size() const
{
......@@ -173,15 +200,23 @@ public:
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV, int level, int k>
class BernsteinDGRefinedDGNode :
public LeafBasisNode,
#else
template<typename GV, int level, int k, typename TP>
class BernsteinDGRefinedDGNode :
public LeafBasisNode<std::size_t, TP>,
#endif
public RefinedNode < typename GV::template Codim<0>::Entity
, typename GV::ctype, GV::dimension, level>
{
static constexpr int dim = GV::dimension;
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
using Base = LeafBasisNode<std::size_t, TP>;
#endif
using RefinedNodeBase =
RefinedNode < typename GV::template Codim<0>::Entity
, typename GV::ctype, dim, level>;
......@@ -190,13 +225,19 @@ class BernsteinDGRefinedDGNode :
public:
using size_type = std::size_t;
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
using TreePath = TP;
#endif
using Element = typename GV::template Codim<0>::Entity;
using SubElement = typename RefinedNodeBase::SubElement;
using FiniteElement = typename FiniteElementCache::FiniteElementType;
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
BernsteinDGRefinedDGNode() :
#else
BernsteinDGRefinedDGNode(const TreePath& treePath) :
Base(treePath),
#endif
RefinedNodeBase(),
finiteElement_(nullptr)
{}
......@@ -243,7 +284,11 @@ protected:
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV, int level, int k, class MI>
#else
template<typename GV, int level, int k, class MI, class TP>
#endif
class BernsteinDGRefinedDGNodeIndexSet
{
// Cannot be an enum -- otherwise the switch statement below produces compiler warnings
......@@ -258,7 +303,11 @@ public:
using PreBasis = BernsteinDGRefinedDGPreBasis<GV, level, k, MI>;
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
using Node = typename PreBasis::Node;
#else
using Node = typename PreBasis::template Node<TP>;
#endif
BernsteinDGRefinedDGNodeIndexSet(const PreBasis& preBasis) :
preBasis_(&preBasis)
......
......@@ -54,8 +54,10 @@ public:
//! Pre-basis providing the implementation details
using PreBasis = PB;
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
//! The empty prefix path that identifies the root in the local ansatz tree
using PrefixPath = TypeTree::HybridTreePath<>;
#endif
//! The grid view that the FE space is defined on
using GridView = typename PreBasis::GridView;
......@@ -70,7 +72,11 @@ public:
using LocalView = ConstrainedLocalView<ConstrainedGlobalBasis<PreBasis>>;
//! Node index set provided by PreBasis
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
using NodeIndexSet = typename PreBasis::IndexSet;
#else
using NodeIndexSet = typename PreBasis::template IndexSet<PrefixPath>;
#endif
//! Type used for prefixes handed to the size() method
using SizePrefix = typename PreBasis::SizePrefix;
......@@ -93,8 +99,10 @@ public:
disableCopyMove<ConstrainedGlobalBasis, T...> = 0,
enableIfConstructible<PreBasis, T...> = 0>
ConstrainedGlobalBasis(T&&... t) :
preBasis_(std::forward<T>(t)...),
prefixPath_()
preBasis_(std::forward<T>(t)...)
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
, prefixPath_()
#endif
{
static_assert(models<Concept::ConstrainedPreBasis<GridView>, PreBasis>(), "Type passed to ConstrainedGlobalBasis does not model the ConstrainedPreBasis concept.");
preBasis_.initializeIndices();
......@@ -164,15 +172,19 @@ public:
return *this;
}
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
//! Return empty path, because this is the root in the local ansatz tree
const PrefixPath& prefixPath() const
{
return prefixPath_;
}
#endif
protected:
PreBasis preBasis_;
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
PrefixPath prefixPath_;
#endif
};
......
......@@ -8,6 +8,7 @@
#include <dune/common/concept.hh>
#include <dune/common/hybridutilities.hh>
#include <dune/common/version.hh>
#include <dune/functions/functionspacebases/concepts.hh>
......@@ -22,10 +23,16 @@ namespace Functions {
template<class GB>
class ConstrainedLocalView
{
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
using PrefixPath = TypeTree::HybridTreePath<>;
#endif
// Node index set provided by PreBasis
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
using NodeIndexSet = typename GB::PreBasis::IndexSet;
#else
using NodeIndexSet = typename GB::PreBasis::template IndexSet<PrefixPath>;
#endif
public:
......@@ -42,7 +49,11 @@ public:
using size_type = std::size_t;
//! Tree of local finite elements / local shape function sets
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
using Tree = typename GlobalBasis::PreBasis::Node;
#else
using Tree = typename GlobalBasis::PreBasis::template Node<PrefixPath>;
#endif
/** \brief Type used for global numbering of the basis vectors */
using MultiIndex = typename NodeIndexSet::MultiIndex;
......@@ -52,8 +63,13 @@ public:
/** \brief Construct local view for a given global finite element basis */
ConstrainedLocalView(const GlobalBasis& globalBasis) :
globalBasis_(&globalBasis),
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
tree_(globalBasis_->preBasis().makeNode()),
nodeIndexSet_(globalBasis_->preBasis().makeIndexSet())
#else
tree_(globalBasis_->preBasis().node(PrefixPath())),
nodeIndexSet_(globalBasis_->preBasis().template indexSet<PrefixPath>())
#endif
{
static_assert(models<Concept::BasisTree<GridView>, Tree>(), "Tree type passed to ConstrainedLocalView does not model the BasisNode concept.");
initializeTree(tree_);
......
......@@ -9,6 +9,7 @@
#include <dune/common/exceptions.hh>
#include <dune/common/power.hh>
#include <dune/common/std/optional.hh>
#include <dune/common/version.hh>
#include <dune/localfunctions/bernstein/pqkfactory.hh>
......@@ -36,11 +37,19 @@ namespace Functions {
// set and can be used without a global basis.
// *****************************************************************************
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV>
class HangingNodeBernsteinP2Node;
template<typename GV, class MI>
class HangingNodeBernsteinP2NodeIndexSet;
#else
template<typename GV, typename TP>
class HangingNodeBernsteinP2Node;
template<typename GV, class MI, class TP>
class HangingNodeBernsteinP2NodeIndexSet;
#endif
template<typename GV, class MI>
class HangingNodeBernsteinP2PreBasis;
......@@ -72,13 +81,22 @@ public:
private:
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename, class>
#else
template<typename, class, class>
#endif
friend class HangingNodeBernsteinP2NodeIndexSet;
using FiniteElementCache = typename Dune::BernsteinLocalFiniteElementCache<typename GV::ctype, double, dim, 2>;
public:
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
using Node = HangingNodeBernsteinP2Node<GV>;
using IndexSet = HangingNodeBernsteinP2NodeIndexSet<GV, MI>;
#else
//! Template mapping root tree path to type of created tree node
template<class TP>
using Node = HangingNodeBernsteinP2Node<GV, TP>;
......@@ -86,6 +104,7 @@ public:
//! Template mapping root tree path to type of created tree node index set
template<class TP>
using IndexSet = HangingNodeBernsteinP2NodeIndexSet<GV, MI, TP>;
#endif
//! Type used for global numbering of the basis vectors
using MultiIndex = MI;
......@@ -264,6 +283,26 @@ public:
gridView_ = gv;
}
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
/**
* \brief Create tree node
*/
Node makeNode() const
{
return Node{};
}
/**
* \brief Create tree node index set
*
* Create an index set suitable for the tree node obtained
* by makeNode().
*/
IndexSet makeIndexSet() const
{
return IndexSet{*this};
}
#else
/**
* \brief Create tree node with given root tree path
*
......@@ -294,6 +333,7 @@ public:
{
return IndexSet<TP>{*this};
}
#endif
//! Same as size(prefix) with empty prefix
size_type size() const
......@@ -334,25 +374,39 @@ protected:
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV>
class HangingNodeBernsteinP2Node :
public LeafBasisNode
#else
template<typename GV, typename TP>
class HangingNodeBernsteinP2Node :
public LeafBasisNode<std::size_t, TP>
#endif
{
static constexpr int dim = GV::dimension;
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
using Base = LeafBasisNode<std::size_t,TP>;
#endif
using FiniteElementCache = typename Dune::BernsteinLocalFiniteElementCache<typename GV::ctype, double, dim, 2>;
public:
using size_type = std::size_t;
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
using TreePath = TP;
#endif
using Element = typename GV::template Codim<0>::Entity;
using ElementSeed = typename Element::EntitySeed;
using FiniteElement = typename FiniteElementCache::FiniteElementType;
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
HangingNodeBernsteinP2Node() :
#else
HangingNodeBernsteinP2Node(const TreePath& treePath) :
Base(treePath),
#endif
finiteElement_(nullptr),
element_(nullptr)
{}
......@@ -388,7 +442,11 @@ protected:
};
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV, class MI>
#else
template<typename GV, class MI, class TP>
#endif
class HangingNodeBernsteinP2NodeIndexSet
{
enum {dim = GV::dimension};
......@@ -402,7 +460,11 @@ public:
using PreBasis = HangingNodeBernsteinP2PreBasis<GV, MI>;
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
using Node = typename PreBasis::Node;
#else
using Node = typename PreBasis::template Node<TP>;
#endif
using ConstraintWeights = std::array<double, 3>;
......
......@@ -7,6 +7,7 @@
#include <dune/common/exceptions.hh>
#include <dune/common/power.hh>
#include <dune/common/std/optional.hh>
#include <dune/common/version.hh>
#include <dune/localfunctions/lagrange/pqkfactory.hh>
......@@ -34,11 +35,19 @@ namespace Functions {
// set and can be used without a global basis.
// *****************************************************************************
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
template<typename GV>
class HangingNodeLagrangeP2Node;
template<typename GV, class MI>