56 bool Foam::argList::argsMandatory_ =
true;
57 bool Foam::argList::checkProcessorDirectories_ =
true;
58 bool Foam::argList::parallelThreads_ =
false;
75 Foam::argList::initValidTables::initValidTables()
81 "Case directory (instead of current directory)" 87 "Additional library or library list to load.\n" 88 "[Can be used multiple times]",
91 argList::addBoolOption
94 "Disable use of the controlDict 'libs' entry",
102 "Set named DebugSwitch (default value: 1).\n" 103 "[Can be used multiple times]",
111 "Set named InfoSwitch (default value: 1).\n" 112 "[Can be used multiple times]",
120 "Set named OptimisationSwitch (default value: 1).\n" 121 "[Can be used multiple times]",
125 argList::addBoolOption(
"parallel",
"Run in parallel");
126 validParOptions.set(
"parallel",
"");
128 argList::addBoolOption
131 "Request use of MPI threads",
135 argList::addBoolOption
138 "Disable initial MPI_Comm_dup()",
146 "Subprocess root directories for distributed running",
159 "Alternative decomposePar dictionary file" 164 "((host1 dir1) .. (hostN dirN))",
165 "Per-subprocess root directories for distributed running." 166 " The host specification can be a regex.",
172 "((host1 dir1) .. (hostN dirN))" 175 argList::addBoolOption
178 "Do not execute function objects",
186 "Override the file handler type",
194 "Name of the local world for parallel communication",
203 argList::addBoolOption
205 "mpi-split-by-appnum",
206 "Split world communicator based on the APPNUM",
216 Pstream::addValidParOptions(validParOptions);
235 Info<<
"Hosts :\n(" <<
nl;
240 for (
const auto& str : hostProcs)
242 std::string curr(str.substr(0, str.rfind(
'.')));
249 Info<<
" (" << prev.c_str() <<
' ' <<
count <<
')' <<
nl;
253 prev = std::move(curr);
261 Info<<
" (" << prev.c_str() <<
' ' <<
count <<
')' <<
nl;
270 const UList<string>& hostProcs,
271 const UList<fileName>& roots
274 if (hostProcs.size() == roots.size()+1)
277 DynamicList<string> sortedProcs;
278 DynamicList<label> sortedRoots;
282 const fileName& root = roots[i];
283 const string& host = hostProcs[i+1];
284 const label index = sortedProcs.find(host);
288 sortedProcs.push_back(host);
289 sortedRoots.push_back(i);
291 else if (roots[sortedRoots[index]] != root)
298 Info<<
"Roots :\n(" <<
nl;
301 Info<<
" (" << sortedProcs[i].c_str() <<
' ' 302 << roots[sortedRoots[i]] <<
')' <<
nl;
317 void Foam::argList::checkITstream(
const ITstream& is,
const label index)
319 const label remaining = is.nRemainingTokens();
325 <<
"--> FOAM WARNING:" <<
nl 326 <<
"Argument " << index <<
" has " 327 << remaining <<
" excess tokens" <<
nl <<
nl;
333 <<
"--> FOAM WARNING:" <<
nl 334 <<
"Argument " << index <<
" had no tokens" <<
nl <<
nl;
339 void Foam::argList::checkITstream(
const ITstream& is,
const word& optName)
341 const label remaining = is.nRemainingTokens();
347 <<
"--> FOAM WARNING:" <<
nl 348 <<
"Option -" << optName <<
" has " 349 << remaining <<
" excess tokens" <<
nl <<
nl;
355 <<
"--> FOAM WARNING:" <<
nl 356 <<
"Option -" << optName <<
" had no tokens" <<
nl <<
nl;
361 void Foam::argList::raiseBadInput(
const word& optName)
const 366 <<
"Option -" << optName <<
" with invalid input" <<
nl 373 const string& argName,
377 validArgs.push_back(argName);
381 const label index = validArgs.size();
385 argUsage.erase(index);
389 argUsage.set(index, usage);
413 validOptions.set(optName, param);
416 optionUsage.set(optName, usage);
420 advancedOptions.set(optName);
427 if (advanced && validOptions.contains(optName))
429 advancedOptions.set(optName);
433 advancedOptions.erase(optName);
441 std::pair<const char*,int> compat
444 validOptionsCompat.insert
447 std::pair<word,int>(optName, compat.second)
454 std::pair<const char*,int> compat,
458 ignoreOptionsCompat.insert
461 std::pair<bool,int>(expectArg, compat.second)
474 optionUsage.erase(optName);
478 optionUsage.set(optName, usage);
487 notes.push_back(note);
494 validOptions.erase(optName);
495 optionUsage.erase(optName);
496 advancedOptions.erase(optName);
502 argsMandatory_ =
false;
508 return argsMandatory_;
530 const word optName(
"dry-run",
false);
535 advancedOptions.erase(optName);
546 const word optName(
"verbose",
false);
553 "Additional verbosity (can be used multiple times)",
563 advancedOptions.erase(optName);
570 removeOption(
"noFunctionObjects");
574 ignoreOptionCompat({
"noFunctionObjects", 0},
false);
580 "withFunctionObjects",
581 "Execute functionObjects" 599 "Disable use of the controlDict libs entry",
607 removeOption(
"parallel");
608 removeOption(
"roots");
609 removeOption(
"decomposeParDict");
610 removeOption(
"hostRoots");
611 removeOption(
"world");
612 removeOption(
"mpi-threads");
613 removeOption(
"mpi-no-comm-dup");
614 removeOption(
"mpi-split-by-appnum");
615 validParOptions.clear();
621 parallelThreads_ =
true;
627 checkProcessorDirectories_ =
false;
633 for (
int argi = 1; argi < argc; ++argi)
635 const char *optName = argv[argi];
637 if (optName[0] ==
'-')
641 if (optName == postProcessOptionName)
655 for (
int argi = 1; argi < argc; ++argi)
657 if (strcmp(argv[argi],
"-verbose") == 0)
686 if (
input.isAbsolute())
688 return input.relative(envGlobalPath(), caseTag);
697 Foam::word Foam::argList::optionCompat(
const word& optName)
702 if (!validOptionsCompat.empty())
704 const auto fnd = validOptionsCompat.cfind(optName.substr(1));
708 const auto& alt = fnd.val();
714 <<
"--> FOAM IOWarning :" <<
nl 715 <<
" Found [v" << alt.second <<
"] '" 716 << optName <<
"' instead of '-" 717 << alt.first <<
"' option" 724 return "-" + alt.first;
733 int Foam::argList::optionIgnore(
const word& optName)
737 if (!ignoreOptionsCompat.empty())
739 const auto fnd = ignoreOptionsCompat.cfind(optName);
743 const auto& alt = fnd.val();
747 const int nskip = (alt.first ? 2 : 1);
753 <<
"--> FOAM IOWarning :" <<
nl 754 <<
" Ignoring [v" << alt.second <<
"] '-" 755 << optName << (nskip > 1 ?
" ARG" :
"")
773 bool Foam::argList::regroupArgv(
int& argc,
char**& argv)
783 args_[0] = fileName(argv[0]);
784 for (
int argi = 1; argi < argc; ++argi)
786 const char *optName = argv[argi];
788 if (optName[0] ==
'(' && optName[1] ==
'\0')
794 else if (optName[0] ==
')' && optName[1] ==
'\0')
803 args_[nArgs++] =
group;
810 args_[nArgs++] = argv[argi];
820 else if (optName[0] ==
'-')
824 if (validOptions.contains(optName))
827 args_[nArgs++] = argv[argi];
829 else if ((ignore = optionIgnore(optName)) > 0)
840 args_[nArgs++] = optionCompat(argv[argi]);
845 args_[nArgs++] = argv[argi];
852 args_[nArgs++] =
group;
858 for (
const auto&
s : args_)
864 commandLine_.reserve(len);
870 void Foam::argList::setCasePaths()
874 const auto optIter = options_.cfind(
"case");
880 if (caseDir.empty() || caseDir ==
".")
884 options_.erase(
"case");
889 caseDir.toAbsolute();
900 rootPath_ = caseDir.path();
901 globalCase_ = caseDir.name();
908 setEnv(
"FOAM_CASE", caseDir,
true);
909 setEnv(
"FOAM_CASENAME", globalCase_,
true);
912 setEnv(
"FOAM_EXECUTABLE", executable_,
false);
942 word fileHandlerName;
944 if (parallelThreads_)
950 for (
int argi = 1; argi < argc; ++argi)
952 const char *optName = argv[argi];
954 if (optName[0] ==
'-')
957 bool emitErrorMessage =
false;
959 if (strcmp(optName,
"dry-run") == 0)
963 else if (strcmp(optName,
"verbose") == 0)
967 else if (strcmp(optName,
"mpi-threads") == 0)
971 else if (strcmp(optName,
"fileHandler") == 0)
977 fileHandlerName = argv[argi];
981 emitErrorMessage =
true;
984 else if (strcmp(optName,
"debug-switch") == 0)
999 else if (strcmp(optName,
"info-switch") == 0)
1015 else if (strcmp(optName,
"opt-switch") == 0)
1034 runControl_.
parRun(
true);
1037 if (emitErrorMessage)
1043 <<
"Error: option '-" << optName
1044 <<
"' requires an argument" <<
nl <<
nl;
1050 if (fileHandlerName.empty())
1053 if (fileHandlerName.empty())
1069 if (fileOperationInit && fileOperationInit->needsThreading())
1077 if (runControl_.
parRun())
1079 runControl_.
runPar(argc, argv);
1087 regroupArgv(argc, argv);
1088 commandLine_ += args_[0];
1091 executable_ = fileName(args_[0]).name();
1095 for (
int argi = 1; argi < args_.size(); ++argi)
1097 commandLine_ +=
' ';
1098 commandLine_ += args_[argi];
1100 const char *optName = args_[argi].data();
1102 if (optName[0] ==
'-')
1109 <<
"Ignoring lone '-' on the command-line" <<
endl;
1127 wantArg = !optIter.val().empty();
1137 if (argi >= args_.size())
1142 <<
"Error: option '-" << optName
1143 <<
"' requires an argument" <<
nl <<
nl 1144 <<
"See '" << executable_ <<
" -help' for usage" <<
nl 1145 <<
" or '" << executable_
1146 <<
" -help-full' for extended usage" <<
nl 1152 commandLine_ +=
' ';
1153 commandLine_ += args_[argi];
1159 if (strcmp(optName,
"lib") == 0)
1165 else if (strcmp(optName,
"debug-switch") == 0)
1173 else if (strcmp(optName,
"info-switch") == 0)
1181 else if (strcmp(optName,
"opt-switch") == 0)
1193 options_.set(optName, args_[argi]);
1201 options_.insert(optName,
"");
1214 args_[nArgs] = args_[argi];
1220 args_.resize(nArgs);
1222 parse(checkArgs, checkOpts, initialise);
1235 runControl_(
args.runControl_),
1239 executable_(
args.executable_),
1240 rootPath_(
args.rootPath_),
1241 globalCase_(
args.globalCase_),
1245 parse(checkArgs, checkOpts, initialise);
1263 bool quickExit =
false;
1266 if (options_.contains(
"doc"))
1271 else if (options_.contains(
"doc-source"))
1278 if (options_.contains(
"help-full"))
1283 else if (options_.contains(
"help-notes"))
1289 else if (options_.contains(
"help"))
1294 else if (options_.contains(
"help-man"))
1301 if (options_.contains(
"help-compat"))
1314 if (!
check(checkArgs, checkOpts))
1350 <<
"Exec : " << commandLine_.c_str() <<
nl 1351 <<
"Date : " << dateString.c_str() <<
nl 1352 <<
"Time : " << timeString.c_str() <<
nl 1354 <<
"PID : " <<
pid() <<
nl;
1367 const auto space =
build.find(
' ');
1368 if (space != std::string::npos)
1370 build.resize(space);
1382 libs().open(bannerEnabled());
1394 word fileHandlerName
1396 options_.lookup(
"fileHandler",
Foam::getEnv(
"FOAM_FILEHANDLER"))
1399 if (fileHandlerName.empty())
1417 if (runControl_.parRun())
1430 fromSubproc >> procBuild >> hostMachine[proci] >> procPid;
1432 hostProcs[proci] = hostMachine[proci] +
"." +
name(procPid);
1440 <<
" but proc " << subproci <<
" is running " 1464 enum distributedCodes
1466 NON_DISTRIBUTED = 0,
1468 DISTRIBUTED_SINGLE_ROOT = 2,
1469 DISTRIBUTED_MULTIPLE_ROOTS = 3
1473 label distributedType
1475 runControl_.distributed()
1476 ? distributedCodes::DISTRIBUTED
1477 : distributedCodes::NON_DISTRIBUTED
1485 if (runControl_.parRun())
1498 bool adjustOpt =
false;
1502 source /=
"decomposeParDict";
1507 if (!source.isAbsolute() && !source.starts_with(
'.'))
1509 source = rootPath_/globalCase_/source;
1517 options_.set(
"decomposeParDict", source);
1522 label dictNProcs = -1;
1523 if (this->readListIfPresent(
"roots", roots))
1526 runControl_.distributed(
true);
1527 distributedType = distributedCodes::DISTRIBUTED;
1532 <<
"The -roots option must contain values" 1535 if (roots.size() > 1)
1537 dictNProcs = roots.size()+1;
1540 else if (options_.contains(
"hostRoots"))
1542 source =
"-hostRoots";
1543 runControl_.distributed(
true);
1544 distributedType = distributedCodes::DISTRIBUTED;
1546 ITstream is(this->lookup(
"hostRoots"));
1548 List<Tuple2<wordRe, fileName>> hostRoots(is);
1549 checkITstream(is,
"hostRoots");
1551 if (hostRoots.empty())
1554 <<
"The -hostRoots option must contain values" 1560 for (
const auto& hostRoot : hostRoots)
1566 for (
const label matchi : matched)
1568 if (!roots[matchi].empty())
1571 <<
"Multiple matching roots for " 1572 << hostMachine[matchi] <<
" in " 1577 roots[matchi] = hostRoot.second();
1584 if (roots[hosti].empty())
1587 <<
"No matching roots for " 1588 << hostMachine[hosti] <<
" in " 1594 if (roots.size() > 1)
1596 dictNProcs = roots.size()+1;
1603 const bool useDefault = source.empty();
1606 source = rootPath_/globalCase_/
"system"/
"decomposeParDict";
1619 autoPtr<ISstream> dictStream
1624 if (dictStream && dictStream->good())
1634 if (decompDict.getOrDefault(
"distributed",
false))
1637 runControl_.distributed(
true);
1638 distributedType = distributedCodes::DISTRIBUTED;
1640 decompDict.readEntry(
"roots", roots);
1645 <<
"WARNING: running distributed" 1646 <<
" but did not specify roots!" <<
nl;
1650 decompDict.readEntry
1652 "numberOfSubdomains",
1664 <<
"WARNING: running without decomposeParDict " 1665 << this->relativePath(source) <<
nl;
1671 <<
"Cannot read decomposeParDict: " 1672 << this->relativePath(source) <<
nl 1678 const_cast<fileOperation&
>(
fileHandler()).nProcs(nOldProcs);
1683 <<
"Running parallel on single processor. This only" 1684 <<
" makes sense for multi-world simulation" <<
endl;
1693 for (fileName& dir : roots)
1700 if (roots.size() > 1 && roots.uniform())
1705 if (roots.size() == 1)
1709 distributedCodes::DISTRIBUTED_SINGLE_ROOT;
1712 if (dictNProcs <= 0)
1717 else if (roots.size() > 1)
1720 distributedCodes::DISTRIBUTED_MULTIPLE_ROOTS;
1725 <<
"Number of roots " << roots.size()
1726 <<
" != number of sub-ranks " 1748 checkProcessorDirectories_
1755 << this->relativePath(source)
1756 <<
" specifies " << dictNProcs
1757 <<
" processors but job was started with " 1773 label nProcDirs = 0;
1784 rootPath_/globalCase_,
1797 <<
"Number of processor directories = " << nProcDirs
1798 <<
" is not equal to the number of ranks = " 1811 << args_ << options_
1813 << label(runControl_.dryRun())
1814 << label(runControl_.verbose());
1820 label numDryRun, numVerbose;
1825 >> args_ >> options_
1827 >> numDryRun >> numVerbose;
1829 runControl_.distributed(distributedType);
1830 runControl_.dryRun(numDryRun);
1831 runControl_.verbose(numVerbose);
1838 distributedType == distributedCodes::DISTRIBUTED_SINGLE_ROOT
1844 fileName newCasePath;
1848 newCasePath = roots[0]/globalCase_;
1854 options_.set(
"case", newCasePath);
1859 distributedType == distributedCodes::DISTRIBUTED_MULTIPLE_ROOTS
1865 fileName newCasePath;
1871 newCasePath = roots[subproci-1]/globalCase_;
1878 options_.set(
"case", newCasePath);
1901 case_ = globalCase_;
1908 case_ = globalCase_;
1919 if (runControl_.parRun() && ranks.size())
1926 const fileName procDir
1954 <<
" distributed - copying missing directories" 1962 fileName masterRootPath(rootPath_);
1974 for (label proci = 1; proci < pathDirs.size(); ++proci)
1976 if (ranks.contains(proci))
1981 if (pathDirs[proci].empty())
1985 const fileName procDir
1991 const fileName foundDir
1999 && !rankToDirs[
rank].contains(foundDir)
2002 rankToDirs[
rank].push_back(foundDir);
2008 const_cast<fileOperation&
>(
fileHandler()).nProcs(nOldProcs);
2017 forAll(rankToDirs, proci)
2023 for (
const auto& srcDir : rankToDirs[proci])
2025 const fileName tgtDir
2028 / srcDir.relative(masterRootPath)
2034 Pout<<
"On rank " << proci <<
nl 2035 <<
" copying : " << srcDir <<
nl 2036 <<
" to : " << tgtDir <<
endl;
2056 if (!writeHostsSwitch)
2061 if (!writeRootsSwitch)
2069 Info<<
"Case : " << (rootPath_/globalCase_).c_str() <<
nl 2070 <<
"nProcs : " << nProcs <<
nl;
2072 if (runControl_.parRun())
2074 if (hostProcs.size())
2076 if (writeHostsSwitch == 1)
2081 else if (writeHostsSwitch)
2084 Info<<
"Hosts :\n(" <<
nl;
2091 for (
const auto& str : hostProcs)
2093 Info<<
" " << str.c_str() <<
nl;
2100 bool hasPrinted =
false;
2101 if (writeRootsSwitch == 1)
2106 if (writeRootsSwitch && !hasPrinted)
2109 Info<<
"Roots : " << roots <<
nl;
2113 Info<<
"Pstream initialized with:" <<
nl;
2115 Info<<
" node communication : ";
2120 Info<<
" topology controls : ";
2127 Info<<
" floatTransfer : enabled" <<
nl;
2131 Info<<
" maxCommsSize : " 2136 Info<<
" nProcsSimpleSum : " 2140 const auto& commsType =
2143 Info<<
" consensus exchange : " 2146 <<
" exchange algorithm : " 2148 <<
" commsType : " << commsType <<
nl 2149 <<
" polling iterations : " 2168 if (hostProcs.size())
2187 Info<<
"fileModificationChecking : " 2188 <<
"Monitoring run-time modified files using " 2201 Info<<
" (fileModificationSkew " 2207 Info<<
" (fileModificationSkew " 2209 <<
", maxFileModificationPolls " 2216 <<
"Invalid setting for maxFileModificationPolls " 2223 Info<<
"allowSystemOperations : ";
2230 Info<<
"Disallowing";
2232 Info<<
" user-supplied system call operations" <<
nl 2261 if (validOptions.contains(
"withFunctionObjects"))
2264 return options_.contains(
"withFunctionObjects");
2266 else if (validOptions.contains(
"noFunctionObjects"))
2269 return !options_.contains(
"noFunctionObjects");
2279 return !options_.contains(
"no-libs");
2288 for (
const word& optName : optionNames)
2290 if (options_.contains(optName))
2302 for (
const word& optName : optionNames)
2304 if (options_.contains(optName))
2319 || optName ==
"parallel" 2320 || optName ==
"roots" 2324 <<
"Option: '" << optName <<
"' is protected" <<
nl 2329 const auto optIter = options_.cfind(optName);
2331 if (!optIter.good() || (optIter.val() != param))
2333 options_.set(optName, param);
2347 || optName ==
"parallel" 2348 || optName ==
"roots" 2352 <<
"Option: '" << optName <<
"' is protected" <<
nl 2358 return options_.erase(optName);
2366 fileName docExt(docDict.get<fileName>(
"doxySourceFileExt"));
2371 docExt.replace(
".",
"_source.");
2376 for (
const fileName& dir : docDirs)
2379 if (dir.starts_with(
"http:") || dir.starts_with(
"https:"))
2381 url = dir/executable_ + docExt;
2389 docFile.starts_with(
"file://")
2390 ?
isFile(docFile.substr(7))
2394 url = std::move(docFile);
2402 <<
"No documentation found for " << executable_
2403 <<
", but you can use -help to display the usage\n" <<
endl;
2408 string docBrowser =
getEnv(
"FOAM_DOC_BROWSER");
2409 if (docBrowser.empty())
2411 docDict.readEntry(
"docBrowser", docBrowser);
2415 if (docBrowser.contains(
"%f"))
2417 docBrowser.replace(
"%f", url);
2421 docBrowser +=
" " + url;
2430 <<
" " << command <<
nl <<
endl;
2442 const label nargs = args_.size()-1;
2443 if (checkArgs && nargs != validArgs.size())
2446 <<
"Expected " << validArgs.size()
2447 <<
" arguments but found " << nargs <<
endl;
2455 const word& optName = iter.key();
2458 !validOptions.contains(optName)
2459 && !validParOptions.contains(optName)
2463 <<
"Invalid option: -" << optName <<
endl;
2473 <<
"See '" << executable_ <<
" -help' for usage" <<
nl 2474 <<
" or '" << executable_
2475 <<
" -help-full' for extended usage" <<
nl 2490 <<
": cannot open root directory " << rootPath()
2504 <<
": 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 void recv(Type &value, const int communicator=UPstream::worldComm)
Receive (from broadcast, root == UPstream::masterNo()) and deserialize a value. Uses operator>> for d...
static refPtr< fileOperation > fileHandlerPtr_
The currently active file handler. Avoid accessing directly.
static void set(bool verbose=false)
Activate SIGFPE handler when FOAM_SIGFPE is enabled. Activate fill memory with signaling_NaN when FOA...
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.
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)
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)
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 printNodeCommsControl(Ostream &os)
Report the node-communication settings.
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 bool & parRun() noexcept
Test if this a parallel run.
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.
Foam::argList::initValidTables dummyInitValidTables
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.
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.
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 broadcast(Type &value, const int communicator=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
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()). Negative if the process is not a...
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 printHostsSubscription(const UList< string > &hostProcs)
static void gatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate.
#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 label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
static void warnLocalBoundaryConsistencyCompat(const dictionary &)
Warn about keyword changes for local boundary consistency checks.
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 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.
static void printTopoControl(Ostream &os)
Report the topology routines settings.
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.
static void set(bool verbose=false)
Activate SIGQUIT signal handler.
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
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
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...
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 SIGINT 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.
void incrDryRun(int i=1) noexcept
Increase the dry-run level.
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 void send(const Type &value, const int communicator=UPstream::worldComm)
Serialize a value and broadcast (root == UPstream::masterNo()). Uses operator<< for serialization...
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.
void incrVerbose(int i=1) noexcept
Increase the verbosity level.
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict(s).
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)
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...
static void set(bool verbose=false)
Activate SIGSEGV signal handler.
forAllConstIters(mixture.phases(), phase)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
readOption
Enumeration defining read preferences.