1#ifndef DUNE_FEM_HPDG_SPACE_COMMON_DATAPROJECTION_DEFAULT_HH
2#define DUNE_FEM_HPDG_SPACE_COMMON_DATAPROJECTION_DEFAULT_HH
12#include <dune/fem/function/localfunction/localfunction.hh>
13#include <dune/fem/function/localfunction/const.hh>
14#include <dune/fem/function/localfunction/mutable.hh>
15#include <dune/fem/space/common/localinterpolation.hh>
17#include "dataprojection.hh"
37 template<
class DiscreteFunction >
39 :
public DataProjection< typename DiscreteFunction::DiscreteFunctionSpaceType, DefaultDataProjection< DiscreteFunction > >
53 using RangeFieldType =
typename DiscreteFunction::RangeFieldType;
57 static const std::size_t localBlockSize = DiscreteFunctionSpaceType::localBlockSize;
58 typedef LocalInterpolation< DiscreteFunctionSpaceType > LocalInterpolationType;
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() );
98 LocalInterpolationType& ip = this->interpolation();
99 auto guard = bindGuard( ip, entity );
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() );
120 ConstLocalFunction< TemporaryStorage > tmpLF( tmp );
122 LocalInterpolationType interpolation( df.space() );
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 );
132 auto lguard = bindGuard( lf, 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(); }
188 const DiscreteFunctionSpaceType &space ()
const {
return discreteFunction().space(); }
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;
interface for local functions
Definition: localfunction.hh:77
const LocalDofVectorType & localDofVector() const
return const reference to local Dof Vector
Definition: localfunction.hh:424
void assign(const LocalFunction< BasisFunctionSet, T > &other)
assign all DoFs of this local function
Definition: localfunction.hh:192
SizeType size() const
obtain the number of local DoFs
Definition: localfunction.hh:369
Definition: mutable.hh:31
Abstract definition of the local restriction and prolongation of discrete functions.
Definition: dataprojection.hh:29
typename BasisFunctionSetType::EntityType EntityType
entity type
Definition: dataprojection.hh:38
DiscreteFunctionSpace DiscreteFunctionSpaceType
discrete function space type
Definition: dataprojection.hh:34
typename DiscreteFunctionSpaceType::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: dataprojection.hh:36
Local -projection for the restriction and prolongation of discrete functions.
Definition: default.hh:40
void addToList(Communicator &comm)
()
Definition: default.hh:150
typename BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
discrete function space type
Definition: default.hh:46
typename BaseType::EntityType EntityType
entity type
Definition: default.hh:50
typename BaseType::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: 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: default.hh:86
This file implements a dense vector with a dynamic size.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75