STYLE: argList::opt method instead of the longer argList::lookupOrDefault

- also replaced a few instances of readIfPresent with opt<> for
  constant values.
This commit is contained in:
Mark Olesen
2018-12-12 12:10:39 +01:00
parent f38190213c
commit 29a5793b5b
70 changed files with 112 additions and 148 deletions

View File

@ -38,10 +38,9 @@ if (args.found("initialiseUBCs"))
// Construct a pressure field // Construct a pressure field
// If it is available read it otherwise construct from the velocity BCs // If it is available read it otherwise construct from the velocity BCs
// converting fixed-value BCs to zero-gradient and vice versa. // converting fixed-value BCs to zero-gradient and vice versa.
word pName("p");
// Update name of the pressure field from the command-line option // Allow override from command-line -pName option
args.readIfPresent("pName", pName); const word pName = args.opt<word>("pName", "p");
// Infer the pressure BCs from the velocity // Infer the pressure BCs from the velocity
wordList pBCTypes wordList pBCTypes

View File

@ -38,10 +38,9 @@ if (args.found("initialiseUBCs"))
// Construct a pressure field // Construct a pressure field
// If it is available read it otherwise construct from the velocity BCs // If it is available read it otherwise construct from the velocity BCs
// converting fixed-value BCs to zero-gradient and vice versa. // converting fixed-value BCs to zero-gradient and vice versa.
word pName("p");
// Update name of the pressure field from the command-line option // Allow override from command-line -pName option
args.readIfPresent("pName", pName); const word pName = args.opt<word>("pName", "p");
// Infer the pressure BCs from the velocity // Infer the pressure BCs from the velocity
wordList pBCTypes wordList pBCTypes

View File

@ -119,8 +119,10 @@ volScalarField alphac
dimensionedScalar(dimless, Zero) dimensionedScalar(dimless, Zero)
); );
word kinematicCloudName("kinematicCloud"); const word kinematicCloudName
args.readIfPresent("cloud", kinematicCloudName); (
args.opt<word>("cloud", "kinematicCloud")
);
Info<< "Constructing kinematicCloud " << kinematicCloudName << endl; Info<< "Constructing kinematicCloud " << kinematicCloudName << endl;
basicKinematicTypeCloud kinematicCloud basicKinematicTypeCloud kinematicCloud

View File

@ -57,8 +57,10 @@ volScalarField mu
laminarTransport.nu()*rhoInfValue laminarTransport.nu()*rhoInfValue
); );
word kinematicCloudName("kinematicCloud"); const word kinematicCloudName
args.readIfPresent("cloud", kinematicCloudName); (
args.opt<word>("cloud", "kinematicCloud")
);
Info<< "Constructing kinematicCloud " << kinematicCloudName << endl; Info<< "Constructing kinematicCloud " << kinematicCloudName << endl;
basicKinematicCollidingCloud kinematicCloud basicKinematicCollidingCloud kinematicCloud

View File

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

View File

@ -84,8 +84,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
fileName decompDictFile; const fileName decompDictFile = args.opt<fileName>("decomposeParDict", "");
args.readIfPresent("decomposeParDict", decompDictFile);
wordList regionNames; wordList regionNames;
wordList regionDirs; wordList regionDirs;

View File

@ -98,8 +98,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.lookupOrDefault<label>("domains", 0); const label numSubdomains = args.opt<label>("domains", 0);
const word methodName = args.lookupOrDefault<word>("method", word::null); const word methodName = args.opt<word>("method", word::null);
// Set time from database // Set time from database
#include "createTime.H" #include "createTime.H"
@ -107,8 +107,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
fileName decompDictFile; const fileName decompDictFile = args.opt<fileName>("decomposeParDict", "");
args.readIfPresent("decomposeParDict", decompDictFile);
// Get all region names // Get all region names
wordList regionNames; wordList regionNames;
@ -122,8 +121,7 @@ int main(int argc, char *argv[])
else else
{ {
regionNames.resize(1); regionNames.resize(1);
regionNames.first() = regionNames.first() = args.opt<word>("region", fvMesh::defaultRegion);
args.lookupOrDefault<word>("region", fvMesh::defaultRegion);
} }
forAll(regionNames, regioni) forAll(regionNames, regioni)

View File

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

View File

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

View File

@ -65,7 +65,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.lookupOrDefault<label>("n", 20); const label nSeg = args.opt<label>("n", 20);
if (!useCatmullRom && !useBSpline) if (!useCatmullRom && !useBSpline)
{ {

View File

@ -128,7 +128,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
const scalar scaleFactor = args.lookupOrDefault<scalar>("scale", -1); const scalar scaleFactor = args.opt<scalar>("scale", -1);
const word outputFile(args.executable() + ".obj"); const word outputFile(args.executable() + ".obj");

View File

@ -138,7 +138,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.lookupOrDefault<scalar>("scale", 0); const scalar scaleFactor = args.opt<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

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

View File

@ -45,7 +45,7 @@ int main(int argc, char *argv[])
argList args(argc, argv, false, true); argList args(argc, argv, false, true);
const scalar currTime = args.lookupOrDefault<scalar>("time", GREAT); const scalar currTime = args.opt<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;

View File

@ -130,7 +130,6 @@ int main(int argc, char *argv[])
} }
labelIOList pointPriority labelIOList pointPriority
( (
IOobject IOobject

View File

@ -380,8 +380,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 = const scalar concaveAngle = args.opt<scalar>("concaveAngle", 30);
args.lookupOrDefault<scalar>("concaveAngle", 30);
const scalar concaveSin = Foam::sin(degToRad(concaveAngle)); const scalar concaveSin = Foam::sin(degToRad(concaveAngle));

View File

@ -566,7 +566,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.lookupOrDefault<scalar>("tol", 0.2); const scalar edgeTol = args.opt<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

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

View File

@ -186,7 +186,7 @@ int main(int argc, char *argv[])
} }
// By default, no scaling // By default, no scaling
const scalar scaleFactor = args.lookupOrDefault<scalar>("scale", 1); const scalar scaleFactor = args.opt<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

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

View File

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

View File

@ -902,7 +902,7 @@ int main(int argc, char *argv[])
FatalError.exit(); FatalError.exit();
} }
const scalar scaleFactor = args.lookupOrDefault<scalar>("scale", 1); const scalar scaleFactor = args.opt<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

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

View File

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

View File

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

View File

@ -784,16 +784,11 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
Foam::word regionName; word regionName = polyMesh::defaultRegion;
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Foam::Info Info<< "Creating polyMesh for region " << regionName << endl;
<< "Creating polyMesh for region " << regionName << endl;
}
else
{
regionName = Foam::polyMesh::defaultRegion;
} }
const bool keepOrientation = args.found("keepOrientation"); const bool keepOrientation = args.found("keepOrientation");

View File

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

View File

@ -94,7 +94,7 @@ int main(int argc, char *argv[])
FatalError.exit(); FatalError.exit();
} }
const scalar scaleFactor = args.lookupOrDefault<scalar>("scale", 1); const scalar scaleFactor = args.opt<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

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

View File

@ -139,11 +139,11 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
word regionName; word regionName = polyMesh::defaultRegion;
word regionPath; word regionPath;
// Check if the region is specified otherwise mesh the default region // Check if the region is specified otherwise mesh the default region
if (args.readIfPresent("region", regionName, polyMesh::defaultRegion)) if (args.readIfPresent("region", regionName))
{ {
Info<< nl << "Generating mesh for region " << regionName << endl; Info<< nl << "Generating mesh for region " << regionName << endl;
regionPath = regionName; regionPath = regionName;

View File

@ -70,8 +70,8 @@ int main(int argc, char *argv[])
const bool conformationOnly = args.found("conformationOnly"); const bool conformationOnly = args.found("conformationOnly");
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
fileName decompDictFile; const fileName decompDictFile =
args.readIfPresent("decomposeParDict", decompDictFile); args.opt<fileName>("decomposeParDict", "");
IOdictionary foamyHexMeshDict IOdictionary foamyHexMeshDict
( (

View File

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

View File

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

View File

@ -136,8 +136,9 @@ 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");
word surfaceFormat; const word surfaceFormat = args.opt<word>("writeSets", "");
const bool writeSets = args.readIfPresent("writeSets", surfaceFormat); const bool writeSets = surfaceFormat.size();
wordHashSet selectedFields; wordHashSet selectedFields;
bool writeFields = args.readIfPresent bool writeFields = args.readIfPresent
( (

View File

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

View File

@ -103,18 +103,10 @@ int main(int argc, char *argv[])
fileName addCase = args[2]; fileName addCase = args[2];
const word masterRegion = const word masterRegion =
args.lookupOrDefault<word> args.opt<word>("masterRegion", polyMesh::defaultRegion);
(
"masterRegion",
polyMesh::defaultRegion
);
const word addRegion = const word addRegion =
args.lookupOrDefault<word> args.opt<word>("addRegion", polyMesh::defaultRegion);
(
"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

@ -199,7 +199,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.lookupOrDefault<fileName>("dict", ""); fileName dictPath = args.opt<fileName>("dict", "");
IOobject dictIO = IOobject::selectIO IOobject dictIO = IOobject::selectIO
( (

View File

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

View File

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

View File

@ -114,8 +114,7 @@ scalar getMergeDistance
const boundBox& bb const boundBox& bb
) )
{ {
scalar mergeTol = defaultMergeTol; const scalar mergeTol = args.opt<scalar>("mergeTol", defaultMergeTol);
args.readIfPresent("mergeTol", mergeTol);
const scalar writeTol = const scalar writeTol =
Foam::pow(scalar(10), -scalar(IOstream::defaultPrecision())); Foam::pow(scalar(10), -scalar(IOstream::defaultPrecision()));
@ -136,7 +135,7 @@ scalar getMergeDistance
<< exit(FatalError); << exit(FatalError);
} }
scalar mergeDist = mergeTol * bb.mag(); const scalar mergeDist = mergeTol * bb.mag();
Info<< "Overall meshes bounding box : " << bb << nl Info<< "Overall meshes bounding box : " << bb << nl
<< "Relative tolerance : " << mergeTol << nl << "Relative tolerance : " << mergeTol << nl
@ -2497,8 +2496,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
fileName decompDictFile; const fileName decompDictFile = args.opt<fileName>("decomposeParDict", "");
args.readIfPresent("decomposeParDict", decompDictFile);
// Get all region names // Get all region names
wordList regionNames; wordList regionNames;
@ -2512,8 +2510,7 @@ int main(int argc, char *argv[])
else else
{ {
regionNames.resize(1); regionNames.resize(1);
regionNames.first() = regionNames.first() = args.opt<word>("region", fvMesh::defaultRegion);
args.lookupOrDefault<word>("region", fvMesh::defaultRegion);
} }

View File

@ -237,7 +237,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.lookupOrDefault<label>("width", 8)); caseOpts.width(args.opt<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
@ -247,7 +247,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.lookupOrDefault<word>("name", "EnSight"); fileName outputDir = args.opt<word>("name", "EnSight");
if (!outputDir.isAbsolute()) if (!outputDir.isAbsolute())
{ {
outputDir = args.globalPath()/outputDir; outputDir = args.globalPath()/outputDir;

View File

@ -203,7 +203,7 @@ int main(int argc, char *argv[])
// //
ensightCase::options caseOpts(format); ensightCase::options caseOpts(format);
caseOpts.width(args.lookupOrDefault<label>("width", 8)); caseOpts.width(args.opt<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
@ -212,7 +212,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.lookupOrDefault<word>("name", "Ensight"); fileName ensightDir = args.opt<word>("name", "Ensight");
if (!ensightDir.isAbsolute()) if (!ensightDir.isAbsolute())
{ {
ensightDir = args.globalPath()/ensightDir; ensightDir = args.globalPath()/ensightDir;

View File

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

View File

@ -91,10 +91,10 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
const label maxOut = Foam::max(0, args.lookupOrDefault<label>("max", 0)); const label maxOut = Foam::max(0, args.opt<label>("max", 0));
const label span = Foam::max(1, args.lookupOrDefault<label>("span", 1)); const label span = Foam::max(1, args.opt<label>("span", 1));
const scalar relax = args.lookupOrDefault<scalar>("scale", 1); const scalar relax = args.opt<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

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

View File

@ -87,7 +87,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
wordList regionNames(1, fvMesh::defaultRegion); wordList regionNames(1, fvMesh::defaultRegion);
if (!args.readIfPresent("region", regionNames[0])) if (!args.readIfPresent("region", regionNames.first()))
{ {
args.readIfPresent("regions", regionNames); args.readIfPresent("regions", regionNames);
} }

View File

@ -431,11 +431,9 @@ 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);
Foam::word regionName = polyMesh::defaultRegion; fileName regionPrefix;
args.readIfPresent("region", regionName);
fileName regionPrefix = "";
if (regionName != polyMesh::defaultRegion) if (regionName != polyMesh::defaultRegion)
{ {
regionPrefix = regionName; regionPrefix = regionName;

View File

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

View File

@ -87,7 +87,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.lookupOrDefault<scalar>("scale", -1); const scalar scaleFactor = args.opt<scalar>("scale", -1);
if (addPoint) if (addPoint)
{ {

View File

@ -1593,7 +1593,7 @@ int main(int argc, char *argv[])
// Scale factor for both surfaces: // Scale factor for both surfaces:
const scalar scaleFactor = args.lookupOrDefault<scalar>("scale", -1); const scalar scaleFactor = args.opt<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

@ -366,9 +366,9 @@ 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.lookupOrDefault("outputThreshold", 10); const label outputThreshold = args.opt<label>("outputThreshold", 10);
word surfaceFormat; const word surfaceFormat = args.opt<word>("writeSets", "");
const bool writeSets = args.readIfPresent("writeSets", surfaceFormat); const bool writeSets = !surfaceFormat.empty();
autoPtr<surfaceWriter> surfWriter; autoPtr<surfaceWriter> surfWriter;
word edgeFormat; word edgeFormat;

View File

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

View File

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

View File

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

View File

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

View File

@ -86,7 +86,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.lookupOrDefault<scalar>("density", 1); const scalar density = args.opt<scalar>("density", 1);
vector refPt = Zero; vector refPt = Zero;
bool calcAroundRefPt = args.readIfPresent("referencePoint", refPt); bool calcAroundRefPt = args.readIfPresent("referencePoint", refPt);

View File

@ -610,12 +610,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.lookupOrDefault("nSmooth", 10); const label nSmooth = args.opt<label>("nSmooth", 10);
const scalar featureAngle = args.lookupOrDefault<scalar> const scalar featureAngle = args.opt<scalar>("featureAngle", 180);
(
"featureAngle",
180
);
const bool debug = args.found("debug"); const bool debug = args.found("debug");

View File

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

View File

@ -127,7 +127,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.lookupOrDefault<word>("name", "default"); const word importName = args.opt<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))
@ -153,7 +153,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
args.lookupOrDefault<fileName>("dict", "") args.opt<fileName>("dict", "")
); );
if (!ioCsys.typeHeaderOk<coordinateSystems>(false)) if (!ioCsys.typeHeaderOk<coordinateSystems>(false))

View File

@ -140,7 +140,7 @@ int main(int argc, char *argv[])
const fileName importName = args[1]; const fileName importName = args[1];
const word exportName = args.lookupOrDefault<word>("name", "default"); const word exportName = args.opt<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))
@ -166,7 +166,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
args.lookupOrDefault<fileName>("dict", "") args.opt<fileName>("dict", "")
); );
if (!ioCsys.typeHeaderOk<coordinateSystems>(false)) if (!ioCsys.typeHeaderOk<coordinateSystems>(false))

View File

@ -119,7 +119,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.lookupOrDefault<scalar>("scale", -1); const scalar scaling = args.opt<scalar>("scale", -1);
if (scaling > 0) if (scaling > 0)
{ {
DetailInfo << " -scale " << scaling << nl; DetailInfo << " -scale " << scaling << nl;

View File

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

View File

@ -68,7 +68,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.lookupOrDefault<scalar>("scale", -1); const scalar scaling = args.opt<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

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

View File

@ -211,7 +211,7 @@ int main(int argc, char *argv[])
<< " triangle ..." << endl; << " triangle ..." << endl;
} }
const scalar searchTol = args.lookupOrDefault("tol", 1e-3); const scalar searchTol = args.opt<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

@ -385,8 +385,7 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
dictionary& functionsDict = controlDict.subDict("functions"); dictionary& functionsDict = controlDict.subDict("functions");
word region; const word regionName = args.opt<word>("region", "");
args.readIfPresent("region", region);
bool modifiedControlDict = false; bool modifiedControlDict = false;
@ -417,7 +416,7 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
args["func"], args["func"],
functionsDict, functionsDict,
requiredFields, requiredFields,
region regionName
); );
} }
@ -434,7 +433,7 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
funcName, funcName,
functionsDict, functionsDict,
requiredFields, requiredFields,
region regionName
); );
} }
} }

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.lookupOrDefault<fileName>("dict", "") args.opt<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.lookupOrDefault<fileName>("dict", "") args.opt<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.lookupOrDefault<fileName>("dict", "") args.opt<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.lookupOrDefault<fileName>("dict", "") args.opt<fileName>("dict", "")
); );