1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 single floating point number identical to float
34 \*---------------------------------------------------------------------------*/
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 // Define floatScalar as a float
53 typedef float floatScalar;
57 // Define floatScalar as a float
61 typedef float floatScalar;
63 // Largest and smallest floatScalar values allowed in certain parts of the code
64 // (6 is the number of significant figures in an
65 // IEEE single precision number. See limits.h or float.h)
66 static const floatScalar GREAT = 1.0e+6;
67 static const floatScalar VGREAT = 1.0e+37;
68 static const floatScalar SMALL = 1.0e-6;
69 static const floatScalar VSMALL = 1.0e-37;
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
77 #include "direction.H"
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 // template specialisation for pTraits<floatScalar>
86 class pTraits<floatScalar>
93 typedef floatScalar cmptType;
99 dim = 3, // Dimensionality of space
100 rank = 0, // Rank od floatScalar is 0
101 nComponents = 1 // Number of components in floatScalar is 1
104 // Static data members
106 static const char* const typeName;
107 static const char* componentNames[];
108 static const floatScalar zero;
109 static const floatScalar one;
113 //- Construct from Istream
114 pTraits(Istream& is);
118 operator floatScalar() const
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 //template<class Cmpt>
128 //class typeOfRank<Cmpt, 0>
132 // typedef Cmpt type;
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 // Return a string representation of a floatScalar
139 word name(const floatScalar s)
141 return name(scalar(s));
144 #define MAXMINPOW(retType, type1, type2) \
146 MAXMIN(retType, type1, type2) \
148 inline float pow(const type1 s, const type2 e) \
150 return ::pow(float(s), float(e)); \
154 //MAXMINPOW(float, float, float)
155 //MAXMINPOW(float, float, int)
156 //MAXMINPOW(float, int, float)
157 //MAXMINPOW(float, float, long)
158 //MAXMINPOW(float, long, float)
159 //MAXMINPOW(float, float, int)
160 //MAXMINPOW(float, int, float)
161 //MAXMINPOW(float, float, long)
162 //MAXMINPOW(float, long, float)
167 inline floatScalar mag(const floatScalar s)
172 inline floatScalar sign(const floatScalar s)
174 return (s >= 0)? 1: -1;
177 inline floatScalar pos(const floatScalar s)
179 return (s >= 0)? 1: 0;
182 inline floatScalar neg(const floatScalar s)
184 return (s < 0)? 1: 0;
187 inline floatScalar limit(const floatScalar s1, const floatScalar s2)
189 return (mag(s1) < mag(s2))? s1: 0.0;
192 inline floatScalar magSqr(const floatScalar s)
197 inline floatScalar sqr(const floatScalar s)
202 inline floatScalar pow3(const floatScalar s)
207 inline floatScalar pow4(const floatScalar s)
212 inline floatScalar cmptAv(const floatScalar s)
217 inline floatScalar cmptMag(const floatScalar s)
222 inline floatScalar scale(const floatScalar s, const floatScalar d)
228 #define transFunc(func) \
229 inline floatScalar func(const floatScalar s) \
234 // Standard C++ transcendental functions
252 // Standard ANSI-C (but not in <cmath>) transcendental functions
263 // Stabilisation around zero for division
264 inline floatScalar stabilise(const floatScalar s, const floatScalar small)
277 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
279 //floatScalar readScalar(Istream& is);
280 Istream& operator>>(Istream&, floatScalar&);
281 Ostream& operator<<(Ostream&, const floatScalar);
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 } // End namespace Foam
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 // ************************************************************************* //