floatScalar.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 | Copyright (C) 2011-2015 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 Typedef
25  Foam::floatScalar
26 
27 Description
28  Float precision floating point scalar type.
29 
30 SourceFiles
31  floatScalar.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef floatScalar_H
36 #define floatScalar_H
37 
38 #include "doubleFloat.H"
39 #include "direction.H"
40 #include "word.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 typedef float floatScalar;
50 
51 // Largest and smallest scalar values allowed in certain parts of the code
52 // (6 is the number of significant figures in an
53 // IEEE single precision number. See limits.h or float.h)
54 static const floatScalar floatScalarGREAT = 1.0e+6;
55 static const floatScalar floatScalarVGREAT = 1.0e+37;
56 static const floatScalar floatScalarROOTVGREAT = 1.0e+18;
57 static const floatScalar floatScalarSMALL = 1.0e-6;
58 static const floatScalar floatScalarROOTSMALL = 1.0e-3;
59 static const floatScalar floatScalarVSMALL = 1.0e-37;
60 static const floatScalar floatScalarROOTVSMALL = 1.0e-18;
61 
62 //- Read whole of buf as a scalar. Return true if succesful.
63 inline bool readScalar(const char* buf, floatScalar& s)
64 {
65  char* endPtr;
66  s = strtof(buf, &endPtr);
67 
68  return (*endPtr == '\0');
69 }
70 
71 #define Scalar floatScalar
72 #define ScalarVGREAT floatScalarVGREAT
73 #define ScalarVSMALL floatScalarVSMALL
74 #define ScalarROOTVGREAT floatScalarROOTVGREAT
75 #define ScalarROOTVSMALL floatScalarROOTVSMALL
76 #define readScalar readFloatScalar
77 
78 inline Scalar mag(const Scalar s)
79 {
80  return ::fabsf(s);
81 }
82 
83 #define transFunc(func) \
84 inline Scalar func(const Scalar s) \
85 { \
86  return ::func##f(s); \
87 }
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 } // End namespace Foam
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 #include "Scalar.H"
96 
97 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 
99 namespace Foam
100 {
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 inline Scalar hypot(const Scalar x, const Scalar y)
105 {
106  return ::hypotf(x, y);
107 }
108 
109 inline Scalar atan2(const Scalar y, const Scalar x)
110 {
111  return ::atan2f(y, x);
112 }
113 
114 inline Scalar jn(const int n, const Scalar s)
115 {
116  return ::jnf(n, s);
117 }
118 
119 inline Scalar yn(const int n, const Scalar s)
120 {
121  return ::ynf(n, s);
122 }
123 
124 #undef Scalar
125 #undef ScalarVGREAT
126 #undef ScalarVSMALL
127 #undef ScalarROOTVGREAT
128 #undef ScalarROOTVSMALL
129 #undef readScalar
130 #undef transFunc
131 
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 } // End namespace Foam
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 #endif
140 
141 // ************************************************************************* //
static const floatScalar floatScalarROOTVGREAT
Definition: floatScalar.H:56
static const floatScalar floatScalarROOTSMALL
Definition: floatScalar.H:58
static const floatScalar floatScalarGREAT
Definition: floatScalar.H:54
dimensionedScalar yn(const int n, const dimensionedScalar &ds)
static const floatScalar floatScalarSMALL
Definition: floatScalar.H:57
scalar y
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dimensionedScalar jn(const int n, const dimensionedScalar &ds)
float floatScalar
Float precision floating point scalar type.
Definition: floatScalar.H:49
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
#define Scalar
Definition: floatScalar.H:71
static const floatScalar floatScalarVSMALL
Definition: floatScalar.H:59
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
Direction is an 8-bit unsigned integer type used to represent the Cartesian directions etc...
dimensioned< scalar > mag(const dimensioned< Type > &)
label n
static const floatScalar floatScalarROOTVSMALL
Definition: floatScalar.H:60
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
static const floatScalar floatScalarVGREAT
Definition: floatScalar.H:55
Namespace for OpenFOAM.