1 #ifndef DUNE_SPGRID_LINKAGE_HH
2 #define DUNE_SPGRID_LINKAGE_HH
31 const std::vector< Mesh > &decomposition );
33 const Interface &
interface (
const InterfaceType iftype )
const;
36 template< InterfaceType iftype >
37 bool build (
const int localRank,
const PartitionPool &localPool,
44 Interface interface_[ 5 ];
57 typedef std::vector< Node > NodeContainer;
60 typedef typename NodeContainer::const_iterator
Iterator;
70 std::size_t
size ()
const {
return nodes_.size(); }
74 nodes_.emplace_back( rank, sendList, receiveList );
89 static_assert( (
int( ForwardCommunication ) == 0) && (
int( BackwardCommunication ) == 1),
90 "enumeration CommunicationDirection has changed." );
95 const PartitionList &sendList (
const CommunicationDirection direction = ForwardCommunication )
const;
96 const PartitionList &receiveList (
const CommunicationDirection direction = ForwardCommunication )
const;
110 template< InterfaceType iftype >
116 static const PartitionIteratorType sendPartition = InteriorBorder_Partition;
117 static const PartitionIteratorType receivePartition = InteriorBorder_Partition;
123 static const PartitionIteratorType sendPartition = InteriorBorder_Partition;
124 static const PartitionIteratorType receivePartition = All_Partition;
130 static const PartitionIteratorType sendPartition = Overlap_Partition;
131 static const PartitionIteratorType receivePartition = OverlapFront_Partition;
137 static const PartitionIteratorType sendPartition = Overlap_Partition;
138 static const PartitionIteratorType receivePartition = All_Partition;
144 static const PartitionIteratorType sendPartition = All_Partition;
145 static const PartitionIteratorType receivePartition = All_Partition;
157 const std::vector< Mesh > &decomposition )
159 const int size = decomposition.size();
164 for(
int remoteRank = 0; remoteRank < size; ++remoteRank )
166 if( remoteRank == localRank )
169 if( build< All_All_Interface >( localRank, localPool, remoteRank, remotePool ) )
171 build< InteriorBorder_InteriorBorder_Interface >( localRank, localPool, remoteRank, remotePool );
172 build< InteriorBorder_All_Interface >( localRank, localPool, remoteRank, remotePool );
173 build< Overlap_OverlapFront_Interface >( localRank, localPool, remoteRank, remotePool );
174 build< Overlap_All_Interface >( localRank, localPool, remoteRank, remotePool );
184 assert( (
int( iftype ) >= 0) && (
int( iftype ) < 5) );
185 return interface_[ int( iftype ) ];
190 template< InterfaceType iftype >
192 ::build (
const int localRank,
const PartitionPool &localPool,
193 const int remoteRank,
const PartitionPool &remotePool )
198 const bool order = (localRank < remoteRank);
201 const PartitionList *sendList, *receiveList;
202 sendList = intersect( order, localPool.template get< piSend >(), remotePool.template get< piReceive >() );
203 if( piSend != piReceive )
204 receiveList = intersect( order, localPool.template get< piReceive >(), remotePool.template get< piSend >() );
206 receiveList = sendList;
209 if( sendList->empty() && receiveList->empty() )
211 if( sendList != receiveList )
217 assert( (iftype >= 0) && (iftype < 5) );
218 interface_[ iftype ].add( remoteRank, sendList, receiveList );
225 SPLinkage< dim >::intersect (
const bool order,
const PartitionList &local,
const PartitionList &remote )
const
227 typedef SPBasicPartition< dim > Intersection;
228 typedef typename PartitionList::Iterator Iterator;
229 typedef typename PartitionList::Partition Partition;
233 PartitionList *link =
new PartitionList;
234 for( Iterator pit = (order ? local.begin() : remote.begin()); pit; ++pit )
236 for( Iterator qit = (order ? remote.begin() : local.begin()); qit; ++qit )
238 const int number = (order ? pit->number() : qit->number());
239 Intersection intersection = pit->intersect( *qit );
240 if( !intersection.empty() )
241 *link += Partition( intersection, number );
260 nodes_.reserve( other.nodes_.size() );
262 for(
Iterator it = other.begin(); it != end; ++it )
266 nodes_->push_back( it->rank(), sendList, receiveList );
274 typedef typename NodeContainer::iterator
Iterator;
276 for(
Iterator it = nodes_.begin(); it != end; ++it )
298 assert( rank_ >= 0 );
307 assert( (
int( direction ) >= 0) && (
int( direction ) <= 1) );
308 assert( partitionList_[ direction ] != 0 );
309 return *partitionList_[ direction ];
316 assert( (
int( direction ) >= 0) && (
int( direction ) <= 1) );
317 assert( partitionList_[ 1 - direction ] != 0 );
318 return *partitionList_[ 1 - direction ];
326 if( partitionList_[ 0 ] != partitionList_[ 1 ] )
327 delete partitionList_[ 1 ];
328 delete partitionList_[ 0 ];
329 partitionList_[ 0 ] = partitionList_[ 1 ] = 0;
Definition: iostream.hh:7
Definition: linkage.hh:17
const Interface & interface(const InterfaceType iftype) const
Definition: linkage.hh:182
SPPartitionList< dim > PartitionList
Definition: linkage.hh:22
PartitionPool::MultiIndex MultiIndex
Definition: linkage.hh:25
SPLinkage(const int localRank, const PartitionPool &localPool, const std::vector< Mesh > &decomposition)
Definition: linkage.hh:155
SPPartitionPool< dim > PartitionPool
Definition: linkage.hh:21
PartitionPool::Mesh Mesh
Definition: linkage.hh:24
Definition: linkage.hh:54
void add(int rank, const PartitionList *sendList, const PartitionList *receiveList)
Definition: linkage.hh:72
NodeContainer::const_iterator Iterator
Definition: linkage.hh:60
Interface(const This &other)
Definition: linkage.hh:258
~Interface()
Definition: linkage.hh:272
Iterator end() const
Definition: linkage.hh:68
Iterator begin() const
Definition: linkage.hh:67
std::size_t size() const
Definition: linkage.hh:70
Interface()
Definition: linkage.hh:253
Definition: linkage.hh:88
int rank() const
Definition: linkage.hh:296
const PartitionList & receiveList(const CommunicationDirection direction=ForwardCommunication) const
Definition: linkage.hh:314
Node(const int rank, const PartitionList *sendList, const PartitionList *receiveList)
Definition: linkage.hh:287
const PartitionList & sendList(const CommunicationDirection direction=ForwardCommunication) const
Definition: linkage.hh:305
void destroy()
Definition: linkage.hh:323
Definition: linkage.hh:111
Definition: partitionlist.hh:16
Definition: partitionpool.hh:18
const MultiIndex & overlap() const
Definition: partitionpool.hh:42
const Mesh & globalMesh() const
Definition: partitionpool.hh:41
const Topology & topology() const
Definition: partitionpool.hh:43