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 );
331 #endif // #ifndef DUNE_ALUGRID_3D_COMMUNICATION_HH