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

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

View File

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

View File

@ -564,8 +564,7 @@ int main(int argc, char *argv[])
else
{
regionNames.resize(1);
regionNames.first() =
args.lookupOrDefault<word>("region", fvMesh::defaultRegion);
regionNames.first() = args.opt<word>("region", fvMesh::defaultRegion);
}
@ -627,7 +626,7 @@ int main(int argc, char *argv[])
// Directory management
// 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);

View File

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

View File

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