1#ifndef DUNE_FEM_COMMOPERATIONS_HH
2#define DUNE_FEM_COMMOPERATIONS_HH
8#include <dune/common/hybridutilities.hh>
24 template<
class... DataHandle >
25 struct CombinedDataType;
27 template<
class DataHandle >
28 struct CombinedDataType< DataHandle >
30 typedef typename DataHandle::DataType Type;
33 template<
class DataHandle,
class... Tail >
34 struct CombinedDataType< DataHandle, Tail... >
36 typedef typename DataHandle::DataType Type;
37 static_assert( std::is_same< Type,
typename CombinedDataType< Tail... >::Type >::value,
"Only data handles for the same data type can be combined." );
48 template<
class... DataHandle >
50 :
public CommDataHandleIF< CombinedDataHandle< DataHandle... >, typename CombinedDataType< DataHandle... >::Type >
52 typedef std::tuple< DataHandle... > DataHandlerTupleType;
53 static constexpr std::size_t tupleSize = std::tuple_size< DataHandlerTupleType >::value;
56 typedef typename CombinedDataType< DataHandle... >::Type DataType;
66 bool contains (
int dim,
int codim)
const
70 [ & ](
auto i ){ value = ( value || std::get< i >( data_ ).contains( dim, codim ) ); } );
74 bool fixedSize (
int dim,
int codim)
const
78 [ & ](
auto i ){ value = ( value && std::get< i >( data_ ).fixedSize( dim, codim ) ); } );
84 template<
class MessageBufferImp,
class EntityType>
85 void gather (MessageBufferImp& buff,
const EntityType& en)
const
87 Hybrid::forEach( std::make_index_sequence< tupleSize >{}, [ & ](
auto i ){ std::get< i >( data_ ).gather( buff, en ); } );
92 template<
class MessageBufferImp,
class EntityType>
93 void scatter (MessageBufferImp& buff,
const EntityType& en, std::size_t n)
95 Hybrid::forEach( std::make_index_sequence< tupleSize >{}, [ & ](
auto i ){ std::get< i >( data_ ).scatter( buff, en, n ); } );
100 template<
class EntityType>
101 std::size_t
size (
const EntityType& en)
const
103 std::size_t value( 0 );
104 Hybrid::forEach( std::make_index_sequence< tupleSize >{}, [ & ](
auto i ){ value += std::get< i >( data_ ).size( en ); } );
109 DataHandlerTupleType data_;
123 enum dfCommunicationOperation { copy, add, sub, min, max };
128 static const dfCommunicationOperation value = copy;
129 static const char * name ()
134 template <
class DataType>
135 inline void operator () (
const DataType & arg, DataType & dest)
const
145 static const dfCommunicationOperation value = add;
146 static const char * name ()
151 template <
class DataType>
152 inline void operator () (
const DataType & arg, DataType & dest)
const
161 static const dfCommunicationOperation value = sub;
162 static const char * name ()
167 template <
class DataType>
168 inline void operator () (
const DataType & arg, DataType & dest)
const
177 static const dfCommunicationOperation value = min;
178 static const char * name ()
183 template <
class DataType>
184 inline void operator () (
const DataType & arg, DataType & dest)
const
186 dest = std::min(dest,arg);
193 static const dfCommunicationOperation value = max;
194 static const char * name ()
199 template <
class DataType>
200 inline void operator () (
const DataType & arg, DataType & dest)
const
202 dest = std::max(dest,arg);
214 template <
class DiscreteFunction>
218 typedef DiscreteFunction DiscreteFunctionType ;
219 typedef typename DiscreteFunctionType :: DiscreteFunctionSpaceType :: IteratorType :: Entity Entity;
225 return entity.isLeaf();
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:78
combine multiple data handles into one
Definition: commoperations.hh:51
check for sets of entities for the load balance procedure
Definition: commoperations.hh:216
Describes the parallel communication interface class for MessageBuffers and DataHandles.
std::size_t size(const EntityType &en) const
loop over all internal data handlers and return sum of data size of given entity
Definition: commoperations.hh:101
void gather(MessageBufferImp &buff, const EntityType &en) const
loop over all internal data handlers and call gather for given entity
Definition: commoperations.hh:85
void scatter(MessageBufferImp &buff, const EntityType &en, std::size_t n)
loop over all internal data handlers and call scatter for given entity
Definition: commoperations.hh:93
bool contains(const Entity &entity) const
return true if the data of this entity should be transfered during load balance
Definition: commoperations.hh:223
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:257
Dune namespace.
Definition: alignedallocator.hh:13
sum up data
Definition: commoperations.hh:144
just copy data
Definition: commoperations.hh:127
keep maximum
Definition: commoperations.hh:192
keep minimum
Definition: commoperations.hh:176
substract data
Definition: commoperations.hh:160
Mathematical operation apply during communication to data that is communicated enum of all avialable ...
Definition: commoperations.hh:122