From 0f0e4a0c3839972811838689f2c5875cc247d3d6 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Tue, 22 Mar 2016 08:23:09 +0000 Subject: [PATCH] zero: Added cast to float and double for consistent scalar and floatScalar initialization and assignment to 0 Zero: New global instance of zero for simple and efficient initialization and assigment of primitives to 0 --- src/OpenFOAM/primitives/zero/zero.H | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/OpenFOAM/primitives/zero/zero.H b/src/OpenFOAM/primitives/zero/zero.H index ca997cae226..8c2f6fb37ae 100644 --- a/src/OpenFOAM/primitives/zero/zero.H +++ b/src/OpenFOAM/primitives/zero/zero.H @@ -36,6 +36,8 @@ SourceFiles #ifndef zero_H #define zero_H +#include "label.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -51,15 +53,38 @@ public: zero() {} + + //- Return 0 for label + inline operator label() const + { + return 0; + } + + //- Return 0 for float + inline operator float() const + { + return 0; + } + + //- Return 0 for double + inline operator double() const + { + return 0; + } }; + +// Global zero +static const zero Zero; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #include "zeroI.H" +#include "zeroI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -- GitLab