dune-fem  2.6-git
function/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 
16 namespace 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 
88  BlockVectorDiscreteFunction ( const std::string& name,
91  : BaseType( name, space ),
92  memObject_(),
94  {}
95 
101  BlockVectorDiscreteFunction ( const std::string& name,
103  : BaseType( name, space ),
104  memObject_(),
106  {}
107 
110  : BaseType( "copy of "+other.name(), other.space() ),
111  memObject_(),
112  dofVector_( allocateDofStorage( other.space() ) )
113  {
114  assign( other );
115  }
116 
119  : BaseType( static_cast< BaseType && >( other ) ),
120  memObject_( std::move( other.memObject_ ) ),
121  dofVector_( other.dofVector_ )
122  {}
123 
125  ThisType& operator= ( const ThisType& ) = delete;
126  ThisType& operator= ( ThisType&& ) = delete;
127 
129  const DofVectorType &dofVector () const
130  {
131  return dofVector_;
132  }
133 
136  {
137  return dofVector_;
138  }
139 
142  {
143  if( memObject_ )
144  memObject_->enableDofCompression();
145  }
146 
147  protected:
149  {
150  std::string name("deprecated");
151  std::pair< DofStorageInterface*, DofVectorType* > memPair(
152  allocateManagedDofStorage< DofVectorType >( space.gridPart().grid(), space.blockMapper(), name ) );
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
Definition: bindguard.hh:11
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:67
std::unique_ptr< DofStorageInterface > memObject_
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:158
BlockVectorDiscreteFunction(ThisType &&other)
Move constructor.
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:118
DofVectorType & allocateDofStorage(const DiscreteFunctionSpaceType &space)
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:148
BlockVector BlockVectorType
type for the class which implements the block vector
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:76
DiscreteFunctionSpace DiscreteFunctionSpaceType
type for the discrete function space this function lives in
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:74
BlockVectorType DofVectorType
type for the class which implements the block vector (which is the dof vector)
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:78
DofVectorType & dofVector_
Definition: function/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: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:88
BlockVectorDiscreteFunction(const std::string &name, const DiscreteFunctionSpaceType &space)
Constructor to use if the vector storing the dofs does not exist yet.
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:101
void enableDofCompression()
Enable this discrete function for dof compression, i.e. during grid changes a dof compression is done...
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:141
const DofVectorType & dofVector() const
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:129
ThisType & operator=(const ThisType &)=delete
DofVectorType & dofVector()
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:135
BlockVectorDiscreteFunction(const ThisType &other)
Copy constructor.
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:109
void assign(const DiscreteFunctionType &g)
Definition: common/discretefunction.hh:764
Tag for discrete functions using block vectors.
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:36
MutableLocalFunction< DiscreteFunctionType > LocalFunctionType
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:51
BlockVectorDiscreteFunction< DiscreteFunctionSpace, BlockVector > DiscreteFunctionType
Definition: function/blockvectordiscretefunction/blockvectordiscretefunction.hh:50
Traits class for a DiscreteFunction.
Definition: common/discretefunction.hh:60
Definition: common/discretefunction.hh:539
const std::string & name() const
obtain the name of the discrete function
Definition: common/discretefunction.hh:644
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:128
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: common/discretefunction.hh:662
Definition: common/discretefunction.hh:1013
Definition: common/scalarproducts.hh:73
Definition: mutable.hh:31
discrete function space