diff --git a/applications/test/dictionary2/Make/options b/applications/test/dictionary2/Make/options index 41306609f208806f0c6f42a2426867d3e10d4897..8cda22efd1fc16a8f6681c55680159ae4b43fea0 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 2f3a58da37cb9cccfc14866d2251cd9386cdfc2e..a3eaa6de419ef8295d55b082e7d26c27cd065a1f 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<scalar> : " << mydict.get<scalar>("scalar") << nl; + Info<<"get<label> : " << mydict.get<label>("label") << nl; + + Info<<"lookup<scalar> : " << mydict.lookup<scalar>("scalar") << nl; + Info<<"lookup<label> : " << mydict.lookup<label>("label") << nl; + } + #else + Info<< "No openfoam.org compatibility methods" << nl; + #endif } diff --git a/applications/test/primitives/Make/options b/applications/test/primitives/Make/options index 7ce182425d9bee4bef91ba2a36b6b8475fc1aeb2..770b1ac627e0a8782563ab247dac73e4b2fc3c4a 100644 --- a/applications/test/primitives/Make/options +++ b/applications/test/primitives/Make/options @@ -1,4 +1,5 @@ EXE_INC = \ + -DCOMPAT_OPENFOAM_ORG \ -I$(LIB_SRC)/fileFormats/lnInclude EXE_LIBS = \ diff --git a/applications/test/primitives/Test-primitives.C b/applications/test/primitives/Test-primitives.C index 13a1d8f12854fe0896d8ff0db84649917180a9ba..0064400290e46464bcf6c92dd448c5d492ede2fd 100644 --- a/applications/test/primitives/Test-primitives.C +++ b/applications/test/primitives/Test-primitives.C @@ -69,7 +69,7 @@ inline Switch readSwitch(const std::string& str) void printInfo(const Switch& sw) { - Info<<"Switch " << sw.c_str() << " (enum=" << label(sw.type()) << ")\n"; + Info<< "Switch " << sw.c_str() << " (enum=" << label(sw.type()) << ")\n"; } @@ -86,6 +86,13 @@ Ostream& toString(Ostream& os, const UList<char>& list) } +template<class T1, class T2> +void printValPair(const char* desc, const T1& val1, const T2& val2) +{ + Info<< desc << ' ' << val1 << ' ' << val2 << nl; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<class T> @@ -360,6 +367,21 @@ int main(int argc, char *argv[]) << "Read " << flatOutput(dstList) << nl; } + #ifdef COMPAT_OPENFOAM_ORG + Info<< nl << "compatibility sizes" << nl + << "name com org" << nl + << "---- --- ---" << nl; + + printValPair("SMALL", SMALL, small); + printValPair("GREAT", GREAT, great); + printValPair("VSMALL", VSMALL, vSmall); + printValPair("VGREAT", VGREAT, vGreat); + printValPair("ROOTSMALL", ROOTSMALL, rootSmall); + printValPair("ROOTGREAT", ROOTGREAT, rootGreat); + #else + Info<< nl << "no compatibility sizes" << nl; + #endif + if (nFail) { Info<< nl << "failed " << nFail << " tests" << nl; diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index 8c79e5a699d532d4403606e178537bee1714644d..02325b4638a58222a6f48680898a4e69be64ba93 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -1297,20 +1297,6 @@ public: return lookup(keyword); } - //- Deprecated(2018-10) find and return a T. - // \deprecated(2018-10) - use get() method - template<class T> - FOAM_DEPRECATED_FOR(2018-10, "get() method") - T lookupType - ( - const word& keyword, - bool recursive = false, - bool patternMatch = true - ) const - { - return get<T>(keyword, matchOpt(recursive, patternMatch)); - } - //- Deprecated(2018-10) // \deprecated(2018-10) - use keyType::option version FOAM_DEPRECATED_FOR(2018-10, "found(keyType::option)") @@ -1461,6 +1447,39 @@ public: } + // More compatibility + + //- Deprecated(2018-10) find and return a T. + // \deprecated(2018-10) - use get() method + template<class T> + FOAM_DEPRECATED_FOR(2018-10, "get() method") + T lookupType + ( + const word& keyword, + bool recursive = false, + bool patternMatch = true + ) const + { + return get<T>(keyword, matchOpt(recursive, patternMatch)); + } + + #ifdef COMPAT_OPENFOAM_ORG + //! \cond compat_openfoam_org + // Accommodate name changes from 2019-11 + template<class T> + FOAM_DEPRECATED_FOR(2019-11, "get(). openfoam.org compatibility") + T lookup + ( + const word& keyword, + bool recursive = false, + bool patternMatch = true + ) const + { + return get<T>(keyword, matchOpt(recursive, patternMatch)); + } + #endif + + // Shortcuts - when a templated classes also inherits from a dictionary #undef defineDictionaryGetter diff --git a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H index b3fcf119fe735ba0d826862bd74427c625b904c9..c75623c51c096c00dae140cd9f11a65bcf18ffe1 100644 --- a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H +++ b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H @@ -55,6 +55,7 @@ namespace Foam // Largest and smallest scalar values allowed in certain parts of the code. // See std::numeric_limits max(), min(), epsilon() constexpr doubleScalar doubleScalarGREAT = 1.0e+15; +constexpr doubleScalar doubleScalarROOTGREAT = 3.0e+8; constexpr doubleScalar doubleScalarVGREAT = 1.0e+300; constexpr doubleScalar doubleScalarROOTVGREAT = 1.0e+150; constexpr doubleScalar doubleScalarSMALL = 1.0e-15; diff --git a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H index d9dc53db515727abe7962babeee798badbfd7ecc..a8546c87a8ce89bd09cf5b4070007a85809dfc7c 100644 --- a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H +++ b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H @@ -55,6 +55,7 @@ namespace Foam // Largest and smallest scalar values allowed in certain parts of the code. // See std::numeric_limits max(), min(), epsilon() constexpr floatScalar floatScalarGREAT = 1.0e+6; +constexpr floatScalar floatScalarROOTGREAT = 1.0e+3; constexpr floatScalar floatScalarVGREAT = 1.0e+37; constexpr floatScalar floatScalarROOTVGREAT = 1.0e+18; constexpr floatScalar floatScalarSMALL = 1.0e-6; diff --git a/src/OpenFOAM/primitives/Scalar/scalar/scalar.H b/src/OpenFOAM/primitives/Scalar/scalar/scalar.H index 74286eb840b1542c1a8a8291383c63e0ce847f65..c947c05df2cacf8ae4a8b970295684d4b7850b4a 100644 --- a/src/OpenFOAM/primitives/Scalar/scalar/scalar.H +++ b/src/OpenFOAM/primitives/Scalar/scalar/scalar.H @@ -53,6 +53,7 @@ SourceFiles namespace Foam { constexpr scalar GREAT = floatScalarGREAT; + constexpr scalar ROOTGREAT = floatScalarROOTGREAT; constexpr scalar VGREAT = floatScalarVGREAT; constexpr scalar ROOTVGREAT = floatScalarROOTVGREAT; constexpr scalar SMALL = floatScalarSMALL; @@ -60,21 +61,40 @@ namespace Foam constexpr scalar VSMALL = floatScalarVSMALL; constexpr scalar ROOTVSMALL = floatScalarROOTVSMALL; + #ifdef COMPAT_OPENFOAM_ORG + //! \cond compat_openfoam_org + // Accommodate name changes from 2018-01 + constexpr scalar great = floatScalarGREAT; + constexpr scalar rootGreat = floatScalarROOTGREAT; + constexpr scalar vGreat = floatScalarVGREAT; + constexpr scalar rootVGreat = floatScalarROOTVGREAT; + constexpr scalar small = floatScalarSMALL; + constexpr scalar rootSmall = floatScalarROOTSMALL; + constexpr scalar vSmall = floatScalarVSMALL; + constexpr scalar rootVSmall = floatScalarROOTVSMALL; + //! \endcond + #endif + + + //- Read scalar from c-string and return value inline scalar readScalar(const char* buf) { return readFloat(buf); } + //- Read scalar from c-string into argument. Return true on success. inline bool readScalar(const char* buf, scalar& val) { return readFloat(buf, val); } + //- Read scalar from string and return value inline scalar readScalar(const std::string& str) { return readFloat(str); } + //- Read scalar from string into argument. Return true on success. inline bool readScalar(const std::string& str, scalar& val) { return readFloat(str, val); @@ -101,6 +121,7 @@ namespace Foam namespace Foam { constexpr scalar GREAT = doubleScalarGREAT; + constexpr scalar ROOTGREAT = doubleScalarROOTGREAT; constexpr scalar VGREAT = doubleScalarVGREAT; constexpr scalar ROOTVGREAT = doubleScalarROOTVGREAT; constexpr scalar SMALL = doubleScalarSMALL; @@ -108,21 +129,40 @@ namespace Foam constexpr scalar VSMALL = doubleScalarVSMALL; constexpr scalar ROOTVSMALL = doubleScalarROOTVSMALL; + #ifdef COMPAT_OPENFOAM_ORG + //! \cond compat_openfoam_org + // Accommodate name changes from 2018-01 + constexpr scalar great = doubleScalarGREAT; + constexpr scalar rootGreat = doubleScalarROOTGREAT; + constexpr scalar vGreat = doubleScalarVGREAT; + constexpr scalar rootVGreat = doubleScalarROOTVGREAT; + constexpr scalar small = doubleScalarSMALL; + constexpr scalar rootSmall = doubleScalarROOTSMALL; + constexpr scalar vSmall = doubleScalarVSMALL; + constexpr scalar rootVSmall = doubleScalarROOTVSMALL; + //! \endcond + #endif + + + //- Read scalar from c-string and return value inline scalar readScalar(const char* buf) { return readDouble(buf); } + //- Read scalar from c-string into argument. Return true on success. inline bool readScalar(const char* buf, scalar& val) { return readDouble(buf, val); } + //- Read scalar from string and return value inline scalar readScalar(const std::string& str) { return readDouble(str); } + //- Read scalar from string into argument. Return true on success. inline bool readScalar(const std::string& str, scalar& val) { return readDouble(str, val);