35template<
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]);
80template<
class T,
class NegateOp>
93 return values[index-1];
97 return negOp(values[-index-1]);
102 <<
"Illegal index " << index
103 <<
" into field of size " << values.size()
104 <<
" with face-flipping"
109 return values[index];
113template<
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];
134 output[i] = values[index-1];
138 output[i] = negOp(values[-index-1]);
143 <<
"Illegal index " << index
144 <<
" into field of size " << values.size()
153 for (label i = 0; i < len; ++i)
155 output[i] = values[indices[i]];
163template<
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())
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)
362 const labelList& map = constructMap[recvProc];
364 checkReceivedSize(recvProc, map.
size(), subField.
size());
391 const labelList& map = constructMap[sendProc];
393 checkReceivedSize(sendProc, map.
size(), subField.
size());
418 accessAndFlip(
field, map, subHasFlip, negOp)
425 field.transfer(newField);
440 if (domain != myRank && map.
size())
447 accessAndFlip(
field, map, subHasFlip, negOp)
450 toDomain << subField;
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())
494 checkReceivedSize(domain, map.
size(), recvField.
size());
518 if (domain != myRank && map.
size())
521 accessAndFlip(
field, map, subHasFlip, negOp);
527 sendFields[domain].cdata_bytes(),
528 sendFields[domain].size_bytes(),
541 const labelList& map = constructMap[domain];
543 if (domain != myRank && map.
size())
551 recvFields[domain].data_bytes(),
552 recvFields[domain].size_bytes(),
563 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp);
569 field.setSize(constructSize);
574 const labelList& map = constructMap[myRank];
575 const List<T>& subField = sendFields[myRank];
598 const labelList& map = constructMap[domain];
600 if (domain != myRank && map.
size())
602 const List<T>& subField = recvFields[domain];
604 checkReceivedSize(domain, map.
size(), subField.
size());
622 <<
"Unknown communication schedule " << int(commsType)
628template<
class T,
class CombineOp,
class NegateOp>
633 const label constructSize,
635 const bool subHasFlip,
637 const bool constructHasFlip,
640 const CombineOp& cop,
641 const NegateOp& negOp,
655 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
659 const labelList& map = constructMap[myRank];
661 field.resize_nocopy(constructSize);
664 flipAndCombine(map, constructHasFlip, subField, cop, negOp,
field);
679 if (domain != myRank && map.
size())
691 accessAndFlip(
field, map, subHasFlip, negOp)
702 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
706 const labelList& map = constructMap[myRank];
708 field.resize_nocopy(constructSize);
725 const labelList& map = constructMap[domain];
727 if (domain != myRank && map.
size())
739 checkReceivedSize(domain, map.
size(), subField.
size());
758 List<T> newField(constructSize, nullValue);
764 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
768 const labelList& map = constructMap[myRank];
783 for (
const labelPair& twoProcs : schedule)
788 const label sendProc = twoProcs[0];
789 const label recvProc = twoProcs[1];
791 if (myRank == sendProc)
808 accessAndFlip(
field, map, subHasFlip, negOp)
823 const labelList& map = constructMap[recvProc];
825 checkReceivedSize(recvProc, map.
size(), subField.
size());
851 const labelList& map = constructMap[sendProc];
853 checkReceivedSize(sendProc, map.
size(), subField.
size());
879 accessAndFlip(
field, map, subHasFlip, negOp)
886 field.transfer(newField);
901 if (domain != myRank && map.
size())
908 accessAndFlip(
field, map, subHasFlip, negOp)
911 toDomain << subField;
922 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp)
926 field.resize_nocopy(constructSize);
930 const labelList& map = constructMap[myRank];
949 const labelList& map = constructMap[domain];
951 if (domain != myRank && map.
size())
956 checkReceivedSize(domain, map.
size(), recvField.
size());
980 if (domain != myRank && map.
size())
983 accessAndFlip(
field, map, subHasFlip, negOp);
989 sendFields[domain].cdata_bytes(),
990 sendFields[domain].size_bytes(),
1003 const labelList& map = constructMap[domain];
1005 if (domain != myRank && map.
size())
1012 recvFields[domain].data_bytes(),
1013 recvFields[domain].size_bytes(),
1023 sendFields[myRank] =
1024 accessAndFlip(
field, subMap[myRank], subHasFlip, negOp);
1030 field.resize_nocopy(constructSize);
1035 const labelList& map = constructMap[myRank];
1036 const List<T>& subField = sendFields[myRank];
1059 const labelList& map = constructMap[domain];
1061 if (domain != myRank && map.
size())
1063 const List<T>& subField = recvFields[domain];
1065 checkReceivedSize(domain, map.
size(), subField.
size());
1083 <<
"Unknown communication schedule " << int(commsType)
1108 toDomain << subField;
1122 field.resize_nocopy(constructSize_);
1126 const labelList& map = constructMap_[domain];
1133 if (recvField.
size() != map.
size())
1136 <<
"Expected from processor " << domain
1137 <<
" " << map.
size() <<
" but received "
1138 << recvField.
size() <<
" elements."
1156template<
class T,
class NegateOp>
1161 const NegateOp& negOp,
1168 whichSchedule(commsType),
1182template<
class T,
class NegateOp>
1188 const NegateOp& negOp,
1195 whichSchedule(commsType),
1211template<
class T,
class NegateOp>
1215 const NegateOp& negOp,
1233 distribute(values,
flipOp(), tag);
1248 distribute(list, tag);
1250 values.setCapacity(list.
size());
1258 const label constructSize,
1263 reverseDistribute<T, flipOp>
1274template<
class T,
class NegateOp>
1278 const label constructSize,
1280 const NegateOp& negOp,
1287 whichSchedule(commsType),
1305 const label constructSize,
1314 whichSchedule(commsType),
1335 const label constructSize,
1353 const label constructSize,
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Input inter-processor communications stream.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(const label n)
Alias for resize()
void resize(const label len)
Adjust allocated size of list.
Output inter-processor communications stream.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
UPstream::rangeType allProcs() const noexcept
Range of ranks indices associated with PstreamBuffers.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
void finishedSends(const bool wait=true)
Mark sends as done.
virtual bool read()
Re-read model coefficients if they have changed.
void size(const label n)
Older name for setAddressableSize.
commsTypes
Types of communications.
@ nonBlocking
"nonBlocking"
static label nRequests()
Get number of outstanding requests.
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
static commsTypes defaultCommsType
Default commsType.
static bool & parRun() noexcept
Test if this a parallel run.
virtual bool write()
Write the output fields.
void send(PstreamBuffers &pBufs, const List< T > &field) const
Do all sends using PstreamBuffers.
void reverseDistribute(const label constructSize, List< T > &values, const int tag=UPstream::msgType()) const
static void flipAndCombine(const labelUList &map, const bool hasFlip, const UList< T > &rhs, const CombineOp &cop, const NegateOp &negOp, List< T > &lhs)
void receive(PstreamBuffers &pBufs, List< T > &field) const
Do all receives using PstreamBuffers.
static T accessAndFlip(const UList< T > &values, const label index, const bool hasFlip, const NegateOp &negOp)
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).
int myProcNo() const noexcept
Return processor number.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManip< error > abort(error &err)
static Ostream & output(Ostream &os, const IntRange< T > &range)
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define forAll(list, i)
Loop across all elements in list.
Functor to negate primitives. Dummy for most other types.
A template class to specify that a data type can be considered as being contiguous in memory.