10 #ifndef DUNE_GRIDGLUE_GRIDGLUE_HH
11 #define DUNE_GRIDGLUE_GRIDGLUE_HH
13 #include <dune/common/array.hh>
14 #include <dune/common/exceptions.hh>
15 #include <dune/common/iteratorfacades.hh>
16 #include <dune/common/shared_ptr.hh>
21 #if DUNE_VERSION_NEWER_REV(DUNE_COMMON,2,3,0)
22 #include <dune/common/parallel/mpitraits.hh>
23 #include <dune/common/parallel/mpicollectivecommunication.hh>
25 #include <dune/common/mpitraits.hh>
26 #include <dune/common/mpicollectivecommunication.hh>
28 #include <dune/common/parallel/indexset.hh>
29 #include <dune/common/parallel/plocalindex.hh>
30 #include <dune/common/parallel/remoteindices.hh>
31 #include <dune/common/parallel/communicator.hh>
32 #include <dune/common/parallel/interface.hh>
44 template<
typename P0,
typename P1>
47 template<
typename P0,
typename P1>
50 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
53 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
56 template<
typename P0,
typename P1>
59 template<
typename P0,
typename P1,
int P>
62 template<
typename P0,
typename P1>
67 typedef typename Patch::GridView::template Codim<0>::Entity
GridElement;
74 template<
typename P0,
typename P1>
79 typedef typename Patch::GridView::template Codim<0>::Entity
GridElement;
95 template<
typename P0,
typename P1>
114 typedef ::Dune::GridGlue::GlobalId
GlobalId;
117 typedef Dune::ParallelLocalIndex <Dune::PartitionType> LocalIndex;
120 typedef Dune::ParallelIndexSet <GlobalId, LocalIndex> PIndexSet;
130 typedef typename Grid0View::Grid
Grid0;
154 typedef typename Grid1View::Grid
Grid1;
182 dimworld = ((int)Grid0Patch::dimworld > (
int)Grid1Patch::dimworld) ? (
int)Grid0Patch::dimworld : (int)Grid1Patch::dimworld
189 typedef typename Grid0View::ctype
ctype;
192 typedef Dune::FieldVector<ctype, dimworld>
Coords;
195 typedef typename Grid0View::Traits::template Codim<0>::Entity
Grid0Element;
200 typedef typename Grid0View::Traits::template Codim<0>::Entity
DomainElement DUNE_DEPRECATED;
208 typedef typename Grid0View::Traits::template Codim<0>::EntityPointer
DomainElementPtr DUNE_DEPRECATED;
211 typedef typename Grid0View::Traits::template Codim<Grid0::dimension>::Entity
Grid0Vertex;
216 typedef typename Grid0View::Traits::template Codim<Grid0::dimension>::Entity
DomainVertex DUNE_DEPRECATED;
219 typedef typename Grid0View::Traits::template Codim<Grid0::dimension>::EntityPointer
Grid0VertexPtr;
224 typedef typename Grid0View::Traits::template Codim<Grid0::dimension>::EntityPointer
DomainVertexPtr DUNE_DEPRECATED;
227 typedef typename Grid1View::Traits::template Codim<0>::Entity
Grid1Element;
232 typedef typename Grid1View::Traits::template Codim<0>::Entity
TargetElement DUNE_DEPRECATED;
240 typedef typename Grid1View::Traits::template Codim<0>::EntityPointer
TargetElementPtr DUNE_DEPRECATED;
243 typedef typename Grid1View::Traits::template Codim<Grid1::dimension>::Entity
Grid1Vertex;
248 typedef typename Grid1View::Traits::template Codim<Grid1::dimension>::Entity
TargetVertex DUNE_DEPRECATED;
251 typedef typename Grid1View::Traits::template Codim<Grid1::dimension>::EntityPointer
Grid1VertexPtr;
256 typedef typename Grid1View::Traits::template Codim<Grid1::dimension>::EntityPointer
TargetVertexPtr DUNE_DEPRECATED;
259 typedef ::Merger<
ctype,
260 Grid0::dimension - Grid0Patch::codim,
261 Grid1::dimension - Grid1Patch::codim,
282 const std::shared_ptr<const Grid0Patch> patch0_;
285 const std::shared_ptr<const Grid1Patch> patch1_;
288 const std::shared_ptr<Merger> merger_;
298 PIndexSet patch0_is_;
301 PIndexSet patch1_is_;
304 Dune::RemoteIndices<PIndexSet> remoteIndices_;
311 mutable std::vector<IntersectionData> intersections_;
331 void mergePatches(
const std::vector<Dune::FieldVector<ctype,dimworld> >& patch0coords,
332 const std::vector<unsigned int>& patch0entities,
333 const std::vector<Dune::GeometryType>& patch0types,
334 const int patch0rank,
335 const std::vector<Dune::FieldVector<ctype,dimworld> >& patch1coords,
336 const std::vector<unsigned int>& patch1entities,
337 const std::vector<Dune::GeometryType>& patch1types,
338 const int patch1rank);
341 template<
typename Extractor>
343 std::vector<Dune::FieldVector<ctype, dimworld> > & coords,
344 std::vector<unsigned int> & faces,
345 std::vector<Dune::GeometryType>& geometryTypes)
const;
361 GridGlue(
const Grid0Patch& gp0,
const Grid1Patch& gp1, Merger* merger);
362 GridGlue(
const std::shared_ptr<const Grid0Patch> gp0,
const std::shared_ptr<const Grid1Patch> gp1,
const std::shared_ptr<Merger> merger);
427 template<
class DataHandleImp,
class DataTypeImp>
429 Dune::InterfaceType iftype, Dune::CommunicationDirection dir)
const
432 typedef typename DataHandle::DataType DataType;
436 if (mpicomm_ != MPI_COMM_SELF)
442 Dune::dinfo <<
"GridGlue: parallel communication" << std::endl;
443 typedef Dune::EnumItem <Dune::PartitionType, Dune::InteriorEntity> InteriorFlags;
444 typedef Dune::EnumItem <Dune::PartitionType, Dune::OverlapEntity> OverlapFlags;
445 typedef Dune::EnumRange <Dune::PartitionType, Dune::InteriorEntity, Dune::GhostEntity> AllFlags;
446 Dune::Interface interface;
447 assert(remoteIndices_.isSynced());
450 case Dune::InteriorBorder_InteriorBorder_Interface :
451 interface.build (remoteIndices_, InteriorFlags(), InteriorFlags() );
453 case Dune::InteriorBorder_All_Interface :
454 if (dir == Dune::ForwardCommunication)
455 interface.build (remoteIndices_, InteriorFlags(), AllFlags() );
457 interface.build (remoteIndices_, AllFlags(), InteriorFlags() );
459 case Dune::Overlap_OverlapFront_Interface :
460 interface.build (remoteIndices_, OverlapFlags(), OverlapFlags() );
462 case Dune::Overlap_All_Interface :
463 if (dir == Dune::ForwardCommunication)
464 interface.build (remoteIndices_, OverlapFlags(), AllFlags() );
466 interface.build (remoteIndices_, AllFlags(), OverlapFlags() );
468 case Dune::All_All_Interface :
469 interface.build (remoteIndices_, AllFlags(), AllFlags() );
472 DUNE_THROW(Dune::NotImplemented,
"GridGlue::communicate for interface " << iftype <<
" not implemented");
480 commInfo.
data = &data;
483 Dune::BufferedCommunicator bComm ;
484 bComm.template build< CommInfo >(commInfo, commInfo, interface);
488 if (dir == Dune::ForwardCommunication)
499 Dune::dinfo <<
"GridGlue: sequential fallback communication" << std::endl;
502 int ssz =
size() * 10;
503 int rsz =
size() * 10;
506 DataType* sendbuffer =
new DataType[ssz];
507 DataType* receivebuffer =
new DataType[rsz];
510 Grid0IntersectionIterator rit = ibegin<0>();
511 Grid0IntersectionIterator ritend = iend<0>();
515 for (; rit != ritend; ++rit)
520 if (dir == Dune::ForwardCommunication)
527 data.
gather(gatherbuffer, rit->inside(), *rit);
537 data.
gather(gatherbuffer, rit->outside(), rit->flip());
543 for (
int i=0; i<ssz; i++)
544 receivebuffer[i] = sendbuffer[i];
548 for (rit = ibegin<0>(); rit != ritend; ++rit)
553 if (dir == Dune::ForwardCommunication)
559 data.
scatter(scatterbuffer, rit->outside(), rit->flip(),
568 data.
scatter(scatterbuffer, rit->inside(), *rit,
575 delete[] receivebuffer;
589 size_t indexSet_size()
const
617 #endif // DUNE_GRIDGLUE_GRIDGLUE_HH
Patch::GridView::template Codim< 0 >::Entity GridElement
Definition: gridglue.hh:79
Dune::GridGlue::IntersectionIterator< P0, P1, 1, 0 > IntersectionIterator
Definition: gridglue.hh:78
Grid0View::Traits::template Codim< 0 >::Entity Grid0Element
The type of the Grid0 elements.
Definition: gridglue.hh:195
Dune::CommunicationDirection dir
Definition: gridgluecommunicate.hh:285
Dune::GridGlue::IntersectionIterator< P0, P1, 1, 0 > Grid1IntersectionIterator
Definition: gridglue.hh:275
static const P0 & patch(const GridGlue< P0, P1 > &g)
Definition: gridglue.hh:68
void scatter(MessageBufferImp &buff, const EntityType &e, const RISType &i, size_t n)
Definition: gridgluecommunicate.hh:115
P0::GridView Grid0View
GridView of grid 0 (aka domain grid)
Definition: gridglue.hh:127
storage class for Dune::GridGlue::Intersection related data
Definition: gridglue.hh:48
const GridGlue * gridglue
Definition: gridgluecommunicate.hh:278
GridOrdering
Definition: gridglue.hh:38
Dune::GridGlue::IntersectionIndexSet< P0, P1 > IndexSet
Type of remote intersection indexSet.
Definition: gridglue.hh:268
Dimension of the grid 0 extractor.
Definition: gridglue.hh:143
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:397
void gather(MessageBufferImp &buff, const EntityType &e, const RISType &i) const
pack data from user to message buffer
Definition: gridgluecommunicate.hh:101
const GridGlueView< P0, P1, P >::Patch & patch() const
Definition: gridglue.hh:368
P1 Patch
Definition: gridglue.hh:77
describes the features of a data handle for communication in parallel runs using the GridGlue::commun...
Definition: gridgluecommunicate.hh:73
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:428
Grid1View::Traits::template Codim< Grid1::dimension >::EntityPointer Grid1VertexPtr
Pointer type to Grid1 vertices.
Definition: gridglue.hh:251
Dune::FieldVector< ctype, dimworld > Coords
The type used for coordinate vectors.
Definition: gridglue.hh:192
Intersection getIntersection(int i) const
Definition: gridglue.hh:596
void build()
Definition: gridglue.cc:183
Grid0View::Grid Grid0
Grid 0 type.
Definition: gridglue.hh:130
Grid1View::Traits::template Codim< 0 >::Entity Grid1Element
The type of the Grid1 elements.
Definition: gridglue.hh:227
Model of the Intersection concept provided by GridGlue.
P0 Grid0Patch
Coupling patch of grid 0.
Definition: gridglue.hh:138
Grid0View::Traits::template Codim< 0 >::EntityPointer Grid0ElementPtr
Pointer type to Grid0 elements.
Definition: gridglue.hh:203
Definition: gridglue.hh:34
P0 Patch
Definition: gridglue.hh:65
P1::GridView Grid1View
GridView of grid 1 (aka target grid)
Definition: gridglue.hh:151
World dimension of the grid 1 extractor.
Definition: gridglue.hh:173
Definition: gridgluecommunicate.hh:22
static const P1 & patch(const GridGlue< P0, P1 > &g)
Definition: gridglue.hh:80
World dimension of the grid 0 extractor.
Definition: gridglue.hh:146
const GridGlueView< P0, P1, P >::Patch::GridView & gridView() const
getter for the GridView of patch P
Definition: gridglue.hh:378
forward gather scatter to user defined CommInfo class
Definition: gridgluecommunicate.hh:190
Grid0View::Traits::template Codim< Grid0::dimension >::EntityPointer DomainVertexPtr
Pointer type to Grid0 vertices.
Definition: gridglue.hh:224
Dimension of the grid 1 extractor.
Definition: gridglue.hh:170
::Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > * data
Definition: gridgluecommunicate.hh:279
size_t size(RISType &i) const
Definition: gridgluecommunicate.hh:89
Grid0View::Traits::template Codim< Grid0::dimension >::Entity DomainVertex
The type of the Grid0 vertices.
Definition: gridglue.hh:216
GridGlueView< P0, P1, I >::IntersectionIterator iend() const
gets the (general) end-iterator for grid glue iterations
Definition: gridglue.hh:410
Definition: gridgluecommunicate.hh:138
Dune::GridGlue::Intersection< P0, P1, 0, 1 > Intersection
Type of remote intersection objects.
Definition: gridglue.hh:265
Definition: gridglue.hh:174
Grid1View::Traits::template Codim< 0 >::EntityPointer TargetElementPtr
Pointer type to Grid1 elements.
Definition: gridglue.hh:240
Grid0View::ctype ctype
The type used for coordinates.
Definition: gridglue.hh:189
::Merger< ctype, Grid0::dimension-Grid0Patch::codim, Grid1::dimension-Grid1Patch::codim, dimworld > Merger
Instance of a Merger.
Definition: gridglue.hh:262
Grid1View::Traits::template Codim< Grid1::dimension >::EntityPointer TargetVertexPtr
Pointer type to Grid1 vertices.
Definition: gridglue.hh:256
Grid1 TargetGridType
Grid 1 type.
Definition: gridglue.hh:159
IndexSet indexSet() const
Definition: gridglue.hh:582
Implement iterators over GridGlue intersections.
Grid0View::Traits::template Codim< 0 >::EntityPointer DomainElementPtr
Pointer type to Grid0 elements.
Definition: gridglue.hh:208
Definition: gridglue.hh:54
Definition: gridglue.hh:60
Definition: gridglue.hh:39
export the world dimension : maximum of the two extractor world dimensions
Definition: gridglue.hh:182
Definition: gridglue.hh:147
Definition: gridglue.hh:40
The intersection of two entities of the two patches of a GridGlue.
Definition: gridglue.hh:51
Grid0View::Traits::template Codim< Grid0::dimension >::Entity Grid0Vertex
The type of the Grid0 vertices.
Definition: gridglue.hh:211
Dune::GridGlue::IntersectionIterator< P0, P1, 0, 1 > IntersectionIterator
Definition: gridglue.hh:66
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:154
Grid0View::Traits::template Codim< Grid0::dimension >::EntityPointer Grid0VertexPtr
Pointer type to Grid0 vertices.
Definition: gridglue.hh:219
Definition: gridglue.hh:144
Grid1View::Traits::template Codim< Grid1::dimension >::Entity TargetVertex
The type of the Grid1 vertices.
Definition: gridglue.hh:248
Grid1View::Traits::template Codim< Grid1::dimension >::Entity Grid1Vertex
The type of the Grid1 vertices.
Definition: gridglue.hh:243
Patch::GridView::template Codim< 0 >::Entity GridElement
Definition: gridglue.hh:67
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:536
Dune::GridGlue::IntersectionIterator< P0, P1, 0, 1 > Grid0IntersectionIterator
Type of the iterator that iterates over remove intersections.
Definition: gridglue.hh:273
Definition: gridglue.hh:57
GridGlue(const Grid0Patch &gp0, const Grid1Patch &gp1, Merger *merger)
constructor
Definition: gridglue.cc:161
Describes the parallel communication interface class for Dune::GridGlue.
Grid0View::Traits::template Codim< 0 >::Entity DomainElement
The type of the Grid0 elements.
Definition: gridglue.hh:200
Grid0 DomainGridType
Grid 0 type.
Definition: gridglue.hh:135
Grid1View::Traits::template Codim< 0 >::Entity TargetElement
The type of the Grid1 elements.
Definition: gridglue.hh:232
Grid1View::Traits::template Codim< 0 >::EntityPointer Grid1ElementPtr
Pointer type to Grid1 elements.
Definition: gridglue.hh:235
size_t size() const
Definition: gridglue.hh:601
Provides codimension-independent methods for grid extraction.
Definition: extractor.hh:48
unsigned int IndexType
Definition: gridglue.hh:165
collects all GridGlue data requried for communication
Definition: gridgluecommunicate.hh:268
sequential adapter to couple two grids at specified close together boundaries
Definition: gridglue.hh:45
Definition: gridglue.hh:171
P1 Grid1Patch
Coupling patch of grid 1.
Definition: gridglue.hh:162