dune-fem 2.8-git
blockvectordiscretefunction/blockvectordiscretefunction.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_BLOCKVECTORDISCRETEFUNCTION_HH
2#define DUNE_FEM_BLOCKVECTORDISCRETEFUNCTION_HH
3
4#include <memory>
5#include <string>
6#include <utility>
7
15
16namespace Dune
17{
18 namespace Fem
19 {
20
21 template< typename DiscreteFunctionSpace, typename BlockVector >
22 class BlockVectorDiscreteFunction;
23
24
25
37
38
39
46 template< typename DiscreteFunctionSpace, typename BlockVector >
48 : public DefaultDiscreteFunctionTraits< DiscreteFunctionSpace, BlockVector >
49 {
52 };
53
54
55
56
63 template< typename DiscreteFunctionSpace, typename BlockVector >
65 : public DiscreteFunctionDefault< BlockVectorDiscreteFunction< DiscreteFunctionSpace, BlockVector > >,
67 {
71
72 public:
76 typedef BlockVector BlockVectorType;
79
80 using BaseType::assign;
81 using BaseType::name;
82
89 BlockVectorDiscreteFunction ( const std::string& name,
92 : BaseType( name, space ),
93 memObject_(),
95 {}
96
102 BlockVectorDiscreteFunction ( const std::string& name,
104 : BaseType( name, space ),
105 memObject_(),
107 {}
108
111 : BaseType( "copy of "+other.name(), other.space() ),
112 memObject_(),
114 {
115 assign( other );
116 }
117
120 : BaseType( static_cast< BaseType && >( other ) ),
121 memObject_( std::move( other.memObject_ ) ),
122 dofVector_( other.dofVector_ )
123 {}
124
126 ThisType& operator= ( const ThisType& ) = delete;
128
130 const DofVectorType &dofVector () const
131 {
132 return dofVector_;
133 }
134
137 {
138 return dofVector_;
139 }
140
143 {
144 if( memObject_ )
145 memObject_->enableDofCompression();
146 }
147
148 protected:
150 {
151 std::pair< DofStorageInterface*, DofVectorType* > memPair(
152 allocateManagedDofStorage< DofVectorType >( space.gridPart().grid(), space.blockMapper() ) );
153
154 memObject_.reset( memPair.first );
155 return *memPair.second;
156 }
157
158 std::unique_ptr< DofStorageInterface > memObject_;
160 };
161
162 } // namespace Fem
163} // namespace Dune
164
165#endif // #ifndef DUNE_FEM_BLOCKVECTORDISCRETEFUNCTION_HH
STL namespace.
Definition: bindguard.hh:11
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:67
ThisType & operator=(const ThisType &)=delete
DofVectorType & dofVector()
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:136
std::unique_ptr< DofStorageInterface > memObject_
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:158
BlockVectorDiscreteFunction(ThisType &&other)
Move constructor.
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:119
DofVectorType & allocateDofStorage(const DiscreteFunctionSpaceType &space)
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:149
const DofVectorType & dofVector() const
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:130
BlockVector BlockVectorType
type for the class which implements the block vector
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:76
DiscreteFunctionSpace DiscreteFunctionSpaceType
type for the discrete function space this function lives in
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:74
const std::string & name() const
obtain the name of the discrete function
Definition: common/discretefunction.hh:685
BlockVectorType DofVectorType
type for the class which implements the block vector (which is the dof vector)
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:78
DofVectorType & dofVector_
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:159
BlockVectorDiscreteFunction(const std::string &name, const DiscreteFunctionSpaceType &space, DofVectorType &dofVector)
Constructor to use if the vector storing the dofs (which is a block vector) already exists.
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:89
BlockVectorDiscreteFunction(const std::string &name, const DiscreteFunctionSpaceType &space)
Constructor to use if the vector storing the dofs does not exist yet.
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:102
void enableDofCompression()
Enable this discrete function for dof compression, i.e. during grid changes a dof compression is done...
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:142
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:133
BlockVectorDiscreteFunction(const ThisType &other)
Copy constructor.
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:110
Tag for discrete functions using block vectors.
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:36
MutableLocalFunction< DiscreteFunctionType > LocalFunctionType
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:51
BlockVectorDiscreteFunction< DiscreteFunctionSpace, BlockVector > DiscreteFunctionType
Definition: blockvectordiscretefunction/blockvectordiscretefunction.hh:50
Traits class for a DiscreteFunction.
Definition: common/discretefunction.hh:61
Definition: common/discretefunction.hh:578
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: common/discretefunction.hh:703
const std::string & name() const
obtain the name of the discrete function
Definition: common/discretefunction.hh:685
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:133
Definition: common/discretefunction.hh:1064
Definition: common/scalarproducts.hh:73
discrete function space