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.append(host);
275 sortedRoots.append(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.append(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);
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);
1023 regroupArgv(argc, argv);
1024 commandLine_ += args_[0];
1027 executable_ = fileName(args_[0]).name();
1031 for (
int argi = 1; argi < args_.size(); ++argi)
1033 commandLine_ +=
' ';
1034 commandLine_ += args_[argi];
1036 const char *optName = args_[argi].data();
1038 if (optName[0] ==
'-')
1045 <<
"Ignoring lone '-' on the command-line" <<
endl;
1063 wantArg = !optIter.val().empty();
1073 if (argi >= args_.size())
1078 <<
"Error: option '-" << optName
1079 <<
"' requires an argument" <<
nl <<
nl 1080 <<
"See '" << executable_ <<
" -help' for usage" <<
nl 1081 <<
" or '" << executable_
1082 <<
" -help-full' for extended usage" <<
nl 1088 commandLine_ +=
' ';
1089 commandLine_ += args_[argi];
1095 if (strcmp(optName,
"lib") == 0)
1099 libs().
append(this->getList<fileName>(argi));
1101 else if (strcmp(optName,
"debug-switch") == 0)
1109 else if (strcmp(optName,
"info-switch") == 0)
1117 else if (strcmp(optName,
"opt-switch") == 0)
1129 options_.set(optName, args_[argi]);
1137 options_.insert(optName,
"");
1150 args_[nArgs] = args_[argi];
1156 args_.resize(nArgs);
1158 parse(checkArgs, checkOpts, initialise);
1171 runControl_(
args.runControl_),
1175 executable_(
args.executable_),
1176 rootPath_(
args.rootPath_),
1177 globalCase_(
args.globalCase_),
1181 parse(checkArgs, checkOpts, initialise);
1199 bool quickExit =
false;
1202 if (options_.contains(
"doc"))
1207 else if (options_.contains(
"doc-source"))
1214 if (options_.contains(
"help-full"))
1219 else if (options_.contains(
"help-notes"))
1225 else if (options_.contains(
"help"))
1230 else if (options_.contains(
"help-man"))
1237 if (options_.contains(
"help-compat"))
1250 if (!
check(checkArgs, checkOpts))
1286 <<
"Exec : " << commandLine_.c_str() <<
nl 1287 <<
"Date : " << dateString.c_str() <<
nl 1288 <<
"Time : " << timeString.c_str() <<
nl 1290 <<
"PID : " <<
pid() <<
nl;
1303 const auto space =
build.find(
' ');
1304 if (space != std::string::npos)
1306 build.resize(space);
1318 libs().open(bannerEnabled());
1330 word fileHandlerName
1332 options_.lookup(
"fileHandler",
Foam::getEnv(
"FOAM_FILEHANDLER"))
1335 if (fileHandlerName.empty())
1353 if (runControl_.parRun())
1366 fromSubproc >> procBuild >> hostMachine[proci] >> procPid;
1368 hostProcs[proci] = hostMachine[proci] +
"." +
name(procPid);
1376 <<
" but proc " << subproci <<
" is running " 1401 if (runControl_.parRun())
1414 bool adjustOpt =
false;
1418 source /=
"decomposeParDict";
1423 if (!source.isAbsolute() && !source.starts_with(
'.'))
1425 source = rootPath_/globalCase_/source;
1433 options_.set(
"decomposeParDict", source);
1438 label dictNProcs = -1;
1439 if (this->readListIfPresent(
"roots", roots))
1442 runControl_.distributed(
true);
1447 <<
"The -roots option must contain values" 1450 if (roots.size() > 1)
1452 dictNProcs = roots.size()+1;
1455 else if (options_.contains(
"hostRoots"))
1457 source =
"-hostRoots";
1458 runControl_.distributed(
true);
1460 ITstream is(this->lookup(
"hostRoots"));
1462 List<Tuple2<wordRe, fileName>> hostRoots(is);
1463 checkITstream(is,
"hostRoots");
1465 if (hostRoots.empty())
1468 <<
"The -hostRoots option must contain values" 1474 for (
const auto& hostRoot : hostRoots)
1480 for (
const label matchi : matched)
1482 if (!roots[matchi].empty())
1485 <<
"Multiple matching roots for " 1486 << hostMachine[matchi] <<
" in " 1491 roots[matchi] = hostRoot.second();
1498 if (roots[hosti].empty())
1501 <<
"No matching roots for " 1502 << hostMachine[hosti] <<
" in " 1508 if (roots.size() > 1)
1510 dictNProcs = roots.size()+1;
1517 const bool useDefault = source.empty();
1520 source = rootPath_/globalCase_/
"system"/
"decomposeParDict";
1533 autoPtr<ISstream> dictStream
1538 if (dictStream && dictStream->good())
1548 if (decompDict.getOrDefault(
"distributed",
false))
1551 runControl_.distributed(
true);
1552 decompDict.readEntry(
"roots", roots);
1557 <<
"WARNING: running distributed" 1558 <<
" but did not specify roots!" <<
nl;
1562 decompDict.readEntry
1564 "numberOfSubdomains",
1576 <<
"WARNING: running without decomposeParDict " 1577 << this->relativePath(source) <<
nl;
1583 <<
"Cannot read decomposeParDict: " 1584 << this->relativePath(source) <<
nl 1590 const_cast<fileOperation&
>(
fileHandler()).nProcs(nOldProcs);
1595 <<
"Running parallel on single processor. This only" 1596 <<
" makes sense for multi-world simulation" <<
endl;
1603 if (roots.size() == 1)
1605 const fileName rootName(roots[0]);
1609 if (dictNProcs <= 0)
1611 dictNProcs = roots.size()+1;
1627 checkProcessorDirectories_
1633 << this->relativePath(source)
1634 <<
" specifies " << dictNProcs
1635 <<
" processors but job was started with " 1646 <<
"number of entries in roots " 1648 <<
" is not equal to the number of sub-processes " 1653 for (fileName& dir : roots)
1659 const bool hadCaseOpt = options_.contains(
"case");
1662 options_.set(
"case", roots[subproci-1]/globalCase_);
1667 << args_ << options_
1668 << runControl_.distributed()
1669 << label(runControl_.dryRun())
1670 << label(runControl_.verbose());
1672 options_.erase(
"case");
1677 options_.set(
"case", rootPath_/globalCase_);
1686 checkProcessorDirectories_
1692 label nProcDirs = 0;
1703 rootPath_/globalCase_,
1717 <<
"number of processor directories = " 1719 <<
" is not equal to the number of processors = " 1731 << args_ << options_
1732 << runControl_.distributed()
1733 << label(runControl_.dryRun())
1734 << label(runControl_.verbose());
1742 label numDryRun, numVerbose;
1751 >> args_ >> options_
1753 >> numDryRun >> numVerbose;
1755 runControl_.distributed(isDistributed);
1756 runControl_.dryRun(numDryRun);
1757 runControl_.verbose(numVerbose);
1770 case_ = globalCase_;
1777 case_ = globalCase_;
1787 if (runControl_.parRun() && ranks.size())
1794 const fileName procDir
1822 <<
" distributed - copying missing directories" 1830 fileName masterRootPath(rootPath_);
1842 for (label proci = 1; proci < pathDirs.size(); ++proci)
1844 if (ranks.contains(proci))
1849 if (pathDirs[proci].empty())
1853 const fileName procDir
1859 const fileName foundDir
1867 && !rankToDirs[
rank].contains(foundDir)
1870 rankToDirs[
rank].push_back(foundDir);
1876 const_cast<fileOperation&
>(
fileHandler()).nProcs(nOldProcs);
1885 forAll(rankToDirs, proci)
1891 for (
const auto& srcDir : rankToDirs[proci])
1893 const fileName tgtDir
1896 / srcDir.relative(masterRootPath)
1902 Pout<<
"On rank " << proci <<
nl 1903 <<
" copying : " << srcDir <<
nl 1904 <<
" to : " << tgtDir <<
endl;
1924 if (!writeHostsSwitch)
1929 if (!writeRootsSwitch)
1937 Info<<
"Case : " << (rootPath_/globalCase_).c_str() <<
nl 1938 <<
"nProcs : " << nProcs <<
nl;
1940 if (runControl_.parRun())
1942 if (hostProcs.size())
1944 if (writeHostsSwitch == 1)
1949 else if (writeHostsSwitch)
1952 Info<<
"Hosts :\n(" <<
nl;
1959 for (
const auto& str : hostProcs)
1961 Info<<
" " << str.c_str() <<
nl;
1968 bool hasPrinted =
false;
1969 if (writeRootsSwitch == 1)
1974 if (writeRootsSwitch && !hasPrinted)
1977 Info<<
"Roots : " << roots <<
nl;
1980 Info<<
"Pstream initialized with:" <<
nl 1981 <<
" floatTransfer : " 1983 <<
" nProcsSimpleSum : " 1985 <<
" nonBlockingExchange: " 1988 <<
" exchange algorithm : " 1992 <<
" polling iterations : " 2010 if (hostProcs.size())
2029 Info<<
"fileModificationChecking : " 2030 <<
"Monitoring run-time modified files using " 2043 Info<<
" (fileModificationSkew " 2049 Info<<
" (fileModificationSkew " 2051 <<
", maxFileModificationPolls " 2058 <<
"Invalid setting for maxFileModificationPolls " 2065 Info<<
"allowSystemOperations : ";
2072 Info<<
"Disallowing";
2074 Info<<
" user-supplied system call operations" <<
nl 2097 if (validOptions.contains(
"withFunctionObjects"))
2100 return options_.contains(
"withFunctionObjects");
2102 else if (validOptions.contains(
"noFunctionObjects"))
2105 return !options_.contains(
"noFunctionObjects");
2115 return !options_.contains(
"no-libs");
2124 for (
const word& optName : optionNames)
2126 if (options_.contains(optName))
2138 for (
const word& optName : optionNames)
2140 if (options_.contains(optName))
2155 || optName ==
"parallel" 2156 || optName ==
"roots" 2160 <<
"Option: '" << optName <<
"' is protected" <<
nl 2165 const auto optIter = options_.cfind(optName);
2167 if (!optIter.good() || (optIter.val() != param))
2169 options_.set(optName, param);
2183 || optName ==
"parallel" 2184 || optName ==
"roots" 2188 <<
"Option: '" << optName <<
"' is protected" <<
nl 2194 return options_.erase(optName);
2202 fileName docExt(docDict.get<fileName>(
"doxySourceFileExt"));
2207 docExt.replace(
".",
"_source.");
2212 for (
const fileName& dir : docDirs)
2215 if (dir.starts_with(
"http:") || dir.starts_with(
"https:"))
2217 url = dir/executable_ + docExt;
2225 docFile.starts_with(
"file://")
2226 ?
isFile(docFile.substr(7))
2230 url = std::move(docFile);
2238 <<
"No documentation found for " << executable_
2239 <<
", but you can use -help to display the usage\n" <<
endl;
2244 string docBrowser =
getEnv(
"FOAM_DOC_BROWSER");
2245 if (docBrowser.empty())
2247 docDict.readEntry(
"docBrowser", docBrowser);
2251 if (docBrowser.contains(
"%f"))
2253 docBrowser.replace(
"%f", url);
2257 docBrowser +=
" " + url;
2266 <<
" " << command <<
nl <<
endl;
2278 const label nargs = args_.size()-1;
2279 if (checkArgs && nargs != validArgs.size())
2282 <<
"Expected " << validArgs.size()
2283 <<
" arguments but found " << nargs <<
endl;
2291 const word& optName = iter.key();
2294 !validOptions.contains(optName)
2295 && !validParOptions.contains(optName)
2299 <<
"Invalid option: -" << optName <<
endl;
2309 <<
"See '" << executable_ <<
" -help' for usage" <<
nl 2310 <<
" or '" << executable_
2311 <<
" -help-full' for extended usage" <<
nl 2326 <<
": cannot open root directory " << rootPath()
2334 if (checkProcessorDirectories_ && pathDir.empty() &&
Pstream::master())
2340 <<
": 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.
labelList findMatchingStrings(const UnaryMatchPredicate &matcher, const UList< StringType > &input, const bool invert=false)
Extract list indices for all matches.
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 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.
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 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 gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
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_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 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.
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...
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.
bool append(const fileName &libName)
Add to the list of names, but do not yet open.
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.
Foam::SubStrings< StringType > splitSpace(const StringType &str)
Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC)
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.
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...
#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.