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> 22 #include <dune/common/parallel/mpitraits.hh> 23 #include <dune/common/parallel/mpicollectivecommunication.hh> 24 #include <dune/common/parallel/indexset.hh> 25 #include <dune/common/parallel/plocalindex.hh> 26 #include <dune/common/parallel/remoteindices.hh> 27 #include <dune/common/parallel/communicator.hh> 28 #include <dune/common/parallel/interface.hh> 40 template<
typename P0,
typename P1>
43 template<
typename P0,
typename P1>
46 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
49 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
52 template<
typename P0,
typename P1>
55 template<
typename P0,
typename P1,
int P>
58 template<
typename P0,
typename P1>
63 typedef typename Patch::GridView::template Codim<0>::Entity
GridElement;
70 template<
typename P0,
typename P1>
75 typedef typename Patch::GridView::template Codim<0>::Entity
GridElement;
91 template<
typename P0,
typename P1>
110 typedef ::Dune::GridGlue::GlobalId
GlobalId;
113 typedef Dune::ParallelLocalIndex <Dune::PartitionType> LocalIndex;
116 typedef Dune::ParallelIndexSet <GlobalId, LocalIndex> PIndexSet;
126 typedef typename Grid0View::Grid
Grid0;
134 grid0dim = Grid0Patch::dim,
135 domdim = Grid0Patch::dim,
137 grid0dimworld = Grid0Patch::dimworld,
138 domdimworld = Grid0Patch::dimworld
145 typedef typename Grid1View::Grid
Grid1;
156 tardim = Grid1Patch::dim,
157 grid1dim = Grid1Patch::dim,
159 tardimworld = Grid1Patch::dimworld,
160 grid1dimworld = Grid1Patch::dimworld
168 dimworld = ((int)Grid0Patch::dimworld > (
int)Grid1Patch::dimworld) ? (
int)Grid0Patch::dimworld : (int)Grid1Patch::dimworld
174 typedef typename PromotionTraits<
typename Grid0View::ctype,
175 typename Grid1View::ctype>::PromotedType
ctype;
178 typedef Dune::FieldVector<ctype, dimworld>
Coords;
181 typedef typename Grid0View::Traits::template Codim<0>::Entity
Grid0Element;
184 typedef typename Grid0View::Traits::template Codim<Grid0::dimension>::Entity
Grid0Vertex;
187 typedef typename Grid1View::Traits::template Codim<0>::Entity
Grid1Element;
190 typedef typename Grid1View::Traits::template Codim<Grid1::dimension>::Entity
Grid1Vertex;
194 Grid0::dimension - Grid0Patch::codim,
195 Grid1::dimension - Grid1Patch::codim,
216 const std::shared_ptr<const Grid0Patch> patch0_;
219 const std::shared_ptr<const Grid1Patch> patch1_;
222 const std::shared_ptr<Merger> merger_;
232 PIndexSet patch0_is_;
235 PIndexSet patch1_is_;
238 Dune::RemoteIndices<PIndexSet> remoteIndices_;
245 mutable std::vector<IntersectionData> intersections_;
265 void mergePatches(
const std::vector<Dune::FieldVector<ctype,dimworld> >& patch0coords,
266 const std::vector<unsigned int>& patch0entities,
267 const std::vector<Dune::GeometryType>& patch0types,
268 const int patch0rank,
269 const std::vector<Dune::FieldVector<ctype,dimworld> >& patch1coords,
270 const std::vector<unsigned int>& patch1entities,
271 const std::vector<Dune::GeometryType>& patch1types,
272 const int patch1rank);
275 template<
typename Extractor>
276 void extractGrid (
const Extractor & extractor,
277 std::vector<Dune::FieldVector<ctype, dimworld> > & coords,
278 std::vector<unsigned int> & faces,
279 std::vector<Dune::GeometryType>& geometryTypes)
const;
295 DUNE_DEPRECATED_MSG(
"Please use a std::shared_ptr for patches and merger")
296 GridGlue(const Grid0Patch& gp0, const Grid1Patch& gp1, Merger* merger);
308 GridGlue(const
std::shared_ptr<const Grid0Patch> gp0, const
std::shared_ptr<const Grid1Patch> gp1, const
std::shared_ptr<Merger> merger);
373 template<
class DataHandleImp,
class DataTypeImp>
375 Dune::InterfaceType iftype, Dune::CommunicationDirection dir)
const 378 typedef typename DataHandle::DataType DataType;
382 if (mpicomm_ != MPI_COMM_SELF)
388 Dune::dinfo <<
"GridGlue: parallel communication" << std::endl;
389 typedef Dune::EnumItem <Dune::PartitionType, Dune::InteriorEntity> InteriorFlags;
390 typedef Dune::EnumItem <Dune::PartitionType, Dune::OverlapEntity> OverlapFlags;
391 typedef Dune::EnumRange <Dune::PartitionType, Dune::InteriorEntity, Dune::GhostEntity> AllFlags;
392 Dune::Interface interface;
393 assert(remoteIndices_.isSynced());
396 case Dune::InteriorBorder_InteriorBorder_Interface :
397 interface.build (remoteIndices_, InteriorFlags(), InteriorFlags() );
399 case Dune::InteriorBorder_All_Interface :
400 if (dir == Dune::ForwardCommunication)
401 interface.build (remoteIndices_, InteriorFlags(), AllFlags() );
403 interface.build (remoteIndices_, AllFlags(), InteriorFlags() );
405 case Dune::Overlap_OverlapFront_Interface :
406 interface.build (remoteIndices_, OverlapFlags(), OverlapFlags() );
408 case Dune::Overlap_All_Interface :
409 if (dir == Dune::ForwardCommunication)
410 interface.build (remoteIndices_, OverlapFlags(), AllFlags() );
412 interface.build (remoteIndices_, AllFlags(), OverlapFlags() );
414 case Dune::All_All_Interface :
415 interface.build (remoteIndices_, AllFlags(), AllFlags() );
418 DUNE_THROW(Dune::NotImplemented,
"GridGlue::communicate for interface " << iftype <<
" not implemented");
426 commInfo.
data = &data;
429 Dune::BufferedCommunicator bComm ;
430 bComm.template build< CommInfo >(commInfo, commInfo, interface);
434 if (dir == Dune::ForwardCommunication)
445 Dune::dinfo <<
"GridGlue: sequential fallback communication" << std::endl;
448 int ssz = size() * 10;
449 int rsz = size() * 10;
452 DataType* sendbuffer =
new DataType[ssz];
453 DataType* receivebuffer =
new DataType[rsz];
456 Grid0IntersectionIterator rit = ibegin<0>();
457 Grid0IntersectionIterator ritend = iend<0>();
461 for (; rit != ritend; ++rit)
466 if (dir == Dune::ForwardCommunication)
473 data.
gather(gatherbuffer, rit->inside(), *rit);
483 data.
gather(gatherbuffer, rit->outside(), rit->flip());
489 for (
int i=0; i<ssz; i++)
490 receivebuffer[i] = sendbuffer[i];
494 for (rit = ibegin<0>(); rit != ritend; ++rit)
499 if (dir == Dune::ForwardCommunication)
505 data.
scatter(scatterbuffer, rit->outside(), rit->flip(),
514 data.
scatter(scatterbuffer, rit->inside(), *rit,
521 delete[] receivebuffer;
530 return IndexSet(
this);
535 size_t indexSet_size()
const 544 return Intersection(
this, & intersections_[i]);
565 #endif // DUNE_GRIDGLUE_GRIDGLUE_HH GridGlueView< P0, P1, I >::IntersectionIterator iend() const
gets the (general) end-iterator for grid glue iterations
Definition: gridglue.hh:356
describes the features of a data handle for communication in parallel runs using the GridGlue::commun...
Definition: gridgluecommunicate.hh:74
Patch::GridView::template Codim< 0 >::Entity GridElement
Definition: gridglue.hh:63
Definition: gridglue.hh:36
forward gather scatter to user defined CommInfo class
Definition: gridgluecommunicate.hh:191
Grid1View::Traits::template Codim< Grid1::dimension >::Entity Grid1Vertex
The type of the Grid1 vertices.
Definition: gridglue.hh:190
GridOrdering
Definition: gridglue.hh:34
Implement iterators over GridGlue intersections.
P0 Patch
Definition: gridglue.hh:61
storage class for Dune::GridGlue::Intersection related data
Definition: gridglue.hh:44
PromotionTraits< typename Grid0View::ctype, typename Grid1View::ctype >::PromotedType ctype
The type used for coordinates.
Definition: gridglue.hh:175
Definition: gridgluecommunicate.hh:23
P1::GridView Grid1View
GridView of grid 1 (aka target grid)
Definition: gridglue.hh:142
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:343
Definition: gridglue.hh:50
Provides codimension-independent methods for grid extraction.
Definition: extractor.hh:42
unsigned int IndexType
Definition: gridglue.hh:151
Patch::GridView::template Codim< 0 >::Entity GridElement
Definition: gridglue.hh:75
::Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > * data
Definition: gridgluecommunicate.hh:280
sequential adapter to couple two grids at specified close together boundaries
Definition: gridglue.hh:41
Grid0View::Traits::template Codim< 0 >::Entity Grid0Element
The type of the Grid0 elements.
Definition: gridglue.hh:181
Model of the Intersection concept provided by GridGlue.
static const P1 & patch(const GridGlue< P0, P1 > &g)
Definition: gridglue.hh:76
collects all GridGlue data requried for communication
Definition: gridgluecommunicate.hh:269
Grid1View::Grid Grid1
Grid 1 type.
Definition: gridglue.hh:145
Grid0View::Traits::template Codim< Grid0::dimension >::Entity Grid0Vertex
The type of the Grid0 vertices.
Definition: gridglue.hh:184
Definition: gridglue.hh:56
P0::GridView Grid0View
GridView of grid 0 (aka domain grid)
Definition: gridglue.hh:123
The intersection of two entities of the two patches of a GridGlue.
Definition: gridglue.hh:47
Dune::FieldVector< ctype, dimworld > Coords
The type used for coordinate vectors.
Definition: gridglue.hh:178
Abstract base for all classes that take extracted grids and build sets of intersections.
Definition: merger.hh:16
Dune::GridGlue::IntersectionIterator< P0, P1, 1, 0 > Grid1IntersectionIterator
Definition: gridglue.hh:209
static const P0 & patch(const GridGlue< P0, P1 > &g)
Definition: gridglue.hh:64
P0 Grid0Patch
Coupling patch of grid 0.
Definition: gridglue.hh:129
Describes the parallel communication interface class for Dune::GridGlue.
const GridGlue * gridglue
Definition: gridgluecommunicate.hh:279
Dune::GridGlue::Intersection< P0, P1, 0, 1 > Intersection
Type of remote intersection objects.
Definition: gridglue.hh:199
Definition: gridglue.hh:35
size_t size() const
Definition: gridglue.hh:547
Grid0View::Grid Grid0
Grid 0 type.
Definition: gridglue.hh:126
Dune::GridGlue::Merger< ctype, Grid0::dimension - Grid0Patch::codim, Grid1::dimension - Grid1Patch::codim, dimworld > Merger
Instance of a Merger.
Definition: gridglue.hh:196
IndexSet indexSet() const
Definition: gridglue.hh:528
Definition: gridglue.hh:53
Dune::GridGlue::IntersectionIterator< P0, P1, 0, 1 > IntersectionIterator
Definition: gridglue.hh:62
Dune::GridGlue::IntersectionIterator< P0, P1, 0, 1 > Grid0IntersectionIterator
Type of the iterator that iterates over remove intersections.
Definition: gridglue.hh:207
size_t size(RISType &i) const
Definition: gridgluecommunicate.hh:90
P1 Patch
Definition: gridglue.hh:73
Dune::GridGlue::IntersectionIterator< P0, P1, 1, 0 > IntersectionIterator
Definition: gridglue.hh:74
Intersection getIntersection(int i) const
Definition: gridglue.hh:542
Dune::GridGlue::IntersectionIndexSet< P0, P1 > IndexSet
Type of remote intersection indexSet.
Definition: gridglue.hh:202
P1 Grid1Patch
Coupling patch of grid 1.
Definition: gridglue.hh:148
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
Definition: gridglue.hh:30
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:374
const GridGlueView< P0, P1, P >::Patch::GridView & gridView() const
getter for the GridView of patch P
Definition: gridglue.hh:324
Grid1View::Traits::template Codim< 0 >::Entity Grid1Element
The type of the Grid1 elements.
Definition: gridglue.hh:187
void scatter(MessageBufferImp &buff, const EntityType &e, const RISType &i, size_t n)
Definition: gridgluecommunicate.hh:116