floatScalar.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-2019 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 #include <limits>
43 using std::numeric_limits;
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 typedef float floatScalar;
53 
54 // Largest and smallest scalar values allowed in certain parts of the code
59 
63  = 1.0/floatScalarSmall;
64 
67 
70 
72  = numeric_limits<floatScalar>::signaling_NaN();
73 
74 //- Read whole of buf as a scalar. Return true if successful.
75 inline bool readScalar(const char* buf, floatScalar& s)
76 {
77  char* endPtr;
78  s = strtof(buf, &endPtr);
79 
80  return (*endPtr == '\0');
81 }
82 
83 #define Scalar floatScalar
84 #define ScalarVGreat floatScalarVGreat
85 #define ScalarVSmall floatScalarVSmall
86 #define ScalarRootVGreat floatScalarRootVGreat
87 #define ScalarRootVSmall floatScalarRootVSmall
88 #define readScalar readFloatScalar
89 
90 inline Scalar mag(const Scalar s)
91 {
92  return ::fabsf(s);
93 }
94 
95 
96 #define MAXMINPOW(retType, type1, type2) \
97  \
98 MAXMIN(retType, type1, type2) \
99  \
100 inline double pow(const type1 s, const type2 e) \
101 { \
102  return ::powf(s, e); \
103 }
104 
110 
111 #undef MAXMINPOW
112 
113 
114 #define transFunc(func) \
115 inline Scalar func(const Scalar s) \
116 { \
117  return ::func##f(s); \
118 }
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 } // End namespace Foam
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 #include "Scalar.H"
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 namespace Foam
131 {
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 inline Scalar hypot(const Scalar x, const Scalar y)
136 {
137  return ::hypotf(x, y);
138 }
139 
140 inline Scalar atan2(const Scalar y, const Scalar x)
141 {
142  return ::atan2f(y, x);
143 }
144 
145 inline Scalar jn(const int n, const Scalar s)
146 {
147  return ::jnf(n, s);
148 }
149 
150 inline Scalar yn(const int n, const Scalar s)
151 {
152  return ::ynf(n, s);
153 }
154 
155 #undef Scalar
156 #undef ScalarVGreat
157 #undef ScalarVSmall
158 #undef ScalarRootVGreat
159 #undef ScalarRootVSmall
160 #undef readScalar
161 #undef transFunc
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
scalar y
label n
Direction is an 8-bit unsigned integer type used to represent the Cartesian directions etc.
const scalar epsilon
#define MAXMINPOW(retType, type1, type2)
Definition: floatScalar.H:96
#define Scalar
Definition: floatScalar.H:83
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.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
static const floatScalar floatScalarRootVSmall
Definition: floatScalar.H:66
static const floatScalar floatScalarGreat
Definition: floatScalar.H:63
static const floatScalar floatScalarRootVGreat
Definition: floatScalar.H:65
static const floatScalar floatScalarRootGreat
Definition: floatScalar.H:68
dimensionedScalar yn(const int n, const dimensionedScalar &ds)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
Definition: doubleScalar.H:75
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
dimensioned< scalar > mag(const dimensioned< Type > &)
static const floatScalar floatScalarRootSmall
Definition: floatScalar.H:69
float floatScalar
Float precision floating point scalar type.
Definition: floatScalar.H:52
dimensionedScalar jn(const int n, const dimensionedScalar &ds)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
static const floatScalar floatScalarVSmall
Definition: floatScalar.H:58
static const floatScalar floatScalarNaN
Definition: floatScalar.H:72
static const floatScalar floatScalarSmall
Definition: floatScalar.H:61
static const floatScalar floatScalarVGreat
Definition: floatScalar.H:56