55 bool Foam::argList::argsMandatory_ =
true;
56 bool Foam::argList::checkProcessorDirectories_ =
true;
57 bool Foam::argList::parallelThreads_ =
false;
74 Foam::argList::initValidTables::initValidTables()
80 "Case directory (instead of current directory)" 86 "Additional library or library list to load.\n" 87 "[Can be used multiple times]",
90 argList::addBoolOption
93 "Disable use of the controlDict 'libs' entry",
101 "Set named DebugSwitch (default value: 1).\n" 102 "[Can be used multiple times]",
110 "Set named InfoSwitch (default value: 1).\n" 111 "[Can be used multiple times]",
119 "Set named OptimisationSwitch (default value: 1).\n" 120 "[Can be used multiple times]",
124 argList::addBoolOption(
"parallel",
"Run in parallel");
125 validParOptions.set(
"parallel",
"");
127 argList::addBoolOption
130 "Request use of MPI threads",
138 "Subprocess root directories for distributed running",
151 "Alternative decomposePar dictionary file" 156 "((host1 dir1) .. (hostN dirN))",
157 "Per-subprocess root directories for distributed running." 158 " The host specification can be a regex.",
164 "((host1 dir1) .. (hostN dirN))" 167 argList::addBoolOption
170 "Do not execute function objects",
178 "Override the file handler type",
186 "Name of the local world for parallel communication",
202 Pstream::addValidParOptions(validParOptions);
221 Info<<
"Hosts :\n(" <<
nl;
226 for (
const auto& str : hostProcs)
228 std::string curr(str.substr(0, str.rfind(
'.')));
235 Info<<
" (" << prev.c_str() <<
' ' <<
count <<
')' <<
nl;
239 prev = std::move(curr);
247 Info<<
" (" << prev.c_str() <<
' ' <<
count <<
')' <<
nl;
256 const UList<string>& hostProcs,
257 const UList<fileName>& roots
260 if (hostProcs.size() == roots.size()+1)
263 DynamicList<string> sortedProcs;
264 DynamicList<label> sortedRoots;
268 const fileName& root = roots[i];
269 const string& host = hostProcs[i+1];
270 const label index = sortedProcs.find(host);
274 sortedProcs.push_back(host);
275 sortedRoots.push_back(i);
277 else if (roots[sortedRoots[index]] != root)
284 Info<<
"Roots :\n(" <<
nl;
287 Info<<
" (" << sortedProcs[i].c_str() <<
' ' 288 << roots[sortedRoots[i]] <<
')' <<
nl;
303 void Foam::argList::checkITstream(
const ITstream& is,
const label index)
305 const label remaining = is.nRemainingTokens();
311 <<
"--> FOAM WARNING:" <<
nl 312 <<
"Argument " << index <<
" has " 313 << remaining <<
" excess tokens" <<
nl <<
nl;
319 <<
"--> FOAM WARNING:" <<
nl 320 <<
"Argument " << index <<
" had no tokens" <<
nl <<
nl;
325 void Foam::argList::checkITstream(
const ITstream& is,
const word& optName)
327 const label remaining = is.nRemainingTokens();
333 <<
"--> FOAM WARNING:" <<
nl 334 <<
"Option -" << optName <<
" has " 335 << remaining <<
" excess tokens" <<
nl <<
nl;
341 <<
"--> FOAM WARNING:" <<
nl 342 <<
"Option -" << optName <<
" had no tokens" <<
nl <<
nl;
347 void Foam::argList::raiseBadInput(
const word& optName)
const 352 <<
"Option -" << optName <<
" with invalid input" <<
nl 359 const string& argName,
363 validArgs.push_back(argName);
367 const label index = validArgs.size();
371 argUsage.erase(index);
375 argUsage.set(index, usage);
399 validOptions.set(optName, param);
402 optionUsage.set(optName, usage);
406 advancedOptions.set(optName);
413 if (advanced && validOptions.contains(optName))
415 advancedOptions.set(optName);
419 advancedOptions.erase(optName);
427 std::pair<const char*,int> compat
430 validOptionsCompat.insert
433 std::pair<word,int>(optName, compat.second)
440 std::pair<const char*,int> compat,
444 ignoreOptionsCompat.insert
447 std::pair<bool,int>(expectArg, compat.second)
460 optionUsage.erase(optName);
464 optionUsage.set(optName, usage);
473 notes.push_back(note);
480 validOptions.erase(optName);
481 optionUsage.erase(optName);
482 advancedOptions.erase(optName);
488 argsMandatory_ =
false;
494 return argsMandatory_;
516 const word optName(
"dry-run",
false);
521 advancedOptions.erase(optName);
532 const word optName(
"verbose",
false);
539 "Additional verbosity (can be used multiple times)",
549 advancedOptions.erase(optName);
556 removeOption(
"noFunctionObjects");
560 ignoreOptionCompat({
"noFunctionObjects", 0},
false);
566 "withFunctionObjects",
567 "Execute functionObjects" 585 "Disable use of the controlDict libs entry",
593 removeOption(
"parallel");
594 removeOption(
"roots");
595 removeOption(
"decomposeParDict");
596 removeOption(
"hostRoots");
597 removeOption(
"world");
598 removeOption(
"mpi-threads");
599 validParOptions.clear();
605 parallelThreads_ =
true;
611 checkProcessorDirectories_ =
false;
617 for (
int argi = 1; argi < argc; ++argi)
619 const char *optName = argv[argi];
621 if (optName[0] ==
'-')
625 if (optName == postProcessOptionName)
639 for (
int argi = 1; argi < argc; ++argi)
641 if (strcmp(argv[argi],
"-verbose") == 0)
670 if (
input.isAbsolute())
672 return input.relative(envGlobalPath(), caseTag);
681 Foam::word Foam::argList::optionCompat(
const word& optName)
686 if (!validOptionsCompat.empty())
688 const auto fnd = validOptionsCompat.cfind(optName.substr(1));
692 const auto& alt = fnd.val();
698 <<
"--> FOAM IOWarning :" <<
nl 699 <<
" Found [v" << alt.second <<
"] '" 700 << optName <<
"' instead of '-" 701 << alt.first <<
"' option" 708 return "-" + alt.first;
717 int Foam::argList::optionIgnore(
const word& optName)
721 if (!ignoreOptionsCompat.empty())
723 const auto fnd = ignoreOptionsCompat.cfind(optName);
727 const auto& alt = fnd.val();
731 const int nskip = (alt.first ? 2 : 1);
737 <<
"--> FOAM IOWarning :" <<
nl 738 <<
" Ignoring [v" << alt.second <<
"] '-" 739 << optName << (nskip > 1 ?
" ARG" :
"")
757 bool Foam::argList::regroupArgv(
int& argc,
char**& argv)
767 args_[0] = fileName(argv[0]);
768 for (
int argi = 1; argi < argc; ++argi)
770 const char *optName = argv[argi];
772 if (optName[0] ==
'(' && optName[1] ==
'\0')
778 else if (optName[0] ==
')' && optName[1] ==
'\0')
787 args_[nArgs++] =
group;
794 args_[nArgs++] = argv[argi];
804 else if (optName[0] ==
'-')
808 if (validOptions.contains(optName))
811 args_[nArgs++] = argv[argi];
813 else if ((ignore = optionIgnore(optName)) > 0)
824 args_[nArgs++] = optionCompat(argv[argi]);
829 args_[nArgs++] = argv[argi];
836 args_[nArgs++] =
group;
842 for (
const auto&
s : args_)
848 commandLine_.reserve(len);
854 void Foam::argList::setCasePaths()
858 const auto optIter = options_.cfind(
"case");
864 if (caseDir.empty() || caseDir ==
".")
868 options_.erase(
"case");
873 caseDir.toAbsolute();
884 rootPath_ = caseDir.path();
885 globalCase_ = caseDir.name();
892 setEnv(
"FOAM_CASE", caseDir,
true);
893 setEnv(
"FOAM_CASENAME", globalCase_,
true);
896 setEnv(
"FOAM_EXECUTABLE", executable_,
false);
924 word fileHandlerName;
926 if (parallelThreads_)
932 for (
int argi = 1; argi < argc; ++argi)
934 const char *optName = argv[argi];
936 if (optName[0] ==
'-')
939 bool emitErrorMessage =
false;
941 if (strcmp(optName,
"dry-run") == 0)
945 else if (strcmp(optName,
"verbose") == 0)
949 else if (strcmp(optName,
"mpi-threads") == 0)
953 else if (strcmp(optName,
"fileHandler") == 0)
959 fileHandlerName = argv[argi];
963 emitErrorMessage =
true;
972 if (emitErrorMessage)
978 <<
"Error: option '-" << optName
979 <<
"' requires an argument" <<
nl <<
nl;
987 if (fileHandlerName.empty())
990 if (fileHandlerName.empty())
1006 if (fileOperationInit && fileOperationInit->needsThreading())
1014 if (runControl_.
parRun())
1016 runControl_.
runPar(argc, argv);
1024 regroupArgv(argc, argv);
1025 commandLine_ += args_[0];
1028 executable_ = fileName(args_[0]).name();
1032 for (
int argi = 1; argi < args_.size(); ++argi)
1034 commandLine_ +=
' ';
1035 commandLine_ += args_[argi];
1037 const char *optName = args_[argi].data();
1039 if (optName[0] ==
'-')
1046 <<
"Ignoring lone '-' on the command-line" <<
endl;
1064 wantArg = !optIter.val().empty();
1074 if (argi >= args_.size())
1079 <<
"Error: option '-" << optName
1080 <<
"' requires an argument" <<
nl <<
nl 1081 <<
"See '" << executable_ <<
" -help' for usage" <<
nl 1082 <<
" or '" << executable_
1083 <<
" -help-full' for extended usage" <<
nl 1089 commandLine_ +=
' ';
1090 commandLine_ += args_[argi];
1096 if (strcmp(optName,
"lib") == 0)
1102 else if (strcmp(optName,
"debug-switch") == 0)
1110 else if (strcmp(optName,
"info-switch") == 0)
1118 else if (strcmp(optName,
"opt-switch") == 0)
1130 options_.set(optName, args_[argi]);
1138 options_.insert(optName,
"");
1151 args_[nArgs] = args_[argi];
1157 args_.resize(nArgs);
1159 parse(checkArgs, checkOpts, initialise);
1172 runControl_(
args.runControl_),
1176 executable_(
args.executable_),
1177 rootPath_(
args.rootPath_),
1178 globalCase_(
args.globalCase_),
1182 parse(checkArgs, checkOpts, initialise);
1200 bool quickExit =
false;
1203 if (options_.contains(
"doc"))
1208 else if (options_.contains(
"doc-source"))
1215 if (options_.contains(
"help-full"))
1220 else if (options_.contains(
"help-notes"))
1226 else if (options_.contains(
"help"))
1231 else if (options_.contains(
"help-man"))
1238 if (options_.contains(
"help-compat"))
1251 if (!
check(checkArgs, checkOpts))
1287 <<
"Exec : " << commandLine_.c_str() <<
nl 1288 <<
"Date : " << dateString.c_str() <<
nl 1289 <<
"Time : " << timeString.c_str() <<
nl 1291 <<
"PID : " <<
pid() <<
nl;
1304 const auto space =
build.find(
' ');
1305 if (space != std::string::npos)
1307 build.resize(space);
1319 libs().open(bannerEnabled());
1331 word fileHandlerName
1333 options_.lookup(
"fileHandler",
Foam::getEnv(
"FOAM_FILEHANDLER"))
1336 if (fileHandlerName.empty())
1354 if (runControl_.parRun())
1367 fromSubproc >> procBuild >> hostMachine[proci] >> procPid;
1369 hostProcs[proci] = hostMachine[proci] +
"." +
name(procPid);
1377 <<
" but proc " << subproci <<
" is running " 1401 enum distributedCodes
1403 NON_DISTRIBUTED = 0,
1405 DISTRIBUTED_SINGLE_ROOT = 2,
1406 DISTRIBUTED_MULTIPLE_ROOTS = 3
1410 label distributedType
1412 runControl_.distributed()
1413 ? distributedCodes::DISTRIBUTED
1414 : distributedCodes::NON_DISTRIBUTED
1422 if (runControl_.parRun())
1435 bool adjustOpt =
false;
1439 source /=
"decomposeParDict";
1444 if (!source.isAbsolute() && !source.starts_with(
'.'))
1446 source = rootPath_/globalCase_/source;
1454 options_.set(
"decomposeParDict", source);
1459 label dictNProcs = -1;
1460 if (this->readListIfPresent(
"roots", roots))
1463 runControl_.distributed(
true);
1464 distributedType = distributedCodes::DISTRIBUTED;
1469 <<
"The -roots option must contain values" 1472 if (roots.size() > 1)
1474 dictNProcs = roots.size()+1;
1477 else if (options_.contains(
"hostRoots"))
1479 source =
"-hostRoots";
1480 runControl_.distributed(
true);
1481 distributedType = distributedCodes::DISTRIBUTED;
1483 ITstream is(this->lookup(
"hostRoots"));
1485 List<Tuple2<wordRe, fileName>> hostRoots(is);
1486 checkITstream(is,
"hostRoots");
1488 if (hostRoots.empty())
1491 <<
"The -hostRoots option must contain values" 1497 for (
const auto& hostRoot : hostRoots)
1503 for (
const label matchi : matched)
1505 if (!roots[matchi].empty())
1508 <<
"Multiple matching roots for " 1509 << hostMachine[matchi] <<
" in " 1514 roots[matchi] = hostRoot.second();
1521 if (roots[hosti].empty())
1524 <<
"No matching roots for " 1525 << hostMachine[hosti] <<
" in " 1531 if (roots.size() > 1)
1533 dictNProcs = roots.size()+1;
1540 const bool useDefault = source.empty();
1543 source = rootPath_/globalCase_/
"system"/
"decomposeParDict";
1556 autoPtr<ISstream> dictStream
1561 if (dictStream && dictStream->good())
1571 if (decompDict.getOrDefault(
"distributed",
false))
1574 runControl_.distributed(
true);
1575 distributedType = distributedCodes::DISTRIBUTED;
1577 decompDict.readEntry(
"roots", roots);
1582 <<
"WARNING: running distributed" 1583 <<
" but did not specify roots!" <<
nl;
1587 decompDict.readEntry
1589 "numberOfSubdomains",
1601 <<
"WARNING: running without decomposeParDict " 1602 << this->relativePath(source) <<
nl;
1608 <<
"Cannot read decomposeParDict: " 1609 << this->relativePath(source) <<
nl 1615 const_cast<fileOperation&
>(
fileHandler()).nProcs(nOldProcs);
1620 <<
"Running parallel on single processor. This only" 1621 <<
" makes sense for multi-world simulation" <<
endl;
1630 for (fileName& dir : roots)
1637 if (roots.size() > 1 && roots.uniform())
1642 if (roots.size() == 1)
1646 distributedCodes::DISTRIBUTED_SINGLE_ROOT;
1649 if (dictNProcs <= 0)
1654 else if (roots.size() > 1)
1657 distributedCodes::DISTRIBUTED_MULTIPLE_ROOTS;
1662 <<
"Number of roots " << roots.size()
1663 <<
" != number of sub-ranks " 1685 checkProcessorDirectories_
1692 << this->relativePath(source)
1693 <<
" specifies " << dictNProcs
1694 <<
" processors but job was started with " 1710 label nProcDirs = 0;
1721 rootPath_/globalCase_,
1734 <<
"Number of processor directories = " << nProcDirs
1735 <<
" is not equal to the number of ranks = " 1748 << args_ << options_
1750 << label(runControl_.dryRun())
1751 << label(runControl_.verbose());
1757 label numDryRun, numVerbose;
1762 >> args_ >> options_
1764 >> numDryRun >> numVerbose;
1766 runControl_.distributed(distributedType);
1767 runControl_.dryRun(numDryRun);
1768 runControl_.verbose(numVerbose);
1775 distributedType == distributedCodes::DISTRIBUTED_SINGLE_ROOT
1781 fileName newCasePath;
1785 newCasePath = roots[0]/globalCase_;
1791 options_.set(
"case", newCasePath);
1796 distributedType == distributedCodes::DISTRIBUTED_MULTIPLE_ROOTS
1802 fileName newCasePath;
1808 newCasePath = roots[subproci-1]/globalCase_;
1815 options_.set(
"case", newCasePath);
1838 case_ = globalCase_;
1845 case_ = globalCase_;
1856 if (runControl_.parRun() && ranks.size())
1863 const fileName procDir
1891 <<
" distributed - copying missing directories" 1899 fileName masterRootPath(rootPath_);
1911 for (label proci = 1; proci < pathDirs.size(); ++proci)
1913 if (ranks.contains(proci))
1918 if (pathDirs[proci].empty())
1922 const fileName procDir
1928 const fileName foundDir
1936 && !rankToDirs[
rank].contains(foundDir)
1939 rankToDirs[
rank].push_back(foundDir);
1945 const_cast<fileOperation&
>(
fileHandler()).nProcs(nOldProcs);
1954 forAll(rankToDirs, proci)
1960 for (
const auto& srcDir : rankToDirs[proci])
1962 const fileName tgtDir
1965 / srcDir.relative(masterRootPath)
1971 Pout<<
"On rank " << proci <<
nl 1972 <<
" copying : " << srcDir <<
nl 1973 <<
" to : " << tgtDir <<
endl;
1993 if (!writeHostsSwitch)
1998 if (!writeRootsSwitch)
2006 Info<<
"Case : " << (rootPath_/globalCase_).c_str() <<
nl 2007 <<
"nProcs : " << nProcs <<
nl;
2009 if (runControl_.parRun())
2011 if (hostProcs.size())
2013 if (writeHostsSwitch == 1)
2018 else if (writeHostsSwitch)
2021 Info<<
"Hosts :\n(" <<
nl;
2028 for (
const auto& str : hostProcs)
2030 Info<<
" " << str.c_str() <<
nl;
2037 bool hasPrinted =
false;
2038 if (writeRootsSwitch == 1)
2043 if (writeRootsSwitch && !hasPrinted)
2046 Info<<
"Roots : " << roots <<
nl;
2049 Info<<
"Pstream initialized with:" <<
nl 2050 <<
" floatTransfer : " 2052 <<
" maxCommsSize : " 2054 <<
" nProcsSimpleSum : " 2056 <<
" nonBlockingExchange: " 2059 <<
" exchange algorithm : " 2063 <<
" polling iterations : " 2081 if (hostProcs.size())
2100 Info<<
"fileModificationChecking : " 2101 <<
"Monitoring run-time modified files using " 2114 Info<<
" (fileModificationSkew " 2120 Info<<
" (fileModificationSkew " 2122 <<
", maxFileModificationPolls " 2129 <<
"Invalid setting for maxFileModificationPolls " 2136 Info<<
"allowSystemOperations : ";
2143 Info<<
"Disallowing";
2145 Info<<
" user-supplied system call operations" <<
nl 2168 if (validOptions.contains(
"withFunctionObjects"))
2171 return options_.contains(
"withFunctionObjects");
2173 else if (validOptions.contains(
"noFunctionObjects"))
2176 return !options_.contains(
"noFunctionObjects");
2186 return !options_.contains(
"no-libs");
2195 for (
const word& optName : optionNames)
2197 if (options_.contains(optName))
2209 for (
const word& optName : optionNames)
2211 if (options_.contains(optName))
2226 || optName ==
"parallel" 2227 || optName ==
"roots" 2231 <<
"Option: '" << optName <<
"' is protected" <<
nl 2236 const auto optIter = options_.cfind(optName);
2238 if (!optIter.good() || (optIter.val() != param))
2240 options_.set(optName, param);
2254 || optName ==
"parallel" 2255 || optName ==
"roots" 2259 <<
"Option: '" << optName <<
"' is protected" <<
nl 2265 return options_.erase(optName);
2273 fileName docExt(docDict.get<fileName>(
"doxySourceFileExt"));
2278 docExt.replace(
".",
"_source.");
2283 for (
const fileName& dir : docDirs)
2286 if (dir.starts_with(
"http:") || dir.starts_with(
"https:"))
2288 url = dir/executable_ + docExt;
2296 docFile.starts_with(
"file://")
2297 ?
isFile(docFile.substr(7))
2301 url = std::move(docFile);
2309 <<
"No documentation found for " << executable_
2310 <<
", but you can use -help to display the usage\n" <<
endl;
2315 string docBrowser =
getEnv(
"FOAM_DOC_BROWSER");
2316 if (docBrowser.empty())
2318 docDict.readEntry(
"docBrowser", docBrowser);
2322 if (docBrowser.contains(
"%f"))
2324 docBrowser.replace(
"%f", url);
2328 docBrowser +=
" " + url;
2337 <<
" " << command <<
nl <<
endl;
2349 const label nargs = args_.size()-1;
2350 if (checkArgs && nargs != validArgs.size())
2353 <<
"Expected " << validArgs.size()
2354 <<
" arguments but found " << nargs <<
endl;
2362 const word& optName = iter.key();
2365 !validOptions.contains(optName)
2366 && !validParOptions.contains(optName)
2370 <<
"Invalid option: -" << optName <<
endl;
2380 <<
"See '" << executable_ <<
" -help' for usage" <<
nl 2381 <<
" or '" << executable_
2382 <<
" -help-full' for extended usage" <<
nl 2397 <<
": cannot open root directory " << rootPath()
2411 <<
": cannot open case directory " <<
path()
static void noJobInfo()
Suppress JobInfo, overriding controlDict setting.
static bool floatTransfer
Should compact transfer be used in which floats replace doubles reducing the bandwidth requirement at...
static const word & myWorld()
My world.
bool checkRootCase() const
Check root path and case path.
void printBuildInfo(std::ostream &os, const bool full=true)
Print information about version, build, arch to output stream.
static refPtr< fileOperation > fileHandlerPtr_
The currently active file handler. Avoid accessing directly.
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void setNamedValue(std::string name, int val, bool report=false)
Set named value, but also handle embedded 'name=value' syntax.
A class for handling file names.
static const Enum< commsTypes > commsTypeNames
Enumerated names for the communication types.
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
static std::string::size_type usageMin
Min indentation when displaying usage (default: 20)
static word postProcessOptionName
Standard name for the post-processing option.
static void noMandatoryArgs()
Flag command arguments as being optional (non-mandatory)
static int nProcsFilter() noexcept
Return collated 'processorsDDD' filtering.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool unsetOption(const word &optName)
Unset option directly (use with caution)
static float fileModificationSkew
Time skew (seconds) for file modification checks.
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.
static void set(bool verbose=false)
Activate SIGSEGV signal handler.
Template class for non-intrusive linked lists.
int infoDetailLevel
Global for selective suppression of Info output.
pid_t ppid()
Return the parent PID of this process.
constexpr char nl
The newline '\n' character (0x0a)
static int maxCommsSize
Optional maximum message size (bytes)
static const fileName null
An empty fileName.
static int nProcsSimpleSum
Number of processors to change from linear to tree communication.
std::ostream & stdStream()
Return std::ostream for output operations.
static SLList< string > notes
General usage notes.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static Ostream & writeDivider(Ostream &os)
Write the standard file section divider.
static void gatherList(const UList< commsStruct > &comms, UList< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
static bool & parRun() noexcept
Test if this a parallel run.
Foam::argList::initValidTables dummyInitValidTables
void incrVerbose(int level=1) noexcept
Increase the verbosity level.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void noParallel()
Remove the parallel options.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
static bool printRootsSubscription(const UList< string > &hostProcs, const UList< fileName > &roots)
bool patched()
Test if the patch string appears to be in use, which is when it is defined (non-zero).
static HashTable< std::pair< word, int > > validOptionsCompat
A list of aliases for options.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
static bool postProcess(int argc, char *argv[])
True if the post-processing option is found in the argv list.
Operations on lists of strings.
static void set(bool verbose=false)
Activate SIGINT signal handler.
simpleObjectRegistry & debugObjects()
Access to registered DebugSwitch objects.
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 HashTable< string, label, Hash< label > > argUsage
Short description for program arguments.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
void runPar(int &argc, char **&argv)
Initialize UPstream for a parallel run.
List< string > stringList
List of string.
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
static std::string date()
The current wall-clock date as a string formatted as (MON dd yyyy), where MON is Jan, Feb, etc.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
virtual ~argList()
Destructor.
static int tuning_NBX_
Tuning parameters for non-blocking exchange (NBX)
bool allowFunctionObjects() const
The controlDict 'functions' entry is allowed to be used.
static bool warnAboutAge(const int version) noexcept
Test if an age warning should be emitted.
simpleObjectRegistry & optimisationObjects()
Access to registered OptimisationSwitch objects.
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...
static void printHostsSubscription(const UList< string > &hostProcs)
static void set(bool verbose=false)
Activate SIGFPE handler when FOAM_SIGFPE is enabled. Activate fill memory with signaling_NaN when FOA...
#define forAll(list, i)
Loop across all elements in list.
static void disable() noexcept
Disallow JobInfo by forcing writeJobInfo (InfoSwitch) off.
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...
constexpr const char *const group
Group name for atomic constants.
static void removeOption(const word &optName)
Remove option from validOptions and from optionUsage.
static autoPtr< fileOperationInitialise > New(const word &type, int &argc, char **&argv)
Select initialisation type.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
static int nProcsNonblockingExchange
Number of processors to change to nonBlocking consensual exchange (NBX). Ignored for zero or negative...
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
bool allowLibs() const
The controlDict 'libs' entry is allowed to be used. (eg, has not been disabled by the -no-libs option...
void displayDoc(bool source=false) const
Display documentation in browser.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static void send(const Type &value, const label comm=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Serialize a value and broadcast (root == UPstream::masterNo()). Uses operator<< for serialization...
static const char * name(const bool b) noexcept
A string representation of bool as "false" / "true".
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
static void recv(Type &value, const int fromProcNo, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Receive and deserialize a value. Uses operator>> for de-serialization.
static int nPollProcInterfaces
Number of polling cycles in processor updates.
static void exit(int errNo=1)
Shutdown (finalize) MPI as required and exit program with errNo.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
static HashTable< string > validParOptions
A list of valid parallel options.
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
static bool bannerEnabled()
Banner status (enabled/disabled).
A class for handling words, derived from Foam::string.
static void addDryRunOption(const string &usage, bool advanced=false)
Enable a 'dry-run' bool option, with usage information.
Extract command arguments and options from the supplied argc and argv parameters. ...
static labelList matching(const wordRe &select, const UList< StringType > &input, const bool invert=false)
Determine the list indices for all matches.
static Istream & input(Istream &is, IntRange< T > &range)
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
static int allowSystemOperations
Flag if system operations are allowed.
bool push_back(const fileName &libName)
Add to the list of names, but do not yet open.
void write() const
Write job info to its file in the "running" jobs directory.
virtual void write(Ostream &os, const bool withTitle=true) const
Print error message.
static int maxFileModificationPolls
Max number of times to poll for file modification changes.
Reading is optional [identical to LAZY_READ].
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
string userName()
Return the user's login name.
static std::string::size_type usageMax
Max screen width when displaying usage (default: 80)
static std::string clockTime()
The current wall-clock (in local time) as a string formatted as as (hh:mm:ss).
static void ignoreOptionCompat(std::pair< const char *, int > compat, bool expectArg)
Specify an option to be ignored.
static HashTable< string > optionUsage
Short description for validOptions.
static void noLibs()
Add the '-no-libs' command line option.
graph_traits< Graph >::vertices_size_type size_type
static void noCheckProcessorDirectories()
Disable checking of processor directories.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
string hostName()
Return the system's host name, as per hostname(1)
const int api
OpenFOAM api number (integer) corresponding to the value of OPENFOAM at the time of compilation...
static void recv(Type &value, const label comm=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Receive (from broadcast, root == UPstream::masterNo()) and deserialize a value. Uses operator>> for d...
pid_t pid()
Return the PID of this process.
static HashTable< std::pair< bool, int > > ignoreOptionsCompat
A list of options to ignore.
bool threads() const noexcept
True if MPI threads are desired (default: false)
static void addVerboseOption(const string &usage="", bool advanced=false)
Enable a 'verbose' bool option, with usage information.
static int cacheLevel() noexcept
Return cache level.
static HashSet< string > advancedOptions
The "advanced" options are shown with -help-full (not with –help)
static const Enum< fileCheckTypes > fileCheckTypesNames
Names for the fileCheckTypes.
simpleObjectRegistry & infoObjects()
Access to registered InfoSwitch objects.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
dlLibraryTable & libs() const noexcept
Mutable access to the loaded dynamic libraries.
static fileCheckTypes fileModificationChecking
Type of file modification checking.
static void check(const int retVal, const char *what)
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 autoPtr< fileOperation > New(const word &handlerType, bool verbose=false)
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.
pid_t pgid()
Return the group PID of this process.
static void set(bool verbose=false)
Activate SIGQUIT signal handler.
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text...
static word envExecutable()
Name of the executable from environment variable.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
const std::string buildArch
OpenFOAM build architecture information (machine endian, label/scalar sizes) as a std::string...
static commsTypes defaultCommsType
Default commsType.
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
static void parallelThreads_on()
MPI threads are desired for the application.
void stop()
Job end with "normal" termination.
static fileName envGlobalPath()
Global case (directory) from environment variable.
static word defaultFileHandler
Name of the default fileHandler.
static bool argsMandatory()
Command arguments type (optional/mandatory).
bool setOption(const word &optName, const string ¶m="")
Set option directly (use with caution)
static fileName validate(const std::string &, const bool doClean=true)
Construct fileName without invalid characters, possibly applying other transformations such as changi...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static int algorithm
Preferred exchange algorithm (may change or be removed in future)
meshDefDict readIfPresent("polyMeshPatches", polyPatchNames)
const std::string patch
OpenFOAM patch number as a std::string.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
fileName cwd()
The physical or logical current working directory path name.
::Foam::direction rank(const expressions::valueTypeCode) noexcept
The vector-space rank associated with given valueTypeCode.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static void noBanner()
Disable emitting the banner information.
static Ostream & writeBanner(Ostream &os, const bool noSyntaxHint=false)
Write the standard OpenFOAM file/dictionary banner.
Foam::SubStrings< StringType > splitSpace(const StringType &str, std::string::size_type pos=0)
Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC)
static const fileOperation & fileHandler()
Return the current file handler. Will create the default file handler if necessary.
bool parRun() const noexcept
True if this is (or will be) a parallel run.
List< label > labelList
A List of labels.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
const std::string build
OpenFOAM build information as a std::string.
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.
static void addUsage(const word &optName, const string &usage)
Add option usage information to optionUsage.
static const wordList & allWorlds() noexcept
All worlds.
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))
List< fileName > fileNameList
List of fileName.
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.
Foam::argList args(argc, argv)
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
dictionary & controlDict()
The central control dictionary, the contents of which are either taken directly from the FOAM_CONTROL...
bool send()
Send buffer contents now and not in destructor [advanced usage]. Returns true on success.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
label count(const UList< word > &optionNames) const
Return how many of the specified options were used.
static HashTable< string > validOptions
A list of valid options.
int verbose() const noexcept
Return the verbose flag.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable, return true on success.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
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...
void incrDryRun(int level=1) noexcept
Increase the dry-run level.
forAllConstIters(mixture.phases(), phase)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
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.
readOption
Enumeration defining read preferences.