1 #ifndef DUNE_ALUGRID_3D_COMMUNICATION_HH
2 #define DUNE_ALUGRID_3D_COMMUNICATION_HH
8 #include <dune/common/stdstreams.hh>
10 #include <dune/grid/common/datahandleif.hh>
11 #include <dune/grid/common/gridenums.hh>
22 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
25 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
28 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
36 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
44 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
59 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
68 template<
class DataHandle,
class Data >
70 InterfaceType iftype, CommunicationDirection dir )
79 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
88 template<
class DataHandle,
class Data >
90 InterfaceType iftype, CommunicationDirection dir,
int level )
99 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
106 typedef typename Grid::Traits::template Codim< dim >::Entity
VertexObject;
107 typedef typename Grid::Traits::template Codim< 2 >::Entity
EdgeObject;
108 typedef typename Grid::Traits::template Codim< 1 >::Entity
FaceObject;
111 typedef typename Grid::Traits::template Codim< dim >::EntityImp
VertexImpl;
112 typedef typename Grid::Traits::template Codim< 2 >::EntityImp
EdgeImpl;
113 typedef typename Grid::Traits::template Codim< 1 >::EntityImp
FaceImpl;
114 typedef typename Grid::Traits::template Codim< 0 >::EntityImp
ElementImpl;
141 : storage_( storage )
144 if( (iftype == Overlap_OverlapFront_Interface) || (iftype == Overlap_All_Interface) )
146 dverb <<
"ALUGrid contains no overlap, therefore no communication for" << std::endl;
147 dverb <<
"Overlap_OverlapFront_Interface or Overlap_All_Interface interfaces!" << std::endl;
150 else if( iftype == InteriorBorder_InteriorBorder_Interface )
151 grid.
myGrid().borderBorderCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
153 else if( iftype == InteriorBorder_All_Interface )
155 if( dir == ForwardCommunication )
156 communication_ = grid.
myGrid().interiorGhostCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
158 else if( dir == BackwardCommunication )
159 communication_ = grid.
myGrid().ghostInteriorCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
162 else if( iftype == All_All_Interface )
163 communication_ = grid.
myGrid().allAllCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
165 DUNE_THROW( GridError,
"Wrong parameters in ALUCommunication." );
169 : storage_( std::move( other.storage_ ) ),
170 communication_( std::move( other.communication_ ) )
175 storage_ = std::move( other.storage_ );
176 communication_ = std::move( other.communication_ );
180 bool pending ()
const {
return communication_.pending(); }
182 void wait () { communication_.wait(); }
185 std::unique_ptr< Storage > storage_;
186 ALU3DSPACE GitterDunePll::Communication communication_;
194 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
205 template<
class DataHandle,
class Data >
210 typedef typename std::conditional<dim == 2,
211 ALU3DSPACE GatherScatterNoData< Grid, CommDataHandleIF, 2 >,
212 ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, 2 >
216 :
Base::Storage( grid, grid.maxLevel() ),
217 vertexGatherScatter_( grid, vertex,
Grid::getRealImplementation( vertex ), dataHandle ),
218 edgeGatherScatter_( grid, edge,
Grid::getRealImplementation( edge ), dataHandle ),
219 faceGatherScatter_( grid, face,
Grid::getRealImplementation( face ), dataHandle ),
220 elementGatherScatter_( grid, element,
Grid::getRealImplementation( element ), dataHandle )
229 using Base::Storage::vertex;
230 using Base::Storage::edge;
231 using Base::Storage::face;
232 using Base::Storage::element;
241 template<
class DataHandle,
class Data >
243 InterfaceType iftype, CommunicationDirection dir )
244 :
Base( grid, new Storage< DataHandle, Data >( grid, data ), iftype, dir )
248 :
Base( static_cast<
Base && >( other ) )
253 static_cast< Base &
>( *this ) =
static_cast< Base &&
>( other );
263 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
274 template<
class DataHandle,
class Data >
279 typedef typename std::conditional<dim == 2,
280 ALU3DSPACE GatherScatterNoData< Grid, CommDataHandleIF, 2 >,
281 ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, 2 >
285 :
Base::Storage( grid, level ),
286 indexSet_( grid.accessLevelIndexSet( level ) ),
287 vertexGatherScatter_( grid, vertex,
Grid::getRealImplementation( vertex ), dataHandle, *indexSet_, level ),
288 edgeGatherScatter_( grid, edge,
Grid::getRealImplementation( edge ), dataHandle, *indexSet_, level ),
289 faceGatherScatter_( grid, face,
Grid::getRealImplementation( face ), dataHandle, *indexSet_, level ),
290 elementGatherScatter_( grid, element,
Grid::getRealImplementation( element ), dataHandle, *indexSet_, level )
299 using Base::Storage::vertex;
300 using Base::Storage::edge;
301 using Base::Storage::face;
302 using Base::Storage::element;
304 std::shared_ptr< typename Grid::LevelIndexSetImp >
indexSet_;
312 template<
class DataHandle,
class Data >
314 InterfaceType iftype, CommunicationDirection dir,
int level )
315 :
Base( grid, new Storage< DataHandle, Data >( grid, level, data ), iftype, dir )
319 :
Base( static_cast<
Base && >( other ) )
324 static_cast< Base &
>( *this ) =
static_cast< Base &&
>( other );
#define ALU3DSPACE
Definition: alu3dinclude.hh:24
Definition: alu3dinclude.hh:80
Definition: communication.hh:23
Definition: communication.hh:26
Definition: communication.hh:29
[ provides Dune::Grid ]
Definition: alugrid/3d/grid.hh:463
GitterImplType & myGrid() const
Definition: grid_inline.hh:115
Definition: communication.hh:46
void wait()
Definition: communication.hh:51
bool pending() const
Definition: communication.hh:49
ALU3dGrid< dim, dimworld, elType, ALUGridNoComm > Grid
Definition: communication.hh:47
Base::Grid Grid
Definition: communication.hh:66
ALULeafCommunication(const Grid &grid, CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir)
Definition: communication.hh:69
Base::Grid Grid
Definition: communication.hh:86
ALULevelCommunication(const Grid &grid, CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir, int level)
Definition: communication.hh:89
Definition: communication.hh:101
Grid::Traits::template Codim< dim >::Entity VertexObject
Definition: communication.hh:106
ALU3DSPACE GatherScatter GatherScatter
Definition: communication.hh:103
ALU3dGrid< dim, dimworld, elType, ALUGridMPIComm > Grid
Definition: communication.hh:102
Grid::Traits::template Codim< 0 >::EntityImp ElementImpl
Definition: communication.hh:114
bool pending() const
Definition: communication.hh:180
Grid::Traits::template Codim< 2 >::Entity EdgeObject
Definition: communication.hh:107
Grid::Traits::template Codim< 1 >::EntityImp FaceImpl
Definition: communication.hh:113
Grid::Traits::template Codim< dim >::EntityImp VertexImpl
Definition: communication.hh:111
Grid::Traits::template Codim< 0 >::Entity ElementObject
Definition: communication.hh:109
Grid::Traits::template Codim< 2 >::EntityImp EdgeImpl
Definition: communication.hh:112
ALUCommunication(ALUCommunication &&other)
Definition: communication.hh:168
Grid::Traits::template Codim< 1 >::Entity FaceObject
Definition: communication.hh:108
ALUCommunication(const Grid &grid, Storage *storage, InterfaceType iftype, CommunicationDirection dir)
Definition: communication.hh:140
void wait()
Definition: communication.hh:182
Storage(const Grid &grid, int level)
Definition: communication.hh:118
virtual GatherScatter & edgeGatherScatter()=0
virtual GatherScatter & elementGatherScatter()=0
virtual GatherScatter & faceGatherScatter()=0
virtual GatherScatter & vertexGatherScatter()=0
virtual ~Storage()
Definition: communication.hh:125
ElementObject element
Definition: communication.hh:136
VertexObject vertex
Definition: communication.hh:133
EdgeObject edge
Definition: communication.hh:134
FaceObject face
Definition: communication.hh:135
Base::GatherScatter GatherScatter
Definition: communication.hh:202
ALULeafCommunication(ALULeafCommunication &&other)
Definition: communication.hh:247
ALULeafCommunication(const Grid &grid, CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir)
Definition: communication.hh:242
Base::Grid Grid
Definition: communication.hh:201
GatherScatter & vertexGatherScatter()
Definition: communication.hh:223
GatherScatter & edgeGatherScatter()
Definition: communication.hh:224
Storage(const Grid &grid, CommDataHandleIF &dataHandle)
Definition: communication.hh:215
ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, dim > vertexGatherScatter_
Definition: communication.hh:234
GatherScatter & faceGatherScatter()
Definition: communication.hh:225
ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, 0 > elementGatherScatter_
Definition: communication.hh:237
EdgeGatherScatterType edgeGatherScatter_
Definition: communication.hh:235
GatherScatter & elementGatherScatter()
Definition: communication.hh:226
Dune::CommDataHandleIF< DataHandle, Data > CommDataHandleIF
Definition: communication.hh:209
ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, 1 > faceGatherScatter_
Definition: communication.hh:236
std::conditional< dim==2, ALU3DSPACE GatherScatterNoData< Grid, CommDataHandleIF, 2 >, ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, 2 > >::type EdgeGatherScatterType
Definition: communication.hh:213
ALULevelCommunication(ALULevelCommunication &&other)
Definition: communication.hh:318
ALULevelCommunication(const Grid &grid, CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir, int level)
Definition: communication.hh:313
Base::GatherScatter GatherScatter
Definition: communication.hh:271
Base::Grid Grid
Definition: communication.hh:270
GatherScatter & elementGatherScatter()
Definition: communication.hh:296
std::conditional< dim==2, ALU3DSPACE GatherScatterNoData< Grid, CommDataHandleIF, 2 >, ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, 2 > >::type EdgeGatherScatterType
Definition: communication.hh:282
ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, dim > vertexGatherScatter_
Definition: communication.hh:305
ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, 0 > elementGatherScatter_
Definition: communication.hh:308
GatherScatter & faceGatherScatter()
Definition: communication.hh:295
EdgeGatherScatterType edgeGatherScatter_
Definition: communication.hh:306
GatherScatter & edgeGatherScatter()
Definition: communication.hh:294
ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, 1 > faceGatherScatter_
Definition: communication.hh:307
Dune::CommDataHandleIF< DataHandle, Data > CommDataHandleIF
Definition: communication.hh:278
std::shared_ptr< typename Grid::LevelIndexSetImp > indexSet_
Definition: communication.hh:304
Storage(const Grid &grid, int level, CommDataHandleIF &dataHandle)
Definition: communication.hh:284
GatherScatter & vertexGatherScatter()
Definition: communication.hh:293
type of class for specialization of serial ALUGrid (No_Comm as communicator)
Definition: declaration.hh:31
type of class for specialization of parallel ALUGrid (MPI_Comm as communicator)
Definition: declaration.hh:39