Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
34namespace 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
41static 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.
65static 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;
113
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:"
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);
192
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 (UPstream::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 = UPstream::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 }
326 }
327
328 return (maxIndex+1);
329}
330
331
333(
334 labelList& map,
335 const label localSize,
336 const label offset,
337 const Map<label>& cMap,
338 const bool hasFlip
339)
340{
341 label maxIndex = -1;
342
343 // Transcribe the map
344 if (hasFlip)
345 {
346 for (label& val : map)
347 {
348 // Unflip indexed value
349 const label index = mag(val)-1;
350 if (index < localSize)
351 {
352 // Local element
353 if (val < 0)
354 {
355 val -= offset;
356 }
357 else
358 {
359 val += offset;
360 }
361 }
362 else
363 {
364 // Remote element
365 if (val < 0)
366 {
367 val = -cMap[index]-1;
368 }
369 else
370 {
371 val = cMap[index]+1;
372 }
373 }
374 maxIndex = max(maxIndex, mag(val)-1);
375 }
376 }
377 else
378 {
379 for (label& val : map)
380 {
381 // Get indexed value (no flipping)
382 if (val < localSize)
383 {
384 val += offset;
385 }
386 else
387 {
388 val = cMap[val];
389 }
390 maxIndex = max(maxIndex, val);
392 }
393
394 return (maxIndex+1);
395}
396
397
399(
400 labelListList& mapElements,
401 const label localSize,
402 const label offset,
403 const Map<label>& cMap,
404 const bool hasFlip
405)
406{
407 label maxIndex = -1;
408
409 // Transcribe the map
410 for (labelList& map : mapElements)
411 {
412 maxIndex = max
413 (
414 maxIndex,
415 renumberMap
416 (
417 map,
418 localSize,
419 offset,
420 cMap,
421 hasFlip
422 )
423 );
424 }
425
426 return (maxIndex+1);
427}
428
429
430void Foam::mapDistributeBase::renumberVisitOrder
431(
432 const labelUList& origElements,
433 labelList& oldToNew,
434 labelListList& maps,
435 const bool hasFlip
436)
437{
438 // Both oldToNew and maps refer to compacted numbers in simple
439 // ascending order, but we want to recover the original walk order.
440
441 // CAUTION:
442 // The following is ill-defined (ie, really bad idea) if the original
443 // elements contained duplicates!
444
445 // Inverse mapping:
446 // Original id -> compact id -> walked id
447
448 labelList compactToWalkOrder(origElements.size(), -1);
449
450 forAll(origElements, walkIndex)
451 {
452 const label origIndex = origElements[walkIndex];
453 const label compactIndex = oldToNew[origIndex];
454
455 if (compactIndex >= origElements.size())
456 {
458 << "Compact index: " << compactIndex
459 << " is not represented in the original ("
460 << origElements.size()
461 << ") elements - indicates an addressing problem" << nl
463 }
464 else if (compactIndex >= 0)
465 {
466 compactToWalkOrder[compactIndex] = walkIndex;
467 oldToNew[origIndex] = walkIndex;
468 }
469 }
470
471 renumberMap(maps, compactToWalkOrder, hasFlip);
472}
473
474
475// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
476
477void Foam::mapDistributeBase::calcCompactDataRequirements
478(
479 const bitSet& allowedLocalElems,
480 const bitSet& allowedRemoteElems,
481 List<bitSet>& sendMasks, // [out]
482 List<bitSet>& recvMasks, // [out]
483 const int tag
484)
485{
486 sendMasks.resize_nocopy(UPstream::nProcs(comm_));
487 recvMasks.resize_nocopy(UPstream::nProcs(comm_));
488
489 // Determine local elements sent to which procs
491 (
492 allowedLocalElems,
493 sendMasks,
494 subMap_,
495 subHasFlip_
496 );
497
498 // Determine remote elements received from which procs
500 (
501 allowedRemoteElems,
502 recvMasks,
503 constructMap_,
504 constructHasFlip_
505 );
506
507 // Synchronize - combine as '&' union
508 unionCombineMasks(sendMasks, recvMasks, tag, comm_);
509}
510
511
512void Foam::mapDistributeBase::calcCompactLocalDataRequirements
513(
514 const bitSet& allowedLocalElems,
515 List<bitSet>& sendMasks, // [out]
516 List<bitSet>& recvMasks, // [out]
517 const int tag
518)
519{
520 sendMasks.resize_nocopy(UPstream::nProcs(comm_));
521 recvMasks.resize_nocopy(UPstream::nProcs(comm_));
522
523 // Determine local elements sent to which procs
525 (
526 allowedLocalElems,
527 sendMasks,
528 subMap_,
529 subHasFlip_
530 );
531
532 blankElementMasks(recvMasks, constructMap_);
533
534 // Exchange: from sendMasks -> recvMasks
535 exchangeMasks(sendMasks, recvMasks, tag, comm_);
536}
537
538
539void Foam::mapDistributeBase::calcCompactRemoteDataRequirements
540(
541 const bitSet& allowedRemoteElems,
542 List<bitSet>& sendMasks, // [out]
543 List<bitSet>& recvMasks, // [out]
544 const int tag
545)
546{
547 sendMasks.resize_nocopy(UPstream::nProcs(comm_));
548 recvMasks.resize_nocopy(UPstream::nProcs(comm_));
549
550 // Determine remote elements received from which procs
552 (
553 allowedRemoteElems,
554 recvMasks,
555 constructMap_,
556 constructHasFlip_
557 );
558
559 blankElementMasks(sendMasks, subMap_);
560
561 // Exchange: from recvMasks -> sendMasks
562 exchangeMasks(recvMasks, sendMasks, tag, comm_);
563}
564
565
566// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
567
568void Foam::mapDistributeBase::compactData
569(
570 const UList<bitSet>& sendMasks,
571 const UList<bitSet>& recvMasks,
572 labelList& oldToNewSub,
573 labelList& oldToNewConstruct,
574 const label localSize // (known) max sizing for subMap
575)
576{
577 // Linear address (subMap) after any flipping
578 const auto unflippedSendIndex =
579 (
580 subHasFlip_
581 ? [](label idx) -> label { return mag(idx)-1; }
582 : [](label idx) -> label { return idx; }
583 );
584
585 // Linear address (constructMap) after any flipping
586 const auto unflippedRecvIndex =
587 (
588 constructHasFlip_
589 ? [](label idx) -> label { return mag(idx)-1; }
590 : [](label idx) -> label { return idx; }
591 );
592
593
594 // Compact renumbering enabled if oldToNew maps are notNull
595
596 bitSet indexUsed;
597
598 // The subMap old-to-new mapping
599 if (notNull(oldToNewSub))
600 {
601 label subMapSize(localSize);
602 if (subMapSize < 0)
603 {
604 subMapSize = getMappedSize(subMap_, subHasFlip_);
605 }
606
607 oldToNewSub.resize_nocopy(subMapSize);
608 oldToNewSub = -1;
609
610 indexUsed.reset(); // zero all bits
611 indexUsed.resize(subMapSize);
612
613 forAll(sendMasks, proci)
614 {
615 const bitSet& mask = sendMasks[proci];
616 const auto& map = subMap_[proci];
617
618 for (const label i : mask)
619 {
620 const label index = unflippedSendIndex(map[i]);
621
622 indexUsed.set(index);
623 }
624 }
625
626 label nCompact = 0;
627 for (const label i : indexUsed)
628 {
629 oldToNewSub[i] = nCompact++;
630 }
631 }
632
633
634 // The constructMap old-to-new mapping
635 if (notNull(oldToNewConstruct))
636 {
637 oldToNewConstruct.resize_nocopy(constructSize_);
638 oldToNewConstruct = -1;
639
640 indexUsed.reset(); // zero all bits
641 indexUsed.resize(constructSize_);
642
643 forAll(recvMasks, proci)
644 {
645 const bitSet& mask = recvMasks[proci];
646 const auto& map = constructMap_[proci];
647
648 for (const label i : mask)
649 {
650 const label index = unflippedRecvIndex(map[i]);
651
652 indexUsed.set(index);
653 }
654 }
655
656 label nCompact = 0;
657 for (const label i : indexUsed)
658 {
659 oldToNewConstruct[i] = nCompact++;
660 }
661 }
662
663
664 // Compact out subMap entries referring to unused elements
665 forAll(sendMasks, proci)
666 {
667 const bitSet& mask = sendMasks[proci];
668 labelList& map = subMap_[proci];
669
670 label nCompact = 0;
671
672 for (const label i : mask)
673 {
674 // const label index = unflippedSendIndex(map[i]);
675 // maxLocalIndex = max(maxLocalIndex, index);
676
677 map[nCompact++] = map[i];
678 }
679
680 map.resize(nCompact);
681 }
682
683
684 // Compact out constructMap entries referring to unused elements
685
686 label maxRemoteIndex = -1;
687
688 forAll(recvMasks, proci)
689 {
690 const bitSet& mask = recvMasks[proci];
691 labelList& map = constructMap_[proci];
692
693 label nCompact = 0;
694
695 for (const label i : mask)
696 {
697 const label index = unflippedRecvIndex(map[i]);
698 maxRemoteIndex = max(maxRemoteIndex, index);
699
700 map[nCompact++] = map[i];
701 }
702
703 map.resize(nCompact);
704 }
705
706 constructSize_ = maxRemoteIndex+1;
707
708
709 // Do compact renumbering...
710
711 if (notNull(oldToNewSub))
712 {
713 renumberMap(subMap_, oldToNewSub, subHasFlip_);
714 }
715
716 if (notNull(oldToNewConstruct))
717 {
718 constructSize_ =
719 renumberMap(constructMap_, oldToNewConstruct, constructHasFlip_);
721
722 // Clear the schedule (note:not necessary if nothing changed)
723 schedulePtr_.reset(nullptr);
724}
725
726
727void Foam::mapDistributeBase::compactData
728(
729 const labelUList& localElements,
730 const labelUList& remoteElements,
731 labelList& oldToNewSub,
732 labelList& oldToNewConstruct,
733 const label localSize,
734 const int tag
735)
736{
737 List<bitSet> sendMasks;
738 List<bitSet> recvMasks;
739
740 calcCompactDataRequirements
741 (
742 bitSet(localElements),
743 bitSet(remoteElements),
744 sendMasks,
745 recvMasks,
746 tag
747 );
748
749 // Perform compaction and renumbering
750 compactData
751 (
752 sendMasks,
753 recvMasks,
754 oldToNewSub,
755 oldToNewConstruct,
756 localSize
757 );
758
759 // Renumber according to visit order
760 renumberVisitOrder
761 (
762 localElements,
763 oldToNewSub,
764 subMap_,
765 subHasFlip_
766 );
767
768 // Renumber according to visit order
769 renumberVisitOrder
770 (
771 remoteElements,
772 oldToNewConstruct,
773 constructMap_,
774 constructHasFlip_
775 );
776}
777
778
780(
781 const labelUList& localElements,
782 labelList& oldToNewSub,
783 labelList& oldToNewConstruct,
784 const label localSize,
785 const int tag
786)
787{
788 List<bitSet> sendMasks;
789 List<bitSet> recvMasks;
790
791 calcCompactLocalDataRequirements
792 (
793 // Retain items required on the local side
794 bitSet(localElements),
795 sendMasks,
796 recvMasks,
797 tag
798 );
799
800 // Perform compaction and renumbering
801 compactData
802 (
803 sendMasks,
804 recvMasks,
805 oldToNewSub,
806 oldToNewConstruct,
807 localSize
808 );
809
810 // Renumber according to visit order
811 renumberVisitOrder
812 (
813 localElements,
814 oldToNewSub,
815 subMap_,
816 subHasFlip_
817 );
818}
819
820
822(
823 const labelUList& remoteElements,
824 labelList& oldToNewSub,
825 labelList& oldToNewConstruct,
826 const label localSize,
827 const int tag
828)
829{
830 List<bitSet> sendMasks;
831 List<bitSet> recvMasks;
832
833 calcCompactRemoteDataRequirements
834 (
835 // Retain items required on the remote side
836 bitSet(remoteElements),
837 sendMasks,
838 recvMasks,
839 tag
840 );
841
842 // Perform compaction and renumbering
843 compactData
844 (
845 sendMasks,
846 recvMasks,
847 oldToNewSub,
848 oldToNewConstruct,
849 localSize
850 );
851
852 // Renumber according to visit order
853 renumberVisitOrder
854 (
855 remoteElements,
856 oldToNewConstruct,
857 constructMap_,
858 constructHasFlip_
859 );
860}
861
862
863void Foam::mapDistributeBase::compactDataImpl
864(
865 const UList<bitSet>& sendMasks,
866 const UList<bitSet>& recvMasks,
867 const bool doRenumber
868)
869{
870 if (doRenumber)
871 {
872 labelList oldToNewSub;
873 labelList oldToNewConstruct;
874
875 compactData
876 (
877 sendMasks,
878 recvMasks,
879 oldToNewSub,
880 oldToNewConstruct,
881 -1 // localSize: automatic
882 );
883 }
884 else
885 {
886 // Call with placeholder values
887 compactData
888 (
889 sendMasks,
890 recvMasks,
891 const_cast<labelList&>(labelList::null()), // disabled
892 const_cast<labelList&>(labelList::null()), // disabled
893 -1 // localSize: automatic
894 );
895 }
896}
897
898
900(
901 const bitSet& allowedLocalElems,
902 const int tag,
903 const bool doRenumber
904)
905{
906 List<bitSet> sendMasks;
907 List<bitSet> recvMasks;
908
909 calcCompactLocalDataRequirements
910 (
911 allowedLocalElems,
912 sendMasks,
913 recvMasks,
914 tag
915 );
916
917 compactDataImpl(sendMasks, recvMasks, doRenumber);
918}
919
920
922(
923 const bitSet& allowedRemoteElems,
924 const int tag,
925 const bool doRenumber
926)
927{
928 List<bitSet> sendMasks;
929 List<bitSet> recvMasks;
930
931 calcCompactRemoteDataRequirements
932 (
933 allowedRemoteElems,
934 sendMasks,
935 recvMasks,
936 tag
937 );
938
939 compactDataImpl(sendMasks, recvMasks, doRenumber);
940}
941
942
944(
945 const bitSet& allowedLocalElems,
946 labelList& oldToNewSub,
947 labelList& oldToNewConstruct,
948 const label localSize,
949 const int tag
950)
951{
952 List<bitSet> sendMasks;
953 List<bitSet> recvMasks;
954
955 calcCompactLocalDataRequirements
956 (
957 allowedLocalElems,
958 sendMasks,
959 recvMasks,
960 tag
961 );
962
963 compactData
964 (
965 sendMasks,
966 recvMasks,
967 oldToNewSub,
968 oldToNewConstruct,
969 localSize
970 );
971}
972
973
975(
976 const bitSet& allowedRemoteElems,
977 labelList& oldToNewSub,
978 labelList& oldToNewConstruct,
979 const label localSize,
980 const int tag
981)
982{
983 List<bitSet> sendMasks;
984 List<bitSet> recvMasks;
985
986 calcCompactRemoteDataRequirements
987 (
988 allowedRemoteElems,
989 sendMasks,
990 recvMasks,
991 tag
992 );
993
994 compactData
995 (
996 sendMasks,
997 recvMasks,
998 oldToNewSub,
999 oldToNewConstruct,
1000 localSize
1001 );
1002}
1003
1004
1005// * * * * * * * * * * * * * * * Housekeeping * * * * * * * * * * * * * * * //
1006
1008(
1009 const boolList& remoteElemUsed,
1010 const int tag
1012{
1013 // Forward to bitSet version
1014 compactRemoteData(bitSet(remoteElemUsed), tag);
1015}
1016
1017
1019(
1020 const boolList& remoteElemUsed,
1021 const label localSize,
1022 labelList& oldToNewSub,
1023 labelList& oldToNewConstruct,
1024 const int tag
1025)
1026{
1027 // Forward to bitSet version
1028 compactRemoteData
1029 (
1030 bitSet(remoteElemUsed),
1031 oldToNewSub,
1032 oldToNewConstruct,
1033 localSize,
1034 tag
1035 );
1036}
1037
1038
1039// ************************************************************************* //
Various functions to operate on Lists.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void resize(const label len)
Adjust allocated size of list.
Definition ListI.H:153
static const List< label > & null() noexcept
Definition List.H:138
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
void reset()
Clear all bits but do not adjust the addressable size.
static std::streamsize read(const UPstream::commsTypes commsType, const int fromProcNo, Type *buffer, std::streamsize count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr)
Receive buffer contents (contiguous types) from given processor.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
bool empty() const noexcept
True if List is empty (ie, size() is zero).
Definition UList.H:701
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
static bool write(const UPstream::commsTypes commsType, const int toProcNo, const Type *buffer, std::streamsize count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Write buffer contents (contiguous types only) to given processor.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
Definition UPstream.H:1706
static label nRequests() noexcept
Number of outstanding requests (on the internal list of requests).
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
Definition UPstream.H:84
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Definition UPstream.H:1669
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:1697
static void waitRequests()
Wait for all requests to finish.
Definition UPstream.H:2497
static bool & parRun() noexcept
Test if this a parallel run.
Definition UPstream.H:1681
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition bitSetI.H:502
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
Definition bitSet.H:334
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 label renumberMap(labelListList &mapElements, const labelUList &oldToNew, const bool hasFlip)
Helper for renumbering the (compacted) map elements using the supplied old-to-new mapping.
void compact(const boolList &remoteElemUsed, const int tag=UPstream::msgType())
OpenFOAM-v2112 and earlier naming for compactRemoteData() using boolList.
label comm() const noexcept
The communicator used.
static void exchangeMasks(const UList< bitSet > &sendMasks, UList< bitSet > &recvMasks, const int tag, const label comm)
Synchronize send/recv mask buffers as a 'copy' operation.
static void unionCombineMasks(UList< bitSet > &sendMasks, UList< bitSet > &recvMasks, const int tag, const label comm)
Bi-direction sync of send/recv buffers using bitwise '&=' combine operation.
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.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static void blankElementMasks(List< bitSet > &masks, const labelListList &maps)
errorManip< error > abort(error &err)
Definition errorManip.H:139
List< bool > boolList
A List of bools.
Definition List.H:60
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
bool notNull(const T *ptr) noexcept
True if ptr is not a pointer (of type T) to the nullObject.
Definition nullObject.H:267
UList< label > labelUList
A UList of labels.
Definition UList.H:75
static label calcElementMasks(const bitSet &allowedElems, List< bitSet > &masks, const labelListList &maps, const bool hasFlip)
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299