dune-localfunctions  2.2.1
dglocalcoefficients.hh
Go to the documentation of this file.
1 #ifndef DUNE_DGLOCALCOEFFICIENTS_HH
2 #define DUNE_DGLOCALCOEFFICIENTS_HH
3 
4 #include <cassert>
5 #include <vector>
6 
7 #include <dune/geometry/topologyfactory.hh>
9 
10 namespace Dune
11 {
12 
13  // DGLocalCoefficients
14  // -------------------
15 
20  {
21  typedef DGLocalCoefficients This;
22 
23  public:
25  DGLocalCoefficients ( const unsigned int n )
26  : localKey_( n )
27  {
28  for( unsigned i = 0; i < n; ++i )
29  localKey_[ i ] = LocalKey( 0, 0, i );
30  }
31 
32  const LocalKey &localKey ( const unsigned int i ) const
33  {
34  assert( i < size() );
35  return localKey_[ i ];
36  }
37 
38  unsigned int size () const
39  {
40  return localKey_.size();
41  }
42 
43  private:
44  std::vector< LocalKey > localKey_;
45  };
46 
47 
48 
49  // DGLocalCoefficientsFactory
50  // --------------------------
54  template< class BasisCreator >
56  template< class BasisFactory >
58  {
59  static const unsigned int dimension = BasisFactory::dimension;
60  typedef typename BasisFactory::Key Key;
62  typedef const DGLocalCoefficients Object;
64  };
65 
66  template< class BasisFactory >
68  public TopologyFactory< DGLocalCoefficientsFactoryTraits<BasisFactory> >
69  {
71 
72  static const unsigned int dimension = Traits::dimension;
73  typedef typename Traits::Key Key;
74  typedef typename Traits::Object Object;
75 
76  template< class Topology >
77  static Object *createObject ( const Key &key )
78  {
79  const typename BasisFactory::Object *basis
80  = BasisFactory::template create< Topology >( key );
81  Object *coefficients = new Object( basis->size() );
82  BasisFactory::release( basis );
83  return coefficients;
84  }
85  };
86 
87 }
88 
89 #endif // #ifndef DUNE_DGLOCALCOEFFICIENTS_HH