1#ifndef DUNE_FEM_HPDG_SPACE_COMMON_DATAPROJECTION_DEFAULT_HH
2#define DUNE_FEM_HPDG_SPACE_COMMON_DATAPROJECTION_DEFAULT_HH
10#include <dune/common/dynvector.hh>
37 template<
class DiscreteFunction >
39 :
public DataProjection< typename DiscreteFunction::DiscreteFunctionSpaceType, DefaultDataProjection< DiscreteFunction > >
53 using RangeFieldType =
typename DiscreteFunction::RangeFieldType;
54 using LocalDofVectorType = Dune::DynamicVector< RangeFieldType >;
57 static const std::size_t localBlockSize = DiscreteFunctionSpaceType::localBlockSize;
66 : discreteFunction_( discreteFunction )
68 discreteFunction_.get().enableDofCompression();
79 ThisType &
operator= (
const ThisType & ) =
delete;
81 ThisType &
operator= ( ThisType && ) =
default;
89 const std::vector< std::size_t > &origin,
90 const std::vector< std::size_t > &destination )
95 assert( present.size() == space().basisFunctionSet( entity ).size() );
96 LocalDofVectorType localDofVector( present.size() );
100 ip( localFunc, localDofVector );
102 write( destination, localDofVector );
106 template <
class TemporaryStorage>
109 auto& df = discreteFunction();
112 auto dfit = df.dbegin();
113 const auto endtmp = tmp.dend();
114 for(
auto it = tmp.dbegin(); it != endtmp; ++it, ++dfit )
116 assert( dfit != df.dend() );
126 const auto end = df.space().end();
127 for(
auto it = df.space().begin(); it != end; ++it )
129 const auto& entity = *it;
131 auto tguard =
bindGuard( tmpLF, entity );
135 if( tmpLF.size() == lf.
size() )
141 auto iguard =
bindGuard( interpolation, entity );
143 interpolation( tmpLF, lf );
149 template<
class Communicator >
152 comm.addToList( discreteFunction() );
156 template<
class LocalDofVector >
157 void read (
const std::vector< std::size_t > &blocks, LocalDofVector &localDofVector )
const
159 assert( localDofVector.size() == localBlockSize*blocks.size() );
160 std::size_t index = 0;
161 for(
auto i : blocks )
163 const auto block = discreteFunction().block( i );
164 for( std::size_t j = 0; j < localBlockSize; ++j )
165 localDofVector[ index++ ] = (*block)[ j ];
167 assert( index == localDofVector.size() );
170 template<
class LocalDofVector >
171 void write (
const std::vector< std::size_t > &blocks,
const LocalDofVector &localDofVector )
173 assert( localDofVector.size() == localBlockSize*blocks.size() );
174 std::size_t index = 0;
175 for(
auto i : blocks )
177 auto block = discreteFunction().block( i );
178 for( std::size_t j = 0; j < localBlockSize; ++j )
179 (*block)[ j ] = localDofVector[ index++ ];
181 assert( index == localDofVector.size() );
184 DiscreteFunction &discreteFunction () {
return discreteFunction_.get(); }
186 const DiscreteFunction &discreteFunction ()
const {
return discreteFunction_.get(); }
189 LocalInterpolationType& interpolation ()
191 if( ! interpolation_ )
192 interpolation_.reset(
new LocalInterpolationType( space() ) );
193 return *interpolation_;
197 std::reference_wrapper< DiscreteFunction > discreteFunction_;
198 std::shared_ptr< LocalInterpolationType > interpolation_;
204 using hpDG::DefaultDataProjection;
Definition: bindguard.hh:11
typename Impl::ConstLocalFunction< GridFunction >::Type ConstLocalFunction
Definition: const.hh:604
static auto bindGuard(Object &object, Args &&... args) -> std::enable_if_t< isBindable< Object, Args... >::value, BindGuard< Object > >
Definition: bindguard.hh:67
interface for local functions
Definition: localfunction.hh:77
const LocalDofVectorType & localDofVector() const
return const reference to local Dof Vector
Definition: localfunction.hh:415
void assign(const LocalFunction< BasisFunctionSet, T > &other)
assign all DoFs of this local function
Definition: localfunction.hh:189
SizeType size() const
obtain the number of local DoFs
Definition: localfunction.hh:360
Definition: mutable.hh:31
Abstract definition of the local restriction and prolongation of discrete functions.
Definition: dataprojection/dataprojection.hh:29
typename BasisFunctionSetType::EntityType EntityType
entity type
Definition: dataprojection/dataprojection.hh:38
DiscreteFunctionSpace DiscreteFunctionSpaceType
discrete function space type
Definition: dataprojection/dataprojection.hh:34
typename DiscreteFunctionSpaceType::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: dataprojection/dataprojection.hh:36
DataProjection & operator=(DataProjection &&)=default
Local -projection for the restriction and prolongation of discrete functions.
Definition: space/common/dataprojection/default.hh:40
void addToList(Communicator &comm)
()
Definition: space/common/dataprojection/default.hh:150
typename BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
discrete function space type
Definition: space/common/dataprojection/default.hh:46
typename BaseType::EntityType EntityType
entity type
Definition: space/common/dataprojection/default.hh:50
typename BaseType::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: space/common/dataprojection/default.hh:48
void operator()(const EntityType &entity, const BasisFunctionSetType &prior, const BasisFunctionSetType &present, const std::vector< std::size_t > &origin, const std::vector< std::size_t > &destination)
Definition: space/common/dataprojection/default.hh:86
DefaultDataProjection(DiscreteFunction &discreteFunction)
Definition: space/common/dataprojection/default.hh:65
Definition: common/localinterpolation.hh:22