mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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)
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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");
|
||||
|
||||
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -177,7 +177,7 @@ int main(int argc, char *argv[])
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
args.get<fileName>("decomposeParDict", "")
|
||||
args.getOrDefault<fileName>("decomposeParDict", "")
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
Reference in New Issue
Block a user