10 #ifndef DUNE_GRIDGLUE_GRIDGLUE_HH
11 #define DUNE_GRIDGLUE_GRIDGLUE_HH
13 #include <dune/common/exceptions.hh>
14 #include <dune/common/iteratorfacades.hh>
15 #include <dune/common/shared_ptr.hh>
20 #if DUNE_VERSION_NEWER_REV(DUNE_COMMON,2,3,0)
21 #include <dune/common/parallel/mpitraits.hh>
22 #include <dune/common/parallel/mpicollectivecommunication.hh>
24 #include <dune/common/mpitraits.hh>
25 #include <dune/common/mpicollectivecommunication.hh>
27 #include <dune/common/parallel/indexset.hh>
28 #include <dune/common/parallel/plocalindex.hh>
29 #include <dune/common/parallel/remoteindices.hh>
30 #include <dune/common/parallel/communicator.hh>
31 #include <dune/common/parallel/interface.hh>
43 template<
typename P0,
typename P1>
46 template<
typename P0,
typename P1>
49 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
52 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
55 template<
typename P0,
typename P1>
58 template<
typename P0,
typename P1,
int P>
61 template<
typename P0,
typename P1>
66 typedef typename Patch::GridView::template Codim<0>::Entity
GridElement;
73 template<
typename P0,
typename P1>
78 typedef typename Patch::GridView::template Codim<0>::Entity
GridElement;
94 template<
typename P0,
typename P1>
113 typedef ::Dune::GridGlue::GlobalId
GlobalId;
116 typedef Dune::ParallelLocalIndex <Dune::PartitionType> LocalIndex;
119 typedef Dune::ParallelIndexSet <GlobalId, LocalIndex> PIndexSet;
129 typedef typename Grid0View::Grid
Grid0;
153 typedef typename Grid1View::Grid
Grid1;
181 dimworld = ((int)Grid0Patch::dimworld > (
int)Grid1Patch::dimworld) ? (
int)Grid0Patch::dimworld : (int)Grid1Patch::dimworld
188 typedef typename Grid0View::ctype
ctype;
191 typedef Dune::FieldVector<ctype, dimworld>
Coords;
194 typedef typename Grid0View::Traits::template Codim<0>::Entity
Grid0Element;
199 typedef typename Grid0View::Traits::template Codim<0>::Entity
DomainElement DUNE_DEPRECATED;
207 typedef typename Grid0View::Traits::template Codim<0>::EntityPointer
DomainElementPtr DUNE_DEPRECATED;
210 typedef typename Grid0View::Traits::template Codim<Grid0::dimension>::Entity
Grid0Vertex;
215 typedef typename Grid0View::Traits::template Codim<Grid0::dimension>::Entity
DomainVertex DUNE_DEPRECATED;
218 typedef typename Grid0View::Traits::template Codim<Grid0::dimension>::EntityPointer
Grid0VertexPtr;
223 typedef typename Grid0View::Traits::template Codim<Grid0::dimension>::EntityPointer
DomainVertexPtr DUNE_DEPRECATED;
226 typedef typename Grid1View::Traits::template Codim<0>::Entity
Grid1Element;
231 typedef typename Grid1View::Traits::template Codim<0>::Entity
TargetElement DUNE_DEPRECATED;
239 typedef typename Grid1View::Traits::template Codim<0>::EntityPointer
TargetElementPtr DUNE_DEPRECATED;
242 typedef typename Grid1View::Traits::template Codim<Grid1::dimension>::Entity
Grid1Vertex;
247 typedef typename Grid1View::Traits::template Codim<Grid1::dimension>::Entity
TargetVertex DUNE_DEPRECATED;
250 typedef typename Grid1View::Traits::template Codim<Grid1::dimension>::EntityPointer
Grid1VertexPtr;
255 typedef typename Grid1View::Traits::template Codim<Grid1::dimension>::EntityPointer
TargetVertexPtr DUNE_DEPRECATED;
259 Grid0::dimension - Grid0Patch::codim,
260 Grid1::dimension - Grid1Patch::codim,
281 const std::shared_ptr<const Grid0Patch> patch0_;
284 const std::shared_ptr<const Grid1Patch> patch1_;
287 const std::shared_ptr<Merger> merger_;
297 PIndexSet patch0_is_;
300 PIndexSet patch1_is_;
303 Dune::RemoteIndices<PIndexSet> remoteIndices_;
310 mutable std::vector<IntersectionData> intersections_;
330 void mergePatches(
const std::vector<Dune::FieldVector<ctype,dimworld> >& patch0coords,
331 const std::vector<unsigned int>& patch0entities,
332 const std::vector<Dune::GeometryType>& patch0types,
333 const int patch0rank,
334 const std::vector<Dune::FieldVector<ctype,dimworld> >& patch1coords,
335 const std::vector<unsigned int>& patch1entities,
336 const std::vector<Dune::GeometryType>& patch1types,
337 const int patch1rank);
340 template<
typename Extractor>
342 std::vector<Dune::FieldVector<ctype, dimworld> > & coords,
343 std::vector<unsigned int> & faces,
344 std::vector<Dune::GeometryType>& geometryTypes)
const;
360 GridGlue(
const Grid0Patch& gp0,
const Grid1Patch& gp1, Merger* merger);
361 GridGlue(
const std::shared_ptr<const Grid0Patch> gp0,
const std::shared_ptr<const Grid1Patch> gp1,
const std::shared_ptr<Merger> merger);
426 template<
class DataHandleImp,
class DataTypeImp>
428 Dune::InterfaceType iftype, Dune::CommunicationDirection dir)
const
431 typedef typename DataHandle::DataType DataType;
435 if (mpicomm_ != MPI_COMM_SELF)
441 Dune::dinfo <<
"GridGlue: parallel communication" << std::endl;
442 typedef Dune::EnumItem <Dune::PartitionType, Dune::InteriorEntity> InteriorFlags;
443 typedef Dune::EnumItem <Dune::PartitionType, Dune::OverlapEntity> OverlapFlags;
444 typedef Dune::EnumRange <Dune::PartitionType, Dune::InteriorEntity, Dune::GhostEntity> AllFlags;
445 Dune::Interface interface;
446 assert(remoteIndices_.isSynced());
449 case Dune::InteriorBorder_InteriorBorder_Interface :
450 interface.build (remoteIndices_, InteriorFlags(), InteriorFlags() );
452 case Dune::InteriorBorder_All_Interface :
453 if (dir == Dune::ForwardCommunication)
454 interface.build (remoteIndices_, InteriorFlags(), AllFlags() );
456 interface.build (remoteIndices_, AllFlags(), InteriorFlags() );
458 case Dune::Overlap_OverlapFront_Interface :
459 interface.build (remoteIndices_, OverlapFlags(), OverlapFlags() );
461 case Dune::Overlap_All_Interface :
462 if (dir == Dune::ForwardCommunication)
463 interface.build (remoteIndices_, OverlapFlags(), AllFlags() );
465 interface.build (remoteIndices_, AllFlags(), OverlapFlags() );
467 case Dune::All_All_Interface :
468 interface.build (remoteIndices_, AllFlags(), AllFlags() );
471 DUNE_THROW(Dune::NotImplemented,
"GridGlue::communicate for interface " << iftype <<
" not implemented");
479 commInfo.
data = &data;
482 Dune::BufferedCommunicator bComm ;
483 bComm.template build< CommInfo >(commInfo, commInfo, interface);
487 if (dir == Dune::ForwardCommunication)
498 Dune::dinfo <<
"GridGlue: sequential fallback communication" << std::endl;
501 int ssz =
size() * 10;
502 int rsz =
size() * 10;
505 DataType* sendbuffer =
new DataType[ssz];
506 DataType* receivebuffer =
new DataType[rsz];
509 Grid0IntersectionIterator rit = ibegin<0>();
510 Grid0IntersectionIterator ritend = iend<0>();
514 for (; rit != ritend; ++rit)
519 if (dir == Dune::ForwardCommunication)
526 data.
gather(gatherbuffer, rit->inside(), *rit);
536 data.
gather(gatherbuffer, rit->outside(), rit->flip());
542 for (
int i=0; i<ssz; i++)
543 receivebuffer[i] = sendbuffer[i];
547 for (rit = ibegin<0>(); rit != ritend; ++rit)
552 if (dir == Dune::ForwardCommunication)
558 data.
scatter(scatterbuffer, rit->outside(), rit->flip(),
567 data.
scatter(scatterbuffer, rit->inside(), *rit,
574 delete[] receivebuffer;
588 size_t indexSet_size()
const
618 #endif // DUNE_GRIDGLUE_GRIDGLUE_HH
The intersection of two entities of the two patches of a GridGlue.
Definition: gridglue.hh:50
Grid1View::Traits::template Codim< 0 >::Entity Grid1Element
The type of the Grid1 elements.
Definition: gridglue.hh:226
Grid1View::Traits::template Codim< 0 >::EntityPointer Grid1ElementPtr
Pointer type to Grid1 elements.
Definition: gridglue.hh:234
Dune::CommunicationDirection dir
Definition: gridgluecommunicate.hh:285
void scatter(MessageBufferImp &buff, const EntityType &e, const RISType &i, size_t n)
Definition: gridgluecommunicate.hh:115
const GridGlue * gridglue
Definition: gridgluecommunicate.hh:278
P1::GridView Grid1View
GridView of grid 1 (aka target grid)
Definition: gridglue.hh:150
void gather(MessageBufferImp &buff, const EntityType &e, const RISType &i) const
pack data from user to message buffer
Definition: gridgluecommunicate.hh:101
describes the features of a data handle for communication in parallel runs using the GridGlue::commun...
Definition: gridgluecommunicate.hh:73
Definition: gridglue.hh:56
const GridGlueView< P0, P1, P >::Patch::GridView & gridView() const
getter for the GridView of patch P
Definition: gridglue.hh:377
Definition: gridglue.hh:33
P1 Grid1Patch
Coupling patch of grid 1.
Definition: gridglue.hh:161
Dimension of the grid 0 extractor.
Definition: gridglue.hh:142
Definition: gridgluecommunicate.hh:138
P0 Patch
Definition: gridglue.hh:64
Dune::GridGlue::Merger< ctype, Grid0::dimension-Grid0Patch::codim, Grid1::dimension-Grid1Patch::codim, dimworld > Merger
Instance of a Merger.
Definition: gridglue.hh:261
Dune::GridGlue::IntersectionIterator< P0, P1, 1, 0 > Grid1IntersectionIterator
Definition: gridglue.hh:274
Dune::GridGlue::IntersectionIterator< P0, P1, 1, 0 > IntersectionIterator
Definition: gridglue.hh:77
Dune::GridGlue::IntersectionIndexSet< P0, P1 > IndexSet
Type of remote intersection indexSet.
Definition: gridglue.hh:267
static const P0 & patch(const GridGlue< P0, P1 > &g)
Definition: gridglue.hh:67
Implement iterators over GridGlue intersections.
const GridGlueView< P0, P1, P >::Patch & patch() const
Definition: gridglue.hh:367
void communicate(Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > &data, Dune::InterfaceType iftype, Dune::CommunicationDirection dir) const
Communicate information on the MergedGrid of a GridGlue.
Definition: gridglue.hh:427
Grid0View::ctype ctype
The type used for coordinates.
Definition: gridglue.hh:188
Model of the Intersection concept provided by GridGlue.
forward gather scatter to user defined CommInfo class
Definition: gridgluecommunicate.hh:190
Grid0View::Traits::template Codim< 0 >::EntityPointer DomainElementPtr
Pointer type to Grid0 elements.
Definition: gridglue.hh:207
Definition: gridglue.hh:173
Definition: gridglue.hh:38
void build()
Definition: gridglue.cc:183
World dimension of the grid 1 extractor.
Definition: gridglue.hh:172
::Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > * data
Definition: gridgluecommunicate.hh:279
size_t size(RISType &i) const
Definition: gridgluecommunicate.hh:89
Grid0View::Grid Grid0
Grid 0 type.
Definition: gridglue.hh:129
World dimension of the grid 0 extractor.
Definition: gridglue.hh:145
storage class for Dune::GridGlue::Intersection related data
Definition: gridglue.hh:47
P0 Grid0Patch
Coupling patch of grid 0.
Definition: gridglue.hh:137
Grid0View::Traits::template Codim< 0 >::EntityPointer Grid0ElementPtr
Pointer type to Grid0 elements.
Definition: gridglue.hh:202
Patch::GridView::template Codim< 0 >::Entity GridElement
Definition: gridglue.hh:78
Dimension of the grid 1 extractor.
Definition: gridglue.hh:169
Provides codimension-independent methods for grid extraction.
Definition: extractor.hh:47
Grid0View::Traits::template Codim< Grid0::dimension >::Entity Grid0Vertex
The type of the Grid0 vertices.
Definition: gridglue.hh:210
void mergePatches(const std::vector< Dune::FieldVector< ctype, dimworld > > &patch0coords, const std::vector< unsigned int > &patch0entities, const std::vector< Dune::GeometryType > &patch0types, const int patch0rank, const std::vector< Dune::FieldVector< ctype, dimworld > > &patch1coords, const std::vector< unsigned int > &patch1entities, const std::vector< Dune::GeometryType > &patch1types, const int patch1rank)
after building the merged grid the intersection can be updated through this method (for internal use)...
Definition: gridglue.cc:449
Grid1View::Grid Grid1
Grid 1 type.
Definition: gridglue.hh:153
Grid1View::Traits::template Codim< Grid1::dimension >::Entity TargetVertex
The type of the Grid1 vertices.
Definition: gridglue.hh:247
GridOrdering
Definition: gridglue.hh:37
export the world dimension : maximum of the two extractor world dimensions
Definition: gridglue.hh:181
Grid1View::Traits::template Codim< Grid1::dimension >::Entity Grid1Vertex
The type of the Grid1 vertices.
Definition: gridglue.hh:242
Definition: gridglue.hh:146
Grid0View::Traits::template Codim< Grid0::dimension >::EntityPointer DomainVertexPtr
Pointer type to Grid0 vertices.
Definition: gridglue.hh:223
P1 Patch
Definition: gridglue.hh:76
sequential adapter to couple two grids at specified close together boundaries
Definition: gridglue.hh:44
static const P1 & patch(const GridGlue< P0, P1 > &g)
Definition: gridglue.hh:79
void extractGrid(const Extractor &extractor, std::vector< Dune::FieldVector< ctype, dimworld > > &coords, std::vector< unsigned int > &faces, std::vector< Dune::GeometryType > &geometryTypes) const
Definition: gridglue.cc:544
Grid0View::Traits::template Codim< Grid0::dimension >::Entity DomainVertex
The type of the Grid0 vertices.
Definition: gridglue.hh:215
Definition: gridglue.hh:39
GridGlueView< P0, P1, I >::IntersectionIterator iend() const
gets the (general) end-iterator for grid glue iterations
Definition: gridglue.hh:409
Dune::GridGlue::Intersection< P0, P1, 0, 1 > Intersection
Type of remote intersection objects.
Definition: gridglue.hh:264
Grid1View::Traits::template Codim< 0 >::EntityPointer TargetElementPtr
Pointer type to Grid1 elements.
Definition: gridglue.hh:239
Grid0View::Traits::template Codim< 0 >::Entity DomainElement
The type of the Grid0 elements.
Definition: gridglue.hh:199
Patch::GridView::template Codim< 0 >::Entity GridElement
Definition: gridglue.hh:66
Grid1View::Traits::template Codim< Grid1::dimension >::EntityPointer TargetVertexPtr
Pointer type to Grid1 vertices.
Definition: gridglue.hh:255
Grid0 DomainGridType
Grid 0 type.
Definition: gridglue.hh:134
Grid1View::Traits::template Codim< 0 >::Entity TargetElement
The type of the Grid1 elements.
Definition: gridglue.hh:231
Grid1 TargetGridType
Grid 1 type.
Definition: gridglue.hh:158
IndexSet indexSet() const
Definition: gridglue.hh:581
size_t size() const
Definition: gridglue.hh:600
unsigned int IndexType
Definition: gridglue.hh:164
Definition: gridglue.hh:143
Definition: gridglue.hh:53
Grid0View::Traits::template Codim< Grid0::dimension >::EntityPointer Grid0VertexPtr
Pointer type to Grid0 vertices.
Definition: gridglue.hh:218
Grid0View::Traits::template Codim< 0 >::Entity Grid0Element
The type of the Grid0 elements.
Definition: gridglue.hh:194
Describes the parallel communication interface class for Dune::GridGlue.
Dune::GridGlue::IntersectionIterator< P0, P1, 0, 1 > IntersectionIterator
Definition: gridglue.hh:65
Definition: gridglue.hh:170
Definition: gridgluecommunicate.hh:22
P0::GridView Grid0View
GridView of grid 0 (aka domain grid)
Definition: gridglue.hh:126
collects all GridGlue data requried for communication
Definition: gridgluecommunicate.hh:268
GridGlueView< P0, P1, I >::IntersectionIterator ibegin() const
gets an iterator over all remote intersections in the merged grid between grid0 and grid1 ...
Definition: gridglue.hh:396
Dune::GridGlue::IntersectionIterator< P0, P1, 0, 1 > Grid0IntersectionIterator
Type of the iterator that iterates over remove intersections.
Definition: gridglue.hh:272
Grid1View::Traits::template Codim< Grid1::dimension >::EntityPointer Grid1VertexPtr
Pointer type to Grid1 vertices.
Definition: gridglue.hh:250
Dune::FieldVector< ctype, dimworld > Coords
The type used for coordinate vectors.
Definition: gridglue.hh:191
Intersection getIntersection(int i) const
Definition: gridglue.hh:595
Definition: gridglue.hh:59
Abstract base for all classes that take extracted grids and build sets of intersections.
Definition: merger.hh:16
GridGlue(const Grid0Patch &gp0, const Grid1Patch &gp1, Merger *merger)
constructor
Definition: gridglue.cc:161