1 #ifndef DUNE_ALUGRID_3D_COMMUNICATION_HH
2 #define DUNE_ALUGRID_3D_COMMUNICATION_HH
12 #include <dune/grid/common/gridenums.hh>
14 #include <dune/alugrid/3d/alu3dinclude.hh>
15 #include <dune/alugrid/3d/datahandle.hh>
23 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
24 struct ALUCommunication;
26 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
27 class ALULeafCommunication;
29 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
30 class ALULevelCommunication;
37 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
45 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
46 struct ALUCommunication< dim, dimworld, elType, ALUGridNoComm >
48 typedef ALU3dGrid< dim, dimworld, elType, ALUGridNoComm > Grid;
50 bool ready()
const {
return true; }
55 bool pending ()
const {
return ! ready(); }
63 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
64 class ALULeafCommunication< dim, dimworld, elType, ALUGridNoComm >
65 :
public ALUCommunication< dim, dimworld, elType, ALUGridNoComm >
67 typedef ALUCommunication< dim, dimworld, elType, ALUGridNoComm > Base;
70 typedef typename Base::Grid Grid;
72 template<
class DataHandle,
class Data >
73 ALULeafCommunication (
const Grid &grid, CommDataHandleIF< DataHandle, Data > &data,
83 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
84 class ALULevelCommunication< dim, dimworld, elType, ALUGridNoComm >
85 :
public ALUCommunication< dim, dimworld, elType, ALUGridNoComm >
87 typedef ALUCommunication< dim, dimworld, elType, ALUGridNoComm > Base;
90 typedef typename Base::Grid Grid;
92 template<
class DataHandle,
class Data >
93 ALULevelCommunication (
const Grid &grid, CommDataHandleIF< DataHandle, Data > &data,
103 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
104 struct ALUCommunication< dim, dimworld, elType, ALUGridMPIComm >
106 typedef ALU3dGrid< dim, dimworld, elType, ALUGridMPIComm > Grid;
107 typedef ALU3DSPACE GatherScatter GatherScatter;
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;
113 typedef typename Grid::Traits::template Codim< 0 >::Entity ElementObject;
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;
122 Storage (
const Grid &grid,
int level )
126 element( ElementImpl() )
129 virtual ~Storage () {}
131 virtual GatherScatter &vertexGatherScatter () = 0;
132 virtual GatherScatter &edgeGatherScatter () = 0;
133 virtual GatherScatter &faceGatherScatter () = 0;
134 virtual GatherScatter &elementGatherScatter () = 0;
140 ElementObject element;
145 : storage_( storage )
150 dverb <<
"ALUGrid contains no overlap, therefore no communication for" << std::endl;
151 dverb <<
"Overlap_OverlapFront_Interface or Overlap_All_Interface interfaces!" << std::endl;
155 grid.myGrid().borderBorderCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
160 communication_ = grid.myGrid().interiorGhostCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
163 communication_ = grid.myGrid().ghostInteriorCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
167 communication_ = grid.myGrid().allAllCommunication( storage_->vertexGatherScatter(), storage_->edgeGatherScatter(), storage_->faceGatherScatter(), storage_->elementGatherScatter() );
169 DUNE_THROW( GridError,
"Wrong parameters in ALUCommunication." );
172 ALUCommunication ( ALUCommunication &&other )
173 : storage_( std::move( other.storage_ ) ),
174 communication_( std::move( other.communication_ ) )
177 ALUCommunication &operator= ( ALUCommunication &&other )
179 storage_ = std::move( other.storage_ );
180 communication_ = std::move( other.communication_ );
184 bool ready ()
const {
return communication_.ready(); }
186 void wait () { communication_.wait(); }
189 bool pending ()
const {
return ! ready(); }
191 std::unique_ptr< Storage > storage_;
192 ALU3DSPACE GitterDunePll::Communication communication_;
200 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
201 class ALULeafCommunication< dim, dimworld, elType, ALUGridMPIComm >
202 :
public ALUCommunication< dim, dimworld, elType, ALUGridMPIComm >
204 typedef ALUCommunication< dim, dimworld, elType, ALUGridMPIComm > Base;
207 typedef typename Base::Grid Grid;
208 typedef typename Base::GatherScatter GatherScatter;
211 template<
class DataHandle,
class Data >
216 typedef typename std::conditional<dim == 2,
217 ALU3DSPACE GatherScatterNoData< Grid, CommDataHandleIF, 2 >,
218 ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, 2 >
219 >::type EdgeGatherScatterType;
221 Storage (
const Grid &grid, CommDataHandleIF &dataHandle )
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 )
229 GatherScatter &vertexGatherScatter () {
return vertexGatherScatter_; }
230 GatherScatter &edgeGatherScatter () {
return edgeGatherScatter_; }
231 GatherScatter &faceGatherScatter () {
return faceGatherScatter_; }
232 GatherScatter &elementGatherScatter () {
return elementGatherScatter_; }
236 using Base::Storage::edge;
237 using Base::Storage::face;
238 using Base::Storage::element;
240 ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, dim > vertexGatherScatter_;
241 EdgeGatherScatterType edgeGatherScatter_;
242 ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, 1 > faceGatherScatter_;
243 ALU3DSPACE GatherScatterLeafData< Grid, CommDataHandleIF, 0 > elementGatherScatter_;
247 template<
class DataHandle,
class Data >
248 ALULeafCommunication (
const Grid &grid, CommDataHandleIF< DataHandle, Data > &data,
250 : Base( grid, new Storage< DataHandle, Data >( grid, data ), iftype, dir )
253 ALULeafCommunication ( ALULeafCommunication &&other )
254 : Base( static_cast< Base && >( other ) )
257 ALULeafCommunication &operator= ( ALULeafCommunication &&other )
259 static_cast< Base &
>( *this ) =
static_cast< Base &&
>( other );
269 template<
int dim,
int dimworld, ALU3dGr
idElementType elType >
270 class ALULevelCommunication< dim, dimworld, elType, ALUGridMPIComm >
271 :
public ALUCommunication< dim, dimworld, elType, ALUGridMPIComm >
273 typedef ALUCommunication< dim, dimworld, elType, ALUGridMPIComm > Base;
276 typedef typename Base::Grid Grid;
277 typedef typename Base::GatherScatter GatherScatter;
280 template<
class DataHandle,
class Data >
285 typedef typename std::conditional<dim == 2,
286 ALU3DSPACE GatherScatterNoData< Grid, CommDataHandleIF, 2 >,
287 ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, 2 >
288 >::type EdgeGatherScatterType;
290 Storage (
const Grid &grid,
int level, CommDataHandleIF &dataHandle )
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 )
299 GatherScatter &vertexGatherScatter () {
return vertexGatherScatter_; }
300 GatherScatter &edgeGatherScatter () {
return edgeGatherScatter_; }
301 GatherScatter &faceGatherScatter () {
return faceGatherScatter_; }
302 GatherScatter &elementGatherScatter () {
return elementGatherScatter_; }
306 using Base::Storage::edge;
307 using Base::Storage::face;
308 using Base::Storage::element;
310 std::shared_ptr< typename Grid::LevelIndexSetImp > indexSet_;
311 ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, dim > vertexGatherScatter_;
312 EdgeGatherScatterType edgeGatherScatter_;
313 ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, 1 > faceGatherScatter_;
314 ALU3DSPACE GatherScatterLevelData< Grid, CommDataHandleIF, 0 > elementGatherScatter_;
318 template<
class DataHandle,
class Data >
319 ALULevelCommunication (
const Grid &grid, CommDataHandleIF< DataHandle, Data > &data,
321 : Base( grid, new Storage< DataHandle, Data >( grid, level, data ), iftype, dir )
324 ALULevelCommunication ( ALULevelCommunication &&other )
325 : Base( static_cast< Base && >( other ) )
328 ALULevelCommunication &operator= ( ALULevelCommunication &&other )
330 static_cast< Base &
>( *this ) =
static_cast< Base &&
>( other );
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:78
Describes the parallel communication interface class for MessageBuffers and DataHandles.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:506
DVerbType dverb(std::cout)
Singleton of verbose debug stream.
Definition: stdstreams.hh:116
Dune namespace.
Definition: alignedallocator.hh:13
Standard Dune debug streams.
Definition of macros controlling symbol visibility at the ABI level.
#define DUNE_PRIVATE
Mark a symbol as being for internal use within the current DSO only.
Definition: visibility.hh:28