42 template<
class PrimitiveType>
49 for (
const auto& item : items)
51 const std::string
s(item.str());
76 if (mainIOranks.empty())
92 if (mainIOranks[i] <= myProci)
94 begProc = mainIOranks[i];
95 if (i+1 < mainIOranks.size())
97 endProc = mainIOranks[i+1];
105 return labelRange(begProc, (endProc-begProc));
124 SHA1Digest myDigest(SHA1(
hostName()).digest());
129 myDigest.cdata_bytes(),
136 DynamicList<label> dynRanks;
140 dynRanks.reserve(numProcs);
145 for (label proci = 1; proci < digests.
size(); ++proci)
147 if (digests[proci] != digests[previ])
149 dynRanks.push_back(proci);
154 ranks.transfer(dynRanks);
168 bool byHostName =
false;
176 if (str.contains(
'('))
185 else if (str ==
"host")
193 dynRanks = splitStringToList<label>(str);
204 <<
"Rank 0 (master) should be in the IO ranks. Currently:" <<
nl 214 if (dynRanks.
front() < 0)
217 <<
"Cannot have negative ranks! Currently:" <<
nl 224 auto last = std::unique(dynRanks.
begin(), dynRanks.
end());
226 if (last < dynRanks.
end())
228 ranks = dynRanks.
slice(0, (last - dynRanks.
begin()));
254 : ioRanks_.contains(proci)
270 DynamicList<label> offsetMaster;
276 label nHostRanks = 0;
279 if (!hosts[ranki].empty())
284 offsetMaster.reserve(nHostRanks+1);
288 if (!hosts[ranki].empty())
290 offsetMaster.push_back(ranki);
295 offsetMaster.push_back(hosts.
size());
298 if (offsetMaster.size() > 2)
301 <<
"I/O on :" <<
nl <<
'(' <<
nl;
304 const label beg = offsetMaster[
group-1];
305 const label
end = offsetMaster[
group];
308 <<
" (" << hosts[beg].c_str() <<
' ' 309 << (
end-beg) <<
')' <<
nl;
bool contains(const T &val, label pos=0) const
Is the value contained in the list?
void size(const label n)
Older name for setAddressableSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
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...
static labelList getGlobalHostIORanks()
Get list of global IO master ranks based on the hostname. It is assumed that each host range is conti...
A range or interval of labels defined by a start and a size.
constexpr char nl
The newline '\n' character (0x0a)
T & front()
Access first element of the list, position [0].
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
static int & msgType() noexcept
Message tag of standard messages.
string getEnv(const std::string &envName)
Get environment value for given envName.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
Sub-ranges of a string with a structure similar to std::match_results, but without the underlying reg...
void push_back(const T &val)
Append an element at the end of the list.
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
UList< label > labelUList
A UList of labels.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all processes in communicator.
bool read(const char *buf, int32_t &val)
Same as readInt32.
#define forAll(list, i)
Loop across all elements in list.
constexpr const char *const group
Group name for atomic constants.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
SubList< T > slice(const label pos, label len=-1)
Return SubList slice (non-const access) - no range checking.
void sort(UList< T > &list)
Sort the list.
static void mpiGather(const char *sendData, char *recvData, int count, const label communicator=worldComm)
Receive identically-sized char data from all ranks.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
string hostName()
Return the system's host name, as per hostname(1)
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
static labelRange subRanks(const labelUList &mainIOranks)
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks.
Foam::SubStrings< StringType > splitAny(const StringType &str, const std::string &delim)
Split string into sub-strings using any characters in delimiter.
void printRanks() const
Helper: output which ranks are IO.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static constexpr unsigned max_size() noexcept
The dimensioned size of the digest is always 20 bytes.
static List< PrimitiveType > splitStringToList(const std::string &str)
bool isIOrank(const label proci) const
Is proci a master rank in the communicator (in parallel) or a master rank in the IO ranks (non-parall...
#define forAllReverse(list, i)
Reverse loop across all elements in list.
static labelList getGlobalIORanks()
Get list of global IO ranks from FOAM_IORANKS env variable. If set, these correspond to the IO master...
iterator end() noexcept
Return an iterator to end traversing the UList.
List< label > labelList
A List of labels.
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;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A class for handling character strings derived from std::string.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
An input stream of tokens.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.