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-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));
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
@ -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 =
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
@ -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)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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")
|
||||
);
|
||||
|
||||
|
||||
@ -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", "")
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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");
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user