dune-localfunctions  2.4.1-rc2
dglocalcoefficients.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_DGLOCALCOEFFICIENTS_HH
4 #define DUNE_DGLOCALCOEFFICIENTS_HH
5 
6 #include <cassert>
7 #include <vector>
8 
9 #include <dune/geometry/topologyfactory.hh>
11 
12 namespace Dune
13 {
14 
15  // DGLocalCoefficients
16  // -------------------
17 
22  {
23  typedef DGLocalCoefficients This;
24 
25  public:
27  DGLocalCoefficients ( const unsigned int n )
28  : localKey_( n )
29  {
30  for( unsigned i = 0; i < n; ++i )
31  localKey_[ i ] = LocalKey( 0, 0, i );
32  }
33 
34  const LocalKey &localKey ( const unsigned int i ) const
35  {
36  assert( i < size() );
37  return localKey_[ i ];
38  }
39 
40  unsigned int size () const
41  {
42  return localKey_.size();
43  }
44 
45  private:
46  std::vector< LocalKey > localKey_;
47  };
48 
49 
50 
51  // DGLocalCoefficientsFactory
52  // --------------------------
56  template< class BasisCreator >
58  template< class BasisFactory >
60  {
61  static const unsigned int dimension = BasisFactory::dimension;
62  typedef typename BasisFactory::Key Key;
64  typedef const DGLocalCoefficients Object;
66  };
67 
68  template< class BasisFactory >
70  public TopologyFactory< DGLocalCoefficientsFactoryTraits<BasisFactory> >
71  {
73 
74  static const unsigned int dimension = Traits::dimension;
75  typedef typename Traits::Key Key;
76  typedef typename Traits::Object Object;
77 
78  template< class Topology >
79  static Object *createObject ( const Key &key )
80  {
81  const typename BasisFactory::Object *basis
82  = BasisFactory::template create< Topology >( key );
83  Object *coefficients = new Object( basis->size() );
84  BasisFactory::release( basis );
85  return coefficients;
86  }
87  };
88 
89 }
90 
91 #endif // #ifndef DUNE_DGLOCALCOEFFICIENTS_HH
DGLocalCoefficients(const unsigned int n)
construct local keys for n basis functions
Definition: dglocalcoefficients.hh:27
A class providing local coefficients for dg spaces.
Definition: dglocalcoefficients.hh:21
BasisFactory::Key Key
Definition: dglocalcoefficients.hh:62
DGLocalCoefficientsFactory< BasisFactory > Factory
Definition: dglocalcoefficients.hh:65
const DGLocalCoefficients Object
Definition: dglocalcoefficients.hh:64
Describe position of one degree of freedom.
Definition: localkey.hh:21
unsigned int size() const
Definition: dglocalcoefficients.hh:40
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:14
DGLocalCoefficientsFactoryTraits< BasisFactory > Traits
Definition: dglocalcoefficients.hh:72
static Object * createObject(const Key &key)
Definition: dglocalcoefficients.hh:79
Definition: dglocalcoefficients.hh:59
DGLocalCoefficients LocalCoefficients
Definition: dglocalcoefficients.hh:63
Traits::Object Object
Definition: dglocalcoefficients.hh:76
A factory class for the dg local coefficients.
Definition: dglocalcoefficients.hh:57
Traits::Key Key
Definition: dglocalcoefficients.hh:75
const LocalKey & localKey(const unsigned int i) const
Definition: dglocalcoefficients.hh:34