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:
@ -52,7 +52,7 @@ int main(int argc, char *argv[])
|
||||
#include "createPolyMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
if (!overwrite)
|
||||
{
|
||||
|
||||
@ -88,8 +88,8 @@ int main(int argc, char *argv[])
|
||||
<< " s\n" << endl << endl;
|
||||
|
||||
|
||||
const scalar featureAngle = args.argRead<scalar>(1);
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const scalar featureAngle = args.read<scalar>(1);
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
const scalar minCos = Foam::cos(degToRad(featureAngle));
|
||||
|
||||
|
||||
@ -126,20 +126,20 @@ int main(int argc, char *argv[])
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
const bool noTopology = args.optionFound("noTopology");
|
||||
const bool allGeometry = args.optionFound("allGeometry");
|
||||
const bool allTopology = args.optionFound("allTopology");
|
||||
const bool meshQuality = args.optionFound("meshQuality");
|
||||
const bool noTopology = args.found("noTopology");
|
||||
const bool allGeometry = args.found("allGeometry");
|
||||
const bool allTopology = args.found("allTopology");
|
||||
const bool meshQuality = args.found("meshQuality");
|
||||
|
||||
word surfaceFormat;
|
||||
const bool writeSets = args.optionReadIfPresent("writeSets", surfaceFormat);
|
||||
const bool writeSets = args.readIfPresent("writeSets", surfaceFormat);
|
||||
HashSet<word> selectedFields;
|
||||
bool writeFields = args.optionReadIfPresent
|
||||
bool writeFields = args.readIfPresent
|
||||
(
|
||||
"writeFields",
|
||||
selectedFields
|
||||
);
|
||||
if (!writeFields && args.optionFound("writeAllFields"))
|
||||
if (!writeFields && args.found("writeAllFields"))
|
||||
{
|
||||
selectedFields.insert("nonOrthoAngle");
|
||||
selectedFields.insert("faceWeight");
|
||||
|
||||
@ -438,7 +438,7 @@ int main(int argc, char *argv[])
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
|
||||
@ -523,13 +523,13 @@ int main(int argc, char *argv[])
|
||||
runTime.functionObjects().off();
|
||||
|
||||
Foam::word meshRegionName = polyMesh::defaultRegion;
|
||||
args.optionReadIfPresent("region", meshRegionName);
|
||||
args.readIfPresent("region", meshRegionName);
|
||||
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
#include "createNamedPolyMesh.H"
|
||||
|
||||
const bool writeObj = args.optionFound("writeObj");
|
||||
const bool writeObj = args.found("writeObj");
|
||||
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const scalar scaleFactor = args.argRead<scalar>(1);
|
||||
const scalar scaleFactor = args.read<scalar>(1);
|
||||
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
|
||||
@ -97,20 +97,20 @@ int main(int argc, char *argv[])
|
||||
FatalError.exit();
|
||||
}
|
||||
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
fileName masterCase = args[1];
|
||||
fileName addCase = args[2];
|
||||
|
||||
const word masterRegion =
|
||||
args.optionLookupOrDefault<word>
|
||||
args.lookupOrDefault<word>
|
||||
(
|
||||
"masterRegion",
|
||||
polyMesh::defaultRegion
|
||||
);
|
||||
|
||||
const word addRegion =
|
||||
args.optionLookupOrDefault<word>
|
||||
args.lookupOrDefault<word>
|
||||
(
|
||||
"masterRegion",
|
||||
polyMesh::defaultRegion
|
||||
@ -166,7 +166,7 @@ int main(int argc, char *argv[])
|
||||
const bool specifiedInstance =
|
||||
(
|
||||
!overwrite
|
||||
&& args.optionReadIfPresent("resultTime", meshInstance)
|
||||
&& args.readIfPresent("resultTime", meshInstance)
|
||||
);
|
||||
|
||||
if (specifiedInstance)
|
||||
|
||||
@ -304,10 +304,10 @@ int main(int argc, char *argv[])
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
const bool readDict = args.optionFound("dict");
|
||||
const bool split = args.optionFound("split");
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool detectOnly = args.optionFound("detectOnly");
|
||||
const bool readDict = args.found("dict");
|
||||
const bool split = args.found("split");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
const bool detectOnly = args.found("detectOnly");
|
||||
|
||||
if (readDict && (split || detectOnly))
|
||||
{
|
||||
|
||||
@ -47,7 +47,7 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
if (!overwrite)
|
||||
{
|
||||
|
||||
@ -168,7 +168,7 @@ int main(int argc, char *argv[])
|
||||
#include "createTime.H"
|
||||
#include "createNamedDynamicFvMesh.H"
|
||||
|
||||
const bool checkAMI = args.optionFound("checkAMI");
|
||||
const bool checkAMI = args.found("checkAMI");
|
||||
|
||||
if (checkAMI)
|
||||
{
|
||||
|
||||
@ -58,7 +58,7 @@ int main(int argc, char *argv[])
|
||||
#include "createNamedPolyMesh.H"
|
||||
|
||||
const word zoneName = args[1];
|
||||
const point outsidePoint = args.argRead<point>(2);
|
||||
const point outsidePoint = args.read<point>(2);
|
||||
|
||||
Info<< "Orienting faceZone " << zoneName
|
||||
<< " such that " << outsidePoint << " is outside"
|
||||
|
||||
@ -401,7 +401,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
const scalar featureAngle = args.argRead<scalar>(1);
|
||||
const scalar featureAngle = args.read<scalar>(1);
|
||||
const scalar minCos = Foam::cos(degToRad(featureAngle));
|
||||
|
||||
Info<< "Feature:" << featureAngle << endl
|
||||
@ -409,7 +409,7 @@ int main(int argc, char *argv[])
|
||||
<< endl;
|
||||
|
||||
|
||||
const bool splitAllFaces = args.optionFound("splitAllFaces");
|
||||
const bool splitAllFaces = args.found("splitAllFaces");
|
||||
if (splitAllFaces)
|
||||
{
|
||||
Info<< "Splitting all internal faces to create multiple faces"
|
||||
@ -417,12 +417,9 @@ int main(int argc, char *argv[])
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool doNotPreserveFaceZones = args.optionFound
|
||||
(
|
||||
"doNotPreserveFaceZones"
|
||||
);
|
||||
const bool concaveMultiCells = args.optionFound("concaveMultiCells");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
const bool doNotPreserveFaceZones = args.found("doNotPreserveFaceZones");
|
||||
const bool concaveMultiCells = args.found("concaveMultiCells");
|
||||
if (concaveMultiCells)
|
||||
{
|
||||
Info<< "Generating multiple cells for points on concave feature edges."
|
||||
|
||||
@ -182,9 +182,9 @@ int main(int argc, char *argv[])
|
||||
// Read/construct control dictionary
|
||||
//
|
||||
|
||||
const bool readDict = args.optionFound("dict");
|
||||
const bool refineAllCells = args.optionFound("all");
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool readDict = args.found("dict");
|
||||
const bool refineAllCells = args.found("all");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
// List of cells to refine
|
||||
labelList refCells;
|
||||
|
||||
@ -653,9 +653,9 @@ int main(int argc, char *argv[])
|
||||
#include "createNamedMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
const bool readDict = args.optionFound("dict");
|
||||
const bool doFrontWidth = args.optionFound("frontWidth");
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool readDict = args.found("dict");
|
||||
const bool doFrontWidth = args.found("frontWidth");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
label band;
|
||||
scalar profile;
|
||||
|
||||
@ -83,10 +83,10 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
vector n1(args.argRead<vector>(1));
|
||||
vector n1(args.read<vector>(1));
|
||||
n1 /= mag(n1);
|
||||
|
||||
vector n2(args.argRead<vector>(2));
|
||||
vector n2(args.read<vector>(2));
|
||||
n2 /= mag(n2);
|
||||
|
||||
const tensor rotT(rotationTensor(n1, n2));
|
||||
|
||||
@ -768,10 +768,10 @@ int main(int argc, char *argv[])
|
||||
#include "createTime.H"
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
const bool writeVTK = !args.optionFound("noVTK");
|
||||
const bool loop = args.optionFound("loop");
|
||||
const bool batch = args.optionFound("batch");
|
||||
const bool noSync = args.optionFound("noSync");
|
||||
const bool writeVTK = !args.found("noVTK");
|
||||
const bool loop = args.found("loop");
|
||||
const bool batch = args.found("batch");
|
||||
const bool noSync = args.found("noSync");
|
||||
|
||||
if (loop && !batch)
|
||||
{
|
||||
|
||||
@ -77,7 +77,7 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const bool noFlipMap = args.optionFound("noFlipMap");
|
||||
const bool noFlipMap = args.found("noFlipMap");
|
||||
|
||||
// Get times list
|
||||
(void)timeSelector::selectIfPresent(runTime, args);
|
||||
|
||||
@ -129,7 +129,7 @@ int main(int argc, char *argv[])
|
||||
const word setName = args[1];
|
||||
const word masterPatch = args[2];
|
||||
const word slavePatch = args[3];
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
// List of faces to split
|
||||
faceSet facesSet(mesh, setName);
|
||||
|
||||
@ -1487,23 +1487,23 @@ int main(int argc, char *argv[])
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
word blockedFacesName;
|
||||
if (args.optionReadIfPresent("blockedFaces", blockedFacesName))
|
||||
if (args.readIfPresent("blockedFaces", blockedFacesName))
|
||||
{
|
||||
Info<< "Reading blocked internal faces from faceSet "
|
||||
<< blockedFacesName << nl << endl;
|
||||
}
|
||||
|
||||
const bool makeCellZones = args.optionFound("makeCellZones");
|
||||
const bool largestOnly = args.optionFound("largestOnly");
|
||||
const bool insidePoint = args.optionFound("insidePoint");
|
||||
const bool useCellZones = args.optionFound("cellZones");
|
||||
const bool useCellZonesOnly = args.optionFound("cellZonesOnly");
|
||||
const bool useCellZonesFile = args.optionFound("cellZonesFileOnly");
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool detectOnly = args.optionFound("detectOnly");
|
||||
const bool sloppyCellZones = args.optionFound("sloppyCellZones");
|
||||
const bool useFaceZones = args.optionFound("useFaceZones");
|
||||
const bool prefixRegion = args.optionFound("prefixRegion");
|
||||
const bool makeCellZones = args.found("makeCellZones");
|
||||
const bool largestOnly = args.found("largestOnly");
|
||||
const bool insidePoint = args.found("insidePoint");
|
||||
const bool useCellZones = args.found("cellZones");
|
||||
const bool useCellZonesOnly = args.found("cellZonesOnly");
|
||||
const bool useCellZonesFile = args.found("cellZonesFileOnly");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
const bool detectOnly = args.found("detectOnly");
|
||||
const bool sloppyCellZones = args.found("sloppyCellZones");
|
||||
const bool useFaceZones = args.found("useFaceZones");
|
||||
const bool prefixRegion = args.found("prefixRegion");
|
||||
|
||||
|
||||
if
|
||||
@ -2001,7 +2001,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (insidePoint)
|
||||
{
|
||||
const point insidePoint = args.optionRead<point>("insidePoint");
|
||||
const point insidePoint = args.opt<point>("insidePoint");
|
||||
|
||||
label regionI = -1;
|
||||
|
||||
|
||||
@ -153,7 +153,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (useCommandArgs)
|
||||
{
|
||||
if (args.optionFound("dict"))
|
||||
if (args.found("dict"))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot specify both dictionary and command-line arguments"
|
||||
@ -171,21 +171,21 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Carp about inapplicable options
|
||||
|
||||
if (args.optionFound("integral"))
|
||||
if (args.found("integral"))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Only specify -integral with command-line arguments"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("partial"))
|
||||
if (args.found("partial"))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Only specify -partial with command-line arguments"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("perfect"))
|
||||
if (args.found("perfect"))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Only specify -perfect with command-line arguments"
|
||||
@ -199,8 +199,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
const bool intermediate = args.optionFound("intermediate");
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool intermediate = args.found("intermediate");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
const word dictName("stitchMeshDict");
|
||||
|
||||
@ -210,9 +210,9 @@ int main(int argc, char *argv[])
|
||||
if (useCommandArgs)
|
||||
{
|
||||
// Command argument driven:
|
||||
const int integralCover = args.optionFound("integral");
|
||||
const int partialCover = args.optionFound("partial");
|
||||
const int perfectCover = args.optionFound("perfect");
|
||||
const int integralCover = args.found("integral");
|
||||
const int partialCover = args.found("partial");
|
||||
const int perfectCover = args.found("perfect");
|
||||
|
||||
if ((integralCover + partialCover + perfectCover) > 1)
|
||||
{
|
||||
@ -377,7 +377,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// set up the tolerances for the sliding mesh
|
||||
dictionary slidingTolerances;
|
||||
if (args.optionFound("toleranceDict"))
|
||||
if (args.found("toleranceDict"))
|
||||
{
|
||||
IOdictionary toleranceFile
|
||||
(
|
||||
|
||||
@ -376,8 +376,8 @@ int main(int argc, char *argv[])
|
||||
word meshInstance = mesh.pointsInstance();
|
||||
word fieldsInstance = runTime.timeName();
|
||||
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool specifiedInstance = args.optionReadIfPresent
|
||||
const bool overwrite = args.found("overwrite");
|
||||
const bool specifiedInstance = args.readIfPresent
|
||||
(
|
||||
"resultTime",
|
||||
fieldsInstance
|
||||
@ -396,7 +396,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
labelList exposedPatchIDs;
|
||||
|
||||
if (args.optionFound("patch"))
|
||||
if (args.found("patch"))
|
||||
{
|
||||
const word patchName = args["patch"];
|
||||
|
||||
@ -412,9 +412,9 @@ int main(int argc, char *argv[])
|
||||
Info<< "Adding exposed internal faces to patch " << patchName
|
||||
<< nl << endl;
|
||||
}
|
||||
else if (args.optionFound("patches"))
|
||||
else if (args.found("patches"))
|
||||
{
|
||||
const wordReList patchNames(args.optionRead<wordReList>("patches"));
|
||||
const wordReList patchNames(args.opt<wordReList>("patches"));
|
||||
|
||||
exposedPatchIDs = mesh.boundaryMesh().patchSet(patchNames).sortedToc();
|
||||
|
||||
|
||||
@ -217,7 +217,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "createNamedPolyMesh.H"
|
||||
|
||||
const bool noSync = args.optionFound("noSync");
|
||||
const bool noSync = args.found("noSync");
|
||||
|
||||
const word dictName("topoSetDict");
|
||||
#include "setSystemMeshDictionaryIO.H"
|
||||
|
||||
@ -202,7 +202,7 @@ int main(int argc, char *argv[])
|
||||
#include "addRegionOption.H"
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool doRotateFields = args.optionFound("rotateFields");
|
||||
const bool doRotateFields = args.found("rotateFields");
|
||||
|
||||
// Verify that an operation has been specified
|
||||
{
|
||||
@ -216,11 +216,11 @@ int main(int argc, char *argv[])
|
||||
"scale"
|
||||
};
|
||||
|
||||
if (!args.optionCount(operationNames))
|
||||
if (!args.count(operationNames))
|
||||
{
|
||||
FatalError
|
||||
<< "No operation supplied, "
|
||||
<< "use least one of the following:" << nl
|
||||
<< "use at least one of the following:" << nl
|
||||
<< " ";
|
||||
|
||||
for (const auto& opName : operationNames)
|
||||
@ -239,7 +239,7 @@ int main(int argc, char *argv[])
|
||||
word regionName = polyMesh::defaultRegion;
|
||||
fileName meshDir = polyMesh::meshSubDir;
|
||||
|
||||
if (args.optionReadIfPresent("region", regionName))
|
||||
if (args.readIfPresent("region", regionName))
|
||||
{
|
||||
meshDir = regionName/polyMesh::meshSubDir;
|
||||
}
|
||||
@ -259,7 +259,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
vector v;
|
||||
if (args.optionReadIfPresent("translate", v))
|
||||
if (args.readIfPresent("translate", v))
|
||||
{
|
||||
Info<< "Translating points by " << v << endl;
|
||||
|
||||
@ -267,18 +267,18 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
vector origin;
|
||||
const bool useOrigin = args.optionReadIfPresent("origin", origin);
|
||||
const bool useOrigin = args.readIfPresent("origin", origin);
|
||||
if (useOrigin)
|
||||
{
|
||||
Info<< "Set origin for rotations to " << origin << endl;
|
||||
points -= origin;
|
||||
}
|
||||
|
||||
if (args.optionFound("rotate"))
|
||||
if (args.found("rotate"))
|
||||
{
|
||||
Pair<vector> n1n2
|
||||
(
|
||||
args.optionLookup("rotate")()
|
||||
args.lookup("rotate")()
|
||||
);
|
||||
n1n2[0] /= mag(n1n2[0]);
|
||||
n1n2[1] /= mag(n1n2[1]);
|
||||
@ -294,11 +294,11 @@ int main(int argc, char *argv[])
|
||||
rotateFields(args, runTime, rotT);
|
||||
}
|
||||
}
|
||||
else if (args.optionFound("rotate-angle"))
|
||||
else if (args.found("rotate-angle"))
|
||||
{
|
||||
const Tuple2<vector, scalar> axisAngle
|
||||
(
|
||||
args.optionLookup("rotate-angle")()
|
||||
args.lookup("rotate-angle")()
|
||||
);
|
||||
|
||||
Info<< "Rotating points " << nl
|
||||
@ -319,7 +319,7 @@ int main(int argc, char *argv[])
|
||||
rotateFields(args, runTime, quat.R());
|
||||
}
|
||||
}
|
||||
else if (args.optionReadIfPresent("rollPitchYaw", v))
|
||||
else if (args.readIfPresent("rollPitchYaw", v))
|
||||
{
|
||||
Info<< "Rotating points by" << nl
|
||||
<< " roll " << v.x() << nl
|
||||
@ -339,7 +339,7 @@ int main(int argc, char *argv[])
|
||||
rotateFields(args, runTime, quat.R());
|
||||
}
|
||||
}
|
||||
else if (args.optionReadIfPresent("yawPitchRoll", v))
|
||||
else if (args.readIfPresent("yawPitchRoll", v))
|
||||
{
|
||||
Info<< "Rotating points by" << nl
|
||||
<< " yaw " << v.x() << nl
|
||||
@ -360,10 +360,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (args.optionFound("scale"))
|
||||
if (args.found("scale"))
|
||||
{
|
||||
// Use readList to handle single or multiple values
|
||||
const List<scalar> scaling = args.optionReadList<scalar>("scale");
|
||||
const List<scalar> scaling = args.readList<scalar>("scale");
|
||||
|
||||
if (scaling.size() == 1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user