dune-fem  2.4.1-rc
vectorfunction/vectorfunction.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_VECTORFUNCTION_HH
2 #define DUNE_FEM_VECTORFUNCTION_HH
3 
4 #include <dune/common/typetraits.hh>
5 
12 
14 
15 namespace Dune
16 {
17 
18  namespace Fem
19  {
20 
21  // Internal Forward Declarations
22  // -----------------------------
23 
24  template < class DiscreteFunctionSpace, class Vector >
26 
27  // VectorDiscreteFunctionTraits
28  // ----------------------------
29 
30  template< typename DiscreteFunctionSpace, typename Vector >
32  : public DefaultDiscreteFunctionTraits< DiscreteFunctionSpace,
33  SimpleBlockVector< Vector, DiscreteFunctionSpace::localBlockSize > >
34  {
37  };
38 
39 
40  // VectorDiscreteFunction
41  // ----------------------
42 
43  template < class DiscreteFunctionSpace, class Vector >
45  : public DiscreteFunctionDefault<
46  VectorDiscreteFunction< DiscreteFunctionSpace, Vector > >
47  {
49  typedef DiscreteFunctionDefault< ThisType > BaseType;
50 
51  public:
52  typedef Vector VectorType;
55  typedef typename DofVectorType :: DofContainerType DofContainerType;
56  typedef typename BaseType :: DofType DofType;
57 
58  using BaseType::assign;
59 
60  VectorDiscreteFunction( const std::string &name,
61  const DiscreteFunctionSpaceType &space,
62  VectorType& vector )
63  : BaseType( name, space ),
64  vec_(),
65  dofVector_( vector )
66  {
67  }
68 
70  : BaseType( "copy of " + other.name(), other.space() ),
71  vec_(),
72  dofVector_( allocateDofVector( other.space() ) )
73  {
74  assign( other );
75  }
76 
77  DofVectorType& dofVector() { return dofVector_; }
78  const DofVectorType& dofVector() const { return dofVector_; }
79 
80  protected:
81  // allocate managed dof storage
82  VectorType& allocateDofVector ( const DiscreteFunctionSpaceType& space )
83  {
84  vec_.reset( new VectorType( space.size() ) );
85  return *vec_;
86  }
87 
88  // pointer to DofContainer
89  std::unique_ptr< VectorType > vec_;
90  // dof vector that stores referenc to vector
91  DofVectorType dofVector_;
92  };
93 
94  // Capabilibies
95  // ------------
96 
97  namespace Capabilities
98  {
99 
100  template< class DiscreteFunctionSpace, class DofVector >
102  < Fem :: VectorDiscreteFunction< DiscreteFunctionSpace, DofVector > >
103  : public HasLeakPointer< DofVector >
104  {};
105 
106  }
107 
108  } // namespace Fem
109 
110 } // namespace Dune
111 
112 #include "managedvectorfunction.hh"
113 
114 #endif // #ifndef DUNE_FEM_VECTORFUNCTION_HH
MutableLocalFunction< DiscreteFunctionType > LocalFunctionType
Definition: vectorfunction/vectorfunction.hh:36
VectorType & allocateDofVector(const DiscreteFunctionSpaceType &space)
Definition: vectorfunction/vectorfunction.hh:82
VectorDiscreteFunction(const VectorDiscreteFunction &other)
Definition: vectorfunction/vectorfunction.hh:69
Definition: vectorfunction/vectorfunction.hh:25
BaseType::DofType DofType
Definition: vectorfunction/vectorfunction.hh:56
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: vectorfunction/vectorfunction.hh:53
Traits class for a DiscreteFunction.
Definition: discretefunction.hh:60
DofVectorType::DofContainerType DofContainerType
Definition: vectorfunction/vectorfunction.hh:55
BaseType::DofVectorType DofVectorType
Definition: vectorfunction/vectorfunction.hh:54
DofVectorType & dofVector()
Definition: vectorfunction/vectorfunction.hh:77
VectorDiscreteFunction< DiscreteFunctionSpace, Vector > DiscreteFunctionType
Definition: vectorfunction/vectorfunction.hh:35
DofVectorType dofVector_
Definition: vectorfunction/vectorfunction.hh:91
Vector VectorType
Definition: vectorfunction/vectorfunction.hh:52
Definition: discretefunction.hh:63
This file implements a dense vector with a dynamic size.
std::unique_ptr< VectorType > vec_
Definition: vectorfunction/vectorfunction.hh:89
Definition: coordinate.hh:4
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: discretefunction.hh:571
Definition: discretefunction.hh:1034
const DofVectorType & dofVector() const
Definition: vectorfunction/vectorfunction.hh:78
Traits::DofVectorType DofVectorType
type of DofVector
Definition: discretefunction.hh:596
BaseType::DofType DofType
Definition: discretefunction.hh:613
discrete function space
VectorDiscreteFunction(const std::string &name, const DiscreteFunctionSpaceType &space, VectorType &vector)
Definition: vectorfunction/vectorfunction.hh:60
Definition: const.hh:24