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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::flipOp
29 
30 Description
31  Functor to negate primitives. Dummy for most other types.
32 
33  Used in mesh transformations where face can flip.
34 
35 SourceFiles
36  flipOp.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef Foam_flipOp_H
41 #define Foam_flipOp_H
42 
43 #include "fieldTypes.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class noOp Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 //- Same as Foam::identityOp. Should \em never be specialized.
55 struct 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 \*---------------------------------------------------------------------------*/
68 
69 struct 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
80 struct flipBoolOp
81 {
82  bool operator()(const bool val) const noexcept
83  {
84  return !val;
85  }
86 };
87 
88 
89 //- Negate integer values
90 struct flipLabelOp
91 {
92  label operator()(const label val) const
93  {
94  return -val;
95  }
96 };
97 
98 
99 // Template specialisation for primitives that support negation
100 template<> scalar flipOp::operator()(const scalar&) const;
101 template<> vector flipOp::operator()(const vector&) const;
102 template<> sphericalTensor flipOp::operator()(const sphericalTensor&) const;
103 template<> symmTensor flipOp::operator()(const symmTensor&) const;
104 template<> tensor flipOp::operator()(const tensor&) const;
105 template<> triad flipOp::operator()(const triad&) const;
106 
107 
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 
110 } // End namespace Foam
111 
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 
114 #endif
115 
116 // ************************************************************************* //
T operator()(const T &val) const
Definition: flipOp.H:69
Invert boolean value.
Definition: flipOp.H:79
const T & operator()(const T &val) const noexcept
Definition: flipOp.H:55
Tensor< scalar > tensor
Definition: symmTensor.H:57
Same as Foam::identityOp. Should never be specialized.
Definition: flipOp.H:52
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition: symmTensor.H:55
bool operator()(const bool val) const noexcept
Definition: flipOp.H:81
Vector< scalar > vector
Definition: vector.H:57
const direction noexcept
Definition: Scalar.H:258
label operator()(const label val) const
Definition: flipOp.H:93
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Negate integer values.
Definition: flipOp.H:91
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
Functor to negate primitives. Dummy for most other types.
Definition: flipOp.H:66
Namespace for OpenFOAM.