1#ifndef DUNE_FEM_BLOCKVECTORDISCRETEFUNCTION_HH
2#define DUNE_FEM_BLOCKVECTORDISCRETEFUNCTION_HH
8#include <dune/fem/common/stackallocator.hh>
9#include <dune/fem/function/common/discretefunction.hh>
10#include <dune/fem/function/common/scalarproducts.hh>
11#include <dune/fem/function/localfunction/mutable.hh>
12#include <dune/fem/function/blockvectors/referenceblockvector.hh>
13#include <dune/fem/storage/envelope.hh>
20 template<
typename DiscreteFunctionSpace,
typename BlockVector >
21 class BlockVectorDiscreteFunction;
45 template<
typename DiscreteFunctionSpace,
typename BlockVector >
47 :
public DefaultDiscreteFunctionTraits< DiscreteFunctionSpace, BlockVector >
62 template<
typename DiscreteFunctionSpace,
typename BlockVector >
63 class BlockVectorDiscreteFunction
64 :
public DiscreteFunctionDefault< BlockVectorDiscreteFunction< DiscreteFunctionSpace, BlockVector > >,
65 public IsBlockVectorDiscreteFunction
67 typedef BlockVectorDiscreteFunction< DiscreteFunctionSpace, BlockVector > ThisType;
68 typedef DiscreteFunctionDefault< ThisType > BaseType;
77 typedef BlockVectorType DofVectorType;
88 BlockVectorDiscreteFunction (
const std::string& name,
89 const DiscreteFunctionSpaceType& space,
90 DofVectorType& dofVector )
91 : BaseType( name, space ),
93 dofVector_( dofVector )
101 BlockVectorDiscreteFunction (
const std::string& name,
102 const DiscreteFunctionSpaceType& space )
103 : BaseType( name, space ),
105 dofVector_( allocateDofStorage( space ) )
109 BlockVectorDiscreteFunction (
const ThisType& other )
110 : BaseType(
"copy of "+other.name(), other.
space() ),
112 dofVector_( allocateDofStorage( other.
space() ) )
118 BlockVectorDiscreteFunction( ThisType&& other )
119 : BaseType( static_cast< BaseType && >( other ) ),
120 memObject_(
std::move( other.memObject_ ) ),
121 dofVector_( other.dofVector_ )
124 BlockVectorDiscreteFunction () =
delete;
125 ThisType& operator= (
const ThisType& ) =
delete;
126 ThisType& operator= ( ThisType&& ) =
delete;
129 const DofVectorType &dofVector ()
const
135 DofVectorType &dofVector ()
141 void enableDofCompression ()
144 memObject_->enableDofCompression();
148 DofVectorType& allocateDofStorage(
const DiscreteFunctionSpaceType& space )
150 std::pair< DofStorageInterface*, DofVectorType* > memPair(
151 allocateManagedDofStorage< DofVectorType >( space.gridPart().grid(), space.blockMapper() ) );
153 memObject_.reset( memPair.first );
154 return *memPair.second;
157 std::unique_ptr< DofStorageInterface > memObject_;
158 DofVectorType& dofVector_;
A vector of blocks with memory management.
Definition: bvector.hh:392
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
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:132
forward declaration
Definition: discretefunction.hh:51
Scalar product for overlapping Schwarz methods.
Definition: scalarproducts.hh:99
Dune namespace.
Definition: alignedallocator.hh:13
void assign(T &dst, const T &src, bool mask)
masked Simd assignment (scalar version)
Definition: simd.hh:447
Traits class for a DiscreteFunction.
Definition: discretefunction.hh:61
Tag for discrete functions using block vectors.
Definition: blockvectordiscretefunction.hh:35