flipOp.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2015-2016 OpenFOAM Foundation
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::flipOp
29
30Description
31 Functor to negate primitives. Dummy for most other types.
32
33 Used in mesh transformations where face can flip.
34
35SourceFiles
36 flipOp.C
37
38\*---------------------------------------------------------------------------*/
39
40#ifndef Foam_flipOp_H
41#define Foam_flipOp_H
42
43#include "fieldTypes.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50/*---------------------------------------------------------------------------*\
51 Class noOp Declaration
52\*---------------------------------------------------------------------------*/
53
54//- Same as Foam::identityOp. Should \em never be specialized.
55struct noOp
56{
57 template<class T>
58 const T& operator()(const T& val) const noexcept
59 {
60 return val;
61 }
62};
63
64
65/*---------------------------------------------------------------------------*\
66 Class flipOp Declaration
67\*---------------------------------------------------------------------------*/
69struct flipOp
70{
71 template<class T>
72 T operator()(const T& val) const
73 {
74 return val;
75 }
76};
77
78
79//- Invert boolean value
80struct flipBoolOp
82 bool operator()(const bool val) const noexcept
83 {
84 return !val;
85 }
86};
87
88
89//- Negate integer values
90struct flipLabelOp
92 label operator()(const label val) const
93 {
94 return -val;
95 }
96};
97
98
99// Template specialisation for primitives that support negation
100template<> scalar flipOp::operator()(const scalar&) const;
101template<> vector flipOp::operator()(const vector&) const;
102template<> sphericalTensor flipOp::operator()(const sphericalTensor&) const;
103template<> symmTensor flipOp::operator()(const symmTensor&) const;
104template<> tensor flipOp::operator()(const tensor&) const;
105template<> triad flipOp::operator()(const triad&) const;
106
107
108// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109
110} // End namespace Foam
111
112// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113
114#endif
115
116// ************************************************************************* //
Ostream & operator()() const
Output stream (master only).
Definition: ensightCaseI.H:74
Representation of a 3D Cartesian coordinate system as a Vector of row vectors.
Definition: triad.H:67
const volScalarField & T
Header files for all the primitive types that Fields are instantiated for.
Namespace for OpenFOAM.
Invert boolean value.
Definition: flipOp.H:80
bool operator()(const bool val) const noexcept
Definition: flipOp.H:81
Negate integer values.
Definition: flipOp.H:90
label operator()(const label val) const
Definition: flipOp.H:91
Functor to negate primitives. Dummy for most other types.
Definition: flipOp.H:69
T operator()(const T &val) const
Definition: flipOp.H:71
Same as Foam::identityOp. Should never be specialized.
Definition: flipOp.H:55
const T & operator()(const T &val) const noexcept
Definition: flipOp.H:57