3#ifndef DUNE_ALUGRID_LBDATAHANDLE_HH
4#define DUNE_ALUGRID_LBDATAHANDLE_HH
6#include <dune/grid/alugrid/3d/datahandle.hh>
13 template<
class Gr
id,
class DataHandleImpl,
class Data >
14 class ALUGridLoadBalanceDataHandle
16 typedef typename Grid :: Traits :: HierarchicIterator HierarchicIterator;
19 typedef typename Grid :: ObjectStreamType ObjectStream;
21 typedef CommDataHandleIF< DataHandleImpl, Data > DataHandle;
28 typedef typename Grid :: Traits :: template Codim< codim > :: Entity Entity;
29 typedef typename Grid :: Traits :: template Codim< codim > :: EntityPointer
37 DataHandle &dataHandle_;
40 ALUGridLoadBalanceDataHandle (
const Grid &grid, DataHandle &dataHandle )
42 dataHandle_( dataHandle )
45 void inlineData ( ObjectStream &stream,
const Element &element )
const
47 inlineElementData( stream, element );
49 const int maxLevel = grid_.maxLevel();
50 const HierarchicIterator end = element.hend( maxLevel );
51 for( HierarchicIterator it = element.hbegin( maxLevel ); it != end; ++it )
52 inlineElementData( stream, *it );
55 void xtractData ( ObjectStream &stream,
const Element &element,
size_t newElements )
57 xtractElementData( stream, element );
59 const int maxLevel = grid_.maxLevel();
60 const HierarchicIterator end = element.hend( maxLevel );
61 for( HierarchicIterator it = element.hbegin( maxLevel ); it != end; ++it )
62 xtractElementData( stream, *it );
69 void inlineElementData ( ObjectStream &stream,
const Element &element )
const
72 if( dataHandle_.contains( dimension, 0 ) )
74 inlineEntityData<0>( stream, element );
78 inlineCodimData< 1 >( stream, element );
79 inlineCodimData< 2 >( stream, element );
80 inlineCodimData< 3 >( stream, element );
83 void xtractElementData ( ObjectStream &stream,
const Element &element )
86 if( dataHandle_.contains( dimension, 0 ) )
88 xtractEntityData<0>( stream, element );
92 xtractCodimData< 1 >( stream, element );
93 xtractCodimData< 2 >( stream, element );
94 xtractCodimData< 3 >( stream, element );
98 void inlineCodimData ( ObjectStream &stream,
const Element &element )
const
100 typedef typename Codim< codim > :: EntityPointer EntityPointer;
102 if( dataHandle_.contains( dimension, codim ) )
104 const int numSubEntities = element.template count< codim >();
105 for(
int i = 0; i < numSubEntities; ++i )
107 const EntityPointer pEntity = element.template subEntity< codim >( i );
108 inlineEntityData< codim >( stream, *pEntity );
113 template<
int codim >
114 void xtractCodimData ( ObjectStream &stream,
const Element &element )
116 typedef typename Codim< codim > :: EntityPointer EntityPointer;
118 if( dataHandle_.contains( dimension, codim ) )
120 const int numSubEntities = element.template count< codim >();
121 for(
int i = 0; i < numSubEntities; ++i )
123 const EntityPointer pEntity = element.template subEntity< codim >( i );
124 xtractEntityData< codim >( stream, *pEntity );
129 template<
int codim >
130 void inlineEntityData ( ObjectStream &stream,
131 const typename Codim< codim > :: Entity &entity )
const
133 const size_t size = dataHandle_.size( entity );
134 stream.write( size );
135 dataHandle_.gather( stream, entity );
138 template<
int codim >
139 void xtractEntityData ( ObjectStream &stream,
140 const typename Codim< codim > :: Entity &entity )
144 dataHandle_.scatter( stream, entity, size );
@ dimension
The dimension of the grid.
Definition: grid.hh:402
Describes the parallel communication interface class for MessageBuffers and DataHandles.
Dune namespace.
Definition: alignment.hh:10