1#ifndef DUNE_FEM_VECTORFUNCTION_HH
2#define DUNE_FEM_VECTORFUNCTION_HH
7#include <dune/fem/common/stackallocator.hh>
8#include <dune/fem/function/blockvectors/defaultblockvectors.hh>
9#include <dune/fem/function/common/discretefunction.hh>
10#include <dune/fem/function/localfunction/mutable.hh>
11#include <dune/fem/storage/envelope.hh>
18 template <
class DiscreteFunctionSpace,
class Vector >
19 class VectorDiscreteFunction;
22 template <
class DiscreteFunctionSpace>
23 class PetscDiscreteFunction;
27 template<
typename DiscreteFunctionSpace,
typename Vector >
29 :
public DefaultDiscreteFunctionTraits< DiscreteFunctionSpace,
30 SimpleBlockVector< Vector, DiscreteFunctionSpace::localBlockSize > >
38 template <
class DiscreteFunctionSpace,
class Vector >
39 class VectorDiscreteFunction
40 :
public DiscreteFunctionDefault<
41 VectorDiscreteFunction< DiscreteFunctionSpace, Vector > >
43 typedef VectorDiscreteFunction< DiscreteFunctionSpace, Vector > ThisType;
44 typedef DiscreteFunctionDefault< ThisType > BaseType;
47 typedef Vector VectorType;
50 typedef typename DofVectorType :: DofContainerType DofContainerType;
51 typedef typename BaseType :: DofType DofType;
61 VectorDiscreteFunction(
const std::string& name,
62 const DiscreteFunctionSpaceType& space,
63 VectorType& dofVector )
64 : BaseType( name, space ),
66 dofVector_( dofVector )
70 VectorDiscreteFunction(
const ThisType& other )
71 : BaseType(
"copy of " + other.
name(), other.
space() ),
73 dofVector_( allocateDofVector( other.
space() ) )
79 VectorDiscreteFunction( ThisType&& other )
80 : BaseType( static_cast< BaseType && >( other ) ),
81 vec_(
std::move( other.vec_ ) ),
82 dofVector_( other.dofVector_ )
85 VectorDiscreteFunction () =
delete;
86 ThisType& operator= (
const ThisType& ) =
delete;
87 ThisType& operator= ( ThisType&& ) =
delete;
90 void assign(
const PetscDiscreteFunction< DiscreteFunctionSpaceType >& g )
92 g.dofVector().copyTo( dofVector() );
97 DofVectorType& dofVector() {
return dofVector_; }
100 const DofVectorType& dofVector()
const {
return dofVector_; }
104 VectorType& allocateDofVector (
const DiscreteFunctionSpaceType& space )
106 vec_.reset(
new VectorType( space.size() ) );
111 std::unique_ptr< VectorType > vec_;
113 DofVectorType dofVector_;
119#include "managedvectorfunction.hh"
Traits::DofVectorType DofVectorType
type of DofVector
Definition: discretefunction.hh:631
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: discretefunction.hh:709
const std::string & name() const
obtain the name of the discrete function
Definition: discretefunction.hh:691
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: discretefunction.hh:606
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:132
forward declaration
Definition: discretefunction.hh:51
Dune namespace.
Definition: alignedallocator.hh:13
void assign(T &dst, const T &src, bool mask)
masked Simd assignment (scalar version)
Definition: simd.hh:447