mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: simplify method names for reading argList options and arguments
- use succincter method names that more closely resemble dictionary
and HashTable method names. This improves method name consistency
between classes and also requires less typing effort:
args.found(optName) vs. args.optionFound(optName)
args.readIfPresent(..) vs. args.optionReadIfPresent(..)
...
args.opt<scalar>(optName) vs. args.optionRead<scalar>(optName)
args.read<scalar>(index) vs. args.argRead<scalar>(index)
- the older method names forms have been retained for code compatibility,
but are now deprecated
This commit is contained in:
@ -181,12 +181,12 @@ int main(int argc, char *argv[])
|
||||
// Default to binary output, unless otherwise specified
|
||||
const IOstream::streamFormat format =
|
||||
(
|
||||
args.optionFound("ascii")
|
||||
args.found("ascii")
|
||||
? IOstream::ASCII
|
||||
: IOstream::BINARY
|
||||
);
|
||||
|
||||
const bool nodeValues = args.optionFound("nodeValues");
|
||||
const bool nodeValues = args.found("nodeValues");
|
||||
|
||||
cpuTime timer;
|
||||
memInfo mem;
|
||||
@ -209,8 +209,8 @@ int main(int argc, char *argv[])
|
||||
//
|
||||
ensightCase::options caseOpts(format);
|
||||
|
||||
caseOpts.nodeValues(args.optionFound("nodeValues"));
|
||||
caseOpts.width(args.optionLookupOrDefault<label>("width", 8));
|
||||
caseOpts.nodeValues(args.found("nodeValues"));
|
||||
caseOpts.width(args.lookupOrDefault<label>("width", 8));
|
||||
caseOpts.overwrite(true); // remove existing output directory
|
||||
|
||||
// Can also have separate directory for lagrangian
|
||||
@ -220,7 +220,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.optionLookupOrDefault<word>("name", "EnSight");
|
||||
fileName ensightDir = args.lookupOrDefault<word>("name", "EnSight");
|
||||
if (!ensightDir.isAbsolute())
|
||||
{
|
||||
ensightDir = args.rootPath()/args.globalCaseName()/ensightDir;
|
||||
@ -231,30 +231,30 @@ int main(int argc, char *argv[])
|
||||
// Output configuration (geometry related)
|
||||
//
|
||||
ensightMesh::options writeOpts(format);
|
||||
writeOpts.noPatches(args.optionFound("noPatches"));
|
||||
writeOpts.noPatches(args.found("noPatches"));
|
||||
|
||||
if (args.optionFound("patches"))
|
||||
if (args.found("patches"))
|
||||
{
|
||||
writeOpts.patchSelection(args.optionReadList<wordRe>("patches"));
|
||||
writeOpts.patchSelection(args.readList<wordRe>("patches"));
|
||||
}
|
||||
if (args.optionFound("faceZones"))
|
||||
if (args.found("faceZones"))
|
||||
{
|
||||
writeOpts.faceZoneSelection(args.optionReadList<wordRe>("faceZones"));
|
||||
writeOpts.faceZoneSelection(args.readList<wordRe>("faceZones"));
|
||||
}
|
||||
|
||||
//
|
||||
// output configuration (field related)
|
||||
//
|
||||
const bool noLagrangian = args.optionFound("noLagrangian");
|
||||
const bool noLagrangian = args.found("noLagrangian");
|
||||
|
||||
wordReList fieldPatterns;
|
||||
if (args.optionFound("fields"))
|
||||
if (args.found("fields"))
|
||||
{
|
||||
fieldPatterns = args.optionReadList<wordRe>("fields");
|
||||
fieldPatterns = args.readList<wordRe>("fields");
|
||||
}
|
||||
|
||||
word cellZoneName;
|
||||
if (args.optionReadIfPresent("cellZone", cellZoneName))
|
||||
if (args.readIfPresent("cellZone", cellZoneName))
|
||||
{
|
||||
Info<< "Converting cellZone " << cellZoneName
|
||||
<< " only (puts outside faces into patch "
|
||||
|
||||
@ -156,7 +156,7 @@ int main(int argc, char *argv[])
|
||||
// Default to binary output, unless otherwise specified
|
||||
const IOstream::streamFormat format =
|
||||
(
|
||||
args.optionFound("ascii")
|
||||
args.found("ascii")
|
||||
? IOstream::ASCII
|
||||
: IOstream::BINARY
|
||||
);
|
||||
@ -182,7 +182,7 @@ int main(int argc, char *argv[])
|
||||
//
|
||||
ensightCase::options caseOpts(format);
|
||||
|
||||
caseOpts.width(args.optionLookupOrDefault<label>("width", 8));
|
||||
caseOpts.width(args.lookupOrDefault<label>("width", 8));
|
||||
caseOpts.overwrite(false); // leave existing output directory
|
||||
|
||||
// Can also have separate directory for lagrangian
|
||||
@ -191,7 +191,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.optionLookupOrDefault<word>("name", "Ensight");
|
||||
fileName ensightDir = args.lookupOrDefault<word>("name", "Ensight");
|
||||
if (!ensightDir.isAbsolute())
|
||||
{
|
||||
ensightDir = args.rootPath()/args.globalCaseName()/ensightDir;
|
||||
@ -214,11 +214,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Control for renumbering iterations
|
||||
label indexingNumber = 0;
|
||||
const bool optIndex = args.optionReadIfPresent("index", indexingNumber);
|
||||
const bool noLagrangian = args.optionFound("noLagrangian");
|
||||
const bool optIndex = args.readIfPresent("index", indexingNumber);
|
||||
const bool noLagrangian = args.found("noLagrangian");
|
||||
|
||||
// Always write the geometry, unless the -noMesh option is specified
|
||||
bool optNoMesh = args.optionFound("noMesh");
|
||||
bool optNoMesh = args.found("noMesh");
|
||||
|
||||
|
||||
// Construct the list of ensight parts for the entire mesh
|
||||
|
||||
@ -209,10 +209,10 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const bool doWriteInternal = !args.optionFound("noInternal");
|
||||
const bool doFaceZones = !args.optionFound("noFaceZones");
|
||||
const bool nearCellValue = args.optionFound("nearCellValue");
|
||||
const bool noPointValues = args.optionFound("noPointValues");
|
||||
const bool doWriteInternal = !args.found("noInternal");
|
||||
const bool doFaceZones = !args.found("noFaceZones");
|
||||
const bool nearCellValue = args.found("nearCellValue");
|
||||
const bool noPointValues = args.found("noPointValues");
|
||||
|
||||
if (nearCellValue)
|
||||
{
|
||||
@ -228,9 +228,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
List<wordRe> excludePatches;
|
||||
if (args.optionFound("excludePatches"))
|
||||
if (args.found("excludePatches"))
|
||||
{
|
||||
args.optionLookup("excludePatches")() >> excludePatches;
|
||||
args.lookup("excludePatches")() >> excludePatches;
|
||||
|
||||
Info<< "Not including patches " << excludePatches << nl << endl;
|
||||
}
|
||||
@ -239,7 +239,7 @@ int main(int argc, char *argv[])
|
||||
word faceSetName;
|
||||
string pltName = runTime.caseName();
|
||||
|
||||
if (args.optionReadIfPresent("cellSet", cellSetName))
|
||||
if (args.readIfPresent("cellSet", cellSetName))
|
||||
{
|
||||
pltName = cellSetName;
|
||||
}
|
||||
@ -255,7 +255,7 @@ int main(int argc, char *argv[])
|
||||
pltName = pltName.substr(i);
|
||||
}
|
||||
}
|
||||
args.optionReadIfPresent("faceSet", faceSetName);
|
||||
args.readIfPresent("faceSet", faceSetName);
|
||||
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
@ -276,8 +276,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if
|
||||
(
|
||||
args.optionFound("time")
|
||||
|| args.optionFound("latestTime")
|
||||
args.found("time")
|
||||
|| args.found("latestTime")
|
||||
|| cellSetName.size()
|
||||
|| faceSetName.size()
|
||||
|| regionName != polyMesh::defaultRegion
|
||||
@ -325,9 +325,9 @@ int main(int argc, char *argv[])
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
|
||||
HashSet<word> selectedFields;
|
||||
if (args.optionFound("fields"))
|
||||
if (args.found("fields"))
|
||||
{
|
||||
args.optionLookup("fields")() >> selectedFields;
|
||||
args.lookup("fields")() >> selectedFields;
|
||||
}
|
||||
|
||||
// Construct the vol fields (on the original mesh if subsetted)
|
||||
|
||||
@ -285,15 +285,15 @@ vtk::outputOptions getOutputOptions(const argList& args)
|
||||
{
|
||||
vtk::outputOptions opts;
|
||||
|
||||
if (args.optionFound("xml"))
|
||||
if (args.found("xml"))
|
||||
{
|
||||
opts.ascii(args.optionFound("ascii"));
|
||||
opts.ascii(args.found("ascii"));
|
||||
}
|
||||
else
|
||||
{
|
||||
opts.legacy(true);
|
||||
|
||||
if (!args.optionFound("ascii"))
|
||||
if (!args.found("ascii"))
|
||||
{
|
||||
if (sizeof(floatScalar) != 4 || sizeof(label) != 4)
|
||||
{
|
||||
@ -466,13 +466,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "createTime.H"
|
||||
|
||||
const bool decomposePoly = !args.optionFound("poly");
|
||||
const bool doWriteInternal = !args.optionFound("noInternal");
|
||||
const bool doFaceZones = !args.optionFound("noFaceZones");
|
||||
const bool doLinks = !args.optionFound("noLinks");
|
||||
const bool useTimeName = args.optionFound("useTimeName");
|
||||
const bool noLagrangian = args.optionFound("noLagrangian");
|
||||
const bool nearCellValue = args.optionFound("nearCellValue");
|
||||
const bool decomposePoly = !args.found("poly");
|
||||
const bool doWriteInternal = !args.found("noInternal");
|
||||
const bool doFaceZones = !args.found("noFaceZones");
|
||||
const bool doLinks = !args.found("noLinks");
|
||||
const bool useTimeName = args.found("useTimeName");
|
||||
const bool noLagrangian = args.found("noLagrangian");
|
||||
const bool nearCellValue = args.found("nearCellValue");
|
||||
|
||||
const vtk::outputOptions fmtType = getOutputOptions(args);
|
||||
|
||||
@ -483,7 +483,7 @@ int main(int argc, char *argv[])
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
const bool noPointValues = args.optionFound("noPointValues");
|
||||
const bool noPointValues = args.found("noPointValues");
|
||||
|
||||
if (noPointValues)
|
||||
{
|
||||
@ -492,12 +492,12 @@ int main(int argc, char *argv[])
|
||||
<< nl;
|
||||
}
|
||||
|
||||
const bool allPatches = args.optionFound("allPatches");
|
||||
const bool allPatches = args.found("allPatches");
|
||||
|
||||
wordReList excludePatches;
|
||||
if (args.optionFound("excludePatches"))
|
||||
if (args.found("excludePatches"))
|
||||
{
|
||||
args.optionLookup("excludePatches")() >> excludePatches;
|
||||
args.lookup("excludePatches")() >> excludePatches;
|
||||
|
||||
Info<< "Not including patches " << excludePatches << nl << endl;
|
||||
}
|
||||
@ -506,12 +506,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
meshSubsetHelper::subsetType cellSubsetType = meshSubsetHelper::NONE;
|
||||
word cellSubsetName;
|
||||
if (args.optionReadIfPresent("cellSet", cellSubsetName))
|
||||
if (args.readIfPresent("cellSet", cellSubsetName))
|
||||
{
|
||||
vtkName = cellSubsetName;
|
||||
cellSubsetType = meshSubsetHelper::SET;
|
||||
}
|
||||
else if (args.optionReadIfPresent("cellZone", cellSubsetName))
|
||||
else if (args.readIfPresent("cellZone", cellSubsetName))
|
||||
{
|
||||
vtkName = cellSubsetName;
|
||||
cellSubsetType = meshSubsetHelper::ZONE;
|
||||
@ -528,13 +528,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
word faceSetName;
|
||||
args.optionReadIfPresent("faceSet", faceSetName);
|
||||
args.readIfPresent("faceSet", faceSetName);
|
||||
|
||||
word pointSetName;
|
||||
args.optionReadIfPresent("pointSet", pointSetName);
|
||||
args.readIfPresent("pointSet", pointSetName);
|
||||
|
||||
// Define sub-directory name to use for VTK data.
|
||||
const word vtkDirName = args.optionLookupOrDefault<word>("name", "VTK");
|
||||
const word vtkDirName = args.lookupOrDefault<word>("name", "VTK");
|
||||
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
@ -553,8 +553,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if
|
||||
(
|
||||
args.optionFound("time")
|
||||
|| args.optionFound("latestTime")
|
||||
args.found("time")
|
||||
|| args.found("latestTime")
|
||||
|| cellSubsetName.size()
|
||||
|| faceSetName.size()
|
||||
|| pointSetName.size()
|
||||
@ -702,7 +702,7 @@ int main(int argc, char *argv[])
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
|
||||
wordHashSet selectedFields;
|
||||
const bool specifiedFields = args.optionReadIfPresent
|
||||
const bool specifiedFields = args.readIfPresent
|
||||
(
|
||||
"fields",
|
||||
selectedFields
|
||||
@ -870,7 +870,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Finite-area mesh and fields - need not exist
|
||||
|
||||
if (args.optionFound("finiteAreaFields"))
|
||||
if (args.found("finiteAreaFields"))
|
||||
{
|
||||
autoPtr<faMesh> aMeshPtr;
|
||||
{
|
||||
@ -1154,7 +1154,7 @@ int main(int argc, char *argv[])
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
if (args.optionFound("surfaceFields"))
|
||||
if (args.found("surfaceFields"))
|
||||
{
|
||||
PtrList<const surfaceScalarField> sScalarFld;
|
||||
readFields
|
||||
|
||||
Reference in New Issue
Block a user