mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: simplify method names for reading argList options and arguments
- use succincter method names that more closely resemble dictionary
and HashTable method names. This improves method name consistency
between classes and also requires less typing effort:
args.found(optName) vs. args.optionFound(optName)
args.readIfPresent(..) vs. args.optionReadIfPresent(..)
...
args.opt<scalar>(optName) vs. args.optionRead<scalar>(optName)
args.read<scalar>(index) vs. args.argRead<scalar>(index)
- the older method names forms have been retained for code compatibility,
but are now deprecated
This commit is contained in:
@ -280,15 +280,17 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool optRegion = args.optionFound("region");
|
||||
const bool allRegions = args.optionFound("allRegions");
|
||||
const bool writeCellDist = args.optionFound("cellDist");
|
||||
const bool copyZero = args.optionFound("copyZero");
|
||||
const bool copyUniform = args.optionFound("copyUniform");
|
||||
const bool decomposeSets = !args.optionFound("noSets");
|
||||
bool decomposeFieldsOnly = args.optionFound("fields");
|
||||
bool forceOverwrite = args.optionFound("force");
|
||||
const bool ifRequiredDecomposition = args.optionFound("ifRequired");
|
||||
const bool optRegion = args.found("region");
|
||||
const bool allRegions = args.found("allRegions");
|
||||
const bool writeCellDist = args.found("cellDist");
|
||||
const bool copyZero = args.found("copyZero");
|
||||
const bool copyUniform = args.found("copyUniform");
|
||||
const bool decomposeSets = !args.found("noSets");
|
||||
const bool ifRequiredDecomposition = args.found("ifRequired");
|
||||
|
||||
bool decomposeFieldsOnly = args.found("fields");
|
||||
bool forceOverwrite = args.found("force");
|
||||
|
||||
|
||||
// Set time from database
|
||||
#include "createTime.H"
|
||||
@ -298,7 +300,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Allow override of decomposeParDict location
|
||||
fileName decompDictFile;
|
||||
args.optionReadIfPresent("decomposeParDict", decompDictFile);
|
||||
args.readIfPresent("decomposeParDict", decompDictFile);
|
||||
|
||||
wordList regionNames;
|
||||
if (allRegions)
|
||||
@ -317,7 +319,7 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
regionNames = {fvMesh::defaultRegion};
|
||||
args.optionReadIfPresent("region", regionNames[0]);
|
||||
args.readIfPresent("region", regionNames[0]);
|
||||
}
|
||||
|
||||
forAll(regionNames, regioni)
|
||||
|
||||
@ -132,9 +132,9 @@ int main(int argc, char *argv[])
|
||||
#include "createTime.H"
|
||||
|
||||
wordHashSet selectedFields;
|
||||
args.optionReadIfPresent("fields", selectedFields);
|
||||
args.readIfPresent("fields", selectedFields);
|
||||
|
||||
const bool noFields = args.optionFound("noFields");
|
||||
const bool noFields = args.found("noFields");
|
||||
|
||||
if (noFields)
|
||||
{
|
||||
@ -142,7 +142,7 @@ int main(int argc, char *argv[])
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
const bool noLagrangian = args.optionFound("noLagrangian");
|
||||
const bool noLagrangian = args.found("noLagrangian");
|
||||
|
||||
if (noLagrangian)
|
||||
{
|
||||
@ -151,7 +151,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
const bool noReconstructSets = args.optionFound("noSets");
|
||||
const bool noReconstructSets = args.found("noSets");
|
||||
|
||||
if (noReconstructSets)
|
||||
{
|
||||
@ -161,7 +161,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
wordHashSet selectedLagrangianFields;
|
||||
if (args.optionReadIfPresent("lagrangianFields", selectedLagrangianFields))
|
||||
if (args.readIfPresent("lagrangianFields", selectedLagrangianFields))
|
||||
{
|
||||
if (noLagrangian)
|
||||
{
|
||||
@ -173,8 +173,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
const bool newTimes = args.optionFound("newTimes");
|
||||
const bool allRegions = args.optionFound("allRegions");
|
||||
const bool newTimes = args.found("newTimes");
|
||||
const bool allRegions = args.found("allRegions");
|
||||
|
||||
wordList regionNames;
|
||||
wordList regionDirs;
|
||||
@ -195,7 +195,7 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
regionNames = {fvMesh::defaultRegion};
|
||||
if (args.optionReadIfPresent("region", regionNames[0]))
|
||||
if (args.readIfPresent("region", regionNames[0]))
|
||||
{
|
||||
regionDirs = regionNames;
|
||||
}
|
||||
|
||||
@ -504,7 +504,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if
|
||||
(
|
||||
args.optionReadIfPresent("region", regionName)
|
||||
args.readIfPresent("region", regionName)
|
||||
&& regionName != polyMesh::defaultRegion
|
||||
)
|
||||
{
|
||||
@ -513,7 +513,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
scalar mergeTol = defaultMergeTol;
|
||||
args.optionReadIfPresent("mergeTol", mergeTol);
|
||||
args.readIfPresent("mergeTol", mergeTol);
|
||||
|
||||
scalar writeTol = Foam::pow(10.0, -scalar(IOstream::defaultPrecision()));
|
||||
|
||||
@ -534,7 +534,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
const bool fullMatch = args.optionFound("fullMatch");
|
||||
const bool fullMatch = args.found("fullMatch");
|
||||
const bool writeCellDist = args.found("cellDist");
|
||||
|
||||
if (fullMatch)
|
||||
{
|
||||
@ -546,14 +547,10 @@ int main(int argc, char *argv[])
|
||||
<< nl << "This assumes a correct decomposition." << endl;
|
||||
}
|
||||
|
||||
bool writeCellDist = args.optionFound("cellDist");
|
||||
|
||||
|
||||
label nProcs = fileHandler().nProcs(args.path());
|
||||
|
||||
Info<< "Found " << nProcs << " processor directories" << nl << endl;
|
||||
|
||||
|
||||
// Read all time databases
|
||||
PtrList<Time> databases(nProcs);
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ scalar getMergeDistance
|
||||
)
|
||||
{
|
||||
scalar mergeTol = defaultMergeTol;
|
||||
args.optionReadIfPresent("mergeTol", mergeTol);
|
||||
args.readIfPresent("mergeTol", mergeTol);
|
||||
|
||||
const scalar writeTol =
|
||||
Foam::pow(scalar(10.0), -scalar(IOstream::defaultPrecision()));
|
||||
@ -2296,12 +2296,12 @@ int main(int argc, char *argv[])
|
||||
// (replacement for setRootCase that does not abort)
|
||||
|
||||
Foam::argList args(argc, argv);
|
||||
bool decompose = args.optionFound("decompose");
|
||||
const bool reconstruct = args.optionFound("reconstruct");
|
||||
const bool writeCellDist = args.optionFound("cellDist");
|
||||
const bool newTimes = args.optionFound("newTimes");
|
||||
bool overwrite = args.optionFound("overwrite");
|
||||
const bool reconstruct = args.found("reconstruct");
|
||||
const bool writeCellDist = args.found("cellDist");
|
||||
const bool newTimes = args.found("newTimes");
|
||||
|
||||
bool decompose = args.found("decompose");
|
||||
bool overwrite = args.found("overwrite");
|
||||
|
||||
if (Foam::sigFpe::requested())
|
||||
{
|
||||
@ -2476,7 +2476,7 @@ int main(int argc, char *argv[])
|
||||
// Determine any region
|
||||
word regionName = polyMesh::defaultRegion;
|
||||
fileName meshSubDir = polyMesh::meshSubDir;
|
||||
if (args.optionReadIfPresent("region", regionName))
|
||||
if (args.readIfPresent("region", regionName))
|
||||
{
|
||||
meshSubDir = regionName/polyMesh::meshSubDir;
|
||||
}
|
||||
@ -2485,7 +2485,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Allow override of decomposeParDict location
|
||||
fileName decompDictFile;
|
||||
args.optionReadIfPresent("decomposeParDict", decompDictFile);
|
||||
args.readIfPresent("decomposeParDict", decompDictFile);
|
||||
|
||||
|
||||
// Demand driven lagrangian mapper
|
||||
|
||||
Reference in New Issue
Block a user