dune-fem  2.8-git
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 <memory>
5 #include <string>
6 
12 
13 namespace Dune
14 {
15  namespace Fem
16  {
17 
18  template < class DiscreteFunctionSpace, class Vector >
19  class VectorDiscreteFunction;
20 
21 #if HAVE_PETSC
22  template <class DiscreteFunctionSpace>
23  class PetscDiscreteFunction;
24 #endif
25 
26 
27  template< typename DiscreteFunctionSpace, typename Vector >
29  : public DefaultDiscreteFunctionTraits< DiscreteFunctionSpace,
30  SimpleBlockVector< Vector, DiscreteFunctionSpace::localBlockSize > >
31  {
34  };
35 
36 
37 
38  template < class DiscreteFunctionSpace, class Vector >
40  : public DiscreteFunctionDefault<
41  VectorDiscreteFunction< DiscreteFunctionSpace, Vector > >
42  {
45 
46  public:
47  typedef Vector VectorType;
50  typedef typename DofVectorType :: DofContainerType DofContainerType;
51  typedef typename BaseType :: DofType DofType;
52 
53  using BaseType::assign;
54 
61  VectorDiscreteFunction( const std::string& name,
64  : BaseType( name, space ),
65  vec_(),
67  {}
68 
71  : BaseType( "copy of " + other.name(), other.space() ),
72  vec_(),
73  dofVector_( allocateDofVector( other.space() ) )
74  {
75  assign( other );
76  }
77 
80  : BaseType( static_cast< BaseType && >( other ) ),
81  vec_( std::move( other.vec_ ) ),
82  dofVector_( other.dofVector_ )
83  {}
84 
86  ThisType& operator= ( const ThisType& ) = delete;
87  ThisType& operator= ( ThisType&& ) = delete;
88 
89 #if HAVE_PETSC
91  {
92  g.dofVector().copyTo( dofVector() );
93  }
94 #endif
95 
98 
100  const DofVectorType& dofVector() const { return dofVector_; }
101 
102  protected:
103  // allocate managed dof storage
105  {
106  vec_.reset( new VectorType( space.size() ) );
107  return *vec_;
108  }
109 
110  // pointer to DofContainer
111  std::unique_ptr< VectorType > vec_;
112  // dof vector that stores reference to vector
114  };
115 
116  } // namespace Fem
117 } // namespace Dune
118 
119 #include "managedvectorfunction.hh"
120 
121 #endif // #ifndef DUNE_FEM_VECTORFUNCTION_HH
Definition: bindguard.hh:11
Traits class for a DiscreteFunction.
Definition: common/discretefunction.hh:61
Definition: common/discretefunction.hh:578
const std::string & name() const
obtain the name of the discrete function
Definition: common/discretefunction.hh:685
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: common/discretefunction.hh:600
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:133
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: common/discretefunction.hh:703
BaseType ::DofType DofType
Definition: common/discretefunction.hh:643
Traits ::DofVectorType DofVectorType
type of DofVector
Definition: common/discretefunction.hh:625
Definition: common/discretefunction.hh:1064
Definition: vectorfunction/vectorfunction.hh:42
VectorDiscreteFunction(ThisType &&other)
Move constructor.
Definition: vectorfunction/vectorfunction.hh:79
BaseType ::DofType DofType
Definition: vectorfunction/vectorfunction.hh:51
const DofVectorType & dofVector() const
Definition: vectorfunction/vectorfunction.hh:100
DofVectorType ::DofContainerType DofContainerType
Definition: vectorfunction/vectorfunction.hh:50
VectorType & allocateDofVector(const DiscreteFunctionSpaceType &space)
Definition: vectorfunction/vectorfunction.hh:104
ThisType & operator=(const ThisType &)=delete
Vector VectorType
Definition: vectorfunction/vectorfunction.hh:47
VectorDiscreteFunction(const ThisType &other)
Copy constructor.
Definition: vectorfunction/vectorfunction.hh:70
VectorDiscreteFunction(const std::string &name, const DiscreteFunctionSpaceType &space, VectorType &dofVector)
Constructor to use if the vector storing the dofs already exists.
Definition: vectorfunction/vectorfunction.hh:61
BaseType ::DofVectorType DofVectorType
Definition: vectorfunction/vectorfunction.hh:49
DofVectorType dofVector_
Definition: vectorfunction/vectorfunction.hh:113
BaseType ::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: vectorfunction/vectorfunction.hh:48
DofVectorType & dofVector()
Definition: vectorfunction/vectorfunction.hh:97
void assign(const DiscreteFunctionType &g)
Definition: common/discretefunction.hh:809
std::unique_ptr< VectorType > vec_
Definition: vectorfunction/vectorfunction.hh:111
VectorDiscreteFunction< DiscreteFunctionSpace, Vector > DiscreteFunctionType
Definition: vectorfunction/vectorfunction.hh:32
MutableLocalFunction< DiscreteFunctionType > LocalFunctionType
Definition: vectorfunction/vectorfunction.hh:33
Definition: cachedcommmanager.hh:47
discrete function space