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));
117 const SHA1Digest myDigest(SHA1(
hostName()).digest());
119 List<SHA1Digest> digests(numProc);
120 digests[myProci] = myDigest;
125 digests.data_bytes(),
133 hostLeaders.push_back(0);
134 for (label previ = 0, proci = 1; proci < digests.size(); ++proci)
136 if (digests[previ] != digests[proci])
138 hostLeaders.push_back(proci);
143 return labelList(std::move(hostLeaders));
156 bool byHostName =
false;
173 else if (str ==
"host")
181 dynRanks = splitStringToList<label>(str);
192 <<
"Rank 0 (master) should be in the IO ranks. Currently:" <<
nl 202 if (dynRanks.
front() < 0)
205 <<
"Cannot have negative ranks! Currently:" <<
nl 212 auto last = std::unique(dynRanks.
begin(), dynRanks.
end());
214 if (last < dynRanks.
end())
216 ranks = dynRanks.
slice(0, (last - dynRanks.
begin()));
242 : ioRanks_.contains(proci)
258 DynamicList<label> offsetMaster;
264 label nHostRanks = 0;
267 if (!hosts[ranki].empty())
272 offsetMaster.reserve(nHostRanks+1);
276 if (!hosts[ranki].empty())
278 offsetMaster.push_back(ranki);
283 offsetMaster.push_back(hosts.
size());
286 if (offsetMaster.size() > 2)
289 <<
"I/O on :" <<
nl <<
'(' <<
nl;
292 const label beg = offsetMaster[
group-1];
293 const label
end = offsetMaster[
group];
296 <<
" (" << hosts[beg].c_str() <<
' ' 297 << (
end-beg) <<
')' <<
nl;
void size(const label n)
Older name for setAddressableSize.
bool contains(char c) const noexcept
True if string contains given character (cf. C++23)
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)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
T & front()
Access first element of the list, position [0].
static bool & parRun() noexcept
Test if this a parallel run.
Foam::SubStrings splitAny(const std::string &str, const std::string &delim, std::string::size_type pos=0)
Split string into sub-strings using any characters in delimiter.
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()). Negative if the process is not a...
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
bool contains(const T &val) const
True if the value is contained in the list.
UList< label > labelUList
A UList of labels.
static void gatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate.
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. ...
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.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
string hostName()
Return the system's host name, as per hostname(1)
static void mpiAllGather(Type *allData, int count, const int communicator=UPstream::worldComm)
Gather/scatter identically-sized data.
static labelRange subRanks(const labelUList &mainIOranks)
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks.
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 int numNodes() noexcept
The number of shared/host nodes in the (const) world communicator.
static List< PrimitiveType > splitStringToList(const std::string &str)
static constexpr unsigned size_bytes() noexcept
The number of bytes in digest (20)
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.