diff --git a/dune/localfunctions/monomial.hh b/dune/localfunctions/monomial.hh index 74dbef5fb897b706e29926f793c66f4c547274b9..9e457504b77e5a4671fd29cf323dd07084eb16fe 100644 --- a/dune/localfunctions/monomial.hh +++ b/dune/localfunctions/monomial.hh @@ -37,7 +37,7 @@ namespace Dune template class MonomialLocalFiniteElement { - enum { static_size = MonomImp::Size::val }; + enum { static_size = MonomialLocalBasis::size() }; public: /** Traits class diff --git a/dune/localfunctions/monomial/monomiallocalbasis.hh b/dune/localfunctions/monomial/monomiallocalbasis.hh index 01a975d35a87b70252ba82899ccb203cdd5b7ecc..d1886bb59fa6b0619e8719e02bd258450c9b2722 100644 --- a/dune/localfunctions/monomial/monomiallocalbasis.hh +++ b/dune/localfunctions/monomial/monomiallocalbasis.hh @@ -14,26 +14,6 @@ namespace Dune { namespace MonomImp { - /** template meta program to calculate the number of shape functions - * \internal - */ - template - struct Size { - enum { val = Size::val+Size::val }; - }; - template - struct Size { - enum { val = 1 }; - }; - template - struct Size<0, k> { - enum { val = 1 }; - }; - template<> - struct Size<0, 0> { - enum { val = 1 }; - }; - template T ipow(T base, int exp) { @@ -230,15 +210,23 @@ namespace Dune template class MonomialLocalBasis { + // Helper: Number of shape functions for a k-th order element in dimension dd + static constexpr unsigned int size (int dd, int k) + { + if (dd==0 || k==0) + return 1; + return size(dd,k-1) + size(dd-1,k); + } + public: //! \brief export type traits for function signature typedef LocalBasisTraits,R,1,Dune::FieldVector, Dune::FieldMatrix > Traits; - //! \brief number of shape functions - unsigned int size () const + /** \brief Number of shape functions */ + static constexpr unsigned int size () { - return MonomImp::Size::val; + return size(d,p); } //! \brief Evaluate all shape functions