mapDistributeBaseSubset.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "mapDistributeBase.H"
29 #include "bitSet.H"
30 #include "ListOps.H"
31 
32 // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // Setup array of element masks to match maps sizes
38 //
39 // \param[out] masks Sized for each position in the maps
40 // \param maps The element maps
41 static void blankElementMasks(List<bitSet>& masks, const labelListList& maps)
42 {
43  // If base container not already sized
44  if (masks.empty())
45  {
46  masks.resize(maps.size());
47  }
48 
49  forAll(masks, proci)
50  {
51  masks[proci].reset(); // zero all bits
52  masks[proci].resize(maps[proci].size());
53  }
54 }
55 
56 
57 // Calculate the element mask correspondig to allowedElems in the maps
58 //
59 // \param allowedElems Permissible mapped elements (true/false)
60 // \param[out] masks True/false for each position within the maps
61 // \param maps The element maps
62 // \param hasFlip Map has flip indexing
63 //
64 // \return the max index used.
65 static label calcElementMasks
66 (
67  const bitSet& allowedElems,
68  List<bitSet>& masks, // [out] - often presized before calling
69  const labelListList& maps,
70  const bool hasFlip
71 )
72 {
73  // Index after flipping
74  const auto unflippedIndex =
75  (
76  hasFlip
77  ? [](label idx) -> label { return mag(idx)-1; }
78  : [](label idx) -> label { return idx; }
79  );
80 
81 
82  // If not already sized
83  if (masks.empty())
84  {
85  masks.resize(maps.size());
86  }
87 
88  label maxIndex = -1;
89 
90  forAll(masks, proci)
91  {
92  bitSet& mask = masks[proci];
93  const labelList& map = maps[proci];
94 
95  mask.reset(); // zero all bits
96  mask.resize(map.size());
97 
98  forAll(map, i)
99  {
100  // Element is used (or not)
101  const label index = unflippedIndex(map[i]);
102 
103  if (allowedElems.test(index))
104  {
105  mask.set(i);
106  maxIndex = max(maxIndex, index);
107  }
108  }
109  }
110 
111  return maxIndex;
112 }
114 } // End namespace Foam
115 
116 
117 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
118 
120 (
121  const UList<bitSet>& sendMasks,
122  UList<bitSet>& recvMasks,
123  const int tag,
124  const label comm
125 )
126 {
127  // Require properly sized mask buffers.
128  // The information *is* known from the maps, so always use that
129  // instead having a needless all-to-all for the sizes.
130 
131  if (sendMasks.size() != recvMasks.size())
132  {
134  << "Mismatched mask sizes: "
135  << sendMasks.size() << " != "
136  << recvMasks.size() << nl
138  }
139 
140  const label myRank = UPstream::myProcNo(comm);
141 
142  if (UPstream::parRun())
143  {
144  #ifdef FULLDEBUG
145  if (sendMasks.size() > UPstream::nProcs(comm))
146  {
148  << "Mask sizes (" << sendMasks.size()
149  << ") are larger than number of procs:"
150  << UPstream::nProcs(comm) << nl
152  }
153  #endif
154 
155  const label startOfRequests = UPstream::nRequests();
156 
157  forAll(recvMasks, proci)
158  {
159  if (proci != myRank && recvMasks[proci].size())
160  {
162  (
164  proci,
165  recvMasks[proci].data_bytes(),
166  recvMasks[proci].size_bytes(),
167  tag,
168  comm
169  );
170  }
171  }
172 
173  forAll(sendMasks, proci)
174  {
175  if (proci != myRank && sendMasks[proci].size())
176  {
178  (
180  proci,
181  sendMasks[proci].cdata_bytes(),
182  sendMasks[proci].size_bytes(),
183  tag,
184  comm
185  );
186  }
187  }
188 
189  // Wait for outstanding requests
190  UPstream::waitRequests(startOfRequests);
191  }
193  // Receiving myself is just a copy
194  recvMasks[myRank] = sendMasks[myRank];
195 }
196 
197 
199 (
200  UList<bitSet>& sendMasks,
201  UList<bitSet>& recvMasks,
202  const int tag,
203  const label comm
204 )
205 {
206  // Require properly sized mask buffers.
207  // The information *is* known from the maps, so always use that
208  // instead having a needless all-to-all for the sizes.
209 
210  if (sendMasks.size() != recvMasks.size())
211  {
213  << "Mismatched mask sizes: "
214  << sendMasks.size() << " != "
215  << recvMasks.size() << nl
217  }
218 
219  if (Pstream::parRun())
220  {
221  // Scratch buffers for union operations
222  List<bitSet> scratch(recvMasks.size());
223 
224  // Size for receives
225  forAll(scratch, proci)
226  {
227  scratch[proci].resize(recvMasks[proci].size());
228  }
229 
230  // Exchange: from sendMasks -> scratch (intermediate receive)
231  exchangeMasks(sendMasks, scratch, tag, comm);
232 
233  // Update recvMasks (as union)
234  forAll(recvMasks, proci)
235  {
236  recvMasks[proci] &= scratch[proci];
237  }
238 
239  // Size for sends
240  forAll(scratch, proci)
241  {
242  scratch[proci].resize(sendMasks[proci].size());
243  }
244 
245  // Exchange: from recvMasks -> scratch (intermediate send)
246  exchangeMasks(recvMasks, scratch, tag, comm);
247 
248  // Final synchronization
249  forAll(sendMasks, proci)
250  {
251  sendMasks[proci] &= scratch[proci];
252  }
253  }
254  else
255  {
256  // Non-parallel: 'synchronize' myself
257  const label myRank = Pstream::myProcNo(comm);
258 
259  recvMasks[myRank] &= sendMasks[myRank];
260  sendMasks[myRank] = recvMasks[myRank];
261  }
262 
263  // Done with parallel exchanges so can shrink the masks to
264  // the min-size actually needed.
265 
266  for (auto& mask : sendMasks)
267  {
268  mask.resize_last();
269  }
270 
271  for (auto& mask : recvMasks)
272  {
273  mask.resize_last();
274  }
275 }
276 
277 
278 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
279 
281 (
282  labelListList& mapElements,
283  const labelUList& oldToNew,
284  const bool hasFlip
285 )
286 {
287  label maxIndex = -1;
288 
289  // Transcribe the map
290  if (hasFlip)
291  {
292  for (labelList& map : mapElements)
293  {
294  for (label& val : map)
295  {
296  // Unflip indexed value
297  const label index = oldToNew[mag(val)-1];
298 
299  if (index >= 0) // Not certain this check is needed
300  {
301  maxIndex = max(maxIndex, index);
302 
303  // Retain flip information from original
304  val = (val < 0 ? (-index-1) : (index+1));
305  }
306  }
307  }
308  }
309  else
310  {
311  for (labelList& map : mapElements)
312  {
313  for (label& val : map)
314  {
315  // Get indexed value (no flipping)
316 
317  const label index = oldToNew[val];
318 
319  if (index >= 0) // Not certain this check is needed
320  {
321  maxIndex = max(maxIndex, index);
322  val = index;
323  }
324  }
325  }
326  }
327 
328  return (maxIndex+1);
329 }
330 
331 
332 void Foam::mapDistributeBase::renumberVisitOrder
333 (
334  const labelUList& origElements,
335  labelList& oldToNew,
336  labelListList& maps,
337  const bool hasFlip
338 )
339 {
340  // Both oldToNew and maps refer to compacted numbers in simple
341  // ascending order, but we want to recover the original walk order.
342 
343  // CAUTION:
344  // The following is ill-defined (ie, really bad idea) if the original
345  // elements contained duplicates!
346 
347  // Inverse mapping:
348  // Original id -> compact id -> walked id
349 
350  labelList compactToWalkOrder(origElements.size(), -1);
351 
352  forAll(origElements, walkIndex)
353  {
354  const label origIndex = origElements[walkIndex];
355  const label compactIndex = oldToNew[origIndex];
356 
357  if (compactIndex >= origElements.size())
358  {
360  << "Compact index: " << compactIndex
361  << " is not represented in the original ("
362  << origElements.size()
363  << ") elements - indicates an addressing problem" << nl
365  }
366  else if (compactIndex >= 0)
367  {
368  compactToWalkOrder[compactIndex] = walkIndex;
369  oldToNew[origIndex] = walkIndex;
370  }
371  }
372 
373  renumberMap(maps, compactToWalkOrder, hasFlip);
374 }
375 
376 
377 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
378 
379 void Foam::mapDistributeBase::calcCompactDataRequirements
380 (
381  const bitSet& allowedLocalElems,
382  const bitSet& allowedRemoteElems,
383  List<bitSet>& sendMasks, // [out]
384  List<bitSet>& recvMasks, // [out]
385  const int tag
386 )
387 {
388  sendMasks.resize_nocopy(UPstream::nProcs(comm_));
389  recvMasks.resize_nocopy(UPstream::nProcs(comm_));
390 
391  // Determine local elements sent to which procs
393  (
394  allowedLocalElems,
395  sendMasks,
396  subMap_,
397  subHasFlip_
398  );
399 
400  // Determine remote elements received from which procs
402  (
403  allowedRemoteElems,
404  recvMasks,
405  constructMap_,
406  constructHasFlip_
407  );
408 
409  // Synchronize - combine as '&' union
410  unionCombineMasks(sendMasks, recvMasks, tag, comm_);
411 }
412 
413 
414 void Foam::mapDistributeBase::calcCompactLocalDataRequirements
415 (
416  const bitSet& allowedLocalElems,
417  List<bitSet>& sendMasks, // [out]
418  List<bitSet>& recvMasks, // [out]
419  const int tag
420 )
421 {
422  sendMasks.resize_nocopy(UPstream::nProcs(comm_));
423  recvMasks.resize_nocopy(UPstream::nProcs(comm_));
424 
425  // Determine local elements sent to which procs
427  (
428  allowedLocalElems,
429  sendMasks,
430  subMap_,
431  subHasFlip_
432  );
433 
434  blankElementMasks(recvMasks, constructMap_);
435 
436  // Exchange: from sendMasks -> recvMasks
437  exchangeMasks(sendMasks, recvMasks, tag, comm_);
438 }
439 
440 
441 void Foam::mapDistributeBase::calcCompactRemoteDataRequirements
442 (
443  const bitSet& allowedRemoteElems,
444  List<bitSet>& sendMasks, // [out]
445  List<bitSet>& recvMasks, // [out]
446  const int tag
447 )
448 {
449  sendMasks.resize_nocopy(UPstream::nProcs(comm_));
450  recvMasks.resize_nocopy(UPstream::nProcs(comm_));
451 
452  // Determine remote elements received from which procs
454  (
455  allowedRemoteElems,
456  recvMasks,
457  constructMap_,
458  constructHasFlip_
459  );
460 
461  blankElementMasks(sendMasks, subMap_);
462 
463  // Exchange: from recvMasks -> sendMasks
464  exchangeMasks(recvMasks, sendMasks, tag, comm_);
465 }
466 
467 
468 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
469 
470 void Foam::mapDistributeBase::compactData
471 (
472  const UList<bitSet>& sendMasks,
473  const UList<bitSet>& recvMasks,
474  labelList& oldToNewSub,
475  labelList& oldToNewConstruct,
476  const label localSize // (known) max sizing for subMap
477 )
478 {
479  // Linear address (subMap) after any flipping
480  const auto unflippedSendIndex =
481  (
482  subHasFlip_
483  ? [](label idx) -> label { return mag(idx)-1; }
484  : [](label idx) -> label { return idx; }
485  );
486 
487  // Linear address (constructMap) after any flipping
488  const auto unflippedRecvIndex =
489  (
490  constructHasFlip_
491  ? [](label idx) -> label { return mag(idx)-1; }
492  : [](label idx) -> label { return idx; }
493  );
494 
495 
496  // Compact renumbering enabled if oldToNew maps are notNull
497 
498  bitSet indexUsed;
499 
500  // The subMap old-to-new mapping
501  if (notNull(oldToNewSub))
502  {
503  label subMapSize(localSize);
504  if (subMapSize < 0)
505  {
506  subMapSize = getMappedSize(subMap_, subHasFlip_);
507  }
508 
509  oldToNewSub.resize_nocopy(subMapSize);
510  oldToNewSub = -1;
511 
512  indexUsed.reset(); // zero all bits
513  indexUsed.resize(subMapSize);
514 
515  forAll(sendMasks, proci)
516  {
517  const bitSet& mask = sendMasks[proci];
518  const auto& map = subMap_[proci];
519 
520  for (const label i : mask)
521  {
522  const label index = unflippedSendIndex(map[i]);
523 
524  indexUsed.set(index);
525  }
526  }
527 
528  label nCompact = 0;
529  for (const label i : indexUsed)
530  {
531  oldToNewSub[i] = nCompact++;
532  }
533  }
534 
535 
536  // The constructMap old-to-new mapping
537  if (notNull(oldToNewConstruct))
538  {
539  oldToNewConstruct.resize_nocopy(constructSize_);
540  oldToNewConstruct = -1;
541 
542  indexUsed.reset(); // zero all bits
543  indexUsed.resize(constructSize_);
544 
545  forAll(recvMasks, proci)
546  {
547  const bitSet& mask = recvMasks[proci];
548  const auto& map = constructMap_[proci];
549 
550  for (const label i : mask)
551  {
552  const label index = unflippedRecvIndex(map[i]);
553 
554  indexUsed.set(index);
555  }
556  }
557 
558  label nCompact = 0;
559  for (const label i : indexUsed)
560  {
561  oldToNewConstruct[i] = nCompact++;
562  }
563  }
564 
565 
566  // Compact out subMap entries referring to unused elements
567  forAll(sendMasks, proci)
568  {
569  const bitSet& mask = sendMasks[proci];
570  labelList& map = subMap_[proci];
571 
572  label nCompact = 0;
573 
574  for (const label i : mask)
575  {
576  // const label index = unflippedSendIndex(map[i]);
577  // maxLocalIndex = max(maxLocalIndex, index);
578 
579  map[nCompact++] = map[i];
580  }
581 
582  map.resize(nCompact);
583  }
584 
585 
586  // Compact out constructMap entries referring to unused elements
587 
588  label maxRemoteIndex = -1;
589 
590  forAll(recvMasks, proci)
591  {
592  const bitSet& mask = recvMasks[proci];
593  labelList& map = constructMap_[proci];
594 
595  label nCompact = 0;
596 
597  for (const label i : mask)
598  {
599  const label index = unflippedRecvIndex(map[i]);
600  maxRemoteIndex = max(maxRemoteIndex, index);
601 
602  map[nCompact++] = map[i];
603  }
604 
605  map.resize(nCompact);
606  }
607 
608  constructSize_ = maxRemoteIndex+1;
609 
610 
611  // Do compact renumbering...
612 
613  if (notNull(oldToNewSub))
614  {
615  renumberMap(subMap_, oldToNewSub, subHasFlip_);
616  }
617 
618  if (notNull(oldToNewConstruct))
619  {
620  constructSize_ =
621  renumberMap(constructMap_, oldToNewConstruct, constructHasFlip_);
622  }
624  // Clear the schedule (note:not necessary if nothing changed)
625  schedulePtr_.reset(nullptr);
626 }
627 
628 
629 void Foam::mapDistributeBase::compactData
630 (
631  const labelUList& localElements,
632  const labelUList& remoteElements,
633  labelList& oldToNewSub,
634  labelList& oldToNewConstruct,
635  const label localSize,
636  const int tag
637 )
638 {
639  List<bitSet> sendMasks;
640  List<bitSet> recvMasks;
641 
642  calcCompactDataRequirements
643  (
644  bitSet(localElements),
645  bitSet(remoteElements),
646  sendMasks,
647  recvMasks,
648  tag
649  );
650 
651  // Perform compaction and renumbering
652  compactData
653  (
654  sendMasks,
655  recvMasks,
656  oldToNewSub,
657  oldToNewConstruct,
658  localSize
659  );
660 
661  // Renumber according to visit order
662  renumberVisitOrder
663  (
664  localElements,
665  oldToNewSub,
666  subMap_,
667  subHasFlip_
668  );
669 
670  // Renumber according to visit order
671  renumberVisitOrder
672  (
673  remoteElements,
674  oldToNewConstruct,
675  constructMap_,
676  constructHasFlip_
677  );
678 }
679 
680 
682 (
683  const labelUList& localElements,
684  labelList& oldToNewSub,
685  labelList& oldToNewConstruct,
686  const label localSize,
687  const int tag
688 )
689 {
690  List<bitSet> sendMasks;
691  List<bitSet> recvMasks;
692 
693  calcCompactLocalDataRequirements
694  (
695  // Retain items required on the local side
696  bitSet(localElements),
697  sendMasks,
698  recvMasks,
699  tag
700  );
701 
702  // Perform compaction and renumbering
703  compactData
704  (
705  sendMasks,
706  recvMasks,
707  oldToNewSub,
708  oldToNewConstruct,
709  localSize
710  );
711 
712  // Renumber according to visit order
713  renumberVisitOrder
714  (
715  localElements,
716  oldToNewSub,
717  subMap_,
718  subHasFlip_
719  );
720 }
721 
722 
724 (
725  const labelUList& remoteElements,
726  labelList& oldToNewSub,
727  labelList& oldToNewConstruct,
728  const label localSize,
729  const int tag
730 )
731 {
732  List<bitSet> sendMasks;
733  List<bitSet> recvMasks;
734 
735  calcCompactRemoteDataRequirements
736  (
737  // Retain items required on the remote side
738  bitSet(remoteElements),
739  sendMasks,
740  recvMasks,
741  tag
742  );
743 
744  // Perform compaction and renumbering
745  compactData
746  (
747  sendMasks,
748  recvMasks,
749  oldToNewSub,
750  oldToNewConstruct,
751  localSize
752  );
753 
754  // Renumber according to visit order
755  renumberVisitOrder
756  (
757  remoteElements,
758  oldToNewConstruct,
759  constructMap_,
760  constructHasFlip_
761  );
762 }
763 
764 
765 void Foam::mapDistributeBase::compactDataImpl
766 (
767  const UList<bitSet>& sendMasks,
768  const UList<bitSet>& recvMasks,
769  const bool doRenumber
770 )
771 {
772  if (doRenumber)
773  {
774  labelList oldToNewSub;
775  labelList oldToNewConstruct;
776 
777  compactData
778  (
779  sendMasks,
780  recvMasks,
781  oldToNewSub,
782  oldToNewConstruct,
783  -1 // localSize: automatic
784  );
785  }
786  else
787  {
788  // Call with placeholder values
789  compactData
790  (
791  sendMasks,
792  recvMasks,
793  const_cast<labelList&>(labelList::null()), // disabled
794  const_cast<labelList&>(labelList::null()), // disabled
795  -1 // localSize: automatic
796  );
797  }
798 }
799 
800 
802 (
803  const bitSet& allowedLocalElems,
804  const int tag,
805  const bool doRenumber
806 )
807 {
808  List<bitSet> sendMasks;
809  List<bitSet> recvMasks;
810 
811  calcCompactLocalDataRequirements
812  (
813  allowedLocalElems,
814  sendMasks,
815  recvMasks,
816  tag
817  );
818 
819  compactDataImpl(sendMasks, recvMasks, doRenumber);
820 }
821 
822 
824 (
825  const bitSet& allowedRemoteElems,
826  const int tag,
827  const bool doRenumber
828 )
829 {
830  List<bitSet> sendMasks;
831  List<bitSet> recvMasks;
832 
833  calcCompactRemoteDataRequirements
834  (
835  allowedRemoteElems,
836  sendMasks,
837  recvMasks,
838  tag
839  );
840 
841  compactDataImpl(sendMasks, recvMasks, doRenumber);
842 }
843 
844 
846 (
847  const bitSet& allowedLocalElems,
848  labelList& oldToNewSub,
849  labelList& oldToNewConstruct,
850  const label localSize,
851  const int tag
852 )
853 {
854  List<bitSet> sendMasks;
855  List<bitSet> recvMasks;
856 
857  calcCompactLocalDataRequirements
858  (
859  allowedLocalElems,
860  sendMasks,
861  recvMasks,
862  tag
863  );
864 
865  compactData
866  (
867  sendMasks,
868  recvMasks,
869  oldToNewSub,
870  oldToNewConstruct,
871  localSize
872  );
873 }
874 
875 
877 (
878  const bitSet& allowedRemoteElems,
879  labelList& oldToNewSub,
880  labelList& oldToNewConstruct,
881  const label localSize,
882  const int tag
883 )
884 {
885  List<bitSet> sendMasks;
886  List<bitSet> recvMasks;
887 
888  calcCompactRemoteDataRequirements
889  (
890  allowedRemoteElems,
891  sendMasks,
892  recvMasks,
893  tag
894  );
895 
896  compactData
897  (
898  sendMasks,
899  recvMasks,
900  oldToNewSub,
901  oldToNewConstruct,
902  localSize
903  );
904 }
905 
906 
907 // * * * * * * * * * * * * * * * Housekeeping * * * * * * * * * * * * * * * //
908 
910 (
911  const boolList& remoteElemUsed,
912  const int tag
913 )
914 {
915  // Forward to bitSet version
916  compactRemoteData(bitSet(remoteElemUsed), tag);
917 }
918 
919 
921 (
922  const boolList& remoteElemUsed,
923  const label localSize,
924  labelList& oldToNewSub,
925  labelList& oldToNewConstruct,
926  const int tag
927 )
928 {
929  // Forward to bitSet version
930  compactRemoteData
931  (
932  bitSet(remoteElemUsed),
933  oldToNewSub,
934  oldToNewConstruct,
935  localSize,
936  tag
937  );
938 }
939 
940 
941 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
void compactLocalData(const bitSet &allowedLocalElems, const int tag=UPstream::msgType(), const bool doRenumber=false)
Compact send/receive maps based on selection of originating local (send) elements.
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:571
static label read(const UPstream::commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, UPstream::Request *req=nullptr)
Read buffer contents from given processor.
Definition: UIPstreamRead.C:35
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:132
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
static label nRequests() noexcept
Number of outstanding requests (on the internal list of requests)
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Definition: UList.H:632
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1004
label comm() const noexcept
The communicator used.
void compactRemoteData(const bitSet &allowedRemoteElems, const int tag=UPstream::msgType(), const bool doRenumber=false)
Compact send/receive maps based on selection of remote (receive) elements.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
Definition: UPstream.H:1029
static const List< label > & null()
Return a null List.
Definition: ListI.H:102
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
static void waitRequests()
Wait for all requests to finish.
Definition: UPstream.H:1536
UList< label > labelUList
A UList of labels.
Definition: UList.H:78
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
Definition: PackedListI.H:388
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:414
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
Definition: UPstream.H:1020
static void exchangeMasks(const UList< bitSet > &sendMasks, UList< bitSet > &recvMasks, const int tag, const label comm)
Synchronize send/recv mask buffers as a &#39;copy&#39; operation.
void compact(const boolList &remoteElemUsed, const int tag=UPstream::msgType())
OpenFOAM-v2112 and earlier naming for compactRemoteData() using boolList.
static label calcElementMasks(const bitSet &allowedElems, List< bitSet > &masks, const labelListList &maps, const bool hasFlip)
errorManip< error > abort(error &err)
Definition: errorManip.H:139
static void blankElementMasks(List< bitSet > &masks, const labelListList &maps)
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
Definition: bitSet.H:341
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:99
static void unionCombineMasks(UList< bitSet > &sendMasks, UList< bitSet > &recvMasks, const int tag, const label comm)
Bi-direction sync of send/recv buffers using bitwise &#39;&=&#39; combine operation.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
static bool write(const UPstream::commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Write buffer contents to given processor.
"nonBlocking" : (MPI_Isend, MPI_Irecv)
void reset()
Clear all bits but do not adjust the addressable size.
Definition: PackedListI.H:484
List< label > labelList
A List of labels.
Definition: List.H:62
bool notNull(const T *ptr)
True if ptr is not a pointer (of type T) to the nullObject.
Definition: nullObject.H:246
Namespace for OpenFOAM.
static label renumberMap(labelListList &mapElements, const labelUList &oldToNew, const bool hasFlip)
Helper for renumbering the (compacted) map elements using the supplied old-to-new mapping...