diff --git a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H index b3f328fe23..b3fcf119fe 100644 --- a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H +++ b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,19 +38,20 @@ SourceFiles #ifndef doubleScalar_H #define doubleScalar_H +#include "scalarFwd.H" #include "doubleFloat.H" #include "direction.H" #include "word.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Typedef (doubleScalar) in scalarFwd.H + namespace Foam { // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -typedef double doubleScalar; - // 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; diff --git a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H index 109dda9980..d9dc53db51 100644 --- a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H +++ b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,19 +38,20 @@ SourceFiles #ifndef floatScalar_H #define floatScalar_H +#include "scalarFwd.H" #include "doubleFloat.H" #include "direction.H" #include "word.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Typedef (floatScalar) in scalarFwd.H + namespace Foam { // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -typedef float floatScalar; - // 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; diff --git a/src/OpenFOAM/primitives/Scalar/scalar/scalar.H b/src/OpenFOAM/primitives/Scalar/scalar/scalar.H index d87bfca1c8..74286eb840 100644 --- a/src/OpenFOAM/primitives/Scalar/scalar/scalar.H +++ b/src/OpenFOAM/primitives/Scalar/scalar/scalar.H @@ -44,19 +44,14 @@ SourceFiles // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Typedefs (floatScalar, doubleScalar, scalar, solveScalar) in scalarFwd.H + #if defined(WM_SP) || defined(WM_SPDP) -// Define scalar as a float +// With scalar == (float), solveScalar == (float | double) namespace Foam { - typedef floatScalar scalar; - #if defined(WM_SPDP) - typedef doubleScalar solveScalar; - #else - typedef floatScalar solveScalar; - #endif - constexpr scalar GREAT = floatScalarGREAT; constexpr scalar VGREAT = floatScalarVGREAT; constexpr scalar ROOTVGREAT = floatScalarROOTVGREAT; @@ -101,13 +96,10 @@ namespace Foam #elif defined(WM_DP) -// Define scalar as a double +// With scalar == (double), solveScalar == (double) namespace Foam { - typedef doubleScalar scalar; - typedef doubleScalar solveScalar; - constexpr scalar GREAT = doubleScalarGREAT; constexpr scalar VGREAT = doubleScalarVGREAT; constexpr scalar ROOTVGREAT = doubleScalarROOTVGREAT; @@ -151,6 +143,8 @@ namespace Foam void readRawScalar(Istream& is, scalar* data, size_t nElem = 1); } +#else +// #error "PRECISION must be set to WM_SP, WM_SPDP or WM_DP" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/Scalar/scalar/scalarFwd.H b/src/OpenFOAM/primitives/Scalar/scalar/scalarFwd.H new file mode 100644 index 0000000000..d692b62391 --- /dev/null +++ b/src/OpenFOAM/primitives/Scalar/scalar/scalarFwd.H @@ -0,0 +1,76 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Description + Typedefs for float/double/scalar without requiring scalar.H + + The definition of scalar as a floating-point number depends + on pre-processor macros WM_SP, WM_SPDP or WM_DP being defined. + +SourceFiles + +\*---------------------------------------------------------------------------*/ + +#ifndef scalarFwd_H +#define scalarFwd_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +//- A typedef for float +typedef float floatScalar; + +//- A typedef for double +typedef double doubleScalar; + + +#if defined(WM_SP) + +typedef floatScalar scalar; +typedef floatScalar solveScalar; + +#elif defined(WM_SPDP) + +typedef floatScalar scalar; +typedef doubleScalar solveScalar; + +#elif defined(WM_DP) + +typedef doubleScalar scalar; +typedef doubleScalar solveScalar; + +#else +// #error "PRECISION must be set to WM_SP, WM_SPDP or WM_DP" +#endif + +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/ints/label/label.H b/src/OpenFOAM/primitives/ints/label/label.H index 36c5906fc6..064de2bf12 100644 --- a/src/OpenFOAM/primitives/ints/label/label.H +++ b/src/OpenFOAM/primitives/ints/label/label.H @@ -40,6 +40,7 @@ Description #define label_H #include "int.H" +#include "labelFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,10 +48,7 @@ Description #define INT_ADD_DEF_SIZE(x,s,y) INT_ADD_SIZE(x,s,y) #define INT_SIZE(x,y) INT_ADD_DEF_SIZE(x,WM_LABEL_SIZE,y) -#if WM_LABEL_SIZE != 32 && WM_LABEL_SIZE != 64 - #error "label.H: WM_LABEL_SIZE must be set to either 32 or 64" -#endif - +// Size checks and typedefs (label) in labelFwd.H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,8 +57,6 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -typedef INT_SIZE(int, _t) label; - constexpr label labelMin = INT_SIZE(INT, _MIN); constexpr label labelMax = INT_SIZE(INT, _MAX); diff --git a/src/OpenFOAM/primitives/ints/label/labelFwd.H b/src/OpenFOAM/primitives/ints/label/labelFwd.H new file mode 100644 index 0000000000..abe2752896 --- /dev/null +++ b/src/OpenFOAM/primitives/ints/label/labelFwd.H @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Description + Typedefs for label/uLabel without requiring label.H + + The definitions of label/uLabel as an integral value depend on the + pre-processor macro WM_LABEL_SIZE. + +\*---------------------------------------------------------------------------*/ + +#ifndef labelFwd_H +#define labelFwd_H + +#include + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +#if WM_LABEL_SIZE == 32 + +typedef int32_t label; +typedef uint32_t uLabel; + +#elif WM_LABEL_SIZE == 64 + +typedef int64_t label; +typedef uint64_t uLabel; + +#else + #error "WM_LABEL_SIZE must be set to either 32 or 64" +#endif + +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/ints/uLabel/uLabel.H b/src/OpenFOAM/primitives/ints/uLabel/uLabel.H index 54158783fb..96efd2a2e8 100644 --- a/src/OpenFOAM/primitives/ints/uLabel/uLabel.H +++ b/src/OpenFOAM/primitives/ints/uLabel/uLabel.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,6 +40,7 @@ Description #define uLabel_H #include "uint.H" +#include "labelFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,10 +48,7 @@ Description #define UINT_ADD_DEF_SIZE(x,s,y) UINT_ADD_SIZE(x,s,y) #define UINT_SIZE(x,y) UINT_ADD_DEF_SIZE(x,WM_LABEL_SIZE,y) -#if WM_LABEL_SIZE != 32 && WM_LABEL_SIZE != 64 - #error "uLabel.H: WM_LABEL_SIZE must be set to either 32 or 64" -#endif - +// Size checks and typedefs (uLabel) in labelFwd.H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,8 +57,6 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -typedef UINT_SIZE(uint, _t) uLabel; - constexpr uLabel uLabelMax = UINT_SIZE(UINT, _MAX); //- Read uLabel from stream. diff --git a/src/OpenFOAM/primitives/nullObject/nullObject.H b/src/OpenFOAM/primitives/nullObject/nullObject.H index 09788dd96c..d7ca3e006e 100644 --- a/src/OpenFOAM/primitives/nullObject/nullObject.H +++ b/src/OpenFOAM/primitives/nullObject/nullObject.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,6 +42,8 @@ SourceFiles #ifndef nullObject_H #define nullObject_H +#include "labelFwd.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/src/OpenFOAM/primitives/zero/zero.H b/src/OpenFOAM/primitives/zero/zero.H index 8e64dc00ad..21a802a1e0 100644 --- a/src/OpenFOAM/primitives/zero/zero.H +++ b/src/OpenFOAM/primitives/zero/zero.H @@ -44,7 +44,7 @@ SeeAlso #ifndef zero_H #define zero_H -#include "label.H" +#include "labelFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -133,13 +133,13 @@ static constexpr const zero Zero; // IOstream Operators -//- Read from Istream consumes no content. +//- Read from Istream consumes no content inline constexpr Istream& operator>>(Istream& is, zero&) noexcept { return is; } -//- Write to Ostream emits no content. +//- Write to Ostream emits no content inline constexpr Ostream& operator<<(Ostream& os, const zero::null&) noexcept { return os; @@ -153,6 +153,7 @@ inline constexpr Ostream& operator<<(Ostream& os, const zero::null&) noexcept // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Global Operators, Functions + #include "zeroI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //