1 #ifndef DUNE_FEM_DEFAULTDATAHANDLE_HH 2 #define DUNE_FEM_DEFAULTDATAHANDLE_HH 7 #include <dune/grid/common/datahandleif.hh> 22 template<
class DiscreteFunction,
class Operation = DFCommunicationOperation::Add >
24 :
public CommDataHandleIF
25 < DefaultCommunicationHandler< DiscreteFunction, Operation >,
26 typename DiscreteFunction::DofType >
29 typedef CommDataHandleIF< ThisType, typename DiscreteFunction::DofType > BaseType;
43 static const unsigned int blockSize = DiscreteFunctionSpaceType::localBlockSize;
60 template <
class Buffer >
66 GatherFunctor( Buffer& buffer, DiscreteFunctionType*
function )
72 template <
class GlobalKey>
73 void operator () (
const size_t local,
const GlobalKey& globalKey )
75 DofBlockPtrType blockPtr = function_->block( globalKey );
76 for(
unsigned int j = 0; j <
blockSize; ++j )
78 buffer_.write( (*blockPtr)[ j ] );
83 template <
class Buffer >
89 ScatterFunctor( Buffer& buffer, DiscreteFunctionType*
function )
95 template <
class GlobalKey>
96 void operator () (
const size_t local,
const GlobalKey& globalKey )
98 DofBlockPtrType blockPtr = function_->block( globalKey );
99 for(
unsigned int j = 0; j <
blockSize; ++j )
102 buffer_.read( value );
104 Operation :: apply( value, (*blockPtr)[ j ] );
120 template<
class MessageBuffer,
class Entity >
121 void gather ( MessageBuffer &buffer,
const Entity &entity )
const 123 GatherFunctor< MessageBuffer > gatherDofs ( buffer,
function_ );
128 template<
class MessageBuffer,
class Entity >
129 void scatter ( MessageBuffer &buffer,
const Entity &entity,
size_t n )
131 assert( n == blockSize *
blockMapper_.numEntityDofs( entity ) );
132 ScatterFunctor< MessageBuffer > scatterDofs ( buffer,
function_ );
138 template<
class Entity >
139 size_t size (
const Entity &entity )
const 141 return blockSize *
blockMapper_.numEntityDofs( entity );
153 #endif // #ifndef DUNE_FEM_DEFAULTDATAHANDLE_HH
void scatter(MessageBuffer &buffer, const Entity &entity, size_t n)
read buffer and apply operation
Definition: defaultcommhandler.hh:129
Default communication handler for discrete functions.
Definition: defaultcommhandler.hh:23
DiscreteFunction DiscreteFunctionType
Definition: defaultcommhandler.hh:34
DefaultCommunicationHandler(const DefaultCommunicationHandler &other)
Definition: defaultcommhandler.hh:51
static const unsigned int blockSize
Definition: defaultcommhandler.hh:43
DiscreteFunctionSpaceType::BlockMapperType BlockMapperType
Definition: defaultcommhandler.hh:39
const BlockMapperType & blockMapper_
Definition: defaultcommhandler.hh:146
bool contains(int dim, int codim) const
Definition: defaultcommhandler.hh:109
size_t size(const Entity &entity) const
return local dof size to be communicated
Definition: defaultcommhandler.hh:139
DiscreteFunctionType::DofBlockPtrType DofBlockPtrType
Definition: defaultcommhandler.hh:41
void gather(MessageBuffer &buffer, const Entity &entity) const
read buffer and apply operation
Definition: defaultcommhandler.hh:121
DiscreteFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: defaultcommhandler.hh:36
Definition: coordinate.hh:4
DefaultCommunicationHandler(DiscreteFunctionType &function)
Definition: defaultcommhandler.hh:46
bool fixedsize(int dim, int codim) const
Definition: defaultcommhandler.hh:114
BaseType::DataType DataType
Definition: defaultcommhandler.hh:32
DiscreteFunctionType *const function_
Definition: defaultcommhandler.hh:145