1 #ifndef DUNE_ALUGRID_3D_COMMUNICATION_HH
2 #define DUNE_ALUGRID_3D_COMMUNICATION_HH
8 #include <dune/common/visibility.hh>
9 #include <dune/common/stdstreams.hh>
11 #include <dune/grid/common/datahandleif.hh>
12 #include <dune/grid/common/gridenums.hh>
23 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
26 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
29 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
37 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
45 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
50 bool ready()
const {
return true; }
55 bool pending ()
const {
return ! ready(); }
63 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
72 template<
class DataHandle,
class Data >
74 InterfaceType iftype, CommunicationDirection dir )
83 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
92 template<
class DataHandle,
class Data >
94 InterfaceType iftype, CommunicationDirection dir,
int level )
103 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
110 typedef typename Grid::Traits::template Codim< dim >::Entity
VertexObject;
111 typedef typename Grid::Traits::template Codim< 2 >::Entity
EdgeObject;
112 typedef typename Grid::Traits::template Codim< 1 >::Entity
FaceObject;
115 typedef typename Grid::Traits::template Codim< dim >::EntityImp
VertexImpl;
116 typedef typename Grid::Traits::template Codim< 2 >::EntityImp
EdgeImpl;
117 typedef typename Grid::Traits::template Codim< 1 >::EntityImp
FaceImpl;
118 typedef typename Grid::Traits::template Codim< 0 >::EntityImp
ElementImpl;
145 : storage_( storage )
148 if( (iftype == Overlap_OverlapFront_Interface) || (iftype == Overlap_All_Interface) )
150 dverb <<
"ALUGrid contains no overlap, therefore no communication for" << std::endl;
151 dverb <<
"Overlap_OverlapFront_Interface or Overlap_All_Interface interfaces!" << std::endl;
154 else if( iftype == InteriorBorder_InteriorBorder_Interface )
155 grid.
myGrid().borderBorderCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
157 else if( iftype == InteriorBorder_All_Interface )
159 if( dir == ForwardCommunication )
160 communication_ = grid.
myGrid().interiorGhostCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
162 else if( dir == BackwardCommunication )
163 communication_ = grid.
myGrid().ghostInteriorCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
166 else if( iftype == All_All_Interface )
167 communication_ = grid.
myGrid().allAllCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
169 DUNE_THROW( GridError,
"Wrong parameters in ALUCommunication." );
173 : storage_( std::move( other.storage_ ) ),
174 communication_( std::move( other.communication_ ) )
179 storage_ = std::move( other.storage_ );
180 communication_ = std::move( other.communication_ );
184 bool ready ()
const {
return communication_.ready(); }
186 void wait () { communication_.wait(); }
191 std::unique_ptr< Storage > storage_;
192 ALU3DSPACE GitterDunePll::Communication communication_;
200 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
211 template<
class DataHandle,
class Data >
212 struct DUNE_PRIVATE Storage
216 typedef typename std::conditional<dim == 2,
217 ALU3DSPACE GatherScatterNoData< Grid, CommDataHandleIF, 2 >,
218 ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, 2 >
222 :
Base::Storage( grid, grid.maxLevel() ),
223 vertexGatherScatter_( grid, vertex, vertex.impl(), dataHandle ),
224 edgeGatherScatter_( grid, edge, edge.impl(), dataHandle ),
225 faceGatherScatter_( grid, face, face.impl(), dataHandle ),
226 elementGatherScatter_( grid, element, element.impl(), dataHandle )
235 using Base::Storage::vertex;
236 using Base::Storage::edge;
237 using Base::Storage::face;
238 using Base::Storage::element;
247 template<
class DataHandle,
class Data >
249 InterfaceType iftype, CommunicationDirection dir )
250 :
Base( grid, new Storage< DataHandle, Data >( grid, data ), iftype, dir )
254 :
Base( static_cast<
Base && >( other ) )
259 static_cast< Base &
>( *this ) =
static_cast< Base &&
>( other );
269 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
280 template<
class DataHandle,
class Data >
281 struct DUNE_PRIVATE Storage
285 typedef typename std::conditional<dim == 2,
286 ALU3DSPACE GatherScatterNoData< Grid, CommDataHandleIF, 2 >,
287 ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, 2 >
291 :
Base::Storage( grid, level ),
292 indexSet_( grid.accessLevelIndexSet( level ) ),
293 vertexGatherScatter_( grid, vertex, vertex.impl(), dataHandle, *indexSet_, level ),
294 edgeGatherScatter_( grid, edge, edge.impl(), dataHandle, *indexSet_, level ),
295 faceGatherScatter_( grid, face, face.impl(), dataHandle, *indexSet_, level ),
296 elementGatherScatter_( grid, element, element.impl(), dataHandle, *indexSet_, level )
305 using Base::Storage::vertex;
306 using Base::Storage::edge;
307 using Base::Storage::face;
308 using Base::Storage::element;
310 std::shared_ptr< typename Grid::LevelIndexSetImp >
indexSet_;
318 template<
class DataHandle,
class Data >
320 InterfaceType iftype, CommunicationDirection dir,
int level )
321 :
Base( grid, new Storage< DataHandle, Data >( grid, level, data ), iftype, dir )
325 :
Base( static_cast<
Base && >( other ) )
330 static_cast< Base &
>( *this ) =
static_cast< Base &&
>( other );
#define ALU3DSPACE
Definition: alu3dinclude.hh:7
Definition: alu3dinclude.hh:63
Definition: communication.hh:24
Definition: communication.hh:27
Definition: communication.hh:30
[ provides Dune::Grid ]
Definition: 3d/grid.hh:429
GitterImplType & myGrid() const
Definition: grid_inline.hh:89
Definition: communication.hh:47
bool ready() const
Definition: communication.hh:50
void wait()
Definition: communication.hh:52
bool pending() const
Definition: communication.hh:55
ALU3dGrid< dim, dimworld, elType, ALUGridNoComm > Grid
Definition: communication.hh:48
Base::Grid Grid
Definition: communication.hh:70
ALULeafCommunication(const Grid &grid, CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir)
Definition: communication.hh:73
Base::Grid Grid
Definition: communication.hh:90
ALULevelCommunication(const Grid &grid, CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir, int level)
Definition: communication.hh:93
Definition: communication.hh:105
Grid::Traits::template Codim< dim >::Entity VertexObject
Definition: communication.hh:110
ALU3DSPACE GatherScatter GatherScatter
Definition: communication.hh:107
ALU3dGrid< dim, dimworld, elType, ALUGridMPIComm > Grid
Definition: communication.hh:106
Grid::Traits::template Codim< 0 >::EntityImp ElementImpl
Definition: communication.hh:118
bool pending() const
Definition: communication.hh:189
Grid::Traits::template Codim< 2 >::Entity EdgeObject
Definition: communication.hh:111
bool ready() const
Definition: communication.hh:184
Grid::Traits::template Codim< 1 >::EntityImp FaceImpl
Definition: communication.hh:117
Grid::Traits::template Codim< dim >::EntityImp VertexImpl
Definition: communication.hh:115
Grid::Traits::template Codim< 0 >::Entity ElementObject
Definition: communication.hh:113
Grid::Traits::template Codim< 2 >::EntityImp EdgeImpl
Definition: communication.hh:116
ALUCommunication(ALUCommunication &&other)
Definition: communication.hh:172
Grid::Traits::template Codim< 1 >::Entity FaceObject
Definition: communication.hh:112
ALUCommunication(const Grid &grid, Storage *storage, InterfaceType iftype, CommunicationDirection dir)
Definition: communication.hh:144
void wait()
Definition: communication.hh:186
Storage(const Grid &grid, int level)
Definition: communication.hh:122
virtual GatherScatter & edgeGatherScatter()=0
virtual GatherScatter & elementGatherScatter()=0
virtual GatherScatter & faceGatherScatter()=0
virtual GatherScatter & vertexGatherScatter()=0
virtual ~Storage()
Definition: communication.hh:129
ElementObject element
Definition: communication.hh:140
VertexObject vertex
Definition: communication.hh:137
EdgeObject edge
Definition: communication.hh:138
FaceObject face
Definition: communication.hh:139
Base::GatherScatter GatherScatter
Definition: communication.hh:208
ALULeafCommunication(ALULeafCommunication &&other)
Definition: communication.hh:253
ALULeafCommunication(const Grid &grid, CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir)
Definition: communication.hh:248
Base::Grid Grid
Definition: communication.hh:207
GatherScatter & vertexGatherScatter()
Definition: communication.hh:229
GatherScatter & edgeGatherScatter()
Definition: communication.hh:230
Storage(const Grid &grid, CommDataHandleIF &dataHandle)
Definition: communication.hh:221
ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, dim > vertexGatherScatter_
Definition: communication.hh:240
GatherScatter & faceGatherScatter()
Definition: communication.hh:231
ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, 0 > elementGatherScatter_
Definition: communication.hh:243
EdgeGatherScatterType edgeGatherScatter_
Definition: communication.hh:241
GatherScatter & elementGatherScatter()
Definition: communication.hh:232
Dune::CommDataHandleIF< DataHandle, Data > CommDataHandleIF
Definition: communication.hh:215
ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, 1 > faceGatherScatter_
Definition: communication.hh:242
std::conditional< dim==2, ALU3DSPACE GatherScatterNoData< Grid, CommDataHandleIF, 2 >, ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, 2 > >::type EdgeGatherScatterType
Definition: communication.hh:219
ALULevelCommunication(ALULevelCommunication &&other)
Definition: communication.hh:324
ALULevelCommunication(const Grid &grid, CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir, int level)
Definition: communication.hh:319
Base::GatherScatter GatherScatter
Definition: communication.hh:277
Base::Grid Grid
Definition: communication.hh:276
GatherScatter & elementGatherScatter()
Definition: communication.hh:302
std::conditional< dim==2, ALU3DSPACE GatherScatterNoData< Grid, CommDataHandleIF, 2 >, ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, 2 > >::type EdgeGatherScatterType
Definition: communication.hh:288
ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, dim > vertexGatherScatter_
Definition: communication.hh:311
ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, 0 > elementGatherScatter_
Definition: communication.hh:314
GatherScatter & faceGatherScatter()
Definition: communication.hh:301
EdgeGatherScatterType edgeGatherScatter_
Definition: communication.hh:312
GatherScatter & edgeGatherScatter()
Definition: communication.hh:300
ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, 1 > faceGatherScatter_
Definition: communication.hh:313
Dune::CommDataHandleIF< DataHandle, Data > CommDataHandleIF
Definition: communication.hh:284
std::shared_ptr< typename Grid::LevelIndexSetImp > indexSet_
Definition: communication.hh:310
Storage(const Grid &grid, int level, CommDataHandleIF &dataHandle)
Definition: communication.hh:290
GatherScatter & vertexGatherScatter()
Definition: communication.hh:299
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:43