diff --git a/applications/test/List/ListTest.C b/applications/test/List/ListTest.C index b9f69fd043..cf5b2d38ec 100644 --- a/applications/test/List/ListTest.C +++ b/applications/test/List/ListTest.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) if (args.optionFound("flag")) { - Info<<"-flag:" << args.option("flag") << endl; + Info<<"-flag:" << args["flag"] << endl; } if (args.optionReadIfPresent("float", xxx)) diff --git a/applications/test/mvBak/mvBakTest.C b/applications/test/mvBak/mvBakTest.C index 7b325cbeeb..a88d1cfd75 100644 --- a/applications/test/mvBak/mvBakTest.C +++ b/applications/test/mvBak/mvBakTest.C @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) if (args.optionFound("ext")) { - if (mvBak(srcFile, args.option("ext"))) + if (mvBak(srcFile, args["ext"])) { ok++; } diff --git a/applications/test/tokenizeTest/tokenizeTest.C b/applications/test/tokenizeTest/tokenizeTest.C index 0e6f9dec37..e70c4e3361 100644 --- a/applications/test/tokenizeTest/tokenizeTest.C +++ b/applications/test/tokenizeTest/tokenizeTest.C @@ -94,11 +94,11 @@ int main(int argc, char *argv[]) { for (label count = 0; count < repeat; ++count) { - IFstream is(args.option("file")); + IFstream is(args["file"]); if (count == 0) { - Info<< "tokenizing file: " << args.option("file") << nl; + Info<< "tokenizing file: " << args["file"] << nl; } while (is.good()) diff --git a/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C b/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C index 3c7ee9b8d1..c6ad157d23 100644 --- a/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C +++ b/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C @@ -101,20 +101,17 @@ int main(int argc, char *argv[]) // List of cells to refine // - bool useSet = args.optionFound("useSet"); - - if (useSet) + word setName; + if (args.optionReadIfPresent("useSet", setName)) { - word setName(args.option("useSet")); - - Info<< "Subsetting cells to cut based on cellSet" << setName << endl - << endl; + Info<< "Subsetting cells to cut based on cellSet" + << setName << nl << endl; cellSet cells(mesh, setName); Info<< "Read " << cells.size() << " cells from cellSet " << cells.instance()/cells.local()/cells.name() - << endl << endl; + << nl << endl; for ( @@ -125,8 +122,8 @@ int main(int argc, char *argv[]) { cutCells.erase(iter.key()); } - Info<< "Removed from cells to cut all the ones not in set " << setName - << endl << endl; + Info<< "Removed from cells to cut all the ones not in set " + << setName << nl << endl; } // Mark all meshpoints on patch @@ -180,9 +177,9 @@ int main(int argc, char *argv[]) allCutEdges.shrink(); allCutEdgeWeights.shrink(); - Info<< "Cutting:" << endl - << " cells:" << cutCells.size() << endl - << " edges:" << allCutEdges.size() << endl + Info<< "Cutting:" << nl + << " cells:" << cutCells.size() << nl + << " edges:" << allCutEdges.size() << nl << endl; // Transfer DynamicLists to straight ones. diff --git a/applications/utilities/mesh/advanced/splitCells/splitCells.C b/applications/utilities/mesh/advanced/splitCells/splitCells.C index ecfb97d050..af7023cbb0 100644 --- a/applications/utilities/mesh/advanced/splitCells/splitCells.C +++ b/applications/utilities/mesh/advanced/splitCells/splitCells.C @@ -552,7 +552,7 @@ int main(int argc, char *argv[]) << "edge snapping tol : " << edgeTol << nl; if (readSet) { - Info<< "candidate cells : cellSet " << args.option("set") << nl; + Info<< "candidate cells : cellSet " << args["set"] << nl; } else { @@ -580,7 +580,7 @@ int main(int argc, char *argv[]) if (readSet) { // Read cells to cut from cellSet - cellSet cells(mesh, args.option("set")); + cellSet cells(mesh, args["set"]); cellsToCut = cells; } diff --git a/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C b/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C index 4c13d23591..153c15e8ae 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C +++ b/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,15 +68,12 @@ int main(int argc, char *argv[]) # include "createTime.H" fileName kivaFileName("otape17"); - if (args.optionFound("file")) - { - kivaFileName = args.option("file"); - } + args.optionReadIfPresent("file", kivaFileName); kivaVersions kivaVersion = kiva3v; if (args.optionFound("version")) { - word kivaVersionName = args.option("version"); + const word kivaVersionName = args["version"]; if (kivaVersionName == "kiva3") { diff --git a/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C b/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C index 47fc9c922f..ae35892b08 100644 --- a/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C +++ b/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -463,7 +463,7 @@ int main(int argc, char *argv[]) } if (doCellSet) { - word setName(args.option("cellSet")); + const word setName = args["cellSet"]; cellSet cells(mesh, setName); @@ -475,7 +475,7 @@ int main(int argc, char *argv[]) } if (doFaceSet) { - word setName(args.option("faceSet")); + const word setName = args["faceSet"]; faceSet faces(mesh, setName); diff --git a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C index 9140c090ec..4efd69cac8 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) if (args.optionFound("dict")) { - fileName dictPath(args.option("dict")); + const fileName dictPath = args["dict"]; meshDictIoPtr.set ( diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index bb187dc361..b3d98d40ef 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -835,15 +835,14 @@ int main(int argc, char *argv[]) # include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); - bool writeVTK = !args.optionFound("noVTK"); - bool loop = args.optionFound("loop"); - bool batch = args.optionFound("batch"); - + const bool writeVTK = !args.optionFound("noVTK"); + const bool loop = args.optionFound("loop"); + const bool batch = args.optionFound("batch"); if (loop && !batch) { FatalErrorIn(args.executable()) - << "Can only loop when in batch mode." + << "Can only loop in batch mode." << exit(FatalError); } @@ -885,7 +884,7 @@ int main(int argc, char *argv[]) if (batch) { - fileName batchFile(args.option("batch")); + const fileName batchFile = args["batch"]; Info<< "Reading commands from file " << batchFile << endl; diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C index c03db84d75..7b9d5ea8ce 100644 --- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C +++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C @@ -1326,9 +1326,8 @@ int main(int argc, char *argv[]) const word oldInstance = mesh.pointsInstance(); word blockedFacesName; - if (args.optionFound("blockedFaces")) + if (args.optionReadIfPresent("blockedFaces", blockedFacesName)) { - blockedFacesName = args.option("blockedFaces"); Info<< "Reading blocked internal faces from faceSet " << blockedFacesName << nl << endl; } @@ -1882,7 +1881,7 @@ int main(int argc, char *argv[]) if (insidePoint) { - point insidePoint(args.optionLookup("insidePoint")()); + const point insidePoint = args.optionRead("insidePoint"); label regionI = -1; diff --git a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C index fdf90a48b7..2c854ecb20 100644 --- a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C +++ b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) if (args.optionFound("patch")) { - word patchName(args.option("patch")); + const word patchName = args["patch"]; patchI = mesh.boundaryMesh().findPatchID(patchName); diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index acf7ce0708..488a74694a 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -210,7 +210,9 @@ int main(int argc, char *argv[]) ) ); + const bool doRotateFields = args.optionFound("rotateFields"); + // this is not actually stringent enough: if (args.options().empty()) { FatalErrorIn(args.executable()) @@ -219,18 +221,20 @@ int main(int argc, char *argv[]) << exit(FatalError); } - if (args.optionFound("translate")) + vector v; + if (args.optionReadIfPresent("translate", v)) { - vector transVector(args.optionLookup("translate")()); + Info<< "Translating points by " << v << endl; - Info<< "Translating points by " << transVector << endl; - - points += transVector; + points += v; } if (args.optionFound("rotate")) { - Pair n1n2(args.optionLookup("rotate")()); + Pair n1n2 + ( + args.optionLookup("rotate")() + ); n1n2[0] /= mag(n1n2[0]); n1n2[1] /= mag(n1n2[1]); tensor T = rotationTensor(n1n2[0], n1n2[1]); @@ -239,20 +243,17 @@ int main(int argc, char *argv[]) points = transform(T, points); - if (args.optionFound("rotateFields")) + if (doRotateFields) { rotateFields(args, runTime, T); } } - else if (args.optionFound("rollPitchYaw")) + else if (args.optionReadIfPresent("rollPitchYaw", v)) { - vector v(args.optionLookup("rollPitchYaw")()); - Info<< "Rotating points by" << nl << " roll " << v.x() << nl << " pitch " << v.y() << nl - << " yaw " << v.z() << endl; - + << " yaw " << v.z() << nl; // Convert to radians v *= pi/180.0; @@ -262,20 +263,17 @@ int main(int argc, char *argv[]) Info<< "Rotating points by quaternion " << R << endl; points = transform(R, points); - if (args.optionFound("rotateFields")) + if (doRotateFields) { rotateFields(args, runTime, R.R()); } } - else if (args.optionFound("yawPitchRoll")) + else if (args.optionReadIfPresent("yawPitchRoll", v)) { - vector v(args.optionLookup("yawPitchRoll")()); - Info<< "Rotating points by" << nl << " yaw " << v.x() << nl << " pitch " << v.y() << nl - << " roll " << v.z() << endl; - + << " roll " << v.z() << nl; // Convert to radians v *= pi/180.0; @@ -291,21 +289,19 @@ int main(int argc, char *argv[]) Info<< "Rotating points by quaternion " << R << endl; points = transform(R, points); - if (args.optionFound("rotateFields")) + if (doRotateFields) { rotateFields(args, runTime, R.R()); } } - if (args.optionFound("scale")) + if (args.optionReadIfPresent("scale", v)) { - vector scaleVector(args.optionLookup("scale")()); + Info<< "Scaling points by " << v << endl; - Info<< "Scaling points by " << scaleVector << endl; - - points.replace(vector::X, scaleVector.x()*points.component(vector::X)); - points.replace(vector::Y, scaleVector.y()*points.component(vector::Y)); - points.replace(vector::Z, scaleVector.z()*points.component(vector::Z)); + points.replace(vector::X, v.x()*points.component(vector::X)); + points.replace(vector::Y, v.y()*points.component(vector::Y)); + points.replace(vector::Z, v.z()*points.component(vector::Z)); } // Set the precision of the points data to 10 diff --git a/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C b/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C index 41abe8dcdb..7c05ba5a29 100644 --- a/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C +++ b/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) { fileName dictFileName ( - args.rootPath()/args.caseName()/args.option("dictionary") + args.rootPath()/args.caseName()/args["dictionary"] ); IFstream dictFile(dictFileName); @@ -103,7 +103,7 @@ int main(int argc, char *argv[]) true // wildcards ); - for (int i=1; idict().found(entryNames[i])) { @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) { FatalErrorIn(args.executable()) << "Cannot find sub-entry " << entryNames[i] - << " in entry " << args.option("entry") + << " in entry " << args["entry"] << " in dictionary " << dictFileName; FatalError.exit(3); } @@ -131,7 +131,7 @@ int main(int argc, char *argv[]) { FatalErrorIn(args.executable()) << "Cannot find entry " - << args.option("entry") + << args["entry"] << " in dictionary " << dictFileName << " is not a sub-dictionary"; FatalError.exit(4); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C index 19920b008a..170721916f 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,7 +80,10 @@ Foam::ensightMesh::ensightMesh if (args.optionFound("patches")) { - wordList patchNameList(args.optionLookup("patches")()); + wordList patchNameList + ( + args.optionLookup("patches")() + ); if (patchNameList.empty()) { diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C index 44384b7efe..2d11a6538d 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -215,9 +215,8 @@ int main(int argc, char *argv[]) word cellSetName; string vtkName; - if (args.optionFound("cellSet")) + if (args.optionReadIfPresent("cellSet", cellSetName)) { - cellSetName = args.option("cellSet"); vtkName = cellSetName; } else if (Pstream::parRun()) @@ -738,7 +737,7 @@ int main(int argc, char *argv[]) if (args.optionFound("faceSet")) { // Load the faceSet - word setName(args.option("faceSet")); + const word setName = args["faceSet"]; labelList faceLabels(faceSet(mesh, setName).toc()); // Filename as if patch with same name. diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 73dc60b762..6855685414 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -329,9 +329,8 @@ int main(int argc, char *argv[]) word cellSetName; string vtkName = runTime.caseName(); - if (args.optionFound("cellSet")) + if (args.optionReadIfPresent("cellSet", cellSetName)) { - cellSetName = args.option("cellSet"); vtkName = cellSetName; } else if (Pstream::parRun()) @@ -423,7 +422,7 @@ int main(int argc, char *argv[]) if (args.optionFound("faceSet")) { // Load the faceSet - faceSet set(mesh, args.option("faceSet")); + faceSet set(mesh, args["faceSet"]); // Filename as if patch with same name. mkDir(fvPath/set.name()); @@ -446,7 +445,7 @@ int main(int argc, char *argv[]) if (args.optionFound("pointSet")) { // Load the pointSet - pointSet set(mesh, args.option("pointSet")); + pointSet set(mesh, args["pointSet"]); // Filename as if patch with same name. mkDir(fvPath/set.name()); diff --git a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C index b9310ffc92..751e80503a 100644 --- a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C +++ b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,7 +59,7 @@ namespace Foam ( IOobject ( - args.option("dict"), + args["dict"], runTime.system(), runTime, IOobject::MUST_READ diff --git a/applications/utilities/preProcessing/mapFields/setTimeIndex.H b/applications/utilities/preProcessing/mapFields/setTimeIndex.H index 80dfb3efca..20012e3d20 100644 --- a/applications/utilities/preProcessing/mapFields/setTimeIndex.H +++ b/applications/utilities/preProcessing/mapFields/setTimeIndex.H @@ -2,7 +2,7 @@ label sourceTimeIndex = runTimeSource.timeIndex(); if (args.optionFound("sourceTime")) { - if (args.option("sourceTime") == "latestTime") + if (args["sourceTime"] == "latestTime") { sourceTimeIndex = sourceTimes.size() - 1; } diff --git a/applications/utilities/surface/surfaceAdd/surfaceAdd.C b/applications/utilities/surface/surfaceAdd/surfaceAdd.C index c10dbb28bd..be0baad23d 100644 --- a/applications/utilities/surface/surfaceAdd/surfaceAdd.C +++ b/applications/utilities/surface/surfaceAdd/surfaceAdd.C @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) << nl << endl; Info<< "Surface : " << inFileName1<< nl - << "Points : " << args.option("points") << nl + << "Points : " << args["points"] << nl << "Writing : " << outFileName << nl << endl; } else @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) if (addPoint) { - IFstream pointsFile(args.option("points")); + IFstream pointsFile(args["points"]); pointField extraPoints(pointsFile); Info<< "Additional Points:" << extraPoints.size() << endl; diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index 909485f5a7..985aa5690b 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) if (args.optionFound("set")) { - fileName setName(args.option("set")); + const fileName setName = args["set"]; Info<< "Reading existing feature set from file " << setName << endl; @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) set = surfaceFeatures(surf, includedAngle); - Info<< endl << "Writing initial features" << endl; + Info<< nl << "Writing initial features" << endl; set.write("initial.fSet"); set.writeObj("initial"); } @@ -210,7 +210,10 @@ int main(int argc, char *argv[]) if (args.optionFound("subsetBox")) { - treeBoundBox bb(args.optionLookup("subsetBox")()); + treeBoundBox bb + ( + args.optionLookup("subsetBox")() + ); Info<< "Removing all edges outside bb " << bb << endl; dumpBox(bb, "subsetBox.obj"); @@ -225,7 +228,10 @@ int main(int argc, char *argv[]) } else if (args.optionFound("deleteBox")) { - treeBoundBox bb(args.optionLookup("deleteBox")()); + treeBoundBox bb + ( + args.optionLookup("deleteBox")() + ); Info<< "Removing all edges inside bb " << bb << endl; dumpBox(bb, "deleteBox.obj"); diff --git a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C index 0dda6353d9..9ba19b5f96 100644 --- a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C +++ b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C @@ -153,7 +153,7 @@ int main(int argc, char *argv[]) if (args.optionFound("dict")) { - fileName dictPath(args.option("dict")); + const fileName dictPath = args["dict"]; csDictIoPtr.set ( @@ -200,7 +200,7 @@ int main(int argc, char *argv[]) if (args.optionFound("from")) { - const word csName(args.option("from")); + const word csName = args["from"]; label csId = csLst.find(csName); if (csId < 0) @@ -216,7 +216,7 @@ int main(int argc, char *argv[]) if (args.optionFound("to")) { - const word csName(args.option("to")); + const word csName = args["to"]; label csId = csLst.find(csName); if (csId < 0) diff --git a/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C index 5455f3c3fe..851f4ac784 100644 --- a/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C +++ b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) if (args.optionFound("dict")) { - fileName dictPath(args.option("dict")); + const fileName dictPath = args["dict"]; ioPtr.set ( @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) if (args.optionFound("from")) { - const word csName(args.option("from")); + const word csName = args["from"]; label csId = csLst.find(csName); if (csId < 0) @@ -171,7 +171,7 @@ int main(int argc, char *argv[]) if (args.optionFound("to")) { - const word csName(args.option("to")); + const word csName = args["to"]; label csId = csLst.find(csName); if (csId < 0) diff --git a/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C b/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C index 2653b60a05..a260598d35 100644 --- a/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C +++ b/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) if (args.optionFound("dict")) { - fileName dictPath(args.option("dict")); + const fileName dictPath = args["dict"]; ioPtr.set ( @@ -168,7 +168,7 @@ int main(int argc, char *argv[]) if (args.optionFound("from")) { - const word csName(args.option("from")); + const word csName = args["from"]; label csId = csLst.find(csName); if (csId < 0) @@ -184,7 +184,7 @@ int main(int argc, char *argv[]) if (args.optionFound("to")) { - const word csName(args.option("to")); + const word csName = args["to"]; label csId = csLst.find(csName); if (csId < 0) diff --git a/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C b/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C index 3ce0dc64f4..ef28d76d34 100644 --- a/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C +++ b/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C @@ -85,12 +85,14 @@ int main(int argc, char *argv[]) if (args.optionFound("patches")) { - wordList patchNames(args.optionLookup("patches")()); + const wordList patchNames + ( + args.optionLookup("patches")() + ); forAll(patchNames, patchNameI) { const word& patchName = patchNames[patchNameI]; - label patchI = bMesh.findPatchID(patchName); if (patchI == -1) diff --git a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C index ddf31a0d78..e5dd518b11 100644 --- a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C +++ b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C @@ -116,18 +116,20 @@ int main(int argc, char *argv[]) pointField points(surf1.points()); - if (args.optionFound("translate")) + vector v; + if (args.optionReadIfPresent("translate", v)) { - vector transVector(args.optionLookup("translate")()); + Info<< "Translating points by " << v << endl; - Info<< "Translating points by " << transVector << endl; - - points += transVector; + points += v; } if (args.optionFound("rotate")) { - Pair n1n2(args.optionLookup("rotate")()); + Pair n1n2 + ( + args.optionLookup("rotate")() + ); n1n2[0] /= mag(n1n2[0]); n1n2[1] /= mag(n1n2[1]); @@ -137,15 +139,12 @@ int main(int argc, char *argv[]) points = transform(T, points); } - else if (args.optionFound("rollPitchYaw")) + else if (args.optionReadIfPresent("rollPitchYaw", v)) { - vector v(args.optionLookup("rollPitchYaw")()); - Info<< "Rotating points by" << nl << " roll " << v.x() << nl << " pitch " << v.y() << nl - << " yaw " << v.z() << endl; - + << " yaw " << v.z() << nl; // Convert to radians v *= pi/180.0; @@ -155,14 +154,12 @@ int main(int argc, char *argv[]) Info<< "Rotating points by quaternion " << R << endl; points = transform(R, points); } - else if (args.optionFound("yawPitchRoll")) + else if (args.optionReadIfPresent("yawPitchRoll", v)) { - vector v(args.optionLookup("yawPitchRoll")()); - Info<< "Rotating points by" << nl << " yaw " << v.x() << nl << " pitch " << v.y() << nl - << " roll " << v.z() << endl; + << " roll " << v.z() << nl; // Convert to radians @@ -180,15 +177,13 @@ int main(int argc, char *argv[]) points = transform(R, points); } - if (args.optionFound("scale")) + if (args.optionReadIfPresent("scale", v)) { - vector scaleVector(args.optionLookup("scale")()); + Info<< "Scaling points by " << v << endl; - Info<< "Scaling points by " << scaleVector << endl; - - points.replace(vector::X, scaleVector.x()*points.component(vector::X)); - points.replace(vector::Y, scaleVector.y()*points.component(vector::Y)); - points.replace(vector::Z, scaleVector.z()*points.component(vector::Z)); + points.replace(vector::X, v.x()*points.component(vector::X)); + points.replace(vector::Y, v.y()*points.component(vector::Y)); + points.replace(vector::Z, v.z()*points.component(vector::Z)); } surf1.movePoints(points); diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 34e3196cbe..0dba0f4829 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -251,7 +251,7 @@ bool Foam::argList::regroupArgv(int& argc, char**& argv) // note: we also re-write directly into args_ // and use a second pass to sort out args/options - for (int argI = 0; argI < argc; argI++) + for (int argI = 0; argI < argc; ++argI) { if (strcmp(argv[argI], "(") == 0) { @@ -369,7 +369,7 @@ Foam::argList::argList { // Check if this run is a parallel run by searching for any parallel option // If found call runPar which might filter argv - for (int argI = 0; argI < argc; argI++) + for (int argI = 0; argI < argc; ++argI) { if (argv[argI][0] == '-') { @@ -395,7 +395,7 @@ Foam::argList::argList int nArgs = 1; string argListString = args_[0]; - for (int argI = 1; argI < args_.size(); argI++) + for (int argI = 1; argI < args_.size(); ++argI) { argListString += ' '; argListString += args_[argI]; diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index f7e0a32c05..16e34c76e7 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -193,7 +193,7 @@ public: // Access - //- Name of executable + //- Name of executable without the path inline const word& executable() const; //- Return root path @@ -211,14 +211,12 @@ public: //- Return arguments inline const stringList& args() const; + //- Return the argument corresponding to index. + inline const string& arg(const label index) const; + //- Return the number of arguments inline label size() const; - //- Return the argument corresponding to index. - // Index 0 corresponds to the name of the executable. - // Index 1 corresponds to the first argument. - inline const string& operator[](const label index) const; - //- Read a value from the argument at index. // Index 0 corresponds to the name of the executable. // Index 1 corresponds to the first argument. @@ -282,6 +280,15 @@ public: } + //- Return the argument corresponding to index. + // Index 0 corresponds to the name of the executable. + // Index 1 corresponds to the first argument. + inline const string& operator[](const label index) const; + + //- Return the argument string associated with the named option + // @sa option() + inline const string& operator[](const word& opt) const; + // Edit //- Add to a bool option to validOptions with usage information diff --git a/src/OpenFOAM/global/argList/argListI.H b/src/OpenFOAM/global/argList/argListI.H index 9da2149de6..7e8edcbd1f 100644 --- a/src/OpenFOAM/global/argList/argListI.H +++ b/src/OpenFOAM/global/argList/argListI.H @@ -64,6 +64,12 @@ inline const Foam::stringList& Foam::argList::args() const } +inline const Foam::string& Foam::argList::arg(const label index) const +{ + return args_[index]; +} + + inline Foam::label Foam::argList::size() const { return args_.size(); @@ -78,7 +84,7 @@ inline const Foam::HashTable& Foam::argList::options() const inline const Foam::string& Foam::argList::option(const word& opt) const { - return options_.operator[](opt); + return options_[opt]; } @@ -90,7 +96,7 @@ inline bool Foam::argList::optionFound(const word& opt) const inline Foam::IStringStream Foam::argList::optionLookup(const word& opt) const { - return IStringStream(option(opt)); + return IStringStream(options_[opt]); } @@ -127,7 +133,7 @@ namespace Foam inline Foam::string Foam::argList::optionRead(const word& opt) const { - return option(opt); + return options_[opt]; } // Template specialization for word @@ -135,7 +141,7 @@ namespace Foam inline Foam::word Foam::argList::optionRead(const word& opt) const { - return option(opt); + return options_[opt]; } // Template specialization for fileName @@ -143,7 +149,7 @@ namespace Foam inline Foam::fileName Foam::argList::optionRead(const word& opt) const { - return option(opt); + return options_[opt]; } } @@ -235,4 +241,10 @@ inline const Foam::string& Foam::argList::operator[](const label index) const } +inline const Foam::string& Foam::argList::operator[](const word& opt) const +{ + return options_[opt]; +} + + // ************************************************************************* // diff --git a/src/postProcessing/foamCalcFunctions/basic/addSubtract/addSubtract.C b/src/postProcessing/foamCalcFunctions/basic/addSubtract/addSubtract.C index 27964a9685..9859d56546 100644 --- a/src/postProcessing/foamCalcFunctions/basic/addSubtract/addSubtract.C +++ b/src/postProcessing/foamCalcFunctions/basic/addSubtract/addSubtract.C @@ -232,14 +232,12 @@ void Foam::calcTypes::addSubtract::preCalc << exit(FatalError); } - if (args.optionFound("field")) + if (args.optionReadIfPresent("field", addSubtractFieldName_)) { - addSubtractFieldName_ = args.option("field"); calcType_ = FIELD; } - else if (args.optionFound("value")) + else if (args.optionReadIfPresent("value", addSubtractValueStr_)) { - addSubtractValueStr_ = args.option("value"); calcType_ = VALUE; } else @@ -249,10 +247,7 @@ void Foam::calcTypes::addSubtract::preCalc << nl << exit(FatalError); } - if (args.optionFound("resultName")) - { - resultName_ = args.option("resultName"); - } + args.optionReadIfPresent("resultName", resultName_); }