dune-localfunctions  2.3.1
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 >
57  struct DGLocalCoefficientsFactory;
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