ENH: support predicate checks for argList (similar to dictionary methods)

- Favour use of argList methods that are more similar to dictionary
  method names with the aim of reducing the cognitive load.

  * Silently deprecate two-parameter get() method in favour of the
    more familiar getOrDefault.
  * Silently deprecate opt() method in favour of get()

  These may be verbosely deprecated in future versions.
This commit is contained in:
Mark Olesen
2020-06-02 12:22:54 +02:00
parent 695766af16
commit 31b172217c
76 changed files with 398 additions and 170 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -383,7 +383,7 @@ int main(int argc, char *argv[])
// Sin of angle between two consecutive edges on a face.
// If sin(angle) larger than this the face will be considered concave.
const scalar concaveAngle = args.get<scalar>("concaveAngle", 30);
const scalar concaveAngle = args.getOrDefault<scalar>("concaveAngle", 30);
const scalar concaveSin = Foam::sin(degToRad(concaveAngle));

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -561,7 +562,7 @@ int main(int argc, char *argv[])
const bool geometry = args.found("geometry");
const bool overwrite = args.found("overwrite");
const scalar edgeTol = args.get<scalar>("tol", 0.2);
const scalar edgeTol = args.getOrDefault<scalar>("tol", 0.2);
Info<< "Trying to split cells with internal angles > feature angle\n" << nl
<< "featureAngle : " << featureAngle << nl

View File

@ -323,7 +323,7 @@ int main(int argc, char *argv[])
FatalError.exit();
}
const scalar scaleFactor = args.get<scalar>("scale", 1);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 1);
#include "createTime.H"

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -188,7 +188,7 @@ int main(int argc, char *argv[])
}
// By default, no scaling
const scalar scaleFactor = args.get<scalar>("scale", 1);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 1);
// Default to binary output, unless otherwise specified
const IOstream::streamFormat format =

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -71,7 +72,7 @@ int main(int argc, char *argv[])
FatalError.exit();
}
const scalar scaleFactor = args.get<scalar>("scale", 1);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 1);
#include "createTime.H"

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -105,7 +105,7 @@ int main(int argc, char *argv[])
(
args[1],
// Default no scaling
args.get<scalar>("scale", 1)
args.getOrDefault<scalar>("scale", 1)
);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -904,7 +905,7 @@ int main(int argc, char *argv[])
FatalError.exit();
}
const scalar scaleFactor = args.get<scalar>("scale", 1);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 1);
const bool writeSets = args.found("writeSets");
const bool writeZones = args.found("writeZones");

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -99,7 +99,7 @@ int main(int argc, char *argv[])
}
// Default rescale from [m] to [mm]
const scalar scaleFactor = args.get<scalar>("scale", 1000);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 1000);
const bool writeBndFile = !args.found("noBnd");
#include "createPolyMesh.H"

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -83,7 +84,7 @@ int main(int argc, char *argv[])
fileName exportName = args[1];
const scalar scaleFactor = args.get<scalar>("scale", 0);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 0);
const bool doTriangulate = args.found("tri");
fileName exportBase = exportName.lessExt();

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -648,7 +649,7 @@ int main(int argc, char *argv[])
FatalError.exit();
}
const scalar scaleFactor = args.get<scalar>("scale", 1);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 1);
#include "createTime.H"

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -87,7 +88,8 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
#include "createTime.H"
const fileName kivaFileName = args.get<fileName>("file", "otape17");
const fileName kivaFileName =
args.getOrDefault<fileName>("file", "otape17");
kivaVersions kivaVersion = kiva3v;
if (args.found("version"))
@ -113,7 +115,7 @@ int main(int argc, char *argv[])
}
}
const scalar zHeadMin = args.get<scalar>("zHeadMin", -GREAT);
const scalar zHeadMin = args.getOrDefault<scalar>("zHeadMin", -GREAT);
#include "readKivaGrid.H"

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -96,7 +97,7 @@ int main(int argc, char *argv[])
FatalError.exit();
}
const scalar scaleFactor = args.get<scalar>("scale", 1);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 1);
const bool readBlank = !args.found("noBlank");
const bool singleBlock = args.found("singleBlock");

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -116,7 +116,7 @@ int main(int argc, char *argv[])
prefix,
runTime,
// Default rescale from [mm] to [m]
args.get<scalar>("scale", 0.001),
args.getOrDefault<scalar>("scale", 0.001),
args.found("solids")
);

View File

@ -250,7 +250,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
),
args.get<fileName>("dict", "")
args.getOrDefault<fileName>("dict", "")
)
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -74,7 +74,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location
const fileName decompDictFile =
args.get<fileName>("decomposeParDict", "");
args.getOrDefault<fileName>("decomposeParDict", "");
IOdictionary foamyHexMeshDict
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -64,7 +64,8 @@ scalar getMergeDistance
const boundBox& bb
)
{
const scalar mergeTol = args.get<scalar>("mergeTol", defaultMergeTol);
const scalar mergeTol =
args.getOrDefault<scalar>("mergeTol", defaultMergeTol);
scalar writeTol =
Foam::pow(scalar(10), -scalar(IOstream::defaultPrecision()));
@ -522,7 +523,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location
const fileName decompDictFile =
args.get<fileName>("decomposeParDict", "");
args.getOrDefault<fileName>("decomposeParDict", "");
labelList decomp = decompositionModel::New
(

View File

@ -894,7 +894,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ,
IOobject::NO_WRITE
),
args.get<fileName>("decomposeParDict", "")
args.getOrDefault<fileName>("decomposeParDict", "")
)
);
@ -1979,7 +1979,7 @@ int main(int argc, char *argv[])
fileName outFileName
(
args.get<fileName>
args.getOrDefault<fileName>
(
"outFile",
"constant/triSurface/simplifiedSurface.stl"

View File

@ -139,7 +139,7 @@ int main(int argc, char *argv[])
const bool allTopology = args.found("allTopology");
const bool meshQuality = args.found("meshQuality");
const word surfaceFormat = args.get<word>("writeSets", "");
const word surfaceFormat = args.getOrDefault<word>("writeSets", "");
const bool writeSets = surfaceFormat.size();
wordHashSet selectedFields;

View File

@ -534,7 +534,7 @@ int main(int argc, char *argv[])
#include "createTime.H"
const word meshRegionName =
args.get<word>("region", polyMesh::defaultRegion);
args.getOrDefault<word>("region", polyMesh::defaultRegion);
const bool overwrite = args.found("overwrite");

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,10 +106,10 @@ int main(int argc, char *argv[])
fileName addCase = args[2];
const word masterRegion =
args.get<word>("masterRegion", polyMesh::defaultRegion);
args.getOrDefault<word>("masterRegion", polyMesh::defaultRegion);
const word addRegion =
args.get<word>("addRegion", polyMesh::defaultRegion);
args.getOrDefault<word>("addRegion", polyMesh::defaultRegion);
// Since we don't use argList processor directory detection, add it to
// the casename ourselves so it triggers the logic inside TimePath.

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -203,7 +203,7 @@ int main(int argc, char *argv[])
const word dictName("refineMeshDict");
// Obtain dictPath here for messages
fileName dictPath = args.get<fileName>("dict", "");
fileName dictPath = args.getOrDefault<fileName>("dict", "");
IOobject dictIO = IOobject::selectIO
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -261,13 +261,13 @@ int main(int argc, char *argv[])
if (args.found("time"))
{
if (args.opt("time") == "constant")
if (args["time"] == "constant")
{
runTime.setTime(instant(0, "constant"), 0);
}
else
{
scalar timeValue = args.get<scalar>("time");
const scalar timeValue = args.get<scalar>("time");
runTime.setTime(instant(timeValue), 0);
}
}

View File

@ -360,7 +360,7 @@ int main(int argc, char *argv[])
// Set the default output precision
{
const unsigned prec = args.lookupOrDefault<unsigned>("precision", 0u);
const unsigned prec = args.getOrDefault<unsigned>("precision", 0u);
if (prec)
{
// if (Pstream::master())

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -330,7 +330,8 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location
const fileName decompDictFile = args.get<fileName>("decomposeParDict", "");
const fileName decompDictFile =
args.getOrDefault<fileName>("decomposeParDict", "");
// Get all region names
wordList regionNames;
@ -344,7 +345,8 @@ int main(int argc, char *argv[])
else
{
regionNames.resize(1);
regionNames.first() = args.get<word>("region", fvMesh::defaultRegion);
regionNames.first() =
args.getOrDefault<word>("region", fvMesh::defaultRegion);
}
forAll(regionNames, regioni)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -509,7 +509,8 @@ int main(int argc, char *argv[])
Info<< "Operating on region " << regionName << nl << endl;
}
const scalar mergeTol = args.get<scalar>("mergeTol", defaultMergeTol);
const scalar mergeTol =
args.getOrDefault<scalar>("mergeTol", defaultMergeTol);
scalar writeTol = Foam::pow(10.0, -scalar(IOstream::defaultPrecision()));

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -119,7 +119,8 @@ scalar getMergeDistance
const boundBox& bb
)
{
const scalar mergeTol = args.get<scalar>("mergeTol", defaultMergeTol);
const scalar mergeTol =
args.getOrDefault<scalar>("mergeTol", defaultMergeTol);
const scalar writeTol =
Foam::pow(scalar(10), -scalar(IOstream::defaultPrecision()));
@ -2500,7 +2501,8 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location
const fileName decompDictFile = args.get<fileName>("decomposeParDict", "");
const fileName decompDictFile =
args.getOrDefault<fileName>("decomposeParDict", "");
// Get all region names
wordList regionNames;
@ -2514,7 +2516,8 @@ int main(int argc, char *argv[])
else
{
regionNames.resize(1);
regionNames.first() = args.get<word>("region", fvMesh::defaultRegion);
regionNames.first() =
args.getOrDefault<word>("region", fvMesh::defaultRegion);
}

View File

@ -357,7 +357,7 @@ int main(int argc, char *argv[])
// Forced point interpolation?
caseOpts.nodeValues(doPointValues && args.found("nodeValues"));
caseOpts.width(args.get<label>("width", 8));
caseOpts.width(args.getOrDefault<label>("width", 8));
caseOpts.overwrite(!args.found("no-overwrite")); // Remove existing?
// Can also have separate directory for lagrangian
@ -366,7 +366,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.get<word>("name", "EnSight");
fileName outputDir = args.getOrDefault<word>("name", "EnSight");
if (!outputDir.isAbsolute())
{
outputDir = args.globalPath()/outputDir;

View File

@ -633,7 +633,8 @@ int main(int argc, char *argv[])
else
{
regionNames.resize(1);
regionNames.first() = args.get<word>("region", fvMesh::defaultRegion);
regionNames.first() =
args.getOrDefault<word>("region", fvMesh::defaultRegion);
}
@ -695,7 +696,7 @@ int main(int argc, char *argv[])
// Directory management
// Sub-directory for output
const word vtkDirName = args.get<word>("name", "VTK");
const word vtkDirName = args.getOrDefault<word>("name", "VTK");
const fileName outputDir(args.globalPath()/vtkDirName);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -93,10 +93,10 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const label maxOut = Foam::max(0, args.get<label>("max", 0));
const label span = Foam::max(1, args.get<label>("span", 1));
const label maxOut = Foam::max(0, args.getOrDefault<label>("max", 0));
const label span = Foam::max(1, args.getOrDefault<label>("span", 1));
const scalar relax = args.get<scalar>("scale", 1);
const scalar relax = args.getOrDefault<scalar>("scale", 1);
const bool slave = args.found("slave");
const bool removeLock = args.found("removeLock");

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -237,12 +237,12 @@ int main(int argc, char *argv[])
}
const int divisions = args.get<int>("divisions", 1);
const int divisions = args.getOrDefault<int>("divisions", 1);
Info<< "Using " << divisions << " per time interval" << nl << endl;
const word interpolationType =
args.get<word>("interpolationType", "linear");
args.getOrDefault<word>("interpolationType", "linear");
Info<< "Using interpolation " << interpolationType << nl << endl;

View File

@ -250,7 +250,7 @@ int main(int argc, char *argv[])
fileName baseDir
(
args.get<fileName>
args.getOrDefault<fileName>
(
"templateDir",
"${WM_PROJECT_DIR}/etc/caseDicts/createZeroDirectoryTemplates"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -434,7 +434,8 @@ int main(int argc, char *argv[])
}
const bool enableEntries = args.found("enableFunctionEntries");
const word regionName = args.get<word>("region", polyMesh::defaultRegion);
const word regionName =
args.getOrDefault<word>("region", polyMesh::defaultRegion);
fileName regionPrefix;
if (regionName != polyMesh::defaultRegion)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -69,7 +69,7 @@ int readNumProcs
IOobject::NO_WRITE,
false // do not register
),
args.get<fileName>(optionName, "")
args.getOrDefault<fileName>(optionName, "")
)
)
);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -771,7 +771,7 @@ int main(int argc, char *argv[])
expressions::exprString
expression
(
args.opt("expression"),
args[expression],
dictionary::null
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -90,7 +90,7 @@ int main(int argc, char *argv[])
const bool addPoint = args.found("points");
const bool mergeRegions = args.found("mergeRegions");
const scalar scaleFactor = args.get<scalar>("scale", -1);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", -1);
if (addPoint)
{

View File

@ -1606,7 +1606,7 @@ int main(int argc, char *argv[])
// Scale factor for both surfaces:
const scalar scaleFactor = args.get<scalar>("scale", -1);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", -1);
const word surf1Name(args[2]);
Info<< "Reading surface " << surf1Name << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -338,8 +338,9 @@ int main(int argc, char *argv[])
const fileName surfFileName = args[1];
const bool checkSelfIntersect = args.found("checkSelfIntersection");
const bool splitNonManifold = args.found("splitNonManifold");
const label outputThreshold = args.get<label>("outputThreshold", 10);
const word surfaceFormat = args.get<word>("writeSets", "");
const label outputThreshold =
args.getOrDefault<label>("outputThreshold", 10);
const word surfaceFormat = args.getOrDefault<word>("writeSets", "");
const bool writeSets = !surfaceFormat.empty();
autoPtr<surfaceWriter> surfWriter;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -96,7 +97,7 @@ int main(int argc, char *argv[])
triSurface surf
(
inFileName,
args.get<scalar>("scale", -1)
args.getOrDefault<scalar>("scale", -1)
);
surf.writeStats(Info);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -104,7 +105,7 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
const scalar scaleFactor = args.get<scalar>("scale", -1);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", -1);
Info<< "Input surface :" << inFileName << nl
<< "Scaling factor :" << scaleFactor << nl

View File

@ -149,7 +149,7 @@ int main(int argc, char *argv[])
argList args(argc, argv);
{
const unsigned prec = args.lookupOrDefault<unsigned>("precision", 0u);
const unsigned prec = args.getOrDefault<unsigned>("precision", 0u);
if (prec)
{
Info<< "Output write precision set to " << prec << endl;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -63,9 +64,9 @@ int main(int argc, char *argv[])
const point samplePt
(
args.get<scalar>("x", 0),
args.get<scalar>("y", 0),
args.get<scalar>("z", 0)
args.getOrDefault<scalar>("x", 0),
args.getOrDefault<scalar>("y", 0),
args.getOrDefault<scalar>("z", 0)
);
Info<< "Looking for nearest face/vertex to " << samplePt << endl;

View File

@ -89,7 +89,7 @@ int main(int argc, char *argv[])
argList args(argc, argv);
const fileName surfFileName = args[1];
const scalar density = args.get<scalar>("density", 1);
const scalar density = args.getOrDefault<scalar>("density", 1);
vector refPt = Zero;
bool calcAroundRefPt = args.readIfPresent("referencePoint", refPt);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -612,8 +613,8 @@ int main(int argc, char *argv[])
const scalar distance(args.get<scalar>(2));
const scalar extendFactor(args.get<scalar>(3));
const bool checkSelfIntersect = args.found("checkSelfIntersection");
const label nSmooth = args.get<label>("nSmooth", 10);
const scalar featureAngle = args.get<scalar>("featureAngle", 180);
const label nSmooth = args.getOrDefault<label>("nSmooth", 10);
const scalar featureAngle = args.getOrDefault<scalar>("featureAngle", 180);
const bool debug = args.found("debug");

View File

@ -230,7 +230,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE,
false
),
args.get<fileName>("dict", "")
args.getOrDefault<fileName>("dict", "")
);
if (!ioCsys.typeHeaderOk<coordinateSystems>(false))

View File

@ -156,7 +156,7 @@ int main(int argc, char *argv[])
Time runTime(args.rootPath(), args.caseName());
const fileName exportName(args[1]);
const word importName(args.get<word>("name", "default"));
const word importName(args.getOrDefault<word>("name", "default"));
const word writeFileType
(
@ -191,7 +191,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE,
false
),
args.get<fileName>("dict", "")
args.getOrDefault<fileName>("dict", "")
);
if (!ioCsys.typeHeaderOk<coordinateSystems>(false))

View File

@ -168,7 +168,7 @@ int main(int argc, char *argv[])
const fileName importName(args[1]);
const word exportName(args.get<word>("name", "default"));
const word exportName(args.getOrDefault<word>("name", "default"));
const word readFileType
(
@ -203,7 +203,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE,
false
),
args.get<fileName>("dict", "")
args.getOrDefault<fileName>("dict", "")
);
if (!ioCsys.typeHeaderOk<coordinateSystems>(false))

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -122,7 +122,7 @@ int main(int argc, char *argv[])
// use UnsortedMeshedSurface, not MeshedSurface to maintain ordering
UnsortedMeshedSurface<face> surf(importName);
const scalar scaling = args.get<scalar>("scale", -1);
const scalar scaling = args.getOrDefault<scalar>("scale", -1);
if (scaling > 0)
{
DetailInfo << " -scale " << scaling << nl;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -95,7 +96,7 @@ int main(int argc, char *argv[])
Info<< "outside" << endl;
}
const scalar scaling = args.get<scalar>("scale", -1);
const scalar scaling = args.getOrDefault<scalar>("scale", -1);
if (scaling > 0)
{
Info<< "Input scaling: " << scaling << nl;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -70,7 +71,7 @@ int main(int argc, char *argv[])
const scalar mergeTol = args.get<scalar>(2);
const fileName outFileName = args[3];
const scalar scaling = args.get<scalar>("scale", -1);
const scalar scaling = args.getOrDefault<scalar>("scale", -1);
Info<< "Reading surface from " << surfFileName << " ..." << nl
<< "Merging points within " << mergeTol << " metre." << nl;

View File

@ -177,7 +177,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ,
IOobject::NO_WRITE
),
args.get<fileName>("decomposeParDict", "")
args.getOrDefault<fileName>("decomposeParDict", "")
)
);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -213,7 +214,7 @@ int main(int argc, char *argv[])
<< " triangle ..." << endl;
}
const scalar searchTol = args.get<scalar>("tol", 1e-3);
const scalar searchTol = args.getOrDefault<scalar>("tol", 1e-3);
// Get search box. Anything not within this box will not be considered.
const boundBox& meshBb = mesh.bounds();