Commit d857d671 authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: use new argList argRead() method and operator[] for cleaner code.

- deprecate argList::additionalArgs() method and remove uses of it
parent 51039eab
......@@ -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
......@@ -109,10 +109,8 @@ int main(int argc, char *argv[])
argList::validArgs.append("ODESolver");
argList args(argc, argv);
word ODESolverName(args.additionalArgs()[0]);
testODE ode;
autoPtr<ODESolver> odeSolver = ODESolver::New(ODESolverName, ode);
autoPtr<ODESolver> odeSolver = ODESolver::New(args[1], ode);
scalar xStart = 1.0;
scalarField yStart(ode.nEqns());
......
......@@ -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
......@@ -130,15 +130,15 @@ int main(int argc, char *argv[])
return 0;
}
else if (args.additionalArgs().empty())
else if (args.size() <= 1)
{
args.printUsage();
}
forAll(args.additionalArgs(), argI)
for (label argI=1; argI < args.size(); ++argI)
{
const string& srcFile = args.additionalArgs()[argI];
const string& srcFile = args[argI];
Info<< nl << "reading " << srcFile << nl;
IFstream ifs(srcFile);
......
......@@ -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
......@@ -51,7 +51,7 @@ int main(int argc, char *argv[])
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
<< endl;
if (args.additionalArgs().empty())
if (args.size() <= 1)
{
{
dictionary dict1(IFstream("testDict")());
......@@ -114,9 +114,9 @@ int main(int argc, char *argv[])
else
{
IOobject::writeDivider(Info);
forAll(args.additionalArgs(), argI)
for (label argI=1; argI < args.size(); ++argI)
{
const string& dictFile = args.additionalArgs()[argI];
const string& dictFile = args[argI];
IFstream is(dictFile);
dictionary dict(is);
......
......@@ -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) 2009-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
argList args(argc, argv, false, true);
if (args.additionalArgs().empty() && args.options().empty())
if (args.size() <= 1 && args.options().empty())
{
args.printUsage();
}
......@@ -90,9 +90,9 @@ int main(int argc, char *argv[])
printCleaning(pathName);
}
forAll(args.additionalArgs(), argI)
for (label argI=1; argI < args.size(); ++argI)
{
pathName = args.additionalArgs()[argI];
pathName = args[argI];
printCleaning(pathName);
}
......
......@@ -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
......@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
# include "createTime.H"
# include "createMesh.H"
point sample(IStringStream(args.additionalArgs()[0])());
const point sample = args.argRead<point>(1);
treeBoundBox meshBb(mesh.points());
......@@ -82,8 +82,8 @@ int main(int argc, char *argv[])
);
Info<< "Point:" << sample << " is in shape "
<< oc.find(sample) << endl;
Info<< "Point:" << sample << " is in cell "
<< oc.find(sample) << nl
<< "Point:" << sample << " is in cell "
<< mesh.findCell(sample) << endl;
......
......@@ -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) 2009-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -45,16 +45,16 @@ int main(int argc, char *argv[])
argList args(argc, argv, false, true);
if (args.additionalArgs().empty())
if (args.size() <= 1)
{
args.printUsage();
}
label ok = 0;
forAll(args.additionalArgs(), argI)
for (label argI=1; argI < args.size(); ++argI)
{
const string& srcFile = args.additionalArgs()[argI];
const string& srcFile = args[argI];
if (args.optionFound("ext"))
{
......@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
}
}
Info<< "mvBak called for " << args.additionalArgs().size()
Info<< "mvBak called for " << args.size()-1
<< " files (moved " << ok << ")\n" << endl;
return 0;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
#include "createMesh.H"
runTime.functionObjects().off();
const word cloudName(args.additionalArgs()[0]);
const word cloudName = args[1];
{
// Start with empty cloud
......
......@@ -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
......@@ -221,7 +221,7 @@ int main(int argc, char *argv[])
# include "createTime.H"
# include "createPolyMesh.H"
word patchName(args.additionalArgs()[0]);
const word patchName = args[1];
label patchI = mesh.boundaryMesh().findPatchID(patchName);
......
......@@ -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
......@@ -42,20 +42,15 @@ int main(int argc, char *argv[])
argList args(argc, argv);
fileName thermoFileName = fileName::null;
if (args.options().found("thermo"))
{
thermoFileName = args.options()["thermo"];
}
fileName CHEMKINFileName(args.additionalArgs()[0]);
args.optionReadIfPresent("thermo", thermoFileName);
chemkinReader ck(CHEMKINFileName, thermoFileName);
chemkinReader ck(args[1], thermoFileName);
//Info<< ck.isotopeAtomicWts() << endl;
//Info<< ck.specieNames() << endl;
//Info<< ck.speciePhase() << endl;
//Info<< ck.specieThermo() << endl;
//Info<< ck.reactions() << endl;
//Info<< ck.isotopeAtomicWts() << nl
// << ck.specieNames() << nl
// << ck.speciePhase() << nl
// << ck.specieThermo() << nl
// << ck.reactions() << endl;
const SLPtrList<gasReaction>& reactions = ck.reactions();
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
argList args(argc, argv, false, true);
if (args.additionalArgs().empty())
if (args.size() <= 1)
{
args.printUsage();
}
......@@ -73,9 +73,9 @@ int main(int argc, char *argv[])
useCatmullRom = true;
}
forAll(args.additionalArgs(), argI)
for (label argI=1; argI < args.size(); ++argI)
{
const string& srcFile = args.additionalArgs()[argI];
const string& srcFile = args[argI];
Info<< nl << "reading " << srcFile << nl;
IFstream ifs(srcFile);
......
......@@ -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
......@@ -51,7 +51,7 @@ int main(int argc, char *argv[])
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Get name of patch
word patchName(args.additionalArgs()[0]);
const word patchName = args[1];
// Find the label in patches by name.
label patchI = patches.findPatchID(patchName);
......
......@@ -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
......@@ -54,9 +54,9 @@ int main(int argc, char *argv[])
cpuTime timer;
for (label count = 0; count < repeat; ++count)
{
forAll(args.additionalArgs(), argI)
for (label argI=1; argI < args.size(); ++argI)
{
const string& rawArg = args.additionalArgs()[argI];
const string& rawArg = args[argI];
if (count == 0)
{
Info<< "input string: " << rawArg << nl;
......
......@@ -464,8 +464,8 @@ int main(int argc, char *argv[])
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
scalar minLen(readScalar(IStringStream(args.additionalArgs()[0])()));
scalar angle(readScalar(IStringStream(args.additionalArgs()[1])()));
const scalar minLen = args.argRead<scalar>(1);
const scalar angle = args.argRead<scalar>(2);
const bool overwrite = args.optionFound("overwrite");
scalar maxCos = Foam::cos(degToRad(angle));
......
......@@ -446,14 +446,12 @@ int main(int argc, char *argv[])
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
scalar minCos = Foam::cos(degToRad(featureAngle));
const scalar featureAngle = args.argRead<scalar>(1);
const scalar minCos = Foam::cos(degToRad(featureAngle));
// Sin of angle between two consecutive edges on a face.
// If sin(angle) larger than this the face will be considered concave.
scalar concaveAngle = args.optionLookupOrDefault("concaveAngle", 30.0);
scalar concaveSin = Foam::sin(degToRad(concaveAngle));
const bool snapMeshDict = args.optionFound("snapMesh");
......
......@@ -60,12 +60,10 @@ int main(int argc, char *argv[])
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
word patchName(args.additionalArgs()[0]);
scalar weight(readScalar(IStringStream(args.additionalArgs()[1])()));
const word patchName = args[1];
const scalar weight = args.argRead<scalar>(2);
const bool overwrite = args.optionFound("overwrite");
label patchID = mesh.boundaryMesh().findPatchID(patchName);
if (patchID == -1)
......
......@@ -57,10 +57,9 @@ int main(int argc, char *argv[])
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
const word setName = args[1];
const bool overwrite = args.optionFound("overwrite");
word setName(args.additionalArgs()[0]);
// Read faces
faceSet candidateSet(mesh, setName);
......
......@@ -537,10 +537,9 @@ int main(int argc, char *argv[])
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
scalar minCos = Foam::cos(degToRad(featureAngle));
scalar minSin = Foam::sin(degToRad(featureAngle));
const scalar featureAngle = args.argRead<scalar>(1);
const scalar minCos = Foam::cos(degToRad(featureAngle));
const scalar minSin = Foam::sin(degToRad(featureAngle));
const bool readSet = args.optionFound("set");
const bool geometry = args.optionFound("geometry");
......
......@@ -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
......@@ -615,7 +615,7 @@ int main(int argc, char *argv[])
wordList foamPatchNames;
{
fileName ccmFile(args.additionalArgs()[0]);
const fileName ccmFile = args[1];
if (!isFile(ccmFile))
{
......
......@@ -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
......@@ -26,7 +26,8 @@ Application
ansysToFoam
Description
Converts an ANSYS input mesh file, exported from I-DEAS, to FOAM format.
Converts an ANSYS input mesh file, exported from I-DEAS,
to OpenFOAM format.
\*---------------------------------------------------------------------------*/
......@@ -252,7 +253,7 @@ int main(int argc, char *argv[])
# include "createTime.H"
fileName ansysFile(args.additionalArgs()[0]);
const fileName ansysFile = args[1];
ifstream ansysStream(ansysFile.c_str());
if (!ansysStream)
......
......@@ -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
......@@ -26,7 +26,7 @@ Application
cfx4ToFoam
Description
Converts a CFX 4 mesh to FOAM format
Converts a CFX 4 mesh to OpenFOAM format
\*---------------------------------------------------------------------------*/
......@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
# include "createTime.H"
IFstream cfxFile(args.additionalArgs()[0]);
IFstream cfxFile(args[1]);
// Read the cfx information using a fixed format reader.
// Comments in the file are in C++ style, so the stream parser will remove
......@@ -603,7 +603,7 @@ int main(int argc, char *argv[])
Info<< "CFX patch " << patchI
<< ", of type " << cfxPatchTypes[patchI]
<< ", name " << cfxPatchNames[patchI]
<< " already exists as FOAM patch " << existingPatch
<< " already exists as OpenFOAM patch " << existingPatch
<< ". Adding faces." << endl;
faceList& renumberedPatch = boundary[existingPatch];
......@@ -655,7 +655,7 @@ int main(int argc, char *argv[])
Info<< "CFX patch " << patchI
<< ", of type " << cfxPatchTypes[patchI]
<< ", name " << cfxPatchNames[patchI]
<< " converted into FOAM patch " << nCreatedPatches
<< " converted into OpenFOAM patch " << nCreatedPatches
<< " type ";
if (cfxPatchTypes[patchI] == "WALL")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment