35 template<
class T,
class CombineOp,
class NegateOp>
42 const NegateOp& negOp,
52 label index = map[i]-1;
53 cop(lhs[index], rhs[i]);
57 label index = -map[i]-1;
58 cop(lhs[index], negOp(rhs[i]));
63 <<
"At index " << i <<
" out of " << map.
size()
64 <<
" have illegal index " << map[i]
65 <<
" for field " << rhs.
size() <<
" with flipMap" 74 cop(lhs[map[i]], rhs[i]);
80 template<
class T,
class NegateOp>
97 return negOp(
values[-index-1]);
102 <<
"Illegal index " << index
103 <<
" into field of size " <<
values.size()
104 <<
" with face-flipping" 113 template<
class T,
class NegateOp>
119 const NegateOp& negOp
122 const label len = indices.
size();
128 for (label i = 0; i < len; ++i)
130 const label index = indices[i];
143 <<
"Illegal index " << index
144 <<
" into field of size " <<
values.size()
153 for (label i = 0; i < len; ++i)
163 template<
class T,
class NegateOp>
168 const label constructSize,
170 const bool subHasFlip,
172 const bool constructHasFlip,
174 const NegateOp& negOp,
188 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
192 const labelList& map = constructMap[myRank];
194 field.setSize(constructSize);
219 if (domain != myRank && map.size())
232 accessAndFlip(
field, map, subHasFlip, negOp)
243 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
247 const labelList& map = constructMap[myRank];
249 field.setSize(constructSize);
265 const labelList& map = constructMap[domain];
267 if (domain != myRank && map.size())
277 List<T> subField(fromNbr);
279 checkReceivedSize(domain, map.size(), subField.size());
298 List<T> newField(constructSize);
304 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
308 const labelList& map = constructMap[myRank];
322 for (
const labelPair& twoProcs : schedule)
327 const label sendProc = twoProcs[0];
328 const label recvProc = twoProcs[1];
330 if (myRank == sendProc)
346 accessAndFlip(
field, map, subHasFlip, negOp)
360 List<T> subField(fromNbr);
362 const labelList& map = constructMap[recvProc];
364 checkReceivedSize(recvProc, map.size(), subField.size());
389 List<T> subField(fromNbr);
391 const labelList& map = constructMap[sendProc];
393 checkReceivedSize(sendProc, map.size(), subField.size());
418 accessAndFlip(
field, map, subHasFlip, negOp)
425 field.transfer(newField);
431 if (!is_contiguous<T>::value)
440 if (domain != myRank && map.size())
443 UOPstream toDomain(domain, pBufs);
447 accessAndFlip(
field, map, subHasFlip, negOp)
450 toDomain << subField;
455 pBufs.finishedSends(
false);
461 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
465 field.setSize(constructSize);
468 const labelList& map = constructMap[myRank];
487 const labelList& map = constructMap[domain];
489 if (domain != myRank && map.size())
491 UIPstream str(domain, pBufs);
492 List<T> recvField(str);
494 checkReceivedSize(domain, map.size(), recvField.size());
512 List<List<T>> sendFields(nProcs);
518 if (domain != myRank && map.size())
521 accessAndFlip(
field, map, subHasFlip, negOp);
527 sendFields[domain].cdata_bytes(),
528 sendFields[domain].size_bytes(),
537 List<List<T>> recvFields(nProcs);
541 const labelList& map = constructMap[domain];
543 if (domain != myRank && map.size())
545 recvFields[domain].
resize(map.size());
550 recvFields[domain].data_bytes(),
551 recvFields[domain].size_bytes(),
561 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp);
567 field.setSize(constructSize);
572 const labelList& map = constructMap[myRank];
573 const List<T>& subField = sendFields[myRank];
595 const labelList& map = constructMap[domain];
597 if (domain != myRank && map.size())
599 const List<T>& subField = recvFields[domain];
601 checkReceivedSize(domain, map.size(), subField.size());
619 <<
"Unknown communication schedule " << int(commsType)
625 template<
class T,
class CombineOp,
class NegateOp>
629 const List<labelPair>& schedule,
630 const label constructSize,
632 const bool subHasFlip,
634 const bool constructHasFlip,
637 const CombineOp& cop,
638 const NegateOp& negOp,
652 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
656 const labelList& map = constructMap[myRank];
658 field.resize_nocopy(constructSize);
661 flipAndCombine(map, constructHasFlip, subField, cop, negOp,
field);
676 if (domain != myRank && map.size())
688 accessAndFlip(
field, map, subHasFlip, negOp)
699 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
703 const labelList& map = constructMap[myRank];
705 field.resize_nocopy(constructSize);
722 const labelList& map = constructMap[domain];
724 if (domain != myRank && map.size())
734 List<T> subField(fromNbr);
736 checkReceivedSize(domain, map.size(), subField.size());
755 List<T> newField(constructSize, nullValue);
761 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
765 const labelList& map = constructMap[myRank];
780 for (
const labelPair& twoProcs : schedule)
785 const label sendProc = twoProcs[0];
786 const label recvProc = twoProcs[1];
788 if (myRank == sendProc)
805 accessAndFlip(
field, map, subHasFlip, negOp)
819 List<T> subField(fromNbr);
820 const labelList& map = constructMap[recvProc];
822 checkReceivedSize(recvProc, map.size(), subField.size());
847 List<T> subField(fromNbr);
848 const labelList& map = constructMap[sendProc];
850 checkReceivedSize(sendProc, map.size(), subField.size());
876 accessAndFlip(
field, map, subHasFlip, negOp)
883 field.transfer(newField);
889 if (!is_contiguous<T>::value)
898 if (domain != myRank && map.size())
901 UOPstream toDomain(domain, pBufs);
905 accessAndFlip(
field, map, subHasFlip, negOp)
908 toDomain << subField;
913 pBufs.finishedSends(
false);
919 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
923 field.resize_nocopy(constructSize);
927 const labelList& map = constructMap[myRank];
946 const labelList& map = constructMap[domain];
948 if (domain != myRank && map.size())
950 UIPstream str(domain, pBufs);
951 List<T> recvField(str);
953 checkReceivedSize(domain, map.size(), recvField.size());
971 List<List<T>> sendFields(nProcs);
977 if (domain != myRank && map.size())
980 accessAndFlip(
field, map, subHasFlip, negOp);
986 sendFields[domain].cdata_bytes(),
987 sendFields[domain].size_bytes(),
996 List<List<T>> recvFields(nProcs);
1000 const labelList& map = constructMap[domain];
1002 if (domain != myRank && map.size())
1004 recvFields[domain].
resize(map.size());
1009 recvFields[domain].data_bytes(),
1010 recvFields[domain].size_bytes(),
1019 sendFields[myRank] =
1020 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp);
1026 field.resize_nocopy(constructSize);
1031 const labelList& map = constructMap[myRank];
1032 const List<T>& subField = sendFields[myRank];
1054 const labelList& map = constructMap[domain];
1056 if (domain != myRank && map.size())
1058 const List<T>& subField = recvFields[domain];
1060 checkReceivedSize(domain, map.size(), subField.size());
1078 <<
"Unknown communication schedule " << int(commsType)
1096 UOPstream toDomain(domain, pBufs);
1100 accessAndFlip(
field, map, subHasFlip_, flipOp())
1103 toDomain << subField;
1108 pBufs.finishedSends(
false);
1117 field.resize_nocopy(constructSize_);
1121 const labelList& map = constructMap_[domain];
1128 if (recvField.
size() != map.
size())
1131 <<
"Expected from processor " << domain
1132 <<
" " << map.
size() <<
" but received " 1133 << recvField.
size() <<
" elements." 1151 template<
class T,
class NegateOp>
1156 const NegateOp& negOp,
1163 whichSchedule(commsType),
1177 template<
class T,
class NegateOp>
1183 const NegateOp& negOp,
1190 whichSchedule(commsType),
1206 template<
class T,
class NegateOp>
1210 const NegateOp& negOp,
1243 distribute(list, tag);
1253 const label constructSize,
1258 reverseDistribute<T, flipOp>
1269 template<
class T,
class NegateOp>
1273 const label constructSize,
1275 const NegateOp& negOp,
1282 whichSchedule(commsType),
1300 const label constructSize,
1309 whichSchedule(commsType),
1330 const label constructSize,
1348 const label constructSize,
List< labelList > labelListList
A List of labelList.
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)
Write buffer contents to given processor.
void size(const label n)
Older name for setAddressableSize.
"blocking" : (MPI_Bsend, MPI_Recv)
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
commsTypes
Types of communications.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void send(PstreamBuffers &pBufs, const List< T > &field) const
Do all sends using PstreamBuffers.
static label nRequests() noexcept
Number of outstanding requests.
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
static bool & parRun() noexcept
Test if this a parallel run.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
#define forAll(list, i)
Loop across all elements in list.
static void flipAndCombine(const labelUList &map, const bool hasFlip, const UList< T > &rhs, const CombineOp &cop, const NegateOp &negOp, List< T > &lhs)
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Input inter-processor communications stream using MPI send/recv etc. - operating on external buffer...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator) is 1 for serial run.
static T accessAndFlip(const UList< T > &values, const label index, const bool hasFlip, const NegateOp &negOp)
Lookup a field value at specified index and return its value after any flip negation operations...
"scheduled" : (MPI_Send, MPI_Recv)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
void reverseDistribute(const label constructSize, List< T > &values, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType and the default flip/negate operator.
errorManip< error > abort(error &err)
Pair< label > labelPair
A pair of labels.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
void receive(PstreamBuffers &pBufs, List< T > &field) const
Do all receives using PstreamBuffers.
static commsTypes defaultCommsType
Default commsType.
static void distribute(const Pstream::commsTypes commsType, const List< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &field, const NegateOp &negOp, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Distribute data with specified negate operator (for flips).
"nonBlocking" : (MPI_Isend, MPI_Irecv)
static Ostream & output(Ostream &os, const IntRange< T > &range)
List< label > labelList
A List of labels.
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Read buffer contents from given processor.
Functor to negate primitives. Dummy for most other types.