1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 single floating point number identical to float
33 \*---------------------------------------------------------------------------*/
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 // Define floatScalar as a float
52 typedef float floatScalar;
56 // Define floatScalar as a float
60 typedef float floatScalar;
62 // Largest and smallest floatScalar values allowed in certain parts of the code
63 // (6 is the number of significant figures in an
64 // IEEE single precision number. See limits.h or float.h)
65 static const floatScalar GREAT = 1.0e+6;
66 static const floatScalar VGREAT = 1.0e+37;
67 static const floatScalar SMALL = 1.0e-6;
68 static const floatScalar VSMALL = 1.0e-37;
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 #include "direction.H"
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
83 // template specialisation for pTraits<floatScalar>
85 class pTraits<floatScalar>
92 typedef floatScalar cmptType;
98 dim = 3, // Dimensionality of space
99 rank = 0, // Rank od floatScalar is 0
100 nComponents = 1 // Number of components in floatScalar is 1
103 // Static data members
105 static const char* const typeName;
106 static const char* componentNames[];
107 static const floatScalar zero;
108 static const floatScalar one;
112 //- Construct from Istream
113 pTraits(Istream& is);
117 operator floatScalar() const
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 //template<class Cmpt>
127 //class typeOfRank<Cmpt, 0>
131 // typedef Cmpt type;
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 // Return a string representation of a floatScalar
138 word name(const floatScalar s)
140 return name(scalar(s));
143 #define MAXMINPOW(retType, type1, type2) \
145 MAXMIN(retType, type1, type2) \
147 inline float pow(const type1 s, const type2 e) \
149 return ::pow(float(s), float(e)); \
153 //MAXMINPOW(float, float, float)
154 //MAXMINPOW(float, float, int)
155 //MAXMINPOW(float, int, float)
156 //MAXMINPOW(float, float, long)
157 //MAXMINPOW(float, long, float)
158 //MAXMINPOW(float, float, int)
159 //MAXMINPOW(float, int, float)
160 //MAXMINPOW(float, float, long)
161 //MAXMINPOW(float, long, float)
166 inline floatScalar mag(const floatScalar s)
171 inline floatScalar sign(const floatScalar s)
173 return (s >= 0)? 1: -1;
176 inline floatScalar pos(const floatScalar s)
178 return (s >= 0)? 1: 0;
181 inline floatScalar neg(const floatScalar s)
183 return (s < 0)? 1: 0;
186 inline floatScalar limit(const floatScalar s1, const floatScalar s2)
188 return (mag(s1) < mag(s2))? s1: 0.0;
191 inline floatScalar magSqr(const floatScalar s)
196 inline floatScalar sqr(const floatScalar s)
201 inline floatScalar pow3(const floatScalar s)
206 inline floatScalar pow4(const floatScalar s)
211 inline floatScalar cmptAv(const floatScalar s)
216 inline floatScalar cmptMag(const floatScalar s)
221 inline floatScalar scale(const floatScalar s, const floatScalar d)
227 #define transFunc(func) \
228 inline floatScalar func(const floatScalar s) \
233 // Standard C++ transcendental functions
251 // Standard ANSI-C (but not in <cmath>) transcendental functions
262 // Stabilisation around zero for division
263 inline floatScalar stabilise(const floatScalar s, const floatScalar small)
276 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
278 //floatScalar readScalar(Istream& is);
279 Istream& operator>>(Istream&, floatScalar&);
280 Ostream& operator<<(Ostream&, const floatScalar);
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 } // End namespace Foam
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 // ************************************************************************* //