dune-localfunctions  2.4
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 
11 
12 namespace Dune
13 {
20  template< class BasisF, class CoeffF, class InterpolF>
22  {
24  typedef LocalFiniteElementTraits< typename BasisF::Object,
25  typename CoeffF::Object,
26  typename InterpolF::Object > Traits;
27 
28  typedef typename BasisF::Key Key;
29  static const unsigned int dimDomain = BasisF::dimension;
30 
31  typedef BasisF BasisFactory;
32  typedef CoeffF CoefficientFactory;
33  typedef InterpolF InterpolationFactory;
34 
35  static_assert(Conversion<Key, typename CoeffF::Key>::sameType,
36  "incompatible keys between BasisCreator and CoefficientsCreator");
37  static_assert(Conversion<Key, typename InterpolF::Key>::sameType,
38  "incompatible keys between BasisCreator and InterpolationCreator" );
39 
41  GenericLocalFiniteElement ( const GeometryType &gt, const Key &key )
42  : topologyId_( gt.id() ),
43  key_( key ),
44  finiteElement_()
45  {
46  GenericGeometry::IfTopology< FiniteElement::template Maker, dimDomain >::apply( topologyId_, key_, finiteElement_ );
47  }
48 
51  : topologyId_( other.topologyId_ ),
52  key_( other.key_ ),
53  finiteElement_()
54  {
55  GenericGeometry::IfTopology< FiniteElement::template Maker, dimDomain >::apply( topologyId_, key_, finiteElement_ );
56  }
57 
59  {
60  finiteElement_.release();
61  }
62 
65  const typename Traits::LocalBasisType& localBasis () const
66  {
67  return *(finiteElement_.basis_);
68  }
69 
73  {
74  return *(finiteElement_.coeff_);
75  }
76 
80  {
81  return *(finiteElement_.interpol_);
82  }
83 
85  unsigned int size () const
86  {
87  return finiteElement_.basis_->size();
88  }
89 
92  GeometryType type () const
93  {
94  return GeometryType(topologyId_,dimDomain);
95  }
96 
99  unsigned int topologyId () const
100  {
101  return topologyId_;
102  }
103  private:
104  struct FiniteElement
105  {
106  FiniteElement() : basis_(0), coeff_(0), interpol_(0) {}
107  template <class Topology>
108  void create( const Key &key )
109  {
110  release();
111  basis_ = BasisF::template create<Topology>(key);
112  coeff_ = CoeffF::template create<Topology>(key);
113  interpol_ = InterpolF::template create<Topology>(key);
114  }
115  void release()
116  {
117  if (basis_)
118  BasisF::release(basis_);
119  if (coeff_)
120  CoeffF::release(coeff_);
121  if (interpol_)
122  InterpolF::release(interpol_);
123  basis_=0;
124  coeff_=0;
125  interpol_=0;
126  }
127  template< class Topology >
128  struct Maker
129  {
130  static void apply ( const Key &key, FiniteElement &finiteElement )
131  {
132  finiteElement.template create<Topology>(key);
133  };
134  };
135  typename Traits::LocalBasisType *basis_;
136  typename Traits::LocalCoefficientsType *coeff_;
137  typename Traits::LocalInterpolationType *interpol_;
138  };
139  unsigned int topologyId_;
140  Key key_;
141  FiniteElement finiteElement_;
142  };
143 
150  template <class FE>
152  : public GenericLocalFiniteElement< typename FE::BasisFactory,
153  DGLocalCoefficientsFactory< typename FE::BasisFactory >,
154  typename FE::InterpolationFactory>
155  {
156  typedef GenericLocalFiniteElement< typename FE::BasisFactory,
158  typename FE::InterpolationFactory> Base;
159  public:
160  typedef typename Base::Traits Traits;
161 
164  DGLocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
165  : Base( gt, key )
166  {}
167  };
175  template <class FE>
177  : public GenericLocalFiniteElement< typename FE::BasisFactory,
178  DGLocalCoefficientsFactory< typename FE::BasisFactory >,
179  LocalL2InterpolationFactory< typename FE::BasisFactory, false > >
180  {
181  typedef GenericLocalFiniteElement< typename FE::BasisFactory,
184  public:
185  typedef typename Base::Traits Traits;
186 
189  L2LocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
190  : Base( gt, key )
191  {}
192  };
193 }
194 
195 #endif
InterpolF InterpolationFactory
Definition: localfiniteelement.hh:33
GenericLocalFiniteElement(const GenericLocalFiniteElement &other)
Definition: localfiniteelement.hh:50
const Traits::LocalInterpolationType & localInterpolation() const
Definition: localfiniteelement.hh:79
unsigned int size() const
Number of shape functions in this finite element.
Definition: localfiniteelement.hh:85
BasisF BasisFactory
Definition: localfiniteelement.hh:31
Definition: localfiniteelement.hh:128
GenericLocalFiniteElement(const GeometryType &gt, const Key &key)
Definition: localfiniteelement.hh:41
L2LocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:189
CoeffF CoefficientFactory
Definition: localfiniteelement.hh:32
Base::Traits Traits
Definition: localfiniteelement.hh:185
A factory class for the dg local coefficients.
Definition: dglocalcoefficients.hh:57
static const unsigned int dimDomain
Definition: localfiniteelement.hh:29
BasisF::Key Key
Definition: localfiniteelement.hh:28
DGLocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:164
const Traits::LocalBasisType & localBasis() const
Definition: localfiniteelement.hh:65
A factory class for the local l2 interpolations taking a basis factory and using GenericGeometry::Qua...
Definition: l2interpolation.hh:169
traits helper struct
Definition: localfiniteelementtraits.hh:10
GenericLocalFiniteElement< typename FE::BasisFactory, DGLocalCoefficientsFactory< typename FE::BasisFactory >, LocalL2InterpolationFactory< typename FE::BasisFactory, false > > Base
Definition: localfiniteelement.hh:183
const Traits::LocalCoefficientsType & localCoefficients() const
Definition: localfiniteelement.hh:72
static void apply(const Key &key, FiniteElement &finiteElement)
Definition: localfiniteelement.hh:130
LI LocalInterpolationType
Definition: localfiniteelementtraits.hh:22
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:14
~GenericLocalFiniteElement()
Definition: localfiniteelement.hh:58
LC LocalCoefficientsType
Definition: localfiniteelementtraits.hh:18
GeometryType type() const
Definition: localfiniteelement.hh:92
Takes the basis and interpolation factory from a given LocalFiniteElement (derived from GenericLocalF...
Definition: localfiniteelement.hh:151
unsigned int topologyId() const
Definition: localfiniteelement.hh:99
Base::Traits Traits
Definition: localfiniteelement.hh:160
A LocalFiniteElement implementation based on three TopologyFactories providing the LocalBasis...
Definition: localfiniteelement.hh:21
LB LocalBasisType
Definition: localfiniteelementtraits.hh:14
GenericLocalFiniteElement< typename FE::BasisFactory, DGLocalCoefficientsFactory< typename FE::BasisFactory >, typename FE::InterpolationFactory > Base
Definition: localfiniteelement.hh:158
LocalFiniteElementTraits< typename BasisF::Object, typename CoeffF::Object, typename InterpolF::Object > Traits
Definition: localfiniteelement.hh:26
GenericLocalFiniteElement< BasisF, CoeffF, InterpolF > This
Definition: localfiniteelement.hh:23
Takes the basis factory from a given LocalFiniteElement (derived from GenericLocalFiniteElement) and ...
Definition: localfiniteelement.hh:176