57bool Foam::argList::argsMandatory_ =
true;
58bool Foam::argList::checkProcessorDirectories_ =
true;
59bool Foam::argList::parallelThreads_ =
false;
76Foam::argList::initValidTables::initValidTables()
82 "Case directory (instead of current directory)"
88 "Additional library or library list to load.\n"
89 "[Can be used multiple times]",
92 argList::addBoolOption
95 "Disable use of the controlDict 'libs' entry",
103 "Set named DebugSwitch (default value: 1).\n"
104 "[Can be used multiple times]",
112 "Set named InfoSwitch (default value: 1).\n"
113 "[Can be used multiple times]",
121 "Set named OptimisationSwitch (default value: 1).\n"
122 "[Can be used multiple times]",
126 argList::addBoolOption(
"parallel",
"Run in parallel");
127 validParOptions.set(
"parallel",
"");
129 argList::addBoolOption
132 "Request use of MPI threads",
136 argList::addBoolOption
139 "Disable initial MPI_Comm_dup()",
147 "Subprocess root directories for distributed running",
160 "Alternative decomposePar dictionary file"
165 "((host1 dir1) .. (hostN dirN))",
166 "Per-subprocess root directories for distributed running."
167 " The host specification can be a regex.",
173 "((host1 dir1) .. (hostN dirN))"
176 argList::addBoolOption
179 "Do not execute function objects",
187 "Override the file handler type",
195 "Name of the local world for parallel communication",
204 argList::addBoolOption
206 "mpi-split-by-appnum",
207 "Split world communicator based on the APPNUM",
217 Pstream::addValidParOptions(validParOptions);
236 Info<<
"Hosts :\n(" <<
nl;
241 for (
const auto& str : hostProcs)
243 std::string curr(str.substr(0, str.rfind(
'.')));
250 Info<<
" (" << prev.c_str() <<
' ' << count <<
')' <<
nl;
254 prev = std::move(curr);
262 Info<<
" (" << prev.c_str() <<
' ' << count <<
')' <<
nl;
275 if (hostProcs.size() ==
roots.size()+1)
284 const string& host = hostProcs[i+1];
285 const label index = sortedProcs.find(host);
289 sortedProcs.push_back(host);
290 sortedRoots.push_back(i);
292 else if (
roots[sortedRoots[index]] != root)
299 Info<<
"Roots :\n(" <<
nl;
302 Info<<
" (" << sortedProcs[i].c_str() <<
' '
303 <<
roots[sortedRoots[i]] <<
')' <<
nl;
318void Foam::argList::checkITstream(
const ITstream& is,
const label index)
320 const label remaining = is.nRemainingTokens();
326 <<
"--> FOAM WARNING:" <<
nl
327 <<
"Argument " << index <<
" has "
328 << remaining <<
" excess tokens" <<
nl <<
nl;
334 <<
"--> FOAM WARNING:" <<
nl
335 <<
"Argument " << index <<
" had no tokens" <<
nl <<
nl;
340void Foam::argList::checkITstream(
const ITstream& is,
const word& optName)
342 const label remaining = is.nRemainingTokens();
348 <<
"--> FOAM WARNING:" <<
nl
349 <<
"Option -" << optName <<
" has "
350 << remaining <<
" excess tokens" <<
nl <<
nl;
356 <<
"--> FOAM WARNING:" <<
nl
357 <<
"Option -" << optName <<
" had no tokens" <<
nl <<
nl;
362void Foam::argList::raiseBadInput(
const word& optName)
const
367 <<
"Option -" << optName <<
" with invalid input" <<
nl
374 const string& argName,
378 validArgs.push_back(argName);
382 const label index = validArgs.size();
386 argUsage.erase(index);
414 validOptions.set(optName, param);
417 optionUsage.set(optName, usage);
428 if (advanced && validOptions.contains(optName))
430 advancedOptions.set(optName);
442 std::pair<const char*,int> compat
445 validOptionsCompat.insert
448 std::pair<word,int>(optName, compat.second)
455 std::pair<const char*,int> compat,
459 ignoreOptionsCompat.insert
462 std::pair<bool,int>(expectArg, compat.second)
475 optionUsage.erase(optName);
488 notes.push_back(note);
503 argsMandatory_ =
false;
509 return argsMandatory_;
531 const word optName(
"dry-run",
false);
547 const word optName(
"verbose",
false);
554 "Additional verbosity (can be used multiple times)",
571 removeOption(
"noFunctionObjects");
575 ignoreOptionCompat({
"noFunctionObjects", 0},
false);
581 "withFunctionObjects",
582 "Execute functionObjects"
600 "Disable use of the controlDict libs entry",
608 removeOption(
"parallel");
609 removeOption(
"roots");
610 removeOption(
"decomposeParDict");
611 removeOption(
"hostRoots");
612 removeOption(
"world");
622 parallelThreads_ =
true;
628 checkProcessorDirectories_ =
false;
634 for (
int argi = 1; argi < argc; ++argi)
636 const char *optName = argv[argi];
638 if (optName[0] ==
'-')
642 if (optName == postProcessOptionName)
656 for (
int argi = 1; argi < argc; ++argi)
658 if (strcmp(argv[argi],
"-verbose") == 0)
689 return input.
relative(envGlobalPath(), caseTag);
698Foam::word Foam::argList::optionCompat(
const word& optName)
703 if (!validOptionsCompat.empty())
705 const auto fnd = validOptionsCompat.cfind(optName.substr(1));
709 const auto& alt = fnd.val();
715 <<
"--> FOAM IOWarning :" <<
nl
716 <<
" Found [v" << alt.second <<
"] '"
717 << optName <<
"' instead of '-"
718 << alt.first <<
"' option"
725 return "-" + alt.first;
734int Foam::argList::optionIgnore(
const word& optName)
738 if (!ignoreOptionsCompat.empty())
740 const auto fnd = ignoreOptionsCompat.cfind(optName);
744 const auto& alt = fnd.val();
748 const int nskip = (alt.first ? 2 : 1);
754 <<
"--> FOAM IOWarning :" <<
nl
755 <<
" Ignoring [v" << alt.second <<
"] '-"
756 << optName << (nskip > 1 ?
" ARG" :
"")
774bool Foam::argList::regroupArgv(
int& argc,
char**& argv)
785 for (
int argi = 1; argi < argc; ++argi)
787 const char *optName = argv[argi];
789 if (optName[0] ==
'(' && optName[1] ==
'\0')
795 else if (optName[0] ==
')' && optName[1] ==
'\0')
804 args_[nArgs++] =
group;
811 args_[nArgs++] = argv[argi];
821 else if (optName[0] ==
'-')
825 if (validOptions.contains(optName))
828 args_[nArgs++] = argv[argi];
830 else if ((ignore = optionIgnore(optName)) > 0)
841 args_[nArgs++] = optionCompat(argv[argi]);
846 args_[nArgs++] = argv[argi];
853 args_[nArgs++] =
group;
858 std::string::size_type len = (nArgs-1);
859 for (
const auto&
s : args_)
865 commandLine_.reserve(len);
871void Foam::argList::setCasePaths()
875 const auto optIter = options_.cfind(
"case");
881 if (caseDir.empty() || caseDir ==
".")
885 options_.erase(
"case");
890 caseDir.toAbsolute();
901 rootPath_ = caseDir.
path();
902 globalCase_ = caseDir.name();
909 setEnv(
"FOAM_CASE", caseDir,
true);
910 setEnv(
"FOAM_CASENAME", globalCase_,
true);
913 setEnv(
"FOAM_EXECUTABLE", executable_,
false);
943 word fileHandlerName;
945 if (parallelThreads_)
951 for (
int argi = 1; argi < argc; ++argi)
953 const char *optName = argv[argi];
955 if (optName[0] ==
'-')
958 bool emitErrorMessage =
false;
960 if (strcmp(optName,
"dry-run") == 0)
964 else if (strcmp(optName,
"verbose") == 0)
966 runControl_.incrVerbose();
968 else if (strcmp(optName,
"mpi-threads") == 0)
970 runControl_.threads(
true);
972 else if (strcmp(optName,
"fileHandler") == 0)
978 fileHandlerName = argv[argi];
982 emitErrorMessage =
true;
985 else if (strcmp(optName,
"debug-switch") == 0)
1000 else if (strcmp(optName,
"info-switch") == 0)
1015 else if (strcmp(optName,
"opt-switch") == 0)
1033 runControl_.parRun(
true);
1036 if (emitErrorMessage)
1042 <<
"Error: option '-" << optName
1043 <<
"' requires an argument" <<
nl <<
nl;
1049 if (fileHandlerName.empty())
1051 fileHandlerName = Foam::getEnv(
"FOAM_FILEHANDLER");
1052 if (fileHandlerName.empty())
1054 fileHandlerName = fileOperation::defaultFileHandler;
1068 if (fileOperationInit && fileOperationInit->needsThreading())
1070 runControl_.threads(
true);
1076 if (runControl_.parRun())
1078 runControl_.runPar(argc, argv);
1086 regroupArgv(argc, argv);
1087 commandLine_ += args_[0];
1094 for (
int argi = 1; argi < args_.size(); ++argi)
1096 commandLine_ +=
' ';
1097 commandLine_ += args_[argi];
1099 const char *optName = args_[argi].data();
1101 if (optName[0] ==
'-')
1108 <<
"Ignoring lone '-' on the command-line" <<
endl;
1119 auto optIter = validOptions.cfind(optName);
1123 || (optIter = validParOptions.cfind(optName)).good()
1126 wantArg = !optIter.val().empty();
1136 if (argi >= args_.size())
1141 <<
"Error: option '-" << optName
1142 <<
"' requires an argument" <<
nl <<
nl
1143 <<
"See '" << executable_ <<
" -help' for usage" <<
nl
1144 <<
" or '" << executable_
1145 <<
" -help-full' for extended usage" <<
nl
1151 commandLine_ +=
' ';
1152 commandLine_ += args_[argi];
1158 if (strcmp(optName,
"lib") == 0)
1162 libs().push_back(this->getList<fileName>(argi));
1164 else if (strcmp(optName,
"debug-switch") == 0)
1172 else if (strcmp(optName,
"info-switch") == 0)
1180 else if (strcmp(optName,
"opt-switch") == 0)
1192 options_.set(optName, args_[argi]);
1200 options_.insert(optName,
"");
1213 args_[nArgs] = args_[argi];
1219 args_.resize(nArgs);
1221 parse(checkArgs, checkOpts, initialise);
1234 runControl_(
args.runControl_),
1238 executable_(
args.executable_),
1239 rootPath_(
args.rootPath_),
1240 globalCase_(
args.globalCase_),
1242 commandLine_(
args.commandLine_)
1244 parse(checkArgs, checkOpts, initialise);
1262 bool quickExit =
false;
1265 if (options_.contains(
"doc"))
1270 else if (options_.contains(
"doc-source"))
1277 if (options_.contains(
"help-full"))
1282 else if (options_.contains(
"help-notes"))
1288 else if (options_.contains(
"help"))
1293 else if (options_.contains(
"help-man"))
1300 if (options_.contains(
"help-compat"))
1313 if (!
check(checkArgs, checkOpts))
1349 <<
"Exec : " << commandLine_.c_str() <<
nl
1350 <<
"Date : " << dateString.c_str() <<
nl
1351 <<
"Time : " << timeString.c_str() <<
nl
1353 <<
"PID : " <<
pid() <<
nl;
1356 jobInfo.add(
"startDate", dateString);
1357 jobInfo.add(
"startTime", timeString);
1366 const auto space =
build.find(
' ');
1367 if (space != std::string::npos)
1369 build.resize(space);
1371 jobInfo.add(
"foamBuild", build);
1374 jobInfo.add(
"code", executable_);
1375 jobInfo.add(
"argList", commandLine_);
1381 libs().open(bannerEnabled());
1393 word fileHandlerName
1395 options_.lookup(
"fileHandler",
Foam::getEnv(
"FOAM_FILEHANDLER"))
1398 if (fileHandlerName.empty())
1416 if (runControl_.parRun())
1429 fromSubproc >> procBuild >> hostMachine[proci] >> procPid;
1431 hostProcs[proci] = hostMachine[proci] +
"." +
name(procPid);
1439 <<
" but proc " << subproci <<
" is running "
1463 enum distributedCodes
1465 NON_DISTRIBUTED = 0,
1467 DISTRIBUTED_SINGLE_ROOT = 2,
1468 DISTRIBUTED_MULTIPLE_ROOTS = 3
1472 label distributedType
1474 runControl_.distributed()
1475 ? distributedCodes::DISTRIBUTED
1476 : distributedCodes::NON_DISTRIBUTED
1484 if (runControl_.parRun())
1497 bool adjustOpt =
false;
1501 source /=
"decomposeParDict";
1506 if (!source.isAbsolute() && !source.starts_with(
'.'))
1508 source = rootPath_/globalCase_/source;
1516 options_.set(
"decomposeParDict", source);
1521 label dictNProcs = -1;
1522 if (this->readListIfPresent(
"roots",
roots))
1525 runControl_.distributed(
true);
1526 distributedType = distributedCodes::DISTRIBUTED;
1531 <<
"The -roots option must contain values"
1534 if (
roots.size() > 1)
1536 dictNProcs =
roots.size()+1;
1539 else if (options_.contains(
"hostRoots"))
1541 source =
"-hostRoots";
1542 runControl_.distributed(
true);
1543 distributedType = distributedCodes::DISTRIBUTED;
1548 checkITstream(is,
"hostRoots");
1550 if (hostRoots.empty())
1553 <<
"The -hostRoots option must contain values"
1559 for (
const auto& hostRoot : hostRoots)
1565 for (
const label matchi : matched)
1567 if (!
roots[matchi].empty())
1570 <<
"Multiple matching roots for "
1571 << hostMachine[matchi] <<
" in "
1576 roots[matchi] = hostRoot.second();
1583 if (
roots[hosti].empty())
1586 <<
"No matching roots for "
1587 << hostMachine[hosti] <<
" in "
1593 if (
roots.size() > 1)
1595 dictNProcs =
roots.size()+1;
1602 const bool useDefault = source.empty();
1605 source = rootPath_/globalCase_/
"system"/
"decomposeParDict";
1623 if (dictStream && dictStream->good())
1633 if (decompDict.getOrDefault(
"distributed",
false))
1636 runControl_.distributed(
true);
1637 distributedType = distributedCodes::DISTRIBUTED;
1639 decompDict.readEntry(
"roots",
roots);
1644 <<
"WARNING: running distributed"
1645 <<
" but did not specify roots!" <<
nl;
1649 decompDict.readEntry
1651 "numberOfSubdomains",
1663 <<
"WARNING: running without decomposeParDict "
1664 << this->relativePath(source) <<
nl;
1670 <<
"Cannot read decomposeParDict: "
1671 << this->relativePath(source) <<
nl
1682 <<
"Running parallel on single processor. This only"
1683 <<
" makes sense for multi-world simulation" <<
endl;
1704 if (
roots.size() == 1)
1708 distributedCodes::DISTRIBUTED_SINGLE_ROOT;
1711 if (dictNProcs <= 0)
1716 else if (
roots.size() > 1)
1719 distributedCodes::DISTRIBUTED_MULTIPLE_ROOTS;
1724 <<
"Number of roots " <<
roots.size()
1725 <<
" != number of sub-ranks "
1747 checkProcessorDirectories_
1754 << this->relativePath(source)
1755 <<
" specifies " << dictNProcs
1756 <<
" processors but job was started with "
1772 label nProcDirs = 0;
1783 rootPath_/globalCase_,
1796 <<
"Number of processor directories = " << nProcDirs
1797 <<
" is not equal to the number of ranks = "
1810 << args_ << options_
1812 << label(runControl_.dryRun())
1813 << label(runControl_.verbose());
1819 label numDryRun, numVerbose;
1824 >> args_ >> options_
1826 >> numDryRun >> numVerbose;
1828 runControl_.distributed(distributedType);
1829 runControl_.dryRun(numDryRun);
1830 runControl_.verbose(numVerbose);
1837 distributedType == distributedCodes::DISTRIBUTED_SINGLE_ROOT
1847 newCasePath =
roots[0]/globalCase_;
1853 options_.set(
"case", newCasePath);
1858 distributedType == distributedCodes::DISTRIBUTED_MULTIPLE_ROOTS
1870 newCasePath =
roots[subproci-1]/globalCase_;
1877 options_.set(
"case", newCasePath);
1900 case_ = globalCase_;
1907 case_ = globalCase_;
1918 if (runControl_.parRun() && ranks.size())
1953 <<
" distributed - copying missing directories"
1961 fileName masterRootPath(rootPath_);
1973 for (label proci = 1; proci < pathDirs.size(); ++proci)
1975 if (ranks.contains(proci))
1980 if (pathDirs[proci].empty())
1998 && !rankToDirs[rank].contains(foundDir)
2001 rankToDirs[
rank].push_back(foundDir);
2016 forAll(rankToDirs, proci)
2022 for (
const auto& srcDir : rankToDirs[proci])
2027 / srcDir.relative(masterRootPath)
2033 Pout<<
"On rank " << proci <<
nl
2034 <<
" copying : " << srcDir <<
nl
2035 <<
" to : " << tgtDir <<
endl;
2055 if (!writeHostsSwitch)
2060 if (!writeRootsSwitch)
2068 Info<<
"Case : " << (rootPath_/globalCase_).c_str() <<
nl
2069 <<
"nProcs : " << nProcs <<
nl;
2071 if (runControl_.parRun())
2073 if (hostProcs.size())
2075 if (writeHostsSwitch == 1)
2080 else if (writeHostsSwitch)
2083 Info<<
"Hosts :\n(" <<
nl;
2090 for (
const auto& str : hostProcs)
2092 Info<<
" " << str.c_str() <<
nl;
2099 bool hasPrinted =
false;
2100 if (writeRootsSwitch == 1)
2105 if (writeRootsSwitch && !hasPrinted)
2112 Info<<
"Pstream initialized with:" <<
nl;
2114 Info<<
" node communication : ";
2119 Info<<
" topology controls : ";
2126 Info<<
" floatTransfer : enabled" <<
nl;
2130 Info<<
" maxCommsSize : "
2135 Info<<
" nProcsSimpleSum : "
2139 const auto& commsType =
2142 Info<<
" consensus exchange : "
2145 <<
" exchange algorithm : "
2147 <<
" commsType : " << commsType <<
nl
2148 <<
" polling iterations : "
2164 jobInfo.add(
"root", rootPath_);
2165 jobInfo.add(
"case", globalCase_);
2166 jobInfo.add(
"nProcs", nProcs);
2167 if (hostProcs.size())
2169 jobInfo.add(
"hosts", hostProcs);
2189 Info<<
"fileModificationChecking : "
2190 <<
"Monitoring run-time modified files using "
2203 Info<<
" (fileModificationSkew "
2209 Info<<
" (fileModificationSkew "
2211 <<
", maxFileModificationPolls "
2218 <<
"Invalid setting for maxFileModificationPolls "
2225 Info<<
"allowSystemOperations : ";
2232 Info<<
"Disallowing";
2234 Info<<
" user-supplied system call operations" <<
nl
2263 if (validOptions.contains(
"withFunctionObjects"))
2266 return options_.contains(
"withFunctionObjects");
2268 else if (validOptions.contains(
"noFunctionObjects"))
2271 return !options_.contains(
"noFunctionObjects");
2281 return !options_.contains(
"no-libs");
2290 for (
const word& optName : optionNames)
2292 if (options_.contains(optName))
2304 for (
const word& optName : optionNames)
2306 if (options_.contains(optName))
2321 || optName ==
"parallel"
2322 || optName ==
"roots"
2326 <<
"Option: '" << optName <<
"' is protected" <<
nl
2331 const auto optIter = options_.cfind(optName);
2333 if (!optIter.good() || (optIter.val() != param))
2335 options_.set(optName, param);
2349 || optName ==
"parallel"
2350 || optName ==
"roots"
2354 <<
"Option: '" << optName <<
"' is protected" <<
nl
2360 return options_.erase(optName);
2368 fileName docExt(docDict.get<fileName>(
"doxySourceFileExt"));
2373 docExt.replace(
".",
"_source.");
2378 for (
const fileName& dir : docDirs)
2381 if (dir.starts_with(
"http:") || dir.starts_with(
"https:"))
2383 url = dir/executable_ + docExt;
2391 docFile.starts_with(
"file://")
2392 ?
isFile(docFile.substr(7))
2396 url = std::move(docFile);
2404 <<
"No documentation found for " << executable_
2405 <<
", but you can use -help to display the usage\n" <<
endl;
2410 string docBrowser =
getEnv(
"FOAM_DOC_BROWSER");
2411 if (docBrowser.empty())
2413 docDict.readEntry(
"docBrowser", docBrowser);
2417 if (docBrowser.contains(
"%f"))
2419 docBrowser.replace(
"%f", url);
2423 docBrowser +=
" " + url;
2432 <<
" " << command <<
nl <<
endl;
2444 const label nargs = args_.size()-1;
2445 if (checkArgs && nargs != validArgs.size())
2448 <<
"Expected " << validArgs.size()
2449 <<
" arguments but found " << nargs <<
endl;
2457 const word& optName = iter.key();
2460 !validOptions.contains(optName)
2461 && !validParOptions.contains(optName)
2465 <<
"Invalid option: -" << optName <<
endl;
2475 <<
"See '" << executable_ <<
" -help' for usage" <<
nl
2476 <<
" or '" << executable_
2477 <<
" -help-full' for extended usage" <<
nl
2492 <<
": cannot open root directory " << rootPath()
2506 <<
": cannot open case directory " <<
path()
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
propsDict readIfPresent("fields", acceptFields)
Foam::argList::initValidTables dummyInitValidTables
An adapter for copying a list of C++ strings into a list of C-style strings for passing to C code tha...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void push_back(const T &val)
Copy append an element to the end of this list.
static void warnLocalBoundaryConsistencyCompat(const dictionary &)
Warn about keyword changes for local boundary consistency checks.
A HashTable with keys but without contents that is similar to std::unordered_set.
A HashTable similar to std::unordered_map.
readOption
Enumeration defining read preferences.
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ MUST_READ
Reading required.
static Ostream & writeDivider(Ostream &os)
Write the standard file section divider.
static Ostream & writeBanner(Ostream &os, const bool noSyntaxHint=false)
Write the standard OpenFOAM file/dictionary banner.
static float fileModificationSkew
Time skew (seconds) for file modification checks.
static fileCheckTypes fileModificationChecking
Type of file modification checking.
static const Enum< fileCheckTypes > fileCheckTypesNames
Names for the fileCheckTypes.
static int maxFileModificationPolls
Max number of times to poll for file modification changes.
Input inter-processor communications stream using MPI broadcast.
static void recv(Type &value, const int communicator=UPstream::worldComm)
Receive (from broadcast, root == UPstream::masterNo()) and deserialize a value. Uses operator>> for d...
Input inter-processor communications stream.
static void recv(Type &value, const int fromProcNo, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Receive and deserialize a value. Uses operator>> for de-serialization.
An input stream of tokens.
static void disable() noexcept
Disallow JobInfo by forcing writeJobInfo (InfoSwitch) off.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void push_back(const T &val)
Append an element at the end of the list.
void resize(const label len)
Adjust allocated size of list.
void clear()
Clear the list, i.e. set size to zero.
static bool create(bool verbose=false)
Create a memory pool instance (if not already active).
Output inter-processor communications stream using MPI broadcast.
static void send(const Type &value, const int communicator=UPstream::worldComm)
Serialize a value and broadcast (root == UPstream::masterNo()). Uses operator<< for serialization.
Output inter-processor communications stream.
bool threads() const noexcept
True if MPI threads are desired (default: false).
void incrDryRun(int i=1) noexcept
Increase the dry-run level.
static int algorithm
Preferred exchange algorithm (may change or be removed in future).
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool empty() const noexcept
True if List is empty (ie, size() is zero).
bool contains(const T &val) const
True if the value is contained in the list.
void size(const label n)
Older name for setAddressableSize.
label find(const T &val) const
Find index of the first occurrence of the value.
bool send()
Send buffer contents now and not in destructor [advanced usage]. Returns true on success.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
@ scheduled
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
static const Enum< commsTypes > commsTypeNames
Enumerated names for the communication types.
static bool floatTransfer
Should compact transfer be used in which floats replace doubles reducing the bandwidth requirement at...
static void printTopoControl(Ostream &os)
Report the topology routines settings.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static int nProcsNonblockingExchange
Number of processors to change to nonBlocking consensual exchange (NBX). Ignored for zero or negative...
static void exit(int errNo=1)
Shutdown (finalize) MPI as required and exit program with errNo.
static int tuning_NBX_
Tuning parameters for non-blocking exchange (NBX).
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
static int nProcsSimpleSum
Number of processors to change from linear to tree communication.
static int nPollProcInterfaces
Number of polling cycles in processor updates.
static const wordList & allWorlds() noexcept
All worlds.
static int maxCommsSize
Optional maximum message size (bytes).
@ gatherList
gatherList [manual algorithm]
@ broadcast
broadcast [MPI]
static void printNodeCommsControl(Ostream &os)
Report the node-communication settings.
static commsTypes defaultCommsType
Default commsType.
static bool & parRun() noexcept
Test if this a parallel run.
static const word & myWorld()
My world.
Extract command arguments and options from the supplied argc and argv parameters.
void parse(bool checkArgs, bool checkOpts, bool initialise)
Scan for -help, -doc options etc prior to checking the validity of other args/opts and finally initia...
static word postProcessOptionName
Standard name for the post-processing option.
static HashTable< string, label, Hash< label > > argUsage
Short description for program arguments.
static void noBanner()
Disable emitting the banner information.
static std::string::size_type usageMin
Min indentation when displaying usage (default: 20).
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static HashTable< std::pair< word, int > > validOptionsCompat
A list of aliases for options.
static HashTable< string > validParOptions
A list of valid parallel options.
static void removeOption(const word &optName)
Remove option from validOptions and from optionUsage.
const stringList & args() const noexcept
Return arguments.
static void addVerboseOption(const string &usage="", bool advanced=false)
Enable a 'verbose' bool option, with usage information.
argList(int &argc, char **&argv, bool checkArgs=argList::argsMandatory(), bool checkOpts=true, bool initialise=true)
Construct from argc and argv checking the arguments and options as requested.
static std::string::size_type usageMax
Max screen width when displaying usage (default: 80).
bool unsetOption(const word &optName)
Unset option directly (use with caution).
static bool postProcess(int argc, char *argv[])
True if the post-processing option is found in the argv list.
const HashTable< string > & options() const noexcept
Return options.
int verbose() const noexcept
Return the verbose flag.
const fileName & rootPath() const noexcept
Return root path.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static bool bannerEnabled()
Banner status (enabled/disabled).
static fileName envGlobalPath()
Global case (directory) from environment variable.
static void noLibs()
Add the '-no-libs' command line option.
static void noJobInfo()
Suppress JobInfo, overriding controlDict setting.
bool allowLibs() const
The controlDict 'libs' entry is allowed to be used. (eg, has not been disabled by the -no-libs option...
void printUsage(bool full=true) const
Print usage.
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
bool check(bool checkArgs=argList::argsMandatory(), bool checkOpts=true) const
Check the parsed command-line for mandatory arguments and that all the options are correct.
virtual ~argList()
Destructor.
fileName relativePath(const fileName &input, const bool caseTag=false) const
Return the input relative to the globalPath by stripping off a leading value of the globalPath.
bool readListIfPresent(const word &optName, List< T > &list) const
If named option is present, get a List of values treating a single entry like a list of size 1.
static HashTable< string > optionUsage
Short description for validOptions.
bool allowFunctionObjects() const
The controlDict 'functions' entry is allowed to be used.
static fileName envRelativePath(const fileName &input, const bool caseTag=false)
Return the input relative to the globalPath by stripping off a leading value of the envGlobalPath.
static bool argsMandatory()
Command arguments type (optional/mandatory).
label count(const UList< word > &optionNames) const
Return how many of the specified options were used.
static HashSet< string > advancedOptions
The "advanced" options are shown with -help-full (not with –help).
bool setOption(const word &optName, const string ¶m="")
Set option directly (use with caution).
static void addDryRunOption(const string &usage, bool advanced=false)
Enable a 'dry-run' bool option, with usage information.
label size() const noexcept
The number of arguments.
static void noCheckProcessorDirectories()
Disable checking of processor directories.
static SLList< string > notes
General usage notes.
bool checkRootCase() const
Check root path and case path.
void displayDoc(bool source=false) const
Display documentation in browser.
static void noMandatoryArgs()
Flag command arguments as being optional (non-mandatory).
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
void printCompat() const
Print option compatibility.
static void noParallel()
Remove the parallel options.
static void addUsage(const word &optName, const string &usage)
Add option usage information to optionUsage.
void printMan() const
Print usage as nroff-man format (Experimental).
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
void printNotes() const
Print notes (if any).
static void parallelThreads_on()
MPI threads are desired for the application.
static HashTable< string > validOptions
A list of valid options.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
ITstream lookup(const word &optName) const
Return an input stream from the named option.
const word & executable() const noexcept
Name of executable without the path.
static word envExecutable()
Name of the executable from environment variable.
static HashTable< std::pair< bool, int > > ignoreOptionsCompat
A list of options to ignore.
static void addNote(const string ¬e)
Add extra notes for the usage information.
static void ignoreOptionCompat(std::pair< const char *, int > compat, bool expectArg)
Specify an option to be ignored.
dlLibraryTable & libs() const noexcept
Mutable access to the loaded dynamic libraries.
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static std::string date()
The current wall-clock date as a string formatted as (MON dd yyyy), where MON is Jan,...
static std::string clockTime()
The current wall-clock (in local time) as a string formatted as as (hh:mm:ss).
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
static int allowSystemOperations
Flag if system operations are allowed.
static bool warnAboutAge(const int version) noexcept
Test if an age warning should be emitted.
A class for handling file names.
fileName relative(const fileName &parent, const bool caseTag=false) const
Return a relative name by stripping off the parent directory where possible.
static fileName validate(const std::string &, const bool doClean=true)
Construct fileName without invalid characters, possibly applying other transformations such as changi...
static bool clean(std::string &str)
Cleanup filename string, possibly applies other transformations such as changing the path separator e...
static const fileName null
An empty fileName.
static std::string path(const std::string &str)
Return directory path name (part before last /).
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
static bool isAbsolute(const std::string &str)
Return true if filename starts with a '/' or '\' or (windows-only) with a filesystem-root.
An encapsulation of filesystem-related operations.
static const fileOperation & fileHandler()
Return the current file handler. Will create the default file handler if necessary.
static refPtr< fileOperation > fileHandlerPtr_
The currently active file handler. Avoid accessing directly.
static word defaultFileHandler
Name of the default fileHandler.
static int cacheLevel() noexcept
Return cache level.
static autoPtr< fileOperation > New(const word &handlerType, bool verbose=false)
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.
static int nProcsFilter() noexcept
Return collated 'processorsDDD' filtering.
static autoPtr< fileOperationInitialise > New(const word &type, int &argc, char **&argv)
Select initialisation type.
Lookup type of boundary radiation properties.
static void set(bool verbose=false)
Activate SIGFPE handler when FOAM_SIGFPE is enabled. Activate fill memory with signaling_NaN when FOA...
static void set(bool verbose=false)
Activate SIGINT signal handler.
static void set(bool verbose=false)
Activate SIGQUIT signal handler.
static void set(bool verbose=false)
Activate SIGSEGV signal handler.
void setNamedValue(const std::string_view name, int val, bool verbose=false, bool dryrun=false)
Set named value, but also handle embedded 'name=value' syntax.
bool contains(char c) const noexcept
True if string contains given character (cf. C++23).
bool starts_with(char c) const
True if string starts with given character (cf. C++20).
string & replace(const std::string &s1, const std::string &s2, size_type pos=0)
Replace first occurrence of sub-string s1 with s2, beginning at pos.
static labelList matching(const wordRe &select, const UList< StringType > &input, const bool invert=false)
Determine the list indices for all matches.
A class for handling words, derived from Foam::string.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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))
constexpr const char *const group
Group name for atomic constants.
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
simpleObjectRegistry & infoObjects()
Access to registered InfoSwitch objects.
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict(s).
dictionary & controlDict()
The central control dictionary, the contents of which are either taken directly from the FOAM_CONTROL...
simpleObjectRegistry & optimisationObjects()
Access to registered OptimisationSwitch objects.
simpleObjectRegistry & debugObjects()
Access to registered DebugSwitch objects.
::Foam::direction rank(const expressions::valueTypeCode) noexcept
The vector-space rank associated with given valueTypeCode.
const std::string patch
OpenFOAM patch number as a std::string.
const std::string build
OpenFOAM build information as a std::string.
const int api
OpenFOAM api number (integer) corresponding to the value of OPENFOAM at the time of compilation.
bool patched()
Test if the patch string appears to be in use, which is when it is defined (non-zero).
const std::string buildArch
OpenFOAM build architecture information (machine endian, label/scalar sizes) as a std::string.
void printBuildInfo(std::ostream &os, const bool full=true)
Print information about version, build, arch to output stream.
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
Foam::SubStrings splitSpace(const std::string &str, std::string::size_type pos=0)
Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC).
string expand(const std::string &s, const HashTable< string > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping and return the expanded string.
fileName cwd()
The physical or logical current working directory path name.
string getEnv(const std::string &envName)
Get environment value for given envName.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable, return true on success.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
LList< SLListBase, T > SLList
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.
List< label > labelList
A List of labels.
List< fileName > fileNameList
List of fileName.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler().
messageStream Info
Information stream (stdout output on master, null elsewhere).
static bool printRootsSubscription(const UList< string > &hostProcs, const UList< fileName > &roots)
static void check(const int retVal, const char *what)
string userName()
Return the user's login name.
List< string > stringList
List of string.
pid_t pgid()
Return the group PID of this process.
Ostream & endl(Ostream &os)
Add newline and flush stream.
string hostName()
Return the system's host name, as per hostname(1).
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
pid_t ppid()
Return the parent PID of this process.
static void printHostsSubscription(const UList< string > &hostProcs)
pid_t pid()
Return the PID of this process.
int infoDetailLevel
Global for selective suppression of Info output.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text.
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Operations on lists of strings.