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