dune-fem  2.6-git
function/blockvectorfunction/blockvectorfunction.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_BLOCKVECTORFUNCTION_HH
2 #define DUNE_FEM_BLOCKVECTORFUNCTION_HH
3 
4 #include <memory>
5 #include <string>
6 #include <utility>
7 
14 
15 namespace Dune
16 {
17  namespace Fem
18  {
25  template< class DiscreteFunctionSpace,
26  class Block >
28  : public DefaultDiscreteFunctionTraits< DiscreteFunctionSpace, ISTLBlockVector< Block > >
29  {
32  };
33 
34 
35 
36  template < class DiscreteFunctionSpace, class Block >
38  : public DiscreteFunctionDefault< ISTLBlockVectorDiscreteFunction< DiscreteFunctionSpace, Block > >
39  {
42 
43  public:
46  typedef typename BaseType :: DofType DofType;
47  typedef typename DofVectorType :: DofContainerType DofContainerType;
49 
51 
52  using BaseType::assign;
53 
61  : BaseType( name, space ),
62  memObject_(),
64  {}
65 
75  : BaseType( name, space ),
76  memObject_(),
77  dofVector_( const_cast< DofContainerType& > (dofVector) )
78  {}
79 
82  : BaseType( "copy of " + other.name(), other.space() ),
83  memObject_(),
84  dofVector_( allocateDofStorage( other.space() ) )
85  {
86  assign( other );
87  }
88 
91  : BaseType( static_cast< BaseType && >( other ) ),
92  memObject_( std::move( other.memObject_ ) ),
93  dofVector_( std::move( other.dofVector_ ) )
94  {}
95 
97  ThisType& operator= ( const ThisType& ) = delete;
98  ThisType& operator= ( ThisType&& ) = delete;
99 
102  {
103  if( memObject_ )
104  memObject_->enableDofCompression();
105  }
106 
108  DofContainerType& blockVector() { return dofVector().array(); }
109 
111  const DofContainerType& blockVector() const { return dofVector().array(); }
112 
115 
117  const DofVectorType& dofVector() const { return dofVector_; }
118 
121 
122  protected:
124 
125  // allocate managed dof storage
127  {
128  std::string name("deprecated");
129  // create memory object
130  std::pair< DofStorageInterface*, DofContainerType* > memPair
131  = allocateManagedDofStorage( space.gridPart().grid(), space.blockMapper(),
132  name, (DofContainerType *) 0 );
133 
134  // save pointer
135  memObject_.reset( memPair.first );
136  return *(memPair.second);
137  }
138 
139  // pointer to allocated DofVector
140  std::unique_ptr< DofStorageInterface > memObject_;
141 
142  // DofVector object holds pointer to dof container
144  };
145 
146  } // namespace Fem
147 } // namespace Dune
148 
149 #endif // #ifndef DUNE_FEM_BLOCKVECTORFUNCTION_HH
static std::pair< DofStorageInterface *, DofStorageType * > allocateManagedDofStorage(const GridType &grid, const MapperType &mapper, const std::string &name, const DofStorageType *=0)
default implementation for creating a managed dof storage
Definition: dofmanager.hh:626
Definition: bindguard.hh:11
MutableLocalFunction< DiscreteFunctionType > LocalFunctionType
Definition: function/blockvectorfunction/blockvectorfunction.hh:31
ISTLBlockVectorDiscreteFunction< DiscreteFunctionSpace, Block > DiscreteFunctionType
Definition: function/blockvectorfunction/blockvectorfunction.hh:30
Definition: function/blockvectorfunction/blockvectorfunction.hh:39
BaseType ::ScalarProductType ScalarProductType
Definition: function/blockvectorfunction/blockvectorfunction.hh:50
ThisType & operator=(const ThisType &)=delete
ISTLBlockVectorDiscreteFunction(const std::string &name, const DiscreteFunctionSpaceType &space)
Constructor to use if the vector storing the dofs does not exist yet.
Definition: function/blockvectorfunction/blockvectorfunction.hh:59
BaseType ::DofType DofType
Definition: function/blockvectorfunction/blockvectorfunction.hh:46
void enableDofCompression()
Enable this discrete function for dof compression, i.e. during grid changes a dof compression is done...
Definition: function/blockvectorfunction/blockvectorfunction.hh:101
BaseType ::DofVectorType DofVectorType
Definition: function/blockvectorfunction/blockvectorfunction.hh:45
DofVectorType & dofVector()
Definition: function/blockvectorfunction/blockvectorfunction.hh:114
ISTLBlockVectorDiscreteFunction(const ThisType &other)
Copy constructor.
Definition: function/blockvectorfunction/blockvectorfunction.hh:81
DofContainerType & blockVector()
convenience method for usage with ISTL solvers
Definition: function/blockvectorfunction/blockvectorfunction.hh:108
BaseType ::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: function/blockvectorfunction/blockvectorfunction.hh:44
ISTLBlockVectorDiscreteFunction(const std::string &name, const DiscreteFunctionSpaceType &space, const DofContainerType &dofVector)
Constructor to use if the vector storing the dofs already exists.
Definition: function/blockvectorfunction/blockvectorfunction.hh:72
DofVectorType dofVector_
Definition: function/blockvectorfunction/blockvectorfunction.hh:143
std::unique_ptr< DofStorageInterface > memObject_
Definition: function/blockvectorfunction/blockvectorfunction.hh:140
ScalarProductType & scalarProduct()
returns ScalarProduct to be used with ISTLInverseOp
Definition: function/blockvectorfunction/blockvectorfunction.hh:120
DofContainerType DofStorageType
Definition: function/blockvectorfunction/blockvectorfunction.hh:48
const DofVectorType & dofVector() const
Definition: function/blockvectorfunction/blockvectorfunction.hh:117
const DofContainerType & blockVector() const
convenience method for usage with ISTL solvers
Definition: function/blockvectorfunction/blockvectorfunction.hh:111
ISTLBlockVectorDiscreteFunction(ThisType &&other)
Move constructor.
Definition: function/blockvectorfunction/blockvectorfunction.hh:90
DofVectorType ::DofContainerType DofContainerType
Definition: function/blockvectorfunction/blockvectorfunction.hh:47
DofContainerType & allocateDofStorage(const DiscreteFunctionSpaceType &space)
Definition: function/blockvectorfunction/blockvectorfunction.hh:126
void assign(const DiscreteFunctionType &g)
Definition: common/discretefunction.hh:764
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
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: common/discretefunction.hh:561
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
ParallelScalarProduct< DiscreteFunctionInterfaceType > ScalarProductType
Definition: common/discretefunction.hh:557
BaseType ::DofType DofType
Definition: common/discretefunction.hh:604
Traits ::DofVectorType DofVectorType
type of DofVector
Definition: common/discretefunction.hh:586
Definition: common/discretefunction.hh:1013
Definition: mutable.hh:31
discrete function space