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

@ -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")
);