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";
1530 autoPtr<ISstream> dictStream
1535 if (dictStream && dictStream->good())
1543 dictionary decompDict(*dictStream);
1545 if (decompDict.getOrDefault(
"distributed",
false))
1548 runControl_.distributed(
true);
1549 decompDict.readEntry(
"roots", roots);
1554 <<
"WARNING: running distributed" 1555 <<
" but did not specify roots!" <<
nl;
1559 decompDict.readEntry
1561 "numberOfSubdomains",
1573 <<
"WARNING: running without decomposeParDict " 1574 << this->relativePath(source) <<
nl;
1580 <<
"Cannot read decomposeParDict: " 1581 << this->relativePath(source) <<
nl 1591 <<
"Running parallel on single processor. This only" 1592 <<
" makes sense for multi-world simulation" <<
endl;
1599 if (roots.size() == 1)
1601 const fileName rootName(roots[0]);
1605 if (dictNProcs <= 0)
1607 dictNProcs = roots.size()+1;
1623 checkProcessorDirectories_
1629 << this->relativePath(source)
1630 <<
" specifies " << dictNProcs
1631 <<
" processors but job was started with " 1642 <<
"number of entries in roots " 1644 <<
" is not equal to the number of sub-processes " 1649 for (fileName& dir : roots)
1655 const bool hadCaseOpt = options_.contains(
"case");
1658 options_.set(
"case", roots[subproci-1]/globalCase_);
1663 << args_ << options_
1664 << runControl_.distributed()
1665 << label(runControl_.dryRun())
1666 << label(runControl_.verbose());
1668 options_.erase(
"case");
1673 options_.set(
"case", rootPath_/globalCase_);
1682 checkProcessorDirectories_
1688 label nProcDirs = 0;
1693 rootPath_/globalCase_
1702 <<
"number of processor directories = " 1704 <<
" is not equal to the number of processors = " 1716 << args_ << options_
1717 << runControl_.distributed()
1718 << label(runControl_.dryRun())
1719 << label(runControl_.verbose());
1727 label numDryRun, numVerbose;
1736 >> args_ >> options_
1738 >> numDryRun >> numVerbose;
1740 runControl_.distributed(isDistributed);
1741 runControl_.dryRun(numDryRun);
1742 runControl_.verbose(numVerbose);
1755 case_ = globalCase_;
1762 case_ = globalCase_;
1766 if (runControl_.distributed())
1777 if (!writeHostsSwitch)
1782 if (!writeRootsSwitch)
1790 Info<<
"Case : " << (rootPath_/globalCase_).c_str() <<
nl 1791 <<
"nProcs : " << nProcs <<
nl;
1793 if (runControl_.parRun())
1795 if (hostProcs.size())
1797 if (writeHostsSwitch == 1)
1802 else if (writeHostsSwitch)
1805 Info<<
"Hosts :\n(" <<
nl;
1812 for (
const auto& str : hostProcs)
1814 Info<<
" " << str.c_str() <<
nl;
1821 bool hasPrinted =
false;
1822 if (writeRootsSwitch == 1)
1827 if (writeRootsSwitch && !hasPrinted)
1830 Info<<
"Roots : " << roots <<
nl;
1833 Info<<
"Pstream initialized with:" <<
nl 1834 <<
" floatTransfer : " 1836 <<
" nProcsSimpleSum : " 1838 <<
" nonBlockingExchange: " 1841 <<
" exchange algorithm : " 1845 <<
" polling iterations : " 1863 if (hostProcs.size())
1882 Info<<
"fileModificationChecking : " 1883 <<
"Monitoring run-time modified files using " 1896 Info<<
" (fileModificationSkew " 1902 Info<<
" (fileModificationSkew " 1904 <<
", maxFileModificationPolls " 1911 <<
"Invalid setting for maxFileModificationPolls " 1918 Info<<
"allowSystemOperations : ";
1925 Info<<
"Disallowing";
1927 Info<<
" user-supplied system call operations" <<
nl 1950 if (validOptions.contains(
"withFunctionObjects"))
1953 return options_.contains(
"withFunctionObjects");
1955 else if (validOptions.contains(
"noFunctionObjects"))
1958 return !options_.contains(
"noFunctionObjects");
1968 return !options_.contains(
"no-libs");
1977 for (
const word& optName : optionNames)
1979 if (options_.contains(optName))
1991 for (
const word& optName : optionNames)
1993 if (options_.contains(optName))
2008 || optName ==
"parallel" 2009 || optName ==
"roots" 2013 <<
"Option: '" << optName <<
"' is protected" <<
nl 2018 const auto optIter = options_.cfind(optName);
2020 if (!optIter.good() || (optIter.val() != param))
2022 options_.set(optName, param);
2036 || optName ==
"parallel" 2037 || optName ==
"roots" 2041 <<
"Option: '" << optName <<
"' is protected" <<
nl 2047 return options_.erase(optName);
2055 fileName docExt(docDict.get<fileName>(
"doxySourceFileExt"));
2060 docExt.replace(
".",
"_source.");
2065 for (
const fileName& dir : docDirs)
2068 if (dir.starts_with(
"http:") || dir.starts_with(
"https:"))
2070 url = dir/executable_ + docExt;
2078 docFile.starts_with(
"file://")
2079 ?
isFile(docFile.substr(7))
2083 url = std::move(docFile);
2091 <<
"No documentation found for " << executable_
2092 <<
", but you can use -help to display the usage\n" <<
endl;
2097 string docBrowser =
getEnv(
"FOAM_DOC_BROWSER");
2098 if (docBrowser.empty())
2100 docDict.readEntry(
"docBrowser", docBrowser);
2104 if (docBrowser.contains(
"%f"))
2106 docBrowser.replace(
"%f", url);
2110 docBrowser +=
" " + url;
2119 <<
" " << command <<
nl <<
endl;
2131 const label nargs = args_.size()-1;
2132 if (checkArgs && nargs != validArgs.size())
2135 <<
"Expected " << validArgs.size()
2136 <<
" arguments but found " << nargs <<
endl;
2144 const word& optName = iter.key();
2147 !validOptions.contains(optName)
2148 && !validParOptions.contains(optName)
2152 <<
"Invalid option: -" << optName <<
endl;
2162 <<
"See '" << executable_ <<
" -help' for usage" <<
nl 2163 <<
" or '" << executable_
2164 <<
" -help-full' for extended usage" <<
nl 2179 <<
": cannot open root directory " << rootPath()
2187 if (checkProcessorDirectories_ && pathDir.empty() &&
Pstream::master())
2193 <<
": 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)
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.
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 set(bool verbose=false)
Activate SIGFPE signal handler when FOAM_SIGFPE is set.
#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 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 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 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.
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)
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.
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.