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 flipOp_H
41 #define flipOp_H
42 
43 #include "fieldTypes.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class flipOp Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 struct flipOp
55 {
56  template<class T>
57  T operator()(const T& val) const
58  {
59  return val;
60  }
61 };
62 
63 
64 //- Pass through value. Should never be specialized.
65 struct noOp
66 {
67  template<class T>
68  const T& operator()(const T& val) const noexcept
69  {
70  return val;
71  }
72 };
73 
74 
75 //- Invert boolean value
76 struct flipBoolOp
77 {
78  bool operator()(const bool& val) const noexcept
79  {
80  return !val;
81  }
82 };
83 
84 
85 //- Negate integer values
86 struct flipLabelOp
87 {
88  label operator()(const label& val) const
89  {
90  return -val;
91  }
92 };
93 
94 
95 // Template specialisation for primitives that support negation
96 template<> scalar flipOp::operator()(const scalar&) const;
97 template<> vector flipOp::operator()(const vector&) const;
98 template<> sphericalTensor flipOp::operator()(const sphericalTensor&) const;
99 template<> symmTensor flipOp::operator()(const symmTensor&) const;
100 template<> tensor flipOp::operator()(const tensor&) const;
101 template<> triad flipOp::operator()(const triad&) const;
102 
103 
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 
106 } // End namespace Foam
107 
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 
110 #endif
111 
112 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::sphericalTensor
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
Definition: sphericalTensor.H:54
Foam::SymmTensor
A templated (3 x 3) symmetric tensor of objects of <T>, effectively containing 6 elements,...
Definition: SymmTensor.H:58
Foam::flipBoolOp::operator()
bool operator()(const bool &val) const noexcept
Definition: flipOp.H:77
Foam::flipLabelOp::operator()
label operator()(const label &val) const
Definition: flipOp.H:87
Foam::flipOp::operator()
T operator()(const T &val) const
Definition: flipOp.H:56
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::symmTensor
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition: symmTensor.H:59
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::SphericalTensor< scalar >
Foam::triad
Representation of a 3D Cartesian coordinate system as a Vector of row vectors.
Definition: triad.H:64
Foam::noOp::operator()
const T & operator()(const T &val) const noexcept
Definition: flipOp.H:67
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:62
fieldTypes.H
Header files for all the primitive types that Fields are instantiated for.
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
Definition: symmTensor.H:61
Foam::flipBoolOp
Invert boolean value.
Definition: flipOp.H:75
Foam::noOp
Pass through value. Should never be specialized.
Definition: flipOp.H:64
Foam::flipOp
Functor to negate primitives. Dummy for most other types.
Definition: flipOp.H:53
Foam::flipLabelOp
Negate integer values.
Definition: flipOp.H:85