From 1071d413a341867e86750c4a82939b348b9083e6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 15 Oct 2020 16:56:03 +0200 Subject: [PATCH] ENH: add ROOTGREAT constants (symmetry with ROOTSMALL) ENH: add some scalar constants for .org compatibility (#1881) Although it can very much be a moving target, it can prove partly useful to have some compatibility constants/methods. - The wholesale change of 'GREAT' -> 'great' etc (JAN-2018), makes user coding for multiple versions problematic. When COMPAT_OPENFOAM_ORG is defined, now define constants (aliases) named as per the openfoam.org version. Values, however, remain identical. - For type-safe dictionary value retrieval, we have the templated get<> methods added around NOV-2018 and deprecated the lookupType method. The .org version followed suit in NOV-2019, but opted for renaming the templated lookupType method as a templated 'lookup' method. Using this is discouraged, but allowed when COMPAT_OPENFOAM_ORG is defined. --- applications/test/dictionary2/Make/options | 2 +- .../test/dictionary2/Test-dictionary2.C | 24 ++++++++++ applications/test/primitives/Make/options | 1 + .../test/primitives/Test-primitives.C | 24 +++++++++- src/OpenFOAM/db/dictionary/dictionary.H | 47 +++++++++++++------ .../Scalar/doubleScalar/doubleScalar.H | 1 + .../Scalar/floatScalar/floatScalar.H | 1 + .../primitives/Scalar/scalar/scalar.H | 40 ++++++++++++++++ 8 files changed, 124 insertions(+), 16 deletions(-) diff --git a/applications/test/dictionary2/Make/options b/applications/test/dictionary2/Make/options index 41306609f2..8cda22efd1 100644 --- a/applications/test/dictionary2/Make/options +++ b/applications/test/dictionary2/Make/options @@ -1 +1 @@ -EXE_INC = +EXE_INC = -DCOMPAT_OPENFOAM_ORG diff --git a/applications/test/dictionary2/Test-dictionary2.C b/applications/test/dictionary2/Test-dictionary2.C index 2f3a58da37..a3eaa6de41 100644 --- a/applications/test/dictionary2/Test-dictionary2.C +++ b/applications/test/dictionary2/Test-dictionary2.C @@ -410,6 +410,30 @@ int main(int argc, char *argv[]) // try_getScalar(dict2.findEntry("bad"), "bad"); try_getScalar(dict2.findEntry("empty"), "empty"); } + + #ifdef COMPAT_OPENFOAM_ORG + { + Info<< nl + << "Test openfoam.org compatibility" << nl; + + dictionary mydict + ( + IStringStream + ( + "scalar 3.14159;\n" + "label 10;\n" + )() + ); + + Info<<"get : " << mydict.get("scalar") << nl; + Info<<"get