oneI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "one.H"
27 #include "scalar.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 template<class arg2>
37 class innerProduct<one, arg2>
38 {
39 public:
40 
41  typedef arg2 type;
42 };
43 
44 inline scalar operator+(const scalar& t, const one&)
45 {
46  return t + 1;
47 }
48 
49 inline scalar operator+(const one&, const scalar& t)
50 {
51  return 1 + t;
52 }
53 
54 inline scalar operator-(const scalar& t, const one&)
55 {
56  return t - 1;
57 }
58 
59 inline scalar operator-(const one&, const scalar& t)
60 {
61  return 1 - t;
62 }
63 
64 inline const one& operator*(const one& o, const one&)
65 {
66  return o;
67 }
68 
69 template<class Type>
70 inline const Type& operator*(const Type& t, const one&)
71 {
72  return t;
73 }
74 
75 template<class Type>
76 inline const Type& operator*(const one&, const Type& t)
77 {
78  return t;
79 }
80 
81 template<class Type>
82 inline const Type& operator&(const one&, const Type& t)
83 {
84  return t;
85 }
86 
87 inline const one& operator/(const one& o, const one&)
88 {
89  return o;
90 }
91 
92 template<class Type>
93 inline Type operator/(const one&, const Type& t)
94 {
95  return scalar(1)/t;
96 }
97 
98 template<class Type>
99 inline const Type& operator/(const Type& t, const one&)
100 {
101  return t;
102 }
103 
104 inline const one& min(const one& o, const one&)
105 {
106  return o;
107 }
108 
109 template<class Type>
110 inline Type min(const one&, const Type& t)
111 {
112  return min(scalar(1), t);
113 }
114 
115 template<class Type>
116 inline Type min(const Type& t, const one&)
117 {
118  return min(t, scalar(1));
119 }
120 
121 inline const one& max(const one& o, const one&)
122 {
123  return o;
124 }
125 
126 template<class Type>
127 inline Type max(const one&, const Type& t)
128 {
129  return max(scalar(1), t);
130 }
131 
132 template<class Type>
133 inline Type max(const Type& t, const one&)
134 {
135  return max(t, scalar(1));
136 }
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 } // End namespace Foam
141 
142 // ************************************************************************* //
tmp< fvMatrix< Type > > operator*(const volScalarField::Internal &, const fvMatrix< Type > &)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
tmp< fvMatrix< Type > > operator/(const fvMatrix< Type > &, const volScalarField::Internal &)
tmp< GeometricField< Type, fvPatchField, volMesh > > operator &(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
tmp< fvMatrix< Type > > operator-(const fvMatrix< Type > &)
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Namespace for OpenFOAM.
A class representing the concept of 1 (scalar(1)) used to avoid unnecessary manipulations for objects...
Definition: one.H:50