dune-localfunctions  2.2.0
power.hh
Go to the documentation of this file.
00001 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002 // vi: set et ts=8 sw=2 sts=2:
00003 
00004 #ifndef DUNE_LOCALFUNCTIONS_META_POWER_HH
00005 #define DUNE_LOCALFUNCTIONS_META_POWER_HH
00006 
00007 #include <cstddef>
00008 
00009 #include <dune/common/shared_ptr.hh>
00010 
00011 #include <dune/geometry/type.hh>
00012 
00013 #include <dune/localfunctions/meta/power/basis.hh>
00014 #include <dune/localfunctions/meta/power/coefficients.hh>
00015 #include <dune/localfunctions/meta/power/interpolation.hh>
00016 
00017 namespace Dune {
00018 
00021 
00027   template<class Backend, std::size_t dimR>
00028   class PowerFiniteElement {
00029   public:
00031     struct Traits {
00033       typedef PowerBasis<typename Backend::Traits::Basis, dimR> Basis;
00035       typedef PowerCoefficients Coefficients;
00037       typedef PowerInterpolation<typename Backend::Traits::Interpolation,
00038                                  typename Basis::Traits> Interpolation;
00039     };
00040   private:
00041     shared_ptr<const Backend> backend;
00042     typename Traits::Basis basis_;
00043     typename Traits::Coefficients coefficients_;
00044     typename Traits::Interpolation interpolation_;
00045 
00046   public:
00048 
00052     PowerFiniteElement(const Backend &backend_) :
00053       backend(new Backend(backend_)),
00054       basis_(backend->basis()),
00055       coefficients_(backend->coefficients(), dimR),
00056       interpolation_(backend->interpolation())
00057     { }
00058 
00060 
00064     PowerFiniteElement(const shared_ptr<const Backend> &backendSPtr) :
00065       backend(backendSPtr),
00066       basis_(backend->basis()),
00067       coefficients_(backend->coefficients(), dimR),
00068       interpolation_(backend->interpolation())
00069     { }
00070 
00072 
00076     const typename Traits::Basis& basis() const { return basis_; }
00078 
00082     const typename Traits::Coefficients& coefficients() const
00083     { return coefficients_; }
00085 
00089     const typename Traits::Interpolation& interpolation() const
00090     { return interpolation_; }
00092     GeometryType type() const { return backend->type(); }
00093   };
00094 
00097 
00104   template<class BackendFiniteElement, std::size_t dimR>
00105   class PowerFiniteElementFactory
00106   {
00107   public:
00109     typedef PowerFiniteElement<BackendFiniteElement, dimR> FiniteElement;
00110 
00112 
00116     const FiniteElement make(const BackendFiniteElement &backend) const
00117     { return FiniteElement(backend); }
00119 
00123     const FiniteElement
00124     make(const shared_ptr<const BackendFiniteElement> &backendSPtr) const
00125     { return FiniteElement(backendSPtr); }
00126 
00127   };
00128 
00129 } // namespace Dune
00130 
00131 #endif // DUNE_LOCALFUNCTIONS_META_POWER_HH