diff --git a/src/OpenFOAM/primitives/ops/flipOp.C b/src/OpenFOAM/primitives/ops/flipOp.C index 39316a03d1..a9ea570596 100644 --- a/src/OpenFOAM/primitives/ops/flipOp.C +++ b/src/OpenFOAM/primitives/ops/flipOp.C @@ -29,8 +29,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<> -Foam::scalar Foam::flipOp::operator()(const scalar& v) const +template<> Foam::scalar Foam::flipOp::operator()(const scalar& v) const { return -v; } @@ -42,7 +41,7 @@ template<> Foam::vector Foam::flipOp::operator()(const vector& v) const } -template<>Foam::sphericalTensor Foam::flipOp::operator() +template<> Foam::sphericalTensor Foam::flipOp::operator() ( const sphericalTensor& v ) const diff --git a/src/OpenFOAM/primitives/ops/flipOp.H b/src/OpenFOAM/primitives/ops/flipOp.H index e1c9f1c247..b8500f6ed4 100644 --- a/src/OpenFOAM/primitives/ops/flipOp.H +++ b/src/OpenFOAM/primitives/ops/flipOp.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2016 OpenFOAM Foundation + Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,7 +28,7 @@ Class Foam::flipOp Description - Class containing functor to negate primitives. Dummy for all other types. + Functor to negate primitives. Dummy for most other types. Used in mesh transformations where face can flip. @@ -50,34 +51,40 @@ namespace Foam Class flipOp Declaration \*---------------------------------------------------------------------------*/ -class flipOp +struct flipOp { -public: - - template - Type operator()(const Type& val) const + template + T operator()(const T& val) const { return val; } }; -class noOp +//- Pass through value. Should never be specialized. +struct noOp { -public: - - template - Type operator()(const Type& val) const + template + const T& operator()(const T& val) const noexcept { return val; } }; -class flipLabelOp +//- Invert boolean value +struct flipBoolOp { -public: + bool operator()(const bool& val) const noexcept + { + return !val; + } +}; + +//- Negate integer values +struct flipLabelOp +{ label operator()(const label& val) const { return -val;