Go to the documentation of this file.
33 template<
class SubListType>
38 const bool checkOverflow
43 const label len = lists.size();
50 for (label i = 0; i < len; ++i)
53 start += lists[i].size();
55 if (checkOverflow && start <
values[i])
58 <<
"Overflow : sum of sizes exceeds labelMax ("
60 <<
"Please recompile with larger datatype for label." <<
nl
73 template<
class ProcIDsContainer,
class Type>
78 const ProcIDsContainer& procIDs,
92 <<
"Cannot use nonBlocking with non-contiguous data"
106 SubList<Type>(allFld, off[1]-off[0], off[0]) =
107 SubList<Type>(
fld, off[1]-off[0]);
115 for (label i = 1; i < procIDs.size(); ++i)
117 SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
119 if (is_contiguous<Type>::value)
125 procSlot.data_bytes(),
126 procSlot.size_bytes(),
141 fromProc >> procSlot;
152 for (label i = 1; i < procIDs.size(); ++i)
154 SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
160 procSlot.data_bytes(),
161 procSlot.size_bytes(),
179 if (is_contiguous<Type>::value)
228 template<
class Type,
class Addr>
233 const UList<int>& procIDs,
234 const IndirectListBase<Type, Addr>&
fld,
243 <<
"Cannot use nonBlocking with indirect list of data"
250 allFld.resize_nocopy(off.last());
255 SubList<Type> localSlot(allFld, off[1]-off[0], off[0]);
256 if (!localSlot.empty())
262 for (label i = 1; i < procIDs.size(); ++i)
264 SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
274 fromProc >> procSlot;
295 const UList<Type>&
fld,
314 template<
class Type,
class Addr>
337 template<
class ProcIDsContainer,
class Type>
342 const ProcIDsContainer& procIDs,
350 gather(off, comm, procIDs,
fld, allFld, tag, commsType);
382 fld.transfer(allFld);
391 template<
class Type,
class OutputContainer>
394 const UList<Type>& sendData,
395 OutputContainer& allValues,
399 if (!is_contiguous<Type>::value)
402 <<
"Cannot be called for non-contiguous data" <<
nl
408 const globalIndex& globalAddr = *
this;
411 const label nproc = globalAddr.nProcs();
413 auto nSendBytes = sendData.size_bytes();
418 if (proci < nproc && !globalAddr.localSize(proci))
424 List<int> recvOffsets;
428 allValues.resize_nocopy(globalAddr.size());
430 recvSizes.resize(nproc);
431 recvOffsets.resize(nproc+1);
433 for (label proci = 0; proci < nproc; ++proci)
435 recvSizes[proci] = globalAddr.localSize(proci) *
sizeof(Type);
436 recvOffsets[proci] = globalAddr.localStart(proci) *
sizeof(Type);
438 recvOffsets[nproc] = globalAddr.size() *
sizeof(Type);
447 sendData.cdata_bytes(),
449 allValues.data_bytes(),
457 template<
class Type,
class OutputContainer>
464 OutputContainer allValues;
465 mpiGather<Type, OutputContainer>(sendData, allValues, comm);
495 template<
class ProcIDsContainer,
class Type>
500 const ProcIDsContainer& procIDs,
514 <<
"Cannot use nonBlocking with non-contiguous data"
521 const SubList<Type> localSlot(allFld, off[1]-off[0], off[0]);
523 if (!localSlot.empty())
525 fld.deepCopy(localSlot);
534 for (label i = 1; i < procIDs.size(); ++i)
536 const SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
538 if (is_contiguous<Type>::value)
544 procSlot.cdata_bytes(),
545 procSlot.size_bytes(),
571 for (label i = 1; i < procIDs.size(); ++i)
573 const SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
579 procSlot.cdata_bytes(),
580 procSlot.size_bytes(),
598 if (is_contiguous<Type>::value)
650 const UList<Type>& allFld,
670 template<
class Type,
class CombineOp>
675 const CombineOp& cop,
681 if (globalIds.
size())
699 for (
const auto proci : validBins)
706 localIDs[i] = toLocal(proci, es[i]);
709 UOPstream
os(proci, sendBufs);
713 sendBufs.finishedSends(recvSizes);
720 if (recvSizes[proci])
722 UIPstream is(proci, sendBufs);
726 List<Type>
fld(localIDs.size());
729 UOPstream
os(proci, returnBufs);
733 returnBufs.finishedSends();
736 for (
const auto proci : validBins)
738 label start = bins.
offsets()[proci];
739 const SubList<label> es
745 UIPstream is(proci, returnBufs);
748 UIndirectList<Type>(allFld, es) =
fld;
const char * cdata_bytes() const noexcept
const List< label > & offsets() const
List< label > labelList
A List of labels.
static void gather(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::nonBlocking)
static bool write(const commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=UPstream::worldComm)
Output inter-processor communications stream operating on external buffer.
void resize(const label len)
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
Output inter-processor communications stream.
A List obtained as a section of another List.
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
static labelList calcListOffsets(const List< SubListType > &lists, const bool checkOverflow=false)
static void waitRequests(const label start=0)
static bool master(const label communicator=worldComm)
void resize_nocopy(const label len)
void get(List< Type > &allFld, const labelUList &globalIds, const CombineOp &cop, const label comm=UPstream::worldComm, const int tag=UPstream::msgType()) const
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=UPstream::worldComm)
static List< int > & procID(label communicator)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void finishedSends(const bool block=true)
static void gatherOp(const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::nonBlocking)
OBJstream os(runTime.globalPath()/outputName)
errorManip< error > abort(error &err)
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
static int myProcNo(const label communicator=worldComm)
void mpiGather(const UList< Type > &sendData, OutputContainer &allValues, const label comm=UPstream::worldComm) const
label nProcs() const noexcept
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void write(vtk::formatter &fmt, const Type &val, const label n=1)
static void scatter(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &allFld, UList< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::nonBlocking)
A List with indirect addressing.
Input inter-processor communications stream.
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
Input inter-processor communications stream operating on external buffer.
UList< label > labelUList
A UList of labels.
#define WarningInFunction
std::streamsize size_bytes() const noexcept
static label nProcs(const label communicator=worldComm)
static void gather(const char *sendData, int sendSize, char *recvData, const UList< int > &recvSizes, const UList< int > &recvOffsets, const label communicator=worldComm)
A template class to specify that a data type can be considered as being contiguous in memory.