domesticoverlapfrombcrsmatrix.hh
Go to the documentation of this file.
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 /*
4  Copyright (C) 2011-2013 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
25 #ifndef EWOMS_DOMESTIC_OVERLAP_FROM_BCRS_MATRIX_HH
26 #define EWOMS_DOMESTIC_OVERLAP_FROM_BCRS_MATRIX_HH
27 
29 #include "blacklist.hh"
30 #include "globalindices.hh"
31 
33 
34 #include <algorithm>
35 #include <limits>
36 #include <set>
37 #include <map>
38 #include <vector>
39 
40 namespace Ewoms {
41 namespace Linear {
42 
50 template <class BCRSMatrix>
52 {
54  {}
55 
58 
59 public:
64  DomesticOverlapFromBCRSMatrix(const BCRSMatrix &A,
65  const BorderList &borderList,
66  const BlackList &blackList,
67  int overlapSize)
68  : foreignOverlap_(A, borderList, blackList, overlapSize)
69  , blackList_(blackList)
71  {
72  myRank_ = 0;
73  worldSize_ = 1;
74 
75 #if HAVE_MPI
76  MPI_Comm_rank(MPI_COMM_WORLD, &myRank_);
77  MPI_Comm_size(MPI_COMM_WORLD, &worldSize_);
78 #endif // HAVE_MPI
79 
83 
85  }
86 
87  void check() const
88  {
89 #ifndef NDEBUG
90  // check consistency of global indices
91  for (int domIdx = 0; domIdx < numDomestic(); ++domIdx) {
92  assert(int(globalToDomestic(domesticToGlobal(domIdx))) == domIdx);
93  }
94 #endif // NDEBUG
95 
96  // send the foreign overlap for which we are master to the
97  // peers
98  std::map<int, MpiBuffer<int> *> sizeBufferMap;
99 
100  auto peerIt = peerSet_.begin();
101  const auto &peerEndIt = peerSet_.end();
102  for (; peerIt != peerEndIt; ++peerIt) {
103  auto &buffer = *(new MpiBuffer<int>(1));
104  sizeBufferMap[*peerIt] = &buffer;
105  buffer[0] = foreignOverlap_.foreignOverlapWithPeer(*peerIt).size();
106  buffer.send(*peerIt);
107  }
108 
109  peerIt = peerSet_.begin();
110  for (; peerIt != peerEndIt; ++peerIt) {
111  MpiBuffer<int> rcvBuffer(1);
112  rcvBuffer.receive(*peerIt);
113 
114  assert(rcvBuffer[0] == domesticOverlapWithPeer_.find(*peerIt)->second.size());
115  }
116 
117  peerIt = peerSet_.begin();
118  for (; peerIt != peerEndIt; ++peerIt) {
119  sizeBufferMap[*peerIt]->wait();
120  delete sizeBufferMap[*peerIt];
121  }
122  }
123 
127  int myRank() const
128  { return myRank_; }
129 
133  int worldSize() const
134  { return worldSize_; }
135 
140  const PeerSet &peerSet() const
141  { return peerSet_; }
142 
147  int numBorder(int peerRank) const
148  { return foreignOverlap_.numBorder(peerRank); }
149 
153  bool isBorder(int domesticIdx) const
154  {
155  return isLocal(domesticIdx)
157  }
158 
163  bool isBorderWith(int domesticIdx, int peerRank) const
164  {
165  return isLocal(domesticIdx)
167  peerRank);
168  }
169 
174  int numFront(int peerRank) const
175  { return foreignOverlap_.numFront(peerRank); }
176 
180  bool isFront(int domesticIdx) const
181  {
182  if (isLocal(domesticIdx))
183  return false;
184  Index internalDomesticIdx = mapExternalToInternal_(domesticIdx);
185 
186  // check wether the border distance of the domestic overlap is
187  // maximal for the index
188  const auto &domOverlap = domesticOverlapByIndex_[internalDomesticIdx];
189  return domOverlap.size() > 0
190  && int(domOverlap.begin()->second) == foreignOverlap_.overlapSize();
191  }
192 
196  const BlackList& blackList() const
197  { return blackList_; }
198 
203  int numPeers(int domesticIdx) const
204  { return domesticOverlapByIndex_[mapExternalToInternal_(domesticIdx)].size(); }
205 
209  int overlapSize() const
210  { return foreignOverlap_.overlapSize(); }
211 
219  int numNative() const
220  { return foreignOverlap_.numNative(); }
221 
228  int numLocal() const
229  { return foreignOverlap_.numLocal(); }
230 
238  int numDomestic() const
239  { return globalIndices_.numDomestic(); }
240 
247  bool isLocal(int domesticIdx) const
248  { return mapExternalToInternal_(domesticIdx) < numLocal(); }
249 
254  bool iAmMasterOf(int domesticIdx) const
255  {
256  if (!isLocal(domesticIdx))
257  return false;
259  }
260 
264  int masterRank(int domesticIdx) const
265  { return masterRank_[mapExternalToInternal_(domesticIdx)]; }
266 
270  void print() const
271  { globalIndices_.print(); }
272 
276  Index globalToDomestic(Index globalIdx) const
277  {
278  Index internalIdx = globalIndices_.globalToDomestic(globalIdx);
279  if (internalIdx < 0)
280  return -1;
281  return mapInternalToExternal_(internalIdx);
282  }
283 
289 
294  {
295  Index internalIdx = mapExternalToInternal_(domIdx);
296  if (internalIdx >= numLocal())
297  return -1;
298  return foreignOverlap_.localToNative(internalIdx);
299  }
300 
304  Index nativeToDomestic(Index nativeIdx) const
305  {
306  Index localIdx = foreignOverlap_.nativeToLocal(nativeIdx);
307  if (localIdx < 0)
308  return localIdx;
309  return mapInternalToExternal_(localIdx);
310  }
311 
316  bool isInOverlap(Index domesticIdx) const
317  {
318  return !this->isLocal(domesticIdx)
319  || this->foreignOverlap_.isInOverlap(mapExternalToInternal_(domesticIdx));
320  }
321 
326  bool isFrontFor(ProcessRank peerRank, Index domesticIdx) const
327  {
328  int internalIdx = mapExternalToInternal_(domesticIdx);
329  return this->foreignOverlap_.isFrontFor(peerRank, internalIdx);
330  }
331 
335  bool peerHasIndex(int peerRank, int domesticIdx) const
336  {
337  return foreignOverlap_.peerHasIndex(peerRank,
338  mapExternalToInternal_(domesticIdx));
339  }
340 
345  int foreignOverlapSize(ProcessRank peerRank) const
346  { return foreignOverlap_.foreignOverlapWithPeer(peerRank).size(); }
347 
353  int foreignOverlapOffsetToDomesticIdx(ProcessRank peerRank, int overlapOffset) const
354  {
355  int internalIdx =
356  foreignOverlap_.foreignOverlapWithPeer(peerRank)[overlapOffset].index;
357  return mapInternalToExternal_(internalIdx);
358  }
359 
364  int domesticOverlapSize(ProcessRank peerRank) const
365  { return domesticOverlapWithPeer_.at(peerRank).size(); }
366 
372  int domesticOverlapOffsetToDomesticIdx(ProcessRank peerRank, int overlapOffset) const
373  {
374  int internalIdx = domesticOverlapWithPeer_.at(peerRank)[overlapOffset];
375  return mapInternalToExternal_(internalIdx);
376  }
377 
378 protected:
380  {
381  // copy the set of peers from the foreign overlap
383 
384  // resize the array which stores the number of peers for
385  // each entry.
387  borderDistance_.resize(numLocal(), 0);
388 
389  PeerSet::const_iterator peerIt;
390  PeerSet::const_iterator peerEndIt = peerSet_.end();
391 
392  // send the overlap indices to all peer processes
393  peerIt = peerSet_.begin();
394  for (; peerIt != peerEndIt; ++peerIt) {
395  int peerRank = *peerIt;
396  sendIndicesToPeer_(peerRank);
397  }
398 
399  // receive our overlap from the processes to all peer processes
400  peerIt = peerSet_.begin();
401  for (; peerIt != peerEndIt; ++peerIt) {
402  int peerRank = *peerIt;
403  receiveIndicesFromPeer_(peerRank);
404  }
405 
406  // wait until all send operations complete
407  peerIt = peerSet_.begin();
408  for (; peerIt != peerEndIt; ++peerIt) {
409  int peerRank = *peerIt;
410  waitSendIndices_(peerRank);
411  }
412  }
413 
415  {
416  unsigned nLocal = numLocal();
417  unsigned nDomestic = numDomestic();
418  masterRank_.resize(nDomestic);
419 
420  // take the master ranks for the local indices from the
421  // foreign overlap
422  for (size_t i = 0; i < nLocal; ++i) {
424  }
425 
426  // for non-local indices, initially use INT_MAX as their master
427  // rank
428  for (size_t i = nLocal; i < nDomestic; ++i)
429  masterRank_[i] = std::numeric_limits<ProcessRank>::max();
430 
431  // for the non-local indices, take the peer process for which
432  // a given local index is in the interior
433  auto peerIt = peerSet_.begin();
434  const auto &peerEndIt = peerSet_.end();
435  for (; peerIt != peerEndIt; ++peerIt) {
436  const auto &overlapWithPeer = domesticOverlapWithPeer_.find(*peerIt)->second;
437 
438  auto idxIt = overlapWithPeer.begin();
439  const auto &idxEndIt = overlapWithPeer.end();
440  for (; idxIt != idxEndIt; ++idxIt) {
441  if (*idxIt >= 0 && foreignOverlap_.isLocal(*idxIt))
442  continue; // ignore border indices
443 
444  masterRank_[*idxIt] = std::min(masterRank_[*idxIt], *peerIt);
445  }
446  }
447  }
448 
449  void sendIndicesToPeer_(int peerRank)
450  {
451 #if HAVE_MPI
452  const auto &foreignOverlap = foreignOverlap_.foreignOverlapWithPeer(peerRank);
453 
454  // first, send a message containing the number of additional
455  // indices stemming from the overlap (i.e. without the border
456  // indices)
457  int numIndices = foreignOverlap.size();
458  numIndicesSendBuffer_[peerRank] = new MpiBuffer<size_t>(1);
459  (*numIndicesSendBuffer_[peerRank])[0] = numIndices;
460  numIndicesSendBuffer_[peerRank]->send(peerRank);
461 
462  // create MPI buffers
463  indicesSendBuffer_[peerRank] = new MpiBuffer<IndexDistanceNpeers>(numIndices);
464 
465  // then send the additional indices themselfs
466  auto overlapIt = foreignOverlap.begin();
467  const auto &overlapEndIt = foreignOverlap.end();
468  for (int i = 0; overlapIt != overlapEndIt; ++overlapIt, ++i) {
469  int localIdx = overlapIt->index;
470  int borderDistance = overlapIt->borderDistance;
471  int numPeers = foreignOverlap_.foreignOverlapByLocalIndex(localIdx).size();
472 
474  tmp.index = globalIndices_.domesticToGlobal(localIdx);
475  tmp.borderDistance = borderDistance;
476  tmp.numPeers = numPeers;
477 
478  (*indicesSendBuffer_[peerRank])[i] = tmp;
479  }
480 
481  indicesSendBuffer_[peerRank]->send(peerRank);
482 #endif // HAVE_MPI
483  }
484 
485  void waitSendIndices_(int peerRank)
486  {
487  numIndicesSendBuffer_[peerRank]->wait();
488  delete numIndicesSendBuffer_[peerRank];
489 
490  indicesSendBuffer_[peerRank]->wait();
491  delete indicesSendBuffer_[peerRank];
492  }
493 
494  void receiveIndicesFromPeer_(int peerRank)
495  {
496 #if HAVE_MPI
497  // receive the number of additional indices
498  int numIndices = -1;
499  MpiBuffer<size_t> numIndicesRecvBuff(1);
500  numIndicesRecvBuff.receive(peerRank);
501  numIndices = numIndicesRecvBuff[0];
502 
503  // receive the additional indices themselfs
504  MpiBuffer<IndexDistanceNpeers> recvBuff(numIndices);
505  recvBuff.receive(peerRank);
506  for (Index i = 0; i < numIndices; ++i) {
507  Index globalIdx = recvBuff[i].index;
508  BorderDistance borderDistance = recvBuff[i].borderDistance;
509 
510  // if the index is not already known, add it to the
511  // domestic indices
512  if (!globalIndices_.hasGlobalIndex(globalIdx)) {
513  Index newDomesticIdx = globalIndices_.numDomestic();
514  globalIndices_.addIndex(newDomesticIdx, globalIdx);
515 
516  size_t newSize = globalIndices_.numDomestic();
517  borderDistance_.resize(newSize, std::numeric_limits<int>::max());
518  domesticOverlapByIndex_.resize(newSize);
519  }
520 
521  // convert the global index into a domestic one
522  Index domesticIdx = globalIndices_.globalToDomestic(globalIdx);
523 
524  // extend the domestic overlap
525  domesticOverlapByIndex_[domesticIdx][peerRank] = borderDistance;
526  domesticOverlapWithPeer_[peerRank].push_back(domesticIdx);
527 
528  assert(borderDistance >= 0);
529  assert(globalIdx >= 0);
530  assert(domesticIdx >= 0);
531  assert(!(borderDistance == 0 && !foreignOverlap_.isLocal(domesticIdx)));
532  assert(!(borderDistance > 0 && foreignOverlap_.isLocal(domesticIdx)));
533 
534  borderDistance_[domesticIdx] = std::min(borderDistance, borderDistance_[domesticIdx]);
535  }
536 #endif // HAVE_MPI
537  }
538 
539  // this method is intended to set up the code mapping code for
540  // mapping domestic indices to the same ones used by a sequential
541  // grid. this requires detailed knowledge about how a grid
542  // distributes the degrees of freedom over multiple processes, but
543  // it can simplify debugging considerably because the indices can
544  // be made identical for the parallel and the sequential
545  // computations.
546  //
547  // by default, this method does nothing
549  {}
550 
551  // this method is intended to map domestic indices to the ones
552  // used by a sequential grid.
553  //
554  // by default, this method does nothing
555  Index mapInternalToExternal_(Index internalIdx) const
556  { return internalIdx; }
557 
558  // this method is intended to map the indices used by a sequential
559  // to grid domestic indices ones.
560  //
561  // by default, this method does nothing
562  Index mapExternalToInternal_(Index externalIdx) const
563  { return externalIdx; }
564 
565  int myRank_;
567  ForeignOverlap foreignOverlap_;
568 
570 
573  std::vector<BorderDistance> borderDistance_;
574  std::vector<ProcessRank> masterRank_;
575 
576  std::map<ProcessRank, MpiBuffer<size_t> *> numIndicesSendBuffer_;
577  std::map<ProcessRank, MpiBuffer<IndexDistanceNpeers> *> indicesSendBuffer_;
578  GlobalIndices globalIndices_;
580 };
581 
582 } // namespace Linear
583 } // namespace Ewoms
584 
585 #endif
std::map< ProcessRank, DomesticOverlapWithPeer > DomesticOverlapByRank
A type mapping the process rank to the list of domestic indices which are owned by the peer...
Definition: overlaptypes.hh:186
This structure stores an index, a process rank, and the number of processes which "see" the degree of...
Definition: overlaptypes.hh:90
std::map< ProcessRank, MpiBuffer< size_t > * > numIndicesSendBuffer_
Definition: domesticoverlapfrombcrsmatrix.hh:576
OverlapByIndex domesticOverlapByIndex_
Definition: domesticoverlapfrombcrsmatrix.hh:572
A set of process ranks.
Definition: overlaptypes.hh:147
GlobalIndices globalIndices_
Definition: domesticoverlapfrombcrsmatrix.hh:578
bool peerHasIndex(int peerRank, int domesticIdx) const
Returns true iff a domestic index is seen by a peer rank.
Definition: domesticoverlapfrombcrsmatrix.hh:335
const BlackList & blackList() const
Returns the object which represents the black-listed native indices.
Definition: domesticoverlapfrombcrsmatrix.hh:196
unsigned BorderDistance
The type representing the distance of an index to the border.
Definition: overlaptypes.hh:53
void addIndex(int domesticIdx, int globalIdx)
Add an index to the domestic<->global mapping.
Definition: globalindices.hh:126
DomesticOverlapByRank domesticOverlapWithPeer_
Definition: domesticoverlapfrombcrsmatrix.hh:571
Index nativeToDomestic(Index nativeIdx) const
Returns a domestic index given a native one.
Definition: domesticoverlapfrombcrsmatrix.hh:304
bool isBorderWith(int domesticIdx, int peerRank) const
Returns true iff a domestic index is on the border with a given peer process.
Definition: domesticoverlapfrombcrsmatrix.hh:163
int numPeers
Definition: overlaptypes.hh:94
This class creates and manages the foreign overlap given an initial list of border indices and a BCRS...
int domesticToGlobal(int domesticIdx) const
Converts a domestic index to a global one.
Definition: globalindices.hh:87
bool isLocal(int domesticIdx) const
Return true if a domestic index is local for the process.
Definition: domesticoverlapfrombcrsmatrix.hh:247
const std::map< ProcessRank, BorderDistance > & foreignOverlapByLocalIndex(Index localIdx) const
Return the map of (peer rank, border distance) for a given local index.
Definition: foreignoverlapfrombcrsmatrix.hh:206
int nativeToLocal(Index nativeIdx) const
Convert a native index to a local one.
Definition: foreignoverlapfrombcrsmatrix.hh:292
Expresses which degrees of freedom are blacklisted for the parallel linear solvers and which domestic...
Definition: blacklist.hh:45
Index mapExternalToInternal_(Index externalIdx) const
Definition: domesticoverlapfrombcrsmatrix.hh:562
void print() const
Print the foreign overlap for debugging purposes.
Definition: domesticoverlapfrombcrsmatrix.hh:270
int overlapSize() const
Returns the size of the overlap region.
Definition: domesticoverlapfrombcrsmatrix.hh:209
int myRank_
Definition: domesticoverlapfrombcrsmatrix.hh:565
void setupDebugMapping_()
Definition: domesticoverlapfrombcrsmatrix.hh:548
int numNative() const
Returns the number native indices.
Definition: domesticoverlapfrombcrsmatrix.hh:219
Simplifies handling of buffers to be used in conjunction with MPI.
PeerSet peerSet_
Definition: domesticoverlapfrombcrsmatrix.hh:579
int numFront(int peerRank) const
Returns the number of indices on the front within a given peer rank's grid partition.
Definition: domesticoverlapfrombcrsmatrix.hh:174
This class creates and manages the foreign overlap given an initial list of border indices and a BCRS...
Definition: foreignoverlapfrombcrsmatrix.hh:58
BlackList blackList_
Definition: domesticoverlapfrombcrsmatrix.hh:569
bool iAmMasterOf(int domesticIdx) const
Return true iff the current process is the master of a given domestic index.
Definition: domesticoverlapfrombcrsmatrix.hh:254
int masterRank(int domesticIdx) const
Return the rank of a master process for a domestic index.
Definition: domesticoverlapfrombcrsmatrix.hh:264
bool isFrontFor(ProcessRank peerRank, Index domesticIdx) const
Returns true if a given domestic index is a front index for a peer rank.
Definition: domesticoverlapfrombcrsmatrix.hh:326
int localToNative(Index localIdx) const
Convert a local index to a native one.
Definition: foreignoverlapfrombcrsmatrix.hh:298
void print() const
Prints the global indices of all domestic indices for debugging purposes.
Definition: globalindices.hh:187
Index mapInternalToExternal_(Index internalIdx) const
Definition: domesticoverlapfrombcrsmatrix.hh:555
int numFront(int peerRank) const
Returns the number of front indices of a peer process in the local partition.
Definition: foreignoverlapfrombcrsmatrix.hh:225
bool isBorder(Index localIdx) const
Returns true iff a local index is a border index.
Definition: foreignoverlapfrombcrsmatrix.hh:147
bool isBorderWith(Index localIdx, int peerRank) const
Returns true iff a local index is a border index shared with a given peer process.
Definition: foreignoverlapfrombcrsmatrix.hh:154
int numNative() const
Returns the number of native indices.
Definition: foreignoverlapfrombcrsmatrix.hh:271
void receiveIndicesFromPeer_(int peerRank)
Definition: domesticoverlapfrombcrsmatrix.hh:494
std::vector< BorderDistance > borderDistance_
Definition: domesticoverlapfrombcrsmatrix.hh:573
int numDomestic() const
Returns the number domestic indices.
Definition: domesticoverlapfrombcrsmatrix.hh:238
BorderDistance borderDistance
Definition: overlaptypes.hh:93
std::list< BorderIndex > BorderList
This class managages a list of indices which are on the border of a process' partition of the grid...
Definition: overlaptypes.hh:119
Index index
Definition: overlaptypes.hh:92
int numPeers(int domesticIdx) const
Returns the number of processes which "see" a given index.
Definition: domesticoverlapfrombcrsmatrix.hh:203
Index domesticToNative(Index domIdx) const
Returns a native index given a domestic one.
Definition: domesticoverlapfrombcrsmatrix.hh:293
void sendIndicesToPeer_(int peerRank)
Definition: domesticoverlapfrombcrsmatrix.hh:449
int domesticOverlapOffsetToDomesticIdx(ProcessRank peerRank, int overlapOffset) const
Returns the domestic index given an offset in the domestic overlap of a peer process with the local p...
Definition: domesticoverlapfrombcrsmatrix.hh:372
int domesticOverlapSize(ProcessRank peerRank) const
Returns number of indices which are contained in the domestic overlap with a peer.
Definition: domesticoverlapfrombcrsmatrix.hh:364
int numLocal() const
Returns the number local indices.
Definition: domesticoverlapfrombcrsmatrix.hh:228
void receive(int peerRank)
Receive the buffer syncronously from a peer rank.
Definition: mpibuffer.hh:101
bool isInOverlap(Index localIdx) const
Returns true if a given local index is in the foreign overlap of any rank.
Definition: foreignoverlapfrombcrsmatrix.hh:321
int worldSize_
Definition: domesticoverlapfrombcrsmatrix.hh:566
Index globalToDomestic(Index globalIdx) const
Returns a domestic index given a global one.
Definition: domesticoverlapfrombcrsmatrix.hh:276
bool isFront(int domesticIdx) const
Returns true iff a domestic index is on the front.
Definition: domesticoverlapfrombcrsmatrix.hh:180
void waitSendIndices_(int peerRank)
Definition: domesticoverlapfrombcrsmatrix.hh:485
ProcessRank masterRank(Index localIdx) const
Return the rank of the master process of an index.
Definition: foreignoverlapfrombcrsmatrix.hh:169
std::vector< ProcessRank > masterRank_
Definition: domesticoverlapfrombcrsmatrix.hh:574
Definition: baseauxiliarymodule.hh:35
Index domesticToGlobal(Index domIdx) const
Returns a global index given a domestic one.
Definition: domesticoverlapfrombcrsmatrix.hh:287
bool isBorder(int domesticIdx) const
Returns true iff a domestic index is a border index.
Definition: domesticoverlapfrombcrsmatrix.hh:153
int foreignOverlapOffsetToDomesticIdx(ProcessRank peerRank, int overlapOffset) const
Returns the domestic index given an offset in the foreign overlap of a peer process with the local pr...
Definition: domesticoverlapfrombcrsmatrix.hh:353
DomesticOverlapFromBCRSMatrix(const BCRSMatrix &A, const BorderList &borderList, const BlackList &blackList, int overlapSize)
Constructs the foreign overlap given a BCRS matrix and an initial list of border indices.
Definition: domesticoverlapfrombcrsmatrix.hh:64
const OverlapWithPeer & foreignOverlapWithPeer(int peerRank) const
Return the list of (local indices, border distance, number of processes) triples which are in the ove...
Definition: foreignoverlapfrombcrsmatrix.hh:195
void updateNativeToDomesticMap(const DomesticOverlap &domesticOverlap)
Definition: blacklist.hh:78
This class maps domestic row indices to and from "global" indices which is used to construct an algeb...
Definition: globalindices.hh:53
bool iAmMasterOf(Index localIdx) const
Return true if the current rank is the "master" of an index.
Definition: foreignoverlapfrombcrsmatrix.hh:180
int numDomestic() const
Returns the number domestic indices.
Definition: globalindices.hh:120
const PeerSet & peerSet() const
Return the set of process ranks which share an overlap with the current process.
Definition: foreignoverlapfrombcrsmatrix.hh:258
int worldSize() const
Returns the number of processes in the global MPI communicator.
Definition: domesticoverlapfrombcrsmatrix.hh:133
void buildDomesticOverlap_()
Definition: domesticoverlapfrombcrsmatrix.hh:379
const PeerSet & peerSet() const
Return the set of process ranks which share an overlap with the current process.
Definition: domesticoverlapfrombcrsmatrix.hh:140
std::map< ProcessRank, MpiBuffer< IndexDistanceNpeers > * > indicesSendBuffer_
Definition: domesticoverlapfrombcrsmatrix.hh:577
std::vector< std::map< ProcessRank, BorderDistance > > OverlapByIndex
Maps each index to a list of processes .
Definition: overlaptypes.hh:175
void updateMasterRanks_()
Definition: domesticoverlapfrombcrsmatrix.hh:414
This class creates and manages the foreign overlap given an initial list of border indices and a BCRS...
Definition: domesticoverlapfrombcrsmatrix.hh:51
int Index
The type of an index of a degree of freedom.
Definition: overlaptypes.hh:43
int overlapSize() const
Returns the size of the overlap region.
Definition: foreignoverlapfrombcrsmatrix.hh:141
int myRank() const
Returns the rank of the current process.
Definition: domesticoverlapfrombcrsmatrix.hh:127
int numLocal() const
Returns the number of local indices.
Definition: foreignoverlapfrombcrsmatrix.hh:277
This class maps domestic row indices to and from "global" indices which is used to construct an algeb...
int foreignOverlapSize(ProcessRank peerRank) const
Returns number of indices which are contained in the foreign overlap with a peer. ...
Definition: domesticoverlapfrombcrsmatrix.hh:345
bool isFrontFor(int peerRank, Index localIdx) const
Returns whether a given local index is on the front of a given peer rank.
Definition: foreignoverlapfrombcrsmatrix.hh:243
bool hasGlobalIndex(int globalIdx) const
Return true iff a given global index already exists.
Definition: globalindices.hh:180
bool peerHasIndex(int peerRank, Index localIdx) const
Returns true iff a local index is seen by a peer rank.
Definition: foreignoverlapfrombcrsmatrix.hh:215
int globalToDomestic(int globalIdx) const
Converts a global index to a domestic one.
Definition: globalindices.hh:97
int numBorder(int peerRank) const
Returns the number of indices on the border with a given peer rank.
Definition: domesticoverlapfrombcrsmatrix.hh:147
ForeignOverlap foreignOverlap_
Definition: domesticoverlapfrombcrsmatrix.hh:567
Expresses which degrees of freedom are blacklisted for the parallel linear solvers and which domestic...
void check() const
Definition: domesticoverlapfrombcrsmatrix.hh:87
bool isInOverlap(Index domesticIdx) const
Returns true if a given domestic index is either in the foreign or in the domestic overlap...
Definition: domesticoverlapfrombcrsmatrix.hh:316
unsigned ProcessRank
The type of the rank of a process.
Definition: overlaptypes.hh:48
bool isLocal(Index domesticIdx) const
Returns true iff a domestic index is local.
Definition: foreignoverlapfrombcrsmatrix.hh:283