oneI.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-2016 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 "scalar.H"
30
31// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32
33namespace Foam
34{
35
36// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37
38template<class arg2>
39class innerProduct<one, arg2>
40{
41public:
42
43 typedef arg2 type;
44};
45
46inline scalar operator+(const scalar& t, const one&) noexcept
47{
48 return t + 1;
49}
50
51inline scalar operator+(const one&, const scalar& t) noexcept
52{
53 return 1 + t;
54}
55
56inline scalar operator-(const scalar& t, const one&) noexcept
57{
58 return t - 1;
59}
60
61inline scalar operator-(const one&, const scalar& t) noexcept
62{
63 return 1 - t;
64}
65
66inline constexpr const one& operator*(const one& o, const one&) noexcept
67{
68 return o;
69}
70
71template<class Type>
72inline constexpr const Type& operator*(const Type& val, const one&) noexcept
73{
74 return val;
75}
76
77template<class Type>
78inline constexpr const Type& operator*(const one&, const Type& val) noexcept
79{
80 return val;
81}
82
83template<class Type>
84inline constexpr const Type& operator&(const one&, const Type& val) noexcept
85{
86 return val;
87}
88
89inline constexpr const one& operator/(const one& o, const one&) noexcept
90{
91 return o;
92}
93
94template<class Type>
95inline Type operator/(const one&, const Type& val)
96{
97 return scalar(1)/val;
98}
99
100template<class Type>
101inline constexpr const Type& operator/(const Type& val, const one&) noexcept
102{
103 return val;
104}
105
106inline constexpr const one& min(const one& o, const one&) noexcept
107{
108 return o;
109}
110
111template<class Type>
112inline Type min(const one&, const Type& t) noexcept
113{
114 return min(scalar(1), t);
115}
116
117template<class Type>
118inline Type min(const Type& t, const one&) noexcept
119{
120 return min(t, scalar(1));
121}
122
123inline constexpr const one& max(const one& o, const one&) noexcept
124{
125 return o;
126}
127
128template<class Type>
129inline Type max(const one&, const Type& t) noexcept
130{
131 return max(scalar(1), t);
132}
133
134template<class Type>
135inline Type max(const Type& t, const one&) noexcept
136{
137 return max(t, scalar(1));
138}
139
140// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141
142} // End namespace Foam
143
144// ************************************************************************* //
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Definition: one.H:62
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 > &)
tmp< GeometricField< Type, fvPatchField, volMesh > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
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