zeroI.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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2018 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 \*---------------------------------------------------------------------------*/
28 
29 #include "zero.H"
30 #include "scalar.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
38 
39 inline constexpr zero operator+(const zero&, const zero&) noexcept
40 {
41  return Zero;
42 }
43 
44 template<class Type>
45 inline constexpr const Type& operator+(const Type& val, const zero&) noexcept
46 {
47  return val;
48 }
49 
50 template<class Type>
51 inline constexpr const Type& operator+(const zero&, const Type& val) noexcept
52 {
53  return val;
54 }
55 
56 inline constexpr zero operator-(const zero&, const zero&) noexcept
57 {
58  return Zero;
59 }
60 
61 template<class Type>
62 inline constexpr const Type& operator-(const Type& val, const zero&) noexcept
63 {
64  return val;
65 }
66 
67 template<class Type>
68 inline constexpr Type operator-(const zero&, const Type& val)
69 {
70  return -val;
71 }
72 
73 inline constexpr zero operator*(const zero&, const zero&) noexcept
74 {
75  return Zero;
76 }
77 
78 template<class Type>
79 inline constexpr zero operator*(const Type& val, const zero&) noexcept
80 {
81  return Zero;
82 }
83 
84 template<class Type>
85 inline constexpr zero operator*(const zero&, const Type& val) noexcept
86 {
87  return Zero;
88 }
89 
90 template<class Type>
91 inline constexpr zero operator/(const zero&, const Type& val) noexcept
92 {
93  return Zero;
94 }
95 
96 
97 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
98 
99 inline zero min(const zero&, const zero&)
100 {
101  return Zero;
102 }
103 
104 template<class Type>
105 inline Type min(const zero&, const Type& t)
106 {
107  return min(scalar(0), t);
108 }
109 
110 template<class Type>
111 inline Type min(const Type& t, const zero&)
112 {
113  return min(t, scalar(0));
114 }
115 
116 inline zero max(const zero&, const zero&)
117 {
118  return Zero;
119 }
120 
121 template<class Type>
122 inline Type max(const zero&, const Type& t)
123 {
124  return max(scalar(0), t);
125 }
126 
127 template<class Type>
128 inline Type max(const Type& t, const zero&)
129 {
130  return max(t, scalar(0));
131 }
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 } // End namespace Foam
136 
137 // ************************************************************************* //
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::operator-
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
zero.H
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
scalar.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::operator/
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
Definition: dimensionedScalar.C:68
Foam::operator+
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::operator*
tmp< faMatrix< Type > > operator*(const areaScalarField &, const faMatrix< Type > &)
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62