33 template<
class T,
class CombineOp,
class negateOp>
40 const negateOp& negOp,
50 label index = map[i]-1;
51 cop(lhs[index], rhs[i]);
55 label index = -map[i]-1;
56 cop(lhs[index], negOp(rhs[i]));
61 <<
"At index " << i <<
" out of " << map.
size()
62 <<
" have illegal index " << map[i]
63 <<
" for field " << rhs.
size() <<
" with flipMap" 72 cop(lhs[map[i]], rhs[i]);
78 template<
class T,
class negateOp>
96 t = negOp(fld[-index-1]);
101 <<
"Illegal index " << index
102 <<
" into field of size " << fld.
size()
103 <<
" with face-flipping" 117 template<
class T,
class negateOp>
122 const label constructSize,
124 const bool subHasFlip,
126 const bool constructHasFlip,
128 const negateOp& negOp,
132 if (!Pstream::parRun())
136 const labelList& mySubMap = subMap[Pstream::myProcNo()];
141 subField[i] = accessAndFlip(field, mySubMap[i], subHasFlip, negOp);
145 const labelList& map = constructMap[Pstream::myProcNo()];
162 if (commsType == Pstream::commsTypes::blocking)
168 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
172 if (domain != Pstream::myProcNo() && map.
size())
174 OPstream toNbr(Pstream::commsTypes::blocking, domain, 0, tag);
179 subField[i] = accessAndFlip
192 const labelList& mySubMap = subMap[Pstream::myProcNo()];
197 subField[i] = accessAndFlip(field, mySubMap[i], subHasFlip, negOp);
201 const labelList& map = constructMap[Pstream::myProcNo()];
216 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
218 const labelList& map = constructMap[domain];
220 if (domain != Pstream::myProcNo() && map.
size())
222 IPstream fromNbr(Pstream::commsTypes::blocking, domain, 0, tag);
225 checkReceivedSize(domain, map.
size(), subField.
size());
239 else if (commsType == Pstream::commsTypes::scheduled)
244 List<T> newField(constructSize);
248 const labelList& mySubMap = subMap[Pstream::myProcNo()];
253 subField[i] = accessAndFlip
265 constructMap[Pstream::myProcNo()],
281 label sendProc = twoProcs[0];
282 label recvProc = twoProcs[1];
284 if (Pstream::myProcNo() == sendProc)
290 Pstream::commsTypes::scheduled,
300 subField[i] = accessAndFlip
313 Pstream::commsTypes::scheduled,
320 const labelList& map = constructMap[recvProc];
322 checkReceivedSize(recvProc, map.
size(), subField.
size());
341 Pstream::commsTypes::scheduled,
348 const labelList& map = constructMap[sendProc];
350 checkReceivedSize(sendProc, map.
size(), subField.
size());
365 Pstream::commsTypes::scheduled,
375 subField[i] = accessAndFlip
389 else if (commsType == Pstream::commsTypes::nonBlocking)
391 label nOutstanding = Pstream::nRequests();
393 if (!contiguous<T>())
398 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
402 if (domain != Pstream::myProcNo() && map.
size())
410 subField[i] = accessAndFlip
418 toDomain << subField;
427 const labelList& mySub = subMap[Pstream::myProcNo()];
431 mySubField[i] = accessAndFlip
443 const labelList& map = constructMap[Pstream::myProcNo()];
458 Pstream::waitRequests(nOutstanding);
461 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
463 const labelList& map = constructMap[domain];
465 if (domain != Pstream::myProcNo() && map.
size())
470 checkReceivedSize(domain, map.
size(), recvField.
size());
490 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
494 if (domain != Pstream::myProcNo() && map.
size())
496 List<T>& subField = sendFields[domain];
500 subField[i] = accessAndFlip
511 Pstream::commsTypes::nonBlocking,
513 reinterpret_cast<const char*>(subField.
begin()),
524 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
526 const labelList& map = constructMap[domain];
528 if (domain != Pstream::myProcNo() && map.
size())
533 Pstream::commsTypes::nonBlocking,
535 reinterpret_cast<char*>(recvFields[domain].begin()),
536 recvFields[domain].byteSize(),
546 const labelList& map = subMap[Pstream::myProcNo()];
548 List<T>& subField = sendFields[Pstream::myProcNo()];
552 subField[i] = accessAndFlip
570 const labelList& map = constructMap[Pstream::myProcNo()];
571 const List<T>& subField = sendFields[Pstream::myProcNo()];
587 Pstream::waitRequests(nOutstanding);
592 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
594 const labelList& map = constructMap[domain];
596 if (domain != Pstream::myProcNo() && map.
size())
598 const List<T>& subField = recvFields[domain];
600 checkReceivedSize(domain, map.
size(), subField.
size());
618 <<
"Unknown communication schedule " << int(commsType)
625 template<
class T,
class CombineOp,
class negateOp>
630 const label constructSize,
632 const bool subHasFlip,
634 const bool constructHasFlip,
636 const CombineOp& cop,
637 const negateOp& negOp,
642 if (!Pstream::parRun())
646 const labelList& mySubMap = subMap[Pstream::myProcNo()];
651 subField[i] = accessAndFlip(field, mySubMap[i], subHasFlip, negOp);
655 const labelList& map = constructMap[Pstream::myProcNo()];
660 flipAndCombine(map, constructHasFlip, subField, cop, negOp, field);
665 if (commsType == Pstream::commsTypes::blocking)
671 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
675 if (domain != Pstream::myProcNo() && map.
size())
677 OPstream toNbr(Pstream::commsTypes::blocking, domain, 0, tag);
681 subField[i] = accessAndFlip
694 const labelList& mySubMap = subMap[Pstream::myProcNo()];
699 subField[i] = accessAndFlip(field, mySubMap[i], subHasFlip, negOp);
703 const labelList& map = constructMap[Pstream::myProcNo()];
708 flipAndCombine(map, constructHasFlip, subField, cop, negOp, field);
711 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
713 const labelList& map = constructMap[domain];
715 if (domain != Pstream::myProcNo() && map.
size())
717 IPstream fromNbr(Pstream::commsTypes::blocking, domain, 0, tag);
720 checkReceivedSize(domain, map.
size(), subField.
size());
734 else if (commsType == Pstream::commsTypes::scheduled)
739 List<T> newField(constructSize, nullValue);
742 const labelList& mySubMap = subMap[Pstream::myProcNo()];
748 subField[i] = accessAndFlip
758 const labelList& map = constructMap[Pstream::myProcNo()];
779 label sendProc = twoProcs[0];
780 label recvProc = twoProcs[1];
782 if (Pstream::myProcNo() == sendProc)
788 Pstream::commsTypes::scheduled,
799 subField[i] = accessAndFlip
812 Pstream::commsTypes::scheduled,
818 const labelList& map = constructMap[recvProc];
820 checkReceivedSize(recvProc, map.
size(), subField.
size());
839 Pstream::commsTypes::scheduled,
845 const labelList& map = constructMap[sendProc];
847 checkReceivedSize(sendProc, map.
size(), subField.
size());
862 Pstream::commsTypes::scheduled,
873 subField[i] = accessAndFlip
887 else if (commsType == Pstream::commsTypes::nonBlocking)
889 label nOutstanding = Pstream::nRequests();
891 if (!contiguous<T>())
896 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
900 if (domain != Pstream::myProcNo() && map.
size())
908 subField[i] = accessAndFlip
916 toDomain << subField;
925 const labelList& myMap = subMap[Pstream::myProcNo()];
930 mySubField[i] = accessAndFlip
944 const labelList& map = constructMap[Pstream::myProcNo()];
959 Pstream::waitRequests(nOutstanding);
962 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
964 const labelList& map = constructMap[domain];
966 if (domain != Pstream::myProcNo() && map.
size())
971 checkReceivedSize(domain, map.
size(), recvField.
size());
991 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
995 if (domain != Pstream::myProcNo() && map.
size())
997 List<T>& subField = sendFields[domain];
1001 subField[i] = accessAndFlip
1012 Pstream::commsTypes::nonBlocking,
1014 reinterpret_cast<const char*>(subField.
begin()),
1015 subField.
size()*
sizeof(
T),
1025 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
1027 const labelList& map = constructMap[domain];
1029 if (domain != Pstream::myProcNo() && map.
size())
1034 Pstream::commsTypes::nonBlocking,
1036 reinterpret_cast<char*>(recvFields[domain].begin()),
1037 recvFields[domain].size()*
sizeof(
T),
1046 const labelList& map = subMap[Pstream::myProcNo()];
1048 List<T>& subField = sendFields[Pstream::myProcNo()];
1052 subField[i] = accessAndFlip
1070 const labelList& map = constructMap[Pstream::myProcNo()];
1071 const List<T>& subField = sendFields[Pstream::myProcNo()];
1087 Pstream::waitRequests(nOutstanding);
1092 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
1094 const labelList& map = constructMap[domain];
1096 if (domain != Pstream::myProcNo() && map.
size())
1098 const List<T>& subField = recvFields[domain];
1100 checkReceivedSize(domain, map.
size(), subField.
size());
1118 <<
"Unknown communication schedule " << int(commsType)
1133 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
1145 subField[i] = accessAndFlip
1153 toDomain << subField;
1178 if (recvField.
size() != map.
size())
1181 <<
"Expected from processor " << domain
1182 <<
" " << map.
size() <<
" but received " 1183 << recvField.
size() <<
" elements." 1202 template<
class T,
class negateOp>
1206 const negateOp& negOp,
1295 const label constructSize,
1357 const label constructSize,
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 > &, const negateOp &negOp, const int tag=UPstream::msgType())
Distribute data. Note:schedule only used for.
Class containing functor to negate primitives. Dummy for all other types.
#define forAll(list, i)
Loop across all elements in list.
void receive(PstreamBuffers &, List< T > &) const
Do all receives using PstreamBuffers.
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void reverseDistribute(const label constructSize, List< T > &, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
commsTypes
Types of communications.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
bool subHasFlip_
Whether subMap includes flip or not.
Combination-Reduction operation for a parallel run. The information from all nodes is collected on th...
Input inter-processor communications stream.
Input inter-processor communications stream operating on external buffer.
An ordered pair of two objects of type <T> with first() and second() elements.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
void setCapacity(const label)
Alter the size of the underlying storage.
iterator begin()
Return an iterator to begin traversing the UList.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Output inter-processor communications stream operating on external buffer.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
static void flipAndCombine(const UList< label > &map, const bool hasFlip, const UList< T > &rhs, const CombineOp &cop, const negateOp &negOp, List< T > &lhs)
Output inter-processor communications stream.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
bool constructHasFlip_
Whether constructMap includes flip or not.
static T accessAndFlip(const UList< T > &fld, const label index, const bool hasFlip, const negateOp &negOp)
static commsTypes defaultCommsType
Default commsType.
void setSize(const label)
Reset size of List.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
std::streamsize byteSize() const
Return the binary size in number of characters of the UList.
labelListList constructMap_
Maps from subsetted data to new reconstructed data.
void send(PstreamBuffers &, const List< T > &) const
Do all sends using PstreamBuffers.
label constructSize_
Size of reconstructed data.
label size() const
Return the number of elements in the UList.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
const List< labelPair > & schedule() const
Return a schedule. Demand driven. See above.
labelListList subMap_
Maps from subsetted data back to original data.