10 #ifndef DUNE_GRIDGLUE_GRIDGLUE_HH 11 #define DUNE_GRIDGLUE_GRIDGLUE_HH 13 #include <dune/common/deprecated.hh> 14 #include <dune/common/exceptions.hh> 15 #include <dune/common/iteratorfacades.hh> 16 #include <dune/common/promotiontraits.hh> 17 #include <dune/common/shared_ptr.hh> 18 #include <dune/common/stdstreams.hh> 23 #include <dune/common/parallel/mpitraits.hh> 24 #include <dune/common/parallel/mpicollectivecommunication.hh> 25 #include <dune/common/parallel/indexset.hh> 26 #include <dune/common/parallel/plocalindex.hh> 27 #include <dune/common/parallel/remoteindices.hh> 28 #include <dune/common/parallel/communicator.hh> 29 #include <dune/common/parallel/interface.hh> 41 template<
typename P0,
typename P1>
44 template<
typename P0,
typename P1>
47 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
50 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
53 template<
typename P0,
typename P1>
56 template<
typename P0,
typename P1,
int P>
59 template<
typename P0,
typename P1>
64 typedef typename Patch::GridView::template Codim<0>::Entity
GridElement;
71 template<
typename P0,
typename P1>
76 typedef typename Patch::GridView::template Codim<0>::Entity
GridElement;
92 template<
typename P0,
typename P1>
111 typedef ::Dune::GridGlue::GlobalId
GlobalId;
114 typedef Dune::ParallelLocalIndex <Dune::PartitionType> LocalIndex;
117 typedef Dune::ParallelIndexSet <GlobalId, LocalIndex> PIndexSet;
127 typedef typename Grid0View::Grid
Grid0;
135 grid0dim = Grid0Patch::dim,
136 domdim = Grid0Patch::dim,
138 grid0dimworld = Grid0Patch::dimworld,
139 domdimworld = Grid0Patch::dimworld
146 typedef typename Grid1View::Grid
Grid1;
157 tardim = Grid1Patch::dim,
158 grid1dim = Grid1Patch::dim,
160 tardimworld = Grid1Patch::dimworld,
161 grid1dimworld = Grid1Patch::dimworld
169 dimworld = ((int)Grid0Patch::dimworld > (
int)Grid1Patch::dimworld) ? (
int)Grid0Patch::dimworld : (int)Grid1Patch::dimworld
175 typedef typename PromotionTraits<
typename Grid0View::ctype,
176 typename Grid1View::ctype>::PromotedType
ctype;
179 typedef Dune::FieldVector<ctype, dimworld>
Coords;
182 typedef typename Grid0View::Traits::template Codim<0>::Entity
Grid0Element;
185 typedef typename Grid0View::Traits::template Codim<Grid0::dimension>::Entity
Grid0Vertex;
188 typedef typename Grid1View::Traits::template Codim<0>::Entity
Grid1Element;
191 typedef typename Grid1View::Traits::template Codim<Grid1::dimension>::Entity
Grid1Vertex;
195 Grid0::dimension - Grid0Patch::codim,
196 Grid1::dimension - Grid1Patch::codim,
217 const std::shared_ptr<const Grid0Patch> patch0_;
220 const std::shared_ptr<const Grid1Patch> patch1_;
223 const std::shared_ptr<Merger> merger_;
233 PIndexSet patch0_is_;
236 PIndexSet patch1_is_;
239 Dune::RemoteIndices<PIndexSet> remoteIndices_;
246 mutable std::vector<IntersectionData> intersections_;
266 void mergePatches(
const std::vector<Dune::FieldVector<ctype,dimworld> >& patch0coords,
267 const std::vector<unsigned int>& patch0entities,
268 const std::vector<Dune::GeometryType>& patch0types,
269 const int patch0rank,
270 const std::vector<Dune::FieldVector<ctype,dimworld> >& patch1coords,
271 const std::vector<unsigned int>& patch1entities,
272 const std::vector<Dune::GeometryType>& patch1types,
273 const int patch1rank);
276 template<
typename Extractor>
277 void extractGrid (
const Extractor & extractor,
278 std::vector<Dune::FieldVector<ctype, dimworld> > & coords,
279 std::vector<unsigned int> & faces,
280 std::vector<Dune::GeometryType>& geometryTypes)
const;
296 DUNE_DEPRECATED_MSG(
"Please use a std::shared_ptr for patches and merger")
297 GridGlue(const Grid0Patch& gp0, const Grid1Patch& gp1, Merger* merger);
309 GridGlue(const
std::shared_ptr<const Grid0Patch> gp0, const
std::shared_ptr<const Grid1Patch> gp1, const
std::shared_ptr<Merger> merger);
374 template<
class DataHandleImp,
class DataTypeImp>
376 Dune::InterfaceType iftype, Dune::CommunicationDirection dir)
const 379 typedef typename DataHandle::DataType DataType;
383 if (mpicomm_ != MPI_COMM_SELF)
389 Dune::dinfo <<
"GridGlue: parallel communication" << std::endl;
390 typedef Dune::EnumItem <Dune::PartitionType, Dune::InteriorEntity> InteriorFlags;
391 typedef Dune::EnumItem <Dune::PartitionType, Dune::OverlapEntity> OverlapFlags;
392 typedef Dune::EnumRange <Dune::PartitionType, Dune::InteriorEntity, Dune::GhostEntity> AllFlags;
393 Dune::Interface interface;
394 assert(remoteIndices_.isSynced());
397 case Dune::InteriorBorder_InteriorBorder_Interface :
398 interface.build (remoteIndices_, InteriorFlags(), InteriorFlags() );
400 case Dune::InteriorBorder_All_Interface :
401 if (dir == Dune::ForwardCommunication)
402 interface.build (remoteIndices_, InteriorFlags(), AllFlags() );
404 interface.build (remoteIndices_, AllFlags(), InteriorFlags() );
406 case Dune::Overlap_OverlapFront_Interface :
407 interface.build (remoteIndices_, OverlapFlags(), OverlapFlags() );
409 case Dune::Overlap_All_Interface :
410 if (dir == Dune::ForwardCommunication)
411 interface.build (remoteIndices_, OverlapFlags(), AllFlags() );
413 interface.build (remoteIndices_, AllFlags(), OverlapFlags() );
415 case Dune::All_All_Interface :
416 interface.build (remoteIndices_, AllFlags(), AllFlags() );
419 DUNE_THROW(Dune::NotImplemented,
"GridGlue::communicate for interface " << iftype <<
" not implemented");
427 commInfo.
data = &data;
430 Dune::BufferedCommunicator bComm ;
431 bComm.template build< CommInfo >(commInfo, commInfo, interface);
435 if (dir == Dune::ForwardCommunication)
446 Dune::dinfo <<
"GridGlue: sequential fallback communication" << std::endl;
449 int ssz = size() * 10;
450 int rsz = size() * 10;
453 DataType* sendbuffer =
new DataType[ssz];
454 DataType* receivebuffer =
new DataType[rsz];
457 Grid0IntersectionIterator rit = ibegin<0>();
458 Grid0IntersectionIterator ritend = iend<0>();
462 for (; rit != ritend; ++rit)
467 if (dir == Dune::ForwardCommunication)
474 data.
gather(gatherbuffer, rit->inside(), *rit);
484 data.
gather(gatherbuffer, rit->outside(), rit->flip());
490 for (
int i=0; i<ssz; i++)
491 receivebuffer[i] = sendbuffer[i];
495 for (rit = ibegin<0>(); rit != ritend; ++rit)
500 if (dir == Dune::ForwardCommunication)
506 data.
scatter(scatterbuffer, rit->outside(), rit->flip(),
515 data.
scatter(scatterbuffer, rit->inside(), *rit,
522 delete[] receivebuffer;
531 return IndexSet(
this);
536 size_t indexSet_size()
const 545 return Intersection(
this, & intersections_[i]);
566 #endif // DUNE_GRIDGLUE_GRIDGLUE_HH unsigned int IndexType
Definition: gridglue.hh:152
Patch::GridView::template Codim< 0 >::Entity GridElement
Definition: gridglue.hh:76
const GridGlue * gridglue
Definition: gridgluecommunicate.hh:279
Dune::GridGlue::IntersectionIterator< P0, P1, 0, 1 > IntersectionIterator
Definition: gridglue.hh:63
Abstract base for all classes that take extracted grids and build sets of intersections.
Definition: merger.hh:16
Provides codimension-independent methods for grid extraction.
Definition: extractor.hh:42
forward gather scatter to user defined CommInfo class
Definition: gridgluecommunicate.hh:191
Dune::GridGlue::Intersection< P0, P1, 0, 1 > Intersection
Type of remote intersection objects.
Definition: gridglue.hh:200
Definition: gridgluecommunicate.hh:23
Definition: gridglue.hh:31
Grid1View::Grid Grid1
Grid 1 type.
Definition: gridglue.hh:146
IndexSet indexSet() const
Definition: gridglue.hh:529
storage class for Dune::GridGlue::Intersection related data
Definition: gridglue.hh:45
Grid0View::Traits::template Codim< Grid0::dimension >::Entity Grid0Vertex
The type of the Grid0 vertices.
Definition: gridglue.hh:185
void scatter(MessageBufferImp &buff, const EntityType &e, const RISType &i, size_t n)
Definition: gridgluecommunicate.hh:116
Implement iterators over GridGlue intersections.
P0::GridView Grid0View
GridView of grid 0 (aka domain grid)
Definition: gridglue.hh:124
Dune::GridGlue::IntersectionIterator< P0, P1, 1, 0 > IntersectionIterator
Definition: gridglue.hh:75
Intersection getIntersection(int i) const
Definition: gridglue.hh:543
Dune::FieldVector< ctype, dimworld > Coords
The type used for coordinate vectors.
Definition: gridglue.hh:179
Dune::GridGlue::IntersectionIndexSet< P0, P1 > IndexSet
Type of remote intersection indexSet.
Definition: gridglue.hh:203
Dune::GridGlue::IntersectionIterator< P0, P1, 1, 0 > Grid1IntersectionIterator
Definition: gridglue.hh:210
P1 Grid1Patch
Coupling patch of grid 1.
Definition: gridglue.hh:149
P0 Grid0Patch
Coupling patch of grid 0.
Definition: gridglue.hh:130
Definition: gridglue.hh:51
sequential adapter to couple two grids at specified close together boundaries
Definition: gridglue.hh:42
size_t size() const
Definition: gridglue.hh:548
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:375
Grid0View::Grid Grid0
Grid 0 type.
Definition: gridglue.hh:127
Dune::GridGlue::Merger< ctype, Grid0::dimension - Grid0Patch::codim, Grid1::dimension - Grid1Patch::codim, dimworld > Merger
Instance of a Merger.
Definition: gridglue.hh:197
Definition: gridglue.hh:36
Dune::GridGlue::IntersectionIterator< P0, P1, 0, 1 > Grid0IntersectionIterator
Type of the iterator that iterates over remove intersections.
Definition: gridglue.hh:208
const GridGlueView< P0, P1, P >::Patch::GridView & gridView() const
getter for the GridView of patch P
Definition: gridglue.hh:325
Definition: gridglue.hh:57
GridGlueView< P0, P1, I >::IntersectionIterator iend() const
gets the (general) end-iterator for grid glue iterations
Definition: gridglue.hh:357
P1 Patch
Definition: gridglue.hh:74
The intersection of two entities of the two patches of a GridGlue.
Definition: gridglue.hh:48
void gather(MessageBufferImp &buff, const EntityType &e, const RISType &i) const
pack data from user to message buffer
Definition: gridgluecommunicate.hh:102
Dune::CommunicationDirection dir
Definition: gridgluecommunicate.hh:286
GridOrdering
Definition: gridglue.hh:35
Model of the Intersection concept provided by GridGlue.
Grid1View::Traits::template Codim< 0 >::Entity Grid1Element
The type of the Grid1 elements.
Definition: gridglue.hh:188
Grid1View::Traits::template Codim< Grid1::dimension >::Entity Grid1Vertex
The type of the Grid1 vertices.
Definition: gridglue.hh:191
Definition: gridglue.hh:37
size_t size(RISType &i) const
Definition: gridgluecommunicate.hh:90
::Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > * data
Definition: gridgluecommunicate.hh:280
Describes the parallel communication interface class for Dune::GridGlue.
P1::GridView Grid1View
GridView of grid 1 (aka target grid)
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:344
collects all GridGlue data requried for communication
Definition: gridgluecommunicate.hh:269
PromotionTraits< typename Grid0View::ctype, typename Grid1View::ctype >::PromotedType ctype
The type used for coordinates.
Definition: gridglue.hh:176
static const P0 & patch(const GridGlue< P0, P1 > &g)
Definition: gridglue.hh:65
Patch::GridView::template Codim< 0 >::Entity GridElement
Definition: gridglue.hh:64
P0 Patch
Definition: gridglue.hh:62
Grid0View::Traits::template Codim< 0 >::Entity Grid0Element
The type of the Grid0 elements.
Definition: gridglue.hh:182
static const P1 & patch(const GridGlue< P0, P1 > &g)
Definition: gridglue.hh:77
describes the features of a data handle for communication in parallel runs using the GridGlue::commun...
Definition: gridgluecommunicate.hh:74
Definition: gridglue.hh:54