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.
// 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
wordList pBCTypes

View File

@ -40,7 +40,7 @@ if (args.found("initialiseUBCs"))
// converting fixed-value BCs to zero-gradient and vice versa.
// 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
wordList pBCTypes

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -188,7 +188,7 @@ int main(int argc, char *argv[])
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
<< "~~~~~~~~~~~~~~" << nl;

View File

@ -130,7 +130,7 @@ int main(int argc, char *argv[])
#include "setRootCase.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");
@ -194,7 +194,7 @@ int main(int argc, char *argv[])
word mergeOp;
if (args.found("mergePoints"))
{
cuts.mergePoints(args.opt<scalar>("mergePoints"));
cuts.mergePoints(args.get<scalar>("mergePoints"));
mergeOp = "mergePoints";
}
else if (args.found("mergeEdges"))

View File

@ -141,7 +141,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
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 exportName = optStdout ? "-stdout" : args[2];

View File

@ -53,7 +53,7 @@ int main(int argc, char *argv[])
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");

View File

@ -47,7 +47,7 @@ int main(int argc, char *argv[])
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
<< "when loading " << (args.size()-1) << " files" << nl << nl;
@ -103,7 +103,7 @@ int main(int argc, char *argv[])
{
vtk::seriesWriter writer;
writer.scan(args.opt<fileName>("scan"));
writer.scan(args.get<fileName>("scan"));
Info<< "scanned for files" << nl;
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.
// 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));

View File

@ -561,7 +561,7 @@ int main(int argc, char *argv[])
const bool geometry = args.found("geometry");
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
<< "featureAngle : " << featureAngle << nl

View File

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

View File

@ -188,7 +188,7 @@ int main(int argc, char *argv[])
}
// 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
const IOstream::streamFormat format =

View File

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

View File

@ -105,7 +105,7 @@ int main(int argc, char *argv[])
(
args[1],
// 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();
}
const scalar scaleFactor = args.opt<scalar>("scale", 1);
const scalar scaleFactor = args.get<scalar>("scale", 1);
const bool writeSets = args.found("writeSets");
const bool writeZones = args.found("writeZones");

View File

@ -99,7 +99,7 @@ int main(int argc, char *argv[])
}
// 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");
#include "createPolyMesh.H"

View File

@ -83,7 +83,7 @@ int main(int argc, char *argv[])
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");
fileName exportBase = exportName.lessExt();

View File

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

View File

@ -87,7 +87,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
#include "createTime.H"
const fileName kivaFileName = args.opt<fileName>("file", "otape17");
const fileName kivaFileName = args.get<fileName>("file", "otape17");
kivaVersions kivaVersion = kiva3v;
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"

View File

@ -96,7 +96,7 @@ int main(int argc, char *argv[])
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 singleBlock = args.found("singleBlock");

View File

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

View File

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

View File

@ -250,7 +250,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ_IF_MODIFIED,
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
const fileName decompDictFile =
args.opt<fileName>("decomposeParDict", "");
args.get<fileName>("decomposeParDict", "");
IOdictionary foamyHexMeshDict
(

View File

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

View File

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

View File

@ -139,7 +139,7 @@ int main(int argc, char *argv[])
const bool allTopology = args.found("allTopology");
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();
wordHashSet selectedFields;

View File

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

View File

@ -106,10 +106,10 @@ int main(int argc, char *argv[])
fileName addCase = args[2];
const word masterRegion =
args.opt<word>("masterRegion", polyMesh::defaultRegion);
args.get<word>("masterRegion", polyMesh::defaultRegion);
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
// 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");
// Obtain dictPath here for messages
fileName dictPath = args.opt<fileName>("dict", "");
fileName dictPath = args.get<fileName>("dict", "");
IOobject dictIO = IOobject::selectIO
(

View File

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

View File

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

View File

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

View File

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

View File

@ -509,7 +509,7 @@ int main(int argc, char *argv[])
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()));

View File

@ -117,7 +117,7 @@ scalar getMergeDistance
const boundBox& bb
)
{
const scalar mergeTol = args.opt<scalar>("mergeTol", defaultMergeTol);
const scalar mergeTol = args.get<scalar>("mergeTol", defaultMergeTol);
const scalar writeTol =
Foam::pow(scalar(10), -scalar(IOstream::defaultPrecision()));
@ -2496,7 +2496,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location
const fileName decompDictFile = args.opt<fileName>("decomposeParDict", "");
const fileName decompDictFile = args.get<fileName>("decomposeParDict", "");
// Get all region names
wordList regionNames;
@ -2510,7 +2510,7 @@ int main(int argc, char *argv[])
else
{
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);
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
// 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.
// The path to the ensight directory is at case level only
// - 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())
{
outputDir = args.globalPath()/outputDir;

View File

@ -206,7 +206,7 @@ int main(int argc, char *argv[])
//
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
// 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.
// The path to the ensight directory is at case level only
// - 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())
{
ensightDir = args.globalPath()/ensightDir;

View File

@ -637,7 +637,7 @@ int main(int argc, char *argv[])
else
{
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
// 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);

View File

@ -93,10 +93,10 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const label maxOut = Foam::max(0, args.opt<label>("max", 0));
const label span = Foam::max(1, args.opt<label>("span", 1));
const label maxOut = Foam::max(0, args.get<label>("max", 0));
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 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;
const word interpolationType =
args.opt<word>("interpolationType", "linear");
args.get<word>("interpolationType", "linear");
Info<< "Using interpolation " << interpolationType << nl << endl;

View File

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

View File

@ -64,12 +64,12 @@ dimensionedScalar ybl("ybl", dimLength, Zero);
if (args.found("ybl"))
{
// 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"))
{
// 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 "

View File

@ -252,7 +252,7 @@ int main(int argc, char *argv[])
fileName baseDir
(
args.opt<fileName>
args.get<fileName>
(
"templateDir",
"${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 word regionName = args.opt<word>("region", polyMesh::defaultRegion);
const word regionName = args.get<word>("region", polyMesh::defaultRegion);
fileName regionPrefix;
if (regionName != polyMesh::defaultRegion)

View File

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

View File

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

View File

@ -20,7 +20,7 @@
sourceTimeIndex = Time::findClosestTimeIndex
(
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 mergeRegions = args.found("mergeRegions");
const scalar scaleFactor = args.opt<scalar>("scale", -1);
const scalar scaleFactor = args.get<scalar>("scale", -1);
if (addPoint)
{

View File

@ -1596,7 +1596,7 @@ int main(int argc, char *argv[])
// 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]);
Info<< "Reading surface " << surf1Name << endl;

View File

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

View File

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

View File

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

View File

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

View File

@ -63,9 +63,9 @@ int main(int argc, char *argv[])
const point samplePt
(
args.opt<scalar>("x", 0),
args.opt<scalar>("y", 0),
args.opt<scalar>("z", 0)
args.get<scalar>("x", 0),
args.get<scalar>("y", 0),
args.get<scalar>("z", 0)
);
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);
const fileName surfFileName = args[1];
const scalar density = args.opt<scalar>("density", 1);
const scalar density = args.get<scalar>("density", 1);
vector refPt = Zero;
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 extendFactor(args.get<scalar>(3));
const bool checkSelfIntersect = args.found("checkSelfIntersection");
const label nSmooth = args.opt<label>("nSmooth", 10);
const scalar featureAngle = args.opt<scalar>("featureAngle", 180);
const label nSmooth = args.get<label>("nSmooth", 10);
const scalar featureAngle = args.get<scalar>("featureAngle", 180);
const bool debug = args.found("debug");

View File

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

View File

@ -131,7 +131,7 @@ int main(int argc, char *argv[])
Time runTime(args.rootPath(), args.caseName());
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
if (!MeshedSurface<face>::canWriteType(exportName.ext(), true))
@ -157,7 +157,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE,
false
),
args.opt<fileName>("dict", "")
args.get<fileName>("dict", "")
);
if (!ioCsys.typeHeaderOk<coordinateSystems>(false))

View File

@ -144,7 +144,7 @@ int main(int argc, char *argv[])
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
if (!MeshedSurface<face>::canRead(importName, true))
@ -170,7 +170,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE,
false
),
args.opt<fileName>("dict", "")
args.get<fileName>("dict", "")
);
if (!ioCsys.typeHeaderOk<coordinateSystems>(false))

View File

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

View File

@ -95,7 +95,7 @@ int main(int argc, char *argv[])
Info<< "outside" << endl;
}
const scalar scaling = args.opt<scalar>("scale", -1);
const scalar scaling = args.get<scalar>("scale", -1);
if (scaling > 0)
{
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 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
<< "Merging points within " << mergeTol << " metre." << nl;

View File

@ -177,7 +177,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ,
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;
}
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.
const boundBox& meshBb = mesh.bounds();

View File

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

View File

@ -364,16 +364,6 @@ public:
//- Return non-const access to the command 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
inline bool found(const word& optName) const;
@ -386,15 +376,25 @@ public:
//- Return an input stream from the named option
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
// The default template parameter is string (ie, no conversion).
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.
// Identical to getOrDefault().
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.
// \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.
template<class T>
inline T getOrDefault
(
const word& optName,
const T& deflt
) const;
inline T getOrDefault(const word& optName, const T& deflt) const;
//- Get a List of values from the named option,
//- 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;
//- 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
//- Append a (mandatory) argument to validArgs
@ -650,12 +661,12 @@ public:
}
//- 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>
T FOAM_DEPRECATED_FOR(2018-01, "opt() method")
T FOAM_DEPRECATED_FOR(2018-01, "get() method")
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.

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]);
}
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]);
}
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]);
}
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]);
}
@ -232,19 +232,19 @@ namespace Foam
template<>
inline string argList::opt<Foam::string>(const word& optName) const
inline string argList::get<Foam::string>(const word& optName) const
{
return options_[optName];
}
template<>
inline word argList::opt<Foam::word>(const word& optName) const
inline word argList::get<Foam::word>(const word& optName) const
{
return options_[optName];
}
template<>
inline fileName argList::opt<Foam::fileName>(const word& optName) const
inline fileName argList::get<Foam::fileName>(const word& optName) const
{
return options_[optName];
}
@ -268,7 +268,7 @@ inline T Foam::argList::get(const label index) const
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]);
@ -282,11 +282,11 @@ inline T Foam::argList::opt(const word& optName) const
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))
{
return opt<T>(optName);
return get<T>(optName);
}
return deflt;
@ -302,7 +302,7 @@ inline bool Foam::argList::readIfPresent
{
if (found(optName))
{
val = opt<T>(optName);
val = get<T>(optName);
return true;
}
@ -337,7 +337,7 @@ inline T Foam::argList::getOrDefault
{
if (found(optName))
{
return opt<T>(optName);
return get<T>(optName);
}
return deflt;

View File

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

View File

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