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];
103 return labelRange(begProc, (endProc-begProc));
114 List<SHA1Digest> digests;
117 digests.resize(numProcs);
122 SHA1Digest myDigest(SHA1(
hostName()).digest());
127 myDigest.cdata_bytes(),
128 digests.data_bytes(),
134 DynamicList<label> dynRanks;
138 dynRanks.reserve(numProcs);
143 for (label proci = 1; proci < digests.size(); ++proci)
145 if (digests[proci] != digests[previ])
147 dynRanks.push_back(proci);
152 ranks.transfer(dynRanks);
166 bool byHostName =
false;
174 if (str.contains(
'('))
183 else if (str ==
"host")
191 dynRanks = splitStringToList<label>(str);
202 <<
"Rank 0 (master) should be in the IO ranks. Currently:" <<
nl 212 if (dynRanks.
front() < 0)
215 <<
"Cannot have negative ranks! Currently:" <<
nl 222 auto last = std::unique(dynRanks.
begin(), dynRanks.
end());
224 if (last < dynRanks.
end())
226 ranks = dynRanks.
slice(0, (last - dynRanks.
begin()));
252 : ioRanks_.contains(proci)
268 DynamicList<label> offsetMaster;
274 label nHostRanks = 0;
277 if (!hosts[ranki].empty())
282 offsetMaster.reserve(nHostRanks+1);
286 if (!hosts[ranki].empty())
288 offsetMaster.push_back(ranki);
293 offsetMaster.push_back(hosts.
size());
296 if (offsetMaster.size() > 2)
299 <<
"I/O on :" <<
nl <<
'(' <<
nl;
302 const label beg = offsetMaster[
group-1];
303 const label
end = offsetMaster[
group];
306 <<
" (" << hosts[beg].c_str() <<
' ' 307 << (
end-beg) <<
')' <<
nl;
void size(const label n)
Older name for setAddressableSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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].
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.
bool contains(const T &val) const
True if the value is contained in the list.
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 communicator ranks. Does nothing in non-paral...
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.
An input stream of tokens.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.