ENH: support 'get()' for retrieving argList options

- previously only had 'opt<..>()' for options, but 'get<..>()'
  provides more similarity with dictionary methods.
  The 'opt<..>()' method is retained.
This commit is contained in:
Mark Olesen
2019-11-26 21:07:11 +01:00
committed by Andrew Heather
parent 29ccc00c7d
commit 1310e85225
81 changed files with 155 additions and 141 deletions

View File

@ -40,7 +40,7 @@ if (args.found("initialiseUBCs"))
// converting fixed-value BCs to zero-gradient and vice versa. // converting fixed-value BCs to zero-gradient and vice versa.
// Allow override from command-line -pName option // Allow override from command-line -pName option
const word pName = args.opt<word>("pName", "p"); const word pName = args.get<word>("pName", "p");
// Infer the pressure BCs from the velocity // Infer the pressure BCs from the velocity
wordList pBCTypes wordList pBCTypes

View File

@ -40,7 +40,7 @@ if (args.found("initialiseUBCs"))
// converting fixed-value BCs to zero-gradient and vice versa. // converting fixed-value BCs to zero-gradient and vice versa.
// Allow override from command-line -pName option // Allow override from command-line -pName option
const word pName = args.opt<word>("pName", "p"); const word pName = args.get<word>("pName", "p");
// Infer the pressure BCs from the velocity // Infer the pressure BCs from the velocity
wordList pBCTypes wordList pBCTypes

View File

@ -121,7 +121,7 @@ volScalarField alphac
const word kinematicCloudName const word kinematicCloudName
( (
args.opt<word>("cloud", "kinematicCloud") args.get<word>("cloud", "kinematicCloud")
); );
Info<< "Constructing kinematicCloud " << kinematicCloudName << endl; Info<< "Constructing kinematicCloud " << kinematicCloudName << endl;

View File

@ -59,7 +59,7 @@ volScalarField mu
const word kinematicCloudName const word kinematicCloudName
( (
args.opt<word>("cloud", "kinematicCloud") args.get<word>("cloud", "kinematicCloud")
); );
Info<< "Constructing kinematicCloud " << kinematicCloudName << endl; Info<< "Constructing kinematicCloud " << kinematicCloudName << endl;

View File

@ -51,7 +51,7 @@ autoPtr<compressible::turbulenceModel> turbulence
const word kinematicCloudName const word kinematicCloudName
( (
args.opt<word>("cloud", "kinematicCloud") args.get<word>("cloud", "kinematicCloud")
); );
Info<< "Constructing kinematicCloud " << kinematicCloudName << endl; Info<< "Constructing kinematicCloud " << kinematicCloudName << endl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2018 OpenCFD Ltd. Copyright (C) 2017-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -126,7 +126,8 @@ int main(int argc, char *argv[])
Info<< nl; Info<< nl;
if (args.found("label")) if (args.found("label"))
{ {
Info<< "-label = " << args.opt<label>("label") Info<< "-label = " << args.get<label>("label")
<< " or " << args.opt<label>("label")
#ifdef Foam_argList_1712 #ifdef Foam_argList_1712
<< " or " << args.optionRead<label>("label") // old-compat << " or " << args.optionRead<label>("label") // old-compat
#endif #endif
@ -136,7 +137,8 @@ int main(int argc, char *argv[])
if (args.found("scalar")) if (args.found("scalar"))
{ {
Info<< "-scalar = " << args.opt<scalar>("scalar") Info<< "-scalar = " << args.get<scalar>("scalar")
<< " or " << args.opt<scalar>("label")
#ifdef Foam_argList_1712 #ifdef Foam_argList_1712
<< " or " << args.optionRead<scalar>("scalar") // old-compat << " or " << args.optionRead<scalar>("scalar") // old-compat
#endif #endif
@ -146,7 +148,8 @@ int main(int argc, char *argv[])
if (args.found("string")) if (args.found("string"))
{ {
Info<< "-string = " << args.opt("string") Info<< "-string = " << args.get("string")
<< " or " << args.opt("string")
#ifdef Foam_argList_1712 #ifdef Foam_argList_1712
<< " or " << args.optionRead<scalar>("string") // old-compat << " or " << args.optionRead<scalar>("string") // old-compat
#endif #endif

View File

@ -86,7 +86,7 @@ int main(int argc, char *argv[])
instantList times = timeSelector::selectIfPresent(runTime, args); instantList times = timeSelector::selectIfPresent(runTime, args);
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
const fileName decompDictFile = args.opt<fileName>("decomposeParDict", ""); const fileName decompDictFile = args.get<fileName>("decomposeParDict", "");
wordList regionNames; wordList regionNames;
wordList regionDirs; wordList regionDirs;

View File

@ -100,8 +100,8 @@ int main(int argc, char *argv[])
const bool allRegions = args.found("allRegions"); const bool allRegions = args.found("allRegions");
const bool verbose = args.found("verbose"); const bool verbose = args.found("verbose");
const label numSubdomains = args.opt<label>("domains", 0); const label numSubdomains = args.get<label>("domains", 0);
const word methodName = args.opt<word>("method", word::null); const word methodName = args.get<word>("method", word::null);
// Set time from database // Set time from database
#include "createTime.H" #include "createTime.H"
@ -109,7 +109,7 @@ int main(int argc, char *argv[])
instantList times = timeSelector::selectIfPresent(runTime, args); instantList times = timeSelector::selectIfPresent(runTime, args);
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
const fileName decompDictFile = args.opt<fileName>("decomposeParDict", ""); const fileName decompDictFile = args.get<fileName>("decomposeParDict", "");
// Get all region names // Get all region names
wordList regionNames; wordList regionNames;
@ -123,7 +123,7 @@ int main(int argc, char *argv[])
else else
{ {
regionNames.resize(1); regionNames.resize(1);
regionNames.first() = args.opt<word>("region", fvMesh::defaultRegion); regionNames.first() = args.get<word>("region", fvMesh::defaultRegion);
} }
forAll(regionNames, regioni) forAll(regionNames, regioni)

View File

@ -47,7 +47,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
const label maxCount = args.opt<label>("max", 1000); const label maxCount = args.get<label>("max", 1000);
externalFileCoupler coupler; externalFileCoupler coupler;

View File

@ -198,7 +198,7 @@ int main(int argc, char *argv[])
} }
{ {
const label celli = args.opt<label>("cell", 0); const label celli = args.get<label>("cell", 0);
tensorField mI(momentOfInertia::meshInertia(mesh)); tensorField mI(momentOfInertia::meshInertia(mesh));

View File

@ -67,7 +67,7 @@ int main(int argc, char *argv[])
bool useBSpline = args.found("B"); bool useBSpline = args.found("B");
bool useCatmullRom = args.found("CMR"); bool useCatmullRom = args.found("CMR");
const label nSeg = args.opt<label>("n", 20); const label nSeg = args.get<label>("n", 20);
if (!useCatmullRom && !useBSpline) if (!useCatmullRom && !useBSpline)
{ {

View File

@ -188,7 +188,7 @@ int main(int argc, char *argv[])
if (args.found("fixed")) if (args.found("fixed"))
{ {
const label width = args.opt<label>("fixed"); const label width = args.get<label>("fixed");
Info<< "split on fixed width = " << width << nl Info<< "split on fixed width = " << width << nl
<< "~~~~~~~~~~~~~~" << nl; << "~~~~~~~~~~~~~~" << nl;

View File

@ -130,7 +130,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
const scalar scaleFactor = args.opt<scalar>("scale", -1); const scalar scaleFactor = args.get<scalar>("scale", -1);
const word outputFile(args.executable() + ".obj"); const word outputFile(args.executable() + ".obj");
@ -194,7 +194,7 @@ int main(int argc, char *argv[])
word mergeOp; word mergeOp;
if (args.found("mergePoints")) if (args.found("mergePoints"))
{ {
cuts.mergePoints(args.opt<scalar>("mergePoints")); cuts.mergePoints(args.get<scalar>("mergePoints"));
mergeOp = "mergePoints"; mergeOp = "mergePoints";
} }
else if (args.found("mergeEdges")) else if (args.found("mergeEdges"))

View File

@ -141,7 +141,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
const bool optStdout = args.found("stdout"); const bool optStdout = args.found("stdout");
const scalar scaleFactor = args.opt<scalar>("scale", 0); const scalar scaleFactor = args.get<scalar>("scale", 0);
const fileName importName = args[1]; const fileName importName = args[1];
const fileName exportName = optStdout ? "-stdout" : args[2]; const fileName exportName = optStdout ? "-stdout" : args[2];

View File

@ -53,7 +53,7 @@ int main(int argc, char *argv[])
argList args(argc, argv, false, true); argList args(argc, argv, false, true);
const label repeat = args.opt<label>("repeat", 1); const label repeat = args.get<label>("repeat", 1);
const bool optVerbose = args.found("verbose"); const bool optVerbose = args.found("verbose");

View File

@ -47,7 +47,7 @@ int main(int argc, char *argv[])
argList args(argc, argv, false, true); argList args(argc, argv, false, true);
const scalar currTime = args.opt<scalar>("time", GREAT); const scalar currTime = args.get<scalar>("time", GREAT);
Info<< "Using currTime = " << currTime << nl Info<< "Using currTime = " << currTime << nl
<< "when loading " << (args.size()-1) << " files" << nl << nl; << "when loading " << (args.size()-1) << " files" << nl << nl;
@ -103,7 +103,7 @@ int main(int argc, char *argv[])
{ {
vtk::seriesWriter writer; vtk::seriesWriter writer;
writer.scan(args.opt<fileName>("scan")); writer.scan(args.get<fileName>("scan"));
Info<< "scanned for files" << nl; Info<< "scanned for files" << nl;
writer.print(Info); writer.print(Info);

View File

@ -383,7 +383,7 @@ int main(int argc, char *argv[])
// Sin of angle between two consecutive edges on a face. // Sin of angle between two consecutive edges on a face.
// If sin(angle) larger than this the face will be considered concave. // If sin(angle) larger than this the face will be considered concave.
const scalar concaveAngle = args.opt<scalar>("concaveAngle", 30); const scalar concaveAngle = args.get<scalar>("concaveAngle", 30);
const scalar concaveSin = Foam::sin(degToRad(concaveAngle)); const scalar concaveSin = Foam::sin(degToRad(concaveAngle));

View File

@ -561,7 +561,7 @@ int main(int argc, char *argv[])
const bool geometry = args.found("geometry"); const bool geometry = args.found("geometry");
const bool overwrite = args.found("overwrite"); const bool overwrite = args.found("overwrite");
const scalar edgeTol = args.opt<scalar>("tol", 0.2); const scalar edgeTol = args.get<scalar>("tol", 0.2);
Info<< "Trying to split cells with internal angles > feature angle\n" << nl Info<< "Trying to split cells with internal angles > feature angle\n" << nl
<< "featureAngle : " << featureAngle << nl << "featureAngle : " << featureAngle << nl

View File

@ -323,7 +323,7 @@ int main(int argc, char *argv[])
FatalError.exit(); FatalError.exit();
} }
const scalar scaleFactor = args.opt<scalar>("scale", 1); const scalar scaleFactor = args.get<scalar>("scale", 1);
#include "createTime.H" #include "createTime.H"

View File

@ -188,7 +188,7 @@ int main(int argc, char *argv[])
} }
// By default, no scaling // By default, no scaling
const scalar scaleFactor = args.opt<scalar>("scale", 1); const scalar scaleFactor = args.get<scalar>("scale", 1);
// Default to binary output, unless otherwise specified // Default to binary output, unless otherwise specified
const IOstream::streamFormat format = const IOstream::streamFormat format =

View File

@ -71,7 +71,7 @@ int main(int argc, char *argv[])
FatalError.exit(); FatalError.exit();
} }
const scalar scaleFactor = args.opt<scalar>("scale", 1); const scalar scaleFactor = args.get<scalar>("scale", 1);
#include "createTime.H" #include "createTime.H"

View File

@ -105,7 +105,7 @@ int main(int argc, char *argv[])
( (
args[1], args[1],
// Default no scaling // Default no scaling
args.opt<scalar>("scale", 1) args.get<scalar>("scale", 1)
); );

View File

@ -904,7 +904,7 @@ int main(int argc, char *argv[])
FatalError.exit(); FatalError.exit();
} }
const scalar scaleFactor = args.opt<scalar>("scale", 1); const scalar scaleFactor = args.get<scalar>("scale", 1);
const bool writeSets = args.found("writeSets"); const bool writeSets = args.found("writeSets");
const bool writeZones = args.found("writeZones"); const bool writeZones = args.found("writeZones");

View File

@ -99,7 +99,7 @@ int main(int argc, char *argv[])
} }
// Default rescale from [m] to [mm] // Default rescale from [m] to [mm]
const scalar scaleFactor = args.opt<scalar>("scale", 1000); const scalar scaleFactor = args.get<scalar>("scale", 1000);
const bool writeBndFile = !args.found("noBnd"); const bool writeBndFile = !args.found("noBnd");
#include "createPolyMesh.H" #include "createPolyMesh.H"

View File

@ -83,7 +83,7 @@ int main(int argc, char *argv[])
fileName exportName = args[1]; fileName exportName = args[1];
const scalar scaleFactor = args.opt<scalar>("scale", 0); const scalar scaleFactor = args.get<scalar>("scale", 0);
const bool doTriangulate = args.found("tri"); const bool doTriangulate = args.found("tri");
fileName exportBase = exportName.lessExt(); fileName exportBase = exportName.lessExt();

View File

@ -648,7 +648,7 @@ int main(int argc, char *argv[])
FatalError.exit(); FatalError.exit();
} }
const scalar scaleFactor = args.opt<scalar>("scale", 1); const scalar scaleFactor = args.get<scalar>("scale", 1);
#include "createTime.H" #include "createTime.H"

View File

@ -87,7 +87,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
const fileName kivaFileName = args.opt<fileName>("file", "otape17"); const fileName kivaFileName = args.get<fileName>("file", "otape17");
kivaVersions kivaVersion = kiva3v; kivaVersions kivaVersion = kiva3v;
if (args.found("version")) if (args.found("version"))
@ -113,7 +113,7 @@ int main(int argc, char *argv[])
} }
} }
const scalar zHeadMin = args.opt<scalar>("zHeadMin", -GREAT); const scalar zHeadMin = args.get<scalar>("zHeadMin", -GREAT);
#include "readKivaGrid.H" #include "readKivaGrid.H"

View File

@ -96,7 +96,7 @@ int main(int argc, char *argv[])
FatalError.exit(); FatalError.exit();
} }
const scalar scaleFactor = args.opt<scalar>("scale", 1); const scalar scaleFactor = args.get<scalar>("scale", 1);
const bool readBlank = !args.found("noBlank"); const bool readBlank = !args.found("noBlank");
const bool singleBlock = args.found("singleBlock"); const bool singleBlock = args.found("singleBlock");

View File

@ -116,7 +116,7 @@ int main(int argc, char *argv[])
prefix, prefix,
runTime, runTime,
// Default rescale from [mm] to [m] // Default rescale from [mm] to [m]
args.opt<scalar>("scale", 0.001), args.get<scalar>("scale", 0.001),
args.found("solids") args.found("solids")
); );

View File

@ -468,19 +468,19 @@ int main(int argc, char *argv[])
} }
if (doCell) if (doCell)
{ {
const label celli = args.opt<label>("cell"); const label celli = args.get<label>("cell");
writePoints(mesh, celli, runTime.timeName()); writePoints(mesh, celli, runTime.timeName());
} }
if (doPoint) if (doPoint)
{ {
const label pointi = args.opt<label>("point"); const label pointi = args.get<label>("point");
writePointCells(mesh, pointi, runTime.timeName()); writePointCells(mesh, pointi, runTime.timeName());
} }
if (doFace) if (doFace)
{ {
const label facei = args.opt<label>("face"); const label facei = args.get<label>("face");
fileName fName fileName fName
( (

View File

@ -250,7 +250,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
args.opt<fileName>("dict", "") args.get<fileName>("dict", "")
) )
); );

View File

@ -74,7 +74,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
const fileName decompDictFile = const fileName decompDictFile =
args.opt<fileName>("decomposeParDict", ""); args.get<fileName>("decomposeParDict", "");
IOdictionary foamyHexMeshDict IOdictionary foamyHexMeshDict
( (

View File

@ -64,7 +64,7 @@ scalar getMergeDistance
const boundBox& bb const boundBox& bb
) )
{ {
const scalar mergeTol = args.opt<scalar>("mergeTol", defaultMergeTol); const scalar mergeTol = args.get<scalar>("mergeTol", defaultMergeTol);
scalar writeTol = scalar writeTol =
Foam::pow(scalar(10), -scalar(IOstream::defaultPrecision())); Foam::pow(scalar(10), -scalar(IOstream::defaultPrecision()));
@ -522,7 +522,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
const fileName decompDictFile = const fileName decompDictFile =
args.opt<fileName>("decomposeParDict", ""); args.get<fileName>("decomposeParDict", "");
labelList decomp = decompositionModel::New labelList decomp = decompositionModel::New
( (

View File

@ -885,7 +885,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
args.opt<fileName>("decomposeParDict", "") args.get<fileName>("decomposeParDict", "")
) )
); );
@ -1962,7 +1962,7 @@ int main(int argc, char *argv[])
fileName outFileName fileName outFileName
( (
args.opt<fileName> args.get<fileName>
( (
"outFile", "outFile",
"constant/triSurface/simplifiedSurface.stl" "constant/triSurface/simplifiedSurface.stl"

View File

@ -139,7 +139,7 @@ int main(int argc, char *argv[])
const bool allTopology = args.found("allTopology"); const bool allTopology = args.found("allTopology");
const bool meshQuality = args.found("meshQuality"); const bool meshQuality = args.found("meshQuality");
const word surfaceFormat = args.opt<word>("writeSets", ""); const word surfaceFormat = args.get<word>("writeSets", "");
const bool writeSets = surfaceFormat.size(); const bool writeSets = surfaceFormat.size();
wordHashSet selectedFields; wordHashSet selectedFields;

View File

@ -534,7 +534,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
const word meshRegionName = const word meshRegionName =
args.opt<word>("region", polyMesh::defaultRegion); args.get<word>("region", polyMesh::defaultRegion);
const bool overwrite = args.found("overwrite"); const bool overwrite = args.found("overwrite");

View File

@ -106,10 +106,10 @@ int main(int argc, char *argv[])
fileName addCase = args[2]; fileName addCase = args[2];
const word masterRegion = const word masterRegion =
args.opt<word>("masterRegion", polyMesh::defaultRegion); args.get<word>("masterRegion", polyMesh::defaultRegion);
const word addRegion = const word addRegion =
args.opt<word>("addRegion", polyMesh::defaultRegion); args.get<word>("addRegion", polyMesh::defaultRegion);
// Since we don't use argList processor directory detection, add it to // Since we don't use argList processor directory detection, add it to
// the casename ourselves so it triggers the logic inside TimePath. // the casename ourselves so it triggers the logic inside TimePath.

View File

@ -203,7 +203,7 @@ int main(int argc, char *argv[])
const word dictName("refineMeshDict"); const word dictName("refineMeshDict");
// Obtain dictPath here for messages // Obtain dictPath here for messages
fileName dictPath = args.opt<fileName>("dict", ""); fileName dictPath = args.get<fileName>("dict", "");
IOobject dictIO = IOobject::selectIO IOobject dictIO = IOobject::selectIO
( (

View File

@ -1952,7 +1952,7 @@ int main(int argc, char *argv[])
if (insidePoint) if (insidePoint)
{ {
const point insidePoint = args.opt<point>("insidePoint"); const point insidePoint = args.get<point>("insidePoint");
label regionI = -1; label regionI = -1;

View File

@ -477,7 +477,7 @@ int main(int argc, char *argv[])
else if (args.found("patch")) else if (args.found("patch"))
{ {
exposedPatchIDs.first() = exposedPatchIDs.first() =
getExposedPatchId(mesh, args.opt<word>("patch")); getExposedPatchId(mesh, args.get<word>("patch"));
} }
else else
{ {

View File

@ -267,7 +267,7 @@ int main(int argc, char *argv[])
} }
else else
{ {
scalar timeValue = args.opt<scalar>("time"); scalar timeValue = args.get<scalar>("time");
runTime.setTime(instant(timeValue), 0); runTime.setTime(instant(timeValue), 0);
} }
} }

View File

@ -330,7 +330,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
const fileName decompDictFile = args.opt<fileName>("decomposeParDict", ""); const fileName decompDictFile = args.get<fileName>("decomposeParDict", "");
// Get all region names // Get all region names
wordList regionNames; wordList regionNames;
@ -344,7 +344,7 @@ int main(int argc, char *argv[])
else else
{ {
regionNames.resize(1); regionNames.resize(1);
regionNames.first() = args.opt<word>("region", fvMesh::defaultRegion); regionNames.first() = args.get<word>("region", fvMesh::defaultRegion);
} }
forAll(regionNames, regioni) forAll(regionNames, regioni)

View File

@ -509,7 +509,7 @@ int main(int argc, char *argv[])
Info<< "Operating on region " << regionName << nl << endl; Info<< "Operating on region " << regionName << nl << endl;
} }
const scalar mergeTol = args.opt<scalar>("mergeTol", defaultMergeTol); const scalar mergeTol = args.get<scalar>("mergeTol", defaultMergeTol);
scalar writeTol = Foam::pow(10.0, -scalar(IOstream::defaultPrecision())); scalar writeTol = Foam::pow(10.0, -scalar(IOstream::defaultPrecision()));

View File

@ -117,7 +117,7 @@ scalar getMergeDistance
const boundBox& bb const boundBox& bb
) )
{ {
const scalar mergeTol = args.opt<scalar>("mergeTol", defaultMergeTol); const scalar mergeTol = args.get<scalar>("mergeTol", defaultMergeTol);
const scalar writeTol = const scalar writeTol =
Foam::pow(scalar(10), -scalar(IOstream::defaultPrecision())); Foam::pow(scalar(10), -scalar(IOstream::defaultPrecision()));
@ -2496,7 +2496,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
const fileName decompDictFile = args.opt<fileName>("decomposeParDict", ""); const fileName decompDictFile = args.get<fileName>("decomposeParDict", "");
// Get all region names // Get all region names
wordList regionNames; wordList regionNames;
@ -2510,7 +2510,7 @@ int main(int argc, char *argv[])
else else
{ {
regionNames.resize(1); regionNames.resize(1);
regionNames.first() = args.opt<word>("region", fvMesh::defaultRegion); regionNames.first() = args.get<word>("region", fvMesh::defaultRegion);
} }

View File

@ -245,7 +245,7 @@ int main(int argc, char *argv[])
ensightCase::options caseOpts(format); ensightCase::options caseOpts(format);
caseOpts.nodeValues(args.found("nodeValues")); caseOpts.nodeValues(args.found("nodeValues"));
caseOpts.width(args.opt<label>("width", 8)); caseOpts.width(args.get<label>("width", 8));
caseOpts.overwrite(true); // remove existing output directory caseOpts.overwrite(true); // remove existing output directory
// Can also have separate directory for lagrangian // Can also have separate directory for lagrangian
@ -255,7 +255,7 @@ int main(int argc, char *argv[])
// Define sub-directory name to use for EnSight data. // Define sub-directory name to use for EnSight data.
// The path to the ensight directory is at case level only // The path to the ensight directory is at case level only
// - For parallel cases, data only written from master // - For parallel cases, data only written from master
fileName outputDir = args.opt<word>("name", "EnSight"); fileName outputDir = args.get<word>("name", "EnSight");
if (!outputDir.isAbsolute()) if (!outputDir.isAbsolute())
{ {
outputDir = args.globalPath()/outputDir; outputDir = args.globalPath()/outputDir;

View File

@ -206,7 +206,7 @@ int main(int argc, char *argv[])
// //
ensightCase::options caseOpts(format); ensightCase::options caseOpts(format);
caseOpts.width(args.opt<label>("width", 8)); caseOpts.width(args.get<label>("width", 8));
caseOpts.overwrite(false); // leave existing output directory caseOpts.overwrite(false); // leave existing output directory
// Can also have separate directory for lagrangian // Can also have separate directory for lagrangian
@ -215,7 +215,7 @@ int main(int argc, char *argv[])
// Define sub-directory name to use for EnSight data. // Define sub-directory name to use for EnSight data.
// The path to the ensight directory is at case level only // The path to the ensight directory is at case level only
// - For parallel cases, data only written from master // - For parallel cases, data only written from master
fileName ensightDir = args.opt<word>("name", "Ensight"); fileName ensightDir = args.get<word>("name", "Ensight");
if (!ensightDir.isAbsolute()) if (!ensightDir.isAbsolute())
{ {
ensightDir = args.globalPath()/ensightDir; ensightDir = args.globalPath()/ensightDir;

View File

@ -637,7 +637,7 @@ int main(int argc, char *argv[])
else else
{ {
regionNames.resize(1); regionNames.resize(1);
regionNames.first() = args.opt<word>("region", fvMesh::defaultRegion); regionNames.first() = args.get<word>("region", fvMesh::defaultRegion);
} }
@ -699,7 +699,7 @@ int main(int argc, char *argv[])
// Directory management // Directory management
// Sub-directory for output // Sub-directory for output
const word vtkDirName = args.opt<word>("name", "VTK"); const word vtkDirName = args.get<word>("name", "VTK");
const fileName outputDir(args.globalPath()/vtkDirName); const fileName outputDir(args.globalPath()/vtkDirName);

View File

@ -93,10 +93,10 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
const label maxOut = Foam::max(0, args.opt<label>("max", 0)); const label maxOut = Foam::max(0, args.get<label>("max", 0));
const label span = Foam::max(1, args.opt<label>("span", 1)); const label span = Foam::max(1, args.get<label>("span", 1));
const scalar relax = args.opt<scalar>("scale", 1); const scalar relax = args.get<scalar>("scale", 1);
const bool slave = args.found("slave"); const bool slave = args.found("slave");
const bool removeLock = args.found("removeLock"); const bool removeLock = args.found("removeLock");

View File

@ -237,12 +237,12 @@ int main(int argc, char *argv[])
} }
const int divisions = args.opt<int>("divisions", 1); const int divisions = args.get<int>("divisions", 1);
Info<< "Using " << divisions << " per time interval" << nl << endl; Info<< "Using " << divisions << " per time interval" << nl << endl;
const word interpolationType = const word interpolationType =
args.opt<word>("interpolationType", "linear"); args.get<word>("interpolationType", "linear");
Info<< "Using interpolation " << interpolationType << nl << endl; Info<< "Using interpolation " << interpolationType << nl << endl;

View File

@ -175,7 +175,7 @@ int main(int argc, char *argv[])
} }
if (args.found("field")) if (args.found("field"))
{ {
fields.resetFieldFilters(args.opt<wordRe>("field")); fields.resetFieldFilters(args.get<wordRe>("field"));
} }
// Externally stored dictionary for functionObjectList // Externally stored dictionary for functionObjectList

View File

@ -64,12 +64,12 @@ dimensionedScalar ybl("ybl", dimLength, Zero);
if (args.found("ybl")) if (args.found("ybl"))
{ {
// If the boundary-layer thickness is provided use it // If the boundary-layer thickness is provided use it
ybl.value() = args.opt<scalar>("ybl"); ybl.value() = args.get<scalar>("ybl");
} }
else if (args.found("Cbl")) else if (args.found("Cbl"))
{ {
// Calculate boundary layer thickness as Cbl*mean distance to wall // Calculate boundary layer thickness as Cbl*mean distance to wall
ybl.value() = gAverage(y)*args.opt<scalar>("Cbl"); ybl.value() = gAverage(y)*args.get<scalar>("Cbl");
} }
Info<< "\nCreating boundary-layer for U of thickness " Info<< "\nCreating boundary-layer for U of thickness "

View File

@ -252,7 +252,7 @@ int main(int argc, char *argv[])
fileName baseDir fileName baseDir
( (
args.opt<fileName> args.get<fileName>
( (
"templateDir", "templateDir",
"${WM_PROJECT_DIR}/etc/caseDicts/createZeroDirectoryTemplates" "${WM_PROJECT_DIR}/etc/caseDicts/createZeroDirectoryTemplates"

View File

@ -434,7 +434,7 @@ int main(int argc, char *argv[])
} }
const bool enableEntries = args.found("enableFunctionEntries"); const bool enableEntries = args.found("enableFunctionEntries");
const word regionName = args.opt<word>("region", polyMesh::defaultRegion); const word regionName = args.get<word>("region", polyMesh::defaultRegion);
fileName regionPrefix; fileName regionPrefix;
if (regionName != polyMesh::defaultRegion) if (regionName != polyMesh::defaultRegion)

View File

@ -69,7 +69,7 @@ int readNumProcs
IOobject::NO_WRITE, IOobject::NO_WRITE,
false // do not register false // do not register
), ),
args.opt<fileName>(optionName, "") args.get<fileName>(optionName, "")
) )
) )
); );

View File

@ -11,7 +11,7 @@
sourceTimeIndex = Time::findClosestTimeIndex sourceTimeIndex = Time::findClosestTimeIndex
( (
sourceTimes, sourceTimes,
args.opt<scalar>("sourceTime") args.get<scalar>("sourceTime")
); );
} }
} }

View File

@ -20,7 +20,7 @@
sourceTimeIndex = Time::findClosestTimeIndex sourceTimeIndex = Time::findClosestTimeIndex
( (
sourceTimes, sourceTimes,
args.opt<scalar>("sourceTime") args.get<scalar>("sourceTime")
); );
} }
} }

View File

@ -90,7 +90,7 @@ int main(int argc, char *argv[])
const bool addPoint = args.found("points"); const bool addPoint = args.found("points");
const bool mergeRegions = args.found("mergeRegions"); const bool mergeRegions = args.found("mergeRegions");
const scalar scaleFactor = args.opt<scalar>("scale", -1); const scalar scaleFactor = args.get<scalar>("scale", -1);
if (addPoint) if (addPoint)
{ {

View File

@ -1596,7 +1596,7 @@ int main(int argc, char *argv[])
// Scale factor for both surfaces: // Scale factor for both surfaces:
const scalar scaleFactor = args.opt<scalar>("scale", -1); const scalar scaleFactor = args.get<scalar>("scale", -1);
const word surf1Name(args[2]); const word surf1Name(args[2]);
Info<< "Reading surface " << surf1Name << endl; Info<< "Reading surface " << surf1Name << endl;

View File

@ -338,8 +338,8 @@ int main(int argc, char *argv[])
const fileName surfFileName = args[1]; const fileName surfFileName = args[1];
const bool checkSelfIntersect = args.found("checkSelfIntersection"); const bool checkSelfIntersect = args.found("checkSelfIntersection");
const bool splitNonManifold = args.found("splitNonManifold"); const bool splitNonManifold = args.found("splitNonManifold");
const label outputThreshold = args.opt<label>("outputThreshold", 10); const label outputThreshold = args.get<label>("outputThreshold", 10);
const word surfaceFormat = args.opt<word>("writeSets", ""); const word surfaceFormat = args.get<word>("writeSets", "");
const bool writeSets = !surfaceFormat.empty(); const bool writeSets = !surfaceFormat.empty();
autoPtr<surfaceWriter> surfWriter; autoPtr<surfaceWriter> surfWriter;

View File

@ -96,7 +96,7 @@ int main(int argc, char *argv[])
triSurface surf triSurface surf
( (
inFileName, inFileName,
args.opt<scalar>("scale", -1) args.get<scalar>("scale", -1)
); );
surf.writeStats(Info); surf.writeStats(Info);

View File

@ -104,7 +104,7 @@ int main(int argc, char *argv[])
<< exit(FatalError); << exit(FatalError);
} }
const scalar scaleFactor = args.opt<scalar>("scale", -1); const scalar scaleFactor = args.get<scalar>("scale", -1);
Info<< "Input surface :" << inFileName << nl Info<< "Input surface :" << inFileName << nl
<< "Scaling factor :" << scaleFactor << nl << "Scaling factor :" << scaleFactor << nl

View File

@ -130,7 +130,7 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
const scalar scaleFactor = args.opt<scalar>("scale", -1); const scalar scaleFactor = args.get<scalar>("scale", -1);
Info<< "Reading : " << importName << endl; Info<< "Reading : " << importName << endl;
triSurface surf(importName, scaleFactor); triSurface surf(importName, scaleFactor);

View File

@ -63,9 +63,9 @@ int main(int argc, char *argv[])
const point samplePt const point samplePt
( (
args.opt<scalar>("x", 0), args.get<scalar>("x", 0),
args.opt<scalar>("y", 0), args.get<scalar>("y", 0),
args.opt<scalar>("z", 0) args.get<scalar>("z", 0)
); );
Info<< "Looking for nearest face/vertex to " << samplePt << endl; Info<< "Looking for nearest face/vertex to " << samplePt << endl;

View File

@ -89,7 +89,7 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName surfFileName = args[1]; const fileName surfFileName = args[1];
const scalar density = args.opt<scalar>("density", 1); const scalar density = args.get<scalar>("density", 1);
vector refPt = Zero; vector refPt = Zero;
bool calcAroundRefPt = args.readIfPresent("referencePoint", refPt); bool calcAroundRefPt = args.readIfPresent("referencePoint", refPt);

View File

@ -612,8 +612,8 @@ int main(int argc, char *argv[])
const scalar distance(args.get<scalar>(2)); const scalar distance(args.get<scalar>(2));
const scalar extendFactor(args.get<scalar>(3)); const scalar extendFactor(args.get<scalar>(3));
const bool checkSelfIntersect = args.found("checkSelfIntersection"); const bool checkSelfIntersect = args.found("checkSelfIntersection");
const label nSmooth = args.opt<label>("nSmooth", 10); const label nSmooth = args.get<label>("nSmooth", 10);
const scalar featureAngle = args.opt<scalar>("featureAngle", 180); const scalar featureAngle = args.get<scalar>("featureAngle", 180);
const bool debug = args.found("debug"); const bool debug = args.found("debug");

View File

@ -168,7 +168,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
args.opt<fileName>("dict", "") args.get<fileName>("dict", "")
); );
if (!ioCsys.typeHeaderOk<coordinateSystems>(false)) if (!ioCsys.typeHeaderOk<coordinateSystems>(false))

View File

@ -131,7 +131,7 @@ int main(int argc, char *argv[])
Time runTime(args.rootPath(), args.caseName()); Time runTime(args.rootPath(), args.caseName());
const fileName exportName = args[1]; const fileName exportName = args[1];
const word importName = args.opt<word>("name", "default"); const word importName = args.get<word>("name", "default");
// check that writing is supported // check that writing is supported
if (!MeshedSurface<face>::canWriteType(exportName.ext(), true)) if (!MeshedSurface<face>::canWriteType(exportName.ext(), true))
@ -157,7 +157,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
args.opt<fileName>("dict", "") args.get<fileName>("dict", "")
); );
if (!ioCsys.typeHeaderOk<coordinateSystems>(false)) if (!ioCsys.typeHeaderOk<coordinateSystems>(false))

View File

@ -144,7 +144,7 @@ int main(int argc, char *argv[])
const fileName importName = args[1]; const fileName importName = args[1];
const word exportName = args.opt<word>("name", "default"); const word exportName = args.get<word>("name", "default");
// check that reading is supported // check that reading is supported
if (!MeshedSurface<face>::canRead(importName, true)) if (!MeshedSurface<face>::canRead(importName, true))
@ -170,7 +170,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
args.opt<fileName>("dict", "") args.get<fileName>("dict", "")
); );
if (!ioCsys.typeHeaderOk<coordinateSystems>(false)) if (!ioCsys.typeHeaderOk<coordinateSystems>(false))

View File

@ -122,7 +122,7 @@ int main(int argc, char *argv[])
// use UnsortedMeshedSurface, not MeshedSurface to maintain ordering // use UnsortedMeshedSurface, not MeshedSurface to maintain ordering
UnsortedMeshedSurface<face> surf(importName); UnsortedMeshedSurface<face> surf(importName);
const scalar scaling = args.opt<scalar>("scale", -1); const scalar scaling = args.get<scalar>("scale", -1);
if (scaling > 0) if (scaling > 0)
{ {
DetailInfo << " -scale " << scaling << nl; DetailInfo << " -scale " << scaling << nl;

View File

@ -95,7 +95,7 @@ int main(int argc, char *argv[])
Info<< "outside" << endl; Info<< "outside" << endl;
} }
const scalar scaling = args.opt<scalar>("scale", -1); const scalar scaling = args.get<scalar>("scale", -1);
if (scaling > 0) if (scaling > 0)
{ {
Info<< "Input scaling: " << scaling << nl; Info<< "Input scaling: " << scaling << nl;

View File

@ -70,7 +70,7 @@ int main(int argc, char *argv[])
const scalar mergeTol = args.get<scalar>(2); const scalar mergeTol = args.get<scalar>(2);
const fileName outFileName = args[3]; const fileName outFileName = args[3];
const scalar scaling = args.opt<scalar>("scale", -1); const scalar scaling = args.get<scalar>("scale", -1);
Info<< "Reading surface from " << surfFileName << " ..." << nl Info<< "Reading surface from " << surfFileName << " ..." << nl
<< "Merging points within " << mergeTol << " metre." << nl; << "Merging points within " << mergeTol << " metre." << nl;

View File

@ -177,7 +177,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
args.opt<fileName>("decomposeParDict", "") args.get<fileName>("decomposeParDict", "")
) )
); );

View File

@ -213,7 +213,7 @@ int main(int argc, char *argv[])
<< " triangle ..." << endl; << " triangle ..." << endl;
} }
const scalar searchTol = args.opt<scalar>("tol", 1e-3); const scalar searchTol = args.get<scalar>("tol", 1e-3);
// Get search box. Anything not within this box will not be considered. // Get search box. Anything not within this box will not be considered.
const boundBox& meshBb = mesh.bounds(); const boundBox& meshBb = mesh.bounds();

View File

@ -403,7 +403,7 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
dictionary& functionsDict = controlDict.subDict("functions"); dictionary& functionsDict = controlDict.subDict("functions");
const word regionName = args.opt<word>("region", ""); const word regionName = args.get<word>("region", "");
bool modifiedControlDict = false; bool modifiedControlDict = false;

View File

@ -364,16 +364,6 @@ public:
//- Return non-const access to the command options //- Return non-const access to the command options
inline HashTable<string>& options(); inline HashTable<string>& options();
//- Get a value from the argument at index.
// Index 1 is the first (non-option) argument.
template<class T>
inline T get(const label index) const;
//- Read a value from the argument at index.
// Index 1 is the first (non-option) argument.
template<class T>
inline List<T> getList(const label index) const;
//- Return true if the named option is found //- Return true if the named option is found
inline bool found(const word& optName) const; inline bool found(const word& optName) const;
@ -386,15 +376,25 @@ public:
//- Return an input stream from the named option //- Return an input stream from the named option
inline ITstream lookup(const word& optName) const; inline ITstream lookup(const word& optName) const;
//- Get a value from the argument at index.
// Index 1 is the first (non-option) argument.
template<class T>
inline T get(const label index) const;
//- Get a List of values from the argument at index.
// Index 1 is the first (non-option) argument.
template<class T>
inline List<T> getList(const label index) const;
//- Get a value from the named option //- Get a value from the named option
// The default template parameter is string (ie, no conversion). // The default template parameter is string (ie, no conversion).
template<class T=string> template<class T=string>
inline T opt(const word& optName) const; inline T get(const word& optName) const;
//- Get a value from the named option if present, or return default. //- Get a value from the named option if present, or return default.
// Identical to getOrDefault(). // Identical to getOrDefault().
template<class T> template<class T>
inline T opt(const word& optName, const T& deflt) const; inline T get(const word& optName, const T& deflt) const;
//- Read a value from the named option if present. //- Read a value from the named option if present.
// \return true if the named option was found. // \return true if the named option was found.
@ -414,11 +414,7 @@ public:
//- Get a value from the named option if present, or return default. //- Get a value from the named option if present, or return default.
template<class T> template<class T>
inline T getOrDefault inline T getOrDefault(const word& optName, const T& deflt) const;
(
const word& optName,
const T& deflt
) const;
//- Get a List of values from the named option, //- Get a List of values from the named option,
//- treating a single entry like a list of size 1. //- treating a single entry like a list of size 1.
@ -435,6 +431,21 @@ public:
inline bool readListIfPresent(const word& optName, List<T>& list) const; inline bool readListIfPresent(const word& optName, List<T>& list) const;
//- Alternative name for option get(const word& optName)
template<class T=string>
T opt(const word& optName) const
{
return this->get<T>(optName);
}
//- Alternative name for option get(const word& optName, ...)
template<class T>
T opt(const word& optName, const T& deflt) const
{
return this->get<T>(optName, deflt);
}
// Edit // Edit
//- Append a (mandatory) argument to validArgs //- Append a (mandatory) argument to validArgs
@ -650,12 +661,12 @@ public:
} }
//- Deprecated(2018-01) read a value from the named option //- Deprecated(2018-01) read a value from the named option
// \deprecated(2018-01) - use opt() method // \deprecated(2018-01) - use get() method
template<class T> template<class T>
T FOAM_DEPRECATED_FOR(2018-01, "opt() method") T FOAM_DEPRECATED_FOR(2018-01, "get() method")
optionRead(const word& optName) const optionRead(const word& optName) const
{ {
return opt<T>(optName); return get<T>(optName);
} }
//- Deprecated(2018-01) read a value from the named option if present. //- Deprecated(2018-01) read a value from the named option if present.

View File

@ -191,22 +191,22 @@ namespace Foam
} }
template<> inline int32_t argList::opt<int32_t>(const word& optName) const template<> inline int32_t argList::get<int32_t>(const word& optName) const
{ {
return Foam::readInt32(options_[optName]); return Foam::readInt32(options_[optName]);
} }
template<> inline int64_t argList::opt<int64_t>(const word& optName) const template<> inline int64_t argList::get<int64_t>(const word& optName) const
{ {
return Foam::readInt64(options_[optName]); return Foam::readInt64(options_[optName]);
} }
template<> inline float argList::opt<float>(const word& optName) const template<> inline float argList::get<float>(const word& optName) const
{ {
return Foam::readFloat(options_[optName]); return Foam::readFloat(options_[optName]);
} }
template<> inline double argList::opt<double>(const word& optName) const template<> inline double argList::get<double>(const word& optName) const
{ {
return Foam::readDouble(options_[optName]); return Foam::readDouble(options_[optName]);
} }
@ -232,19 +232,19 @@ namespace Foam
template<> template<>
inline string argList::opt<Foam::string>(const word& optName) const inline string argList::get<Foam::string>(const word& optName) const
{ {
return options_[optName]; return options_[optName];
} }
template<> template<>
inline word argList::opt<Foam::word>(const word& optName) const inline word argList::get<Foam::word>(const word& optName) const
{ {
return options_[optName]; return options_[optName];
} }
template<> template<>
inline fileName argList::opt<Foam::fileName>(const word& optName) const inline fileName argList::get<Foam::fileName>(const word& optName) const
{ {
return options_[optName]; return options_[optName];
} }
@ -268,7 +268,7 @@ inline T Foam::argList::get(const label index) const
template<class T> template<class T>
inline T Foam::argList::opt(const word& optName) const inline T Foam::argList::get(const word& optName) const
{ {
ITstream is(optName, options_[optName]); ITstream is(optName, options_[optName]);
@ -282,11 +282,11 @@ inline T Foam::argList::opt(const word& optName) const
template<class T> template<class T>
inline T Foam::argList::opt(const word& optName, const T& deflt) const inline T Foam::argList::get(const word& optName, const T& deflt) const
{ {
if (found(optName)) if (found(optName))
{ {
return opt<T>(optName); return get<T>(optName);
} }
return deflt; return deflt;
@ -302,7 +302,7 @@ inline bool Foam::argList::readIfPresent
{ {
if (found(optName)) if (found(optName))
{ {
val = opt<T>(optName); val = get<T>(optName);
return true; return true;
} }
@ -337,7 +337,7 @@ inline T Foam::argList::getOrDefault
{ {
if (found(optName)) if (found(optName))
{ {
return opt<T>(optName); return get<T>(optName);
} }
return deflt; return deflt;

View File

@ -2,7 +2,7 @@
if (args.found("time")) if (args.found("time"))
{ {
Foam::scalar timeValue = args.opt<scalar>("time"); Foam::scalar timeValue = args.get<scalar>("time");
startTime = Foam::Time::findClosestTimeIndex(Times, timeValue); startTime = Foam::Time::findClosestTimeIndex(Times, timeValue);
} }

View File

@ -8,5 +8,5 @@ IOobject dictIO = IOobject::selectIO
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
args.opt<fileName>("dict", "") args.get<fileName>("dict", "")
); );

View File

@ -8,5 +8,5 @@ IOobject dictIO = IOobject::selectIO
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
args.opt<fileName>("dict", "") args.get<fileName>("dict", "")
); );

View File

@ -8,5 +8,5 @@ IOobject dictIO = IOobject::selectIO
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
args.opt<fileName>("dict", "") args.get<fileName>("dict", "")
); );

View File

@ -8,5 +8,5 @@ IOobject dictIO = IOobject::selectIO
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
args.opt<fileName>("dict", "") args.get<fileName>("dict", "")
); );