dune-localfunctions  2.3.1-rc1
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  dune_static_assert( (Conversion<Key,typename CoeffF::Key>::sameType),
36  "incompatible keys between BasisCreator and CoefficientsCreator" );
37  dune_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 
86  GeometryType type () const
87  {
88  return GeometryType(topologyId_,dimDomain);
89  /*
90  if ( GenericGeometry::hasGeometryType( topologyId_, dimDomain ) )
91  return GenericGeometry::geometryType( topologyId_, dimDomain );
92  return GeometryType();
93  */
94  }
95 
98  unsigned int topologyId () const
99  {
100  return topologyId_;
101  }
102  private:
103  struct FiniteElement
104  {
105  FiniteElement() : basis_(0), coeff_(0), interpol_(0) {}
106  template <class Topology>
107  void create( const Key &key )
108  {
109  release();
110  basis_ = BasisF::template create<Topology>(key);
111  coeff_ = CoeffF::template create<Topology>(key);
112  interpol_ = InterpolF::template create<Topology>(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  template< class Topology >
127  struct Maker
128  {
129  static void apply ( const Key &key, FiniteElement &finiteElement )
130  {
131  finiteElement.template create<Topology>(key);
132  };
133  };
134  typename Traits::LocalBasisType *basis_;
135  typename Traits::LocalCoefficientsType *coeff_;
136  typename Traits::LocalInterpolationType *interpol_;
137  };
138  unsigned int topologyId_;
139  Key key_;
140  FiniteElement finiteElement_;
141  };
142 
149  template <class FE>
151  : public GenericLocalFiniteElement< typename FE::BasisFactory,
152  DGLocalCoefficientsFactory< typename FE::BasisFactory >,
153  typename FE::InterpolationFactory>
154  {
155  typedef GenericLocalFiniteElement< typename FE::BasisFactory,
157  typename FE::InterpolationFactory> Base;
158  public:
159  typedef typename Base::Traits Traits;
160 
163  DGLocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
164  : Base( gt, key )
165  {}
166  };
174  template <class FE>
176  : public GenericLocalFiniteElement< typename FE::BasisFactory,
177  DGLocalCoefficientsFactory< typename FE::BasisFactory >,
178  LocalL2InterpolationFactory< typename FE::BasisFactory, false > >
179  {
180  typedef GenericLocalFiniteElement< typename FE::BasisFactory,
183  public:
184  typedef typename Base::Traits Traits;
185 
188  L2LocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
189  : Base( gt, key )
190  {}
191  };
192 }
193 
194 #endif
dune_static_assert((Conversion< Key, typename CoeffF::Key >::sameType),"incompatible keys between BasisCreator and CoefficientsCreator")
traits helper struct
Definition: localfiniteelementtraits.hh:10
Base::Traits Traits
Definition: localfiniteelement.hh:159
DGLocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:163
GenericLocalFiniteElement< typename FE::BasisFactory, DGLocalCoefficientsFactory< typename FE::BasisFactory >, typename FE::InterpolationFactory > Base
Definition: localfiniteelement.hh:157
GenericLocalFiniteElement(const GeometryType &gt, const Key &key)
Definition: localfiniteelement.hh:41
L2LocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:188
Base::Traits Traits
Definition: localfiniteelement.hh:184
GeometryType type() const
Definition: localfiniteelement.hh:86
Takes the basis and interpolation factory from a given LocalFiniteElement (derived from GenericLocalF...
Definition: localfiniteelement.hh:150
A LocalFiniteElement implementation based on three TopologyFactories providing the LocalBasis...
Definition: localfiniteelement.hh:21
Takes the basis factory from a given LocalFiniteElement (derived from GenericLocalFiniteElement) and ...
Definition: localfiniteelement.hh:175
GenericLocalFiniteElement< BasisF, CoeffF, InterpolF > This
Definition: localfiniteelement.hh:23
const Traits::LocalCoefficientsType & localCoefficients() const
Definition: localfiniteelement.hh:72
LI LocalInterpolationType
Definition: localfiniteelementtraits.hh:22
const Traits::LocalInterpolationType & localInterpolation() const
Definition: localfiniteelement.hh:79
InterpolF InterpolationFactory
Definition: localfiniteelement.hh:33
LC LocalCoefficientsType
Definition: localfiniteelementtraits.hh:18
BasisF::Key Key
Definition: localfiniteelement.hh:28
static const unsigned int dimDomain
Definition: localfiniteelement.hh:29
~GenericLocalFiniteElement()
Definition: localfiniteelement.hh:58
Definition: localfiniteelement.hh:127
LB LocalBasisType
Definition: localfiniteelementtraits.hh:14
BasisF BasisFactory
Definition: localfiniteelement.hh:31
CoeffF CoefficientFactory
Definition: localfiniteelement.hh:32
A factory class for the dg local coefficients.
Definition: dglocalcoefficients.hh:57
GenericLocalFiniteElement< typename FE::BasisFactory, DGLocalCoefficientsFactory< typename FE::BasisFactory >, LocalL2InterpolationFactory< typename FE::BasisFactory, false > > Base
Definition: localfiniteelement.hh:182
static void apply(const Key &key, FiniteElement &finiteElement)
Definition: localfiniteelement.hh:129
A factory class for the local l2 interpolations taking a basis factory and using GenericGeometry::Qua...
Definition: l2interpolation.hh:169
const Traits::LocalBasisType & localBasis() const
Definition: localfiniteelement.hh:65
unsigned int topologyId() const
Definition: localfiniteelement.hh:98
LocalFiniteElementTraits< typename BasisF::Object, typename CoeffF::Object, typename InterpolF::Object > Traits
Definition: localfiniteelement.hh:26
GenericLocalFiniteElement(const GenericLocalFiniteElement &other)
Definition: localfiniteelement.hh:50