dune-fem 2.8.0
Loading...
Searching...
No Matches
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
13namespace 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 >
41 VectorDiscreteFunction< DiscreteFunctionSpace, Vector > >
42 {
45
46 public:
47 typedef Vector VectorType;
48 typedef typename BaseType :: DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
49 typedef typename BaseType :: DofVectorType DofVectorType;
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_(),
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;
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
120
121#endif // #ifndef DUNE_FEM_VECTORFUNCTION_HH
STL namespace.
Definition: bindguard.hh:11
Traits class for a DiscreteFunction.
Definition: common/discretefunction.hh:61
Definition: common/discretefunction.hh:584
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: common/discretefunction.hh:709
const std::string & name() const
obtain the name of the discrete function
Definition: common/discretefunction.hh:691
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:132
Definition: common/discretefunction.hh:1081
Definition: vectorfunction/vectorfunction.hh:42
VectorDiscreteFunction(ThisType &&other)
Move constructor.
Definition: vectorfunction/vectorfunction.hh:79
ThisType & operator=(const ThisType &)=delete
DofVectorType::DofContainerType DofContainerType
Definition: vectorfunction/vectorfunction.hh:50
BaseType::DofVectorType DofVectorType
Definition: vectorfunction/vectorfunction.hh:49
DofVectorType & dofVector()
Definition: vectorfunction/vectorfunction.hh:97
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: vectorfunction/vectorfunction.hh:48
Vector VectorType
Definition: vectorfunction/vectorfunction.hh:47
BaseType::DofType DofType
Definition: vectorfunction/vectorfunction.hh:51
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
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:132
DofVectorType dofVector_
Definition: vectorfunction/vectorfunction.hh:113
const DofVectorType & dofVector() const
Definition: vectorfunction/vectorfunction.hh:100
std::unique_ptr< VectorType > vec_
Definition: vectorfunction/vectorfunction.hh:111
VectorType & allocateDofVector(const DiscreteFunctionSpaceType &space)
Definition: vectorfunction/vectorfunction.hh:104
VectorDiscreteFunction< DiscreteFunctionSpace, Vector > DiscreteFunctionType
Definition: vectorfunction/vectorfunction.hh:32
MutableLocalFunction< DiscreteFunctionType > LocalFunctionType
Definition: vectorfunction/vectorfunction.hh:33
Definition: cachedcommmanager.hh:47
discrete function space