dune-localfunctions  2.8.0
localfunctions/utility/localfiniteelement.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_GENERIC_LOCALFINITEELEMENT_HH
4 #define DUNE_GENERIC_LOCALFINITEELEMENT_HH
5 
6 #include <dune/geometry/type.hh>
7 #include <dune/geometry/typeindex.hh>
8 
12 
13 namespace Dune
14 {
21  template< class BasisF, class CoeffF, class InterpolF>
23  {
25  typedef LocalFiniteElementTraits< typename BasisF::Object,
26  typename CoeffF::Object,
27  typename InterpolF::Object > Traits;
28 
29  typedef typename BasisF::Key Key;
30  static const unsigned int dimDomain = BasisF::dimension;
31 
32  typedef BasisF BasisFactory;
33  typedef CoeffF CoefficientFactory;
34  typedef InterpolF InterpolationFactory;
35 
37  "incompatible keys between BasisCreator and CoefficientsCreator");
39  "incompatible keys between BasisCreator and InterpolationCreator" );
40 
42  GenericLocalFiniteElement ( const GeometryType &gt, const Key &key )
43  : geometry_( gt ),
44  key_( key ),
45  finiteElement_()
46  {
47  Impl::toGeometryTypeIdConstant<dimDomain>(type(), [&](auto geometryTypeId) {
48  finiteElement_.template create<decltype(geometryTypeId)::value>(key_);
49  });
50  }
51 
54  : geometry_( other.type() ),
55  key_( other.key_ ),
56  finiteElement_()
57  {
58  Impl::toGeometryTypeIdConstant<dimDomain>(type(), [&](auto geometryTypeId) {
59  finiteElement_.template create<decltype(geometryTypeId)::value>(key_);
60  });
61  }
62 
64  {
65  finiteElement_.release();
66  }
67 
70  const typename Traits::LocalBasisType& localBasis () const
71  {
72  return *(finiteElement_.basis_);
73  }
74 
78  {
79  return *(finiteElement_.coeff_);
80  }
81 
85  {
86  return *(finiteElement_.interpol_);
87  }
88 
90  unsigned int size () const
91  {
92  return finiteElement_.basis_->size();
93  }
94 
97  GeometryType type () const
98  {
99  return geometry_;
100  }
101  private:
102  struct FiniteElement
103  {
104  FiniteElement() : basis_(0), coeff_(0), interpol_(0) {}
105 
106  template < GeometryType::Id geometryId >
107  void create( const Key &key )
108  {
109  release();
110  basis_ = BasisF::template create<geometryId>(key);
111  coeff_ = CoeffF::template create<geometryId>(key);
112  interpol_ = InterpolF::template create<geometryId>(key);
113  }
114  void release()
115  {
116  if (basis_)
117  BasisF::release(basis_);
118  if (coeff_)
119  CoeffF::release(coeff_);
120  if (interpol_)
121  InterpolF::release(interpol_);
122  basis_=0;
123  coeff_=0;
124  interpol_=0;
125  }
126  typename Traits::LocalBasisType *basis_;
127  typename Traits::LocalCoefficientsType *coeff_;
128  typename Traits::LocalInterpolationType *interpol_;
129  };
130  GeometryType geometry_;
131  Key key_;
132  FiniteElement finiteElement_;
133  };
134 
141  template <class FE>
143  : public GenericLocalFiniteElement< typename FE::BasisFactory,
144  DGLocalCoefficientsFactory< typename FE::BasisFactory >,
145  typename FE::InterpolationFactory>
146  {
147  typedef GenericLocalFiniteElement< typename FE::BasisFactory,
149  typename FE::InterpolationFactory> Base;
150  public:
151  typedef typename Base::Traits Traits;
152 
155  DGLocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
156  : Base( gt, key )
157  {}
158  };
166  template <class FE>
168  : public GenericLocalFiniteElement< typename FE::BasisFactory,
169  DGLocalCoefficientsFactory< typename FE::BasisFactory >,
170  LocalL2InterpolationFactory< typename FE::BasisFactory, false > >
171  {
172  typedef GenericLocalFiniteElement< typename FE::BasisFactory,
175  public:
176  typedef typename Base::Traits Traits;
177 
180  L2LocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
181  : Base( gt, key )
182  {}
183  };
184 }
185 
186 #endif
Definition: bdfmcube.hh:16
@ value
Definition: tensor.hh:166
traits helper struct
Definition: localfiniteelementtraits.hh:11
LB LocalBasisType
Definition: localfiniteelementtraits.hh:14
LC LocalCoefficientsType
Definition: localfiniteelementtraits.hh:18
LI LocalInterpolationType
Definition: localfiniteelementtraits.hh:22
A factory class for the dg local coefficients.
Definition: dglocalcoefficients.hh:57
A factory class for the local l2 interpolations taking a basis factory.
Definition: l2interpolation.hh:197
A LocalFiniteElement implementation based on three TopologyFactories providing the LocalBasis,...
Definition: localfunctions/utility/localfiniteelement.hh:23
const Traits::LocalInterpolationType & localInterpolation() const
Definition: localfunctions/utility/localfiniteelement.hh:84
const Traits::LocalBasisType & localBasis() const
Definition: localfunctions/utility/localfiniteelement.hh:70
GeometryType type() const
Definition: localfunctions/utility/localfiniteelement.hh:97
GenericLocalFiniteElement(const GenericLocalFiniteElement &other)
Definition: localfunctions/utility/localfiniteelement.hh:53
unsigned int size() const
Number of shape functions in this finite element.
Definition: localfunctions/utility/localfiniteelement.hh:90
CoeffF CoefficientFactory
Definition: localfunctions/utility/localfiniteelement.hh:33
const Traits::LocalCoefficientsType & localCoefficients() const
Definition: localfunctions/utility/localfiniteelement.hh:77
BasisF BasisFactory
Definition: localfunctions/utility/localfiniteelement.hh:32
BasisF::Key Key
Definition: localfunctions/utility/localfiniteelement.hh:29
GenericLocalFiniteElement(const GeometryType &gt, const Key &key)
Definition: localfunctions/utility/localfiniteelement.hh:42
InterpolF InterpolationFactory
Definition: localfunctions/utility/localfiniteelement.hh:34
static const unsigned int dimDomain
Definition: localfunctions/utility/localfiniteelement.hh:30
LocalFiniteElementTraits< typename BasisF::Object, typename CoeffF::Object, typename InterpolF::Object > Traits
Definition: localfunctions/utility/localfiniteelement.hh:27
GenericLocalFiniteElement< BasisF, CoeffF, InterpolF > This
Definition: localfunctions/utility/localfiniteelement.hh:24
~GenericLocalFiniteElement()
Definition: localfunctions/utility/localfiniteelement.hh:63
Takes the basis and interpolation factory from a given LocalFiniteElement (derived from GenericLocalF...
Definition: localfunctions/utility/localfiniteelement.hh:146
Base::Traits Traits
Definition: localfunctions/utility/localfiniteelement.hh:151
DGLocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfunctions/utility/localfiniteelement.hh:155
GenericLocalFiniteElement< typename FE::BasisFactory, DGLocalCoefficientsFactory< typename FE::BasisFactory >, typename FE::InterpolationFactory > Base
Definition: localfunctions/utility/localfiniteelement.hh:149
Takes the basis factory from a given LocalFiniteElement (derived from GenericLocalFiniteElement) and ...
Definition: localfunctions/utility/localfiniteelement.hh:171
L2LocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfunctions/utility/localfiniteelement.hh:180
GenericLocalFiniteElement< typename FE::BasisFactory, DGLocalCoefficientsFactory< typename FE::BasisFactory >, LocalL2InterpolationFactory< typename FE::BasisFactory, false > > Base
Definition: localfunctions/utility/localfiniteelement.hh:174
Base::Traits Traits
Definition: localfunctions/utility/localfiniteelement.hh:176