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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9  Copyright (C) 2017-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Typedef
28  Foam::floatScalar
29 
30 Description
31  Floating-point single precision scalar type.
32 
33 SourceFiles
34  floatScalar.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef floatScalar_H
39 #define floatScalar_H
40 
41 #include "doubleFloat.H"
42 #include "direction.H"
43 #include "word.H"
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.
55 // See std::numeric_limits max(), min(), epsilon()
56 constexpr floatScalar floatScalarGREAT = 1.0e+6;
57 constexpr floatScalar floatScalarVGREAT = 1.0e+37;
58 constexpr floatScalar floatScalarROOTVGREAT = 1.0e+18;
59 constexpr floatScalar floatScalarSMALL = 1.0e-6;
60 constexpr floatScalar floatScalarROOTSMALL = 1.0e-3;
61 constexpr floatScalar floatScalarVSMALL = 1.0e-37;
62 constexpr floatScalar floatScalarROOTVSMALL = 1.0e-18;
63 
64 
65 #define Scalar floatScalar
66 #define ScalarVGREAT floatScalarVGREAT
67 #define ScalarVSMALL floatScalarVSMALL
68 #define ScalarROOTVGREAT floatScalarROOTVGREAT
69 #define ScalarROOTVSMALL floatScalarROOTVSMALL
70 #define ScalarRead readFloat
71 
72 
73 inline Scalar mag(const Scalar s)
74 {
75  return ::fabsf(s);
76 }
77 
78 inline Scalar hypot(const Scalar x, const Scalar y)
79 {
80  return ::hypotf(x, y);
81 }
82 
83 inline Scalar atan2(const Scalar y, const Scalar x)
84 {
85  return ::atan2f(y, x);
86 }
87 
88 // Single-precision transcendental functions (with 'f' appended to the name)
89 #define transFunc(func) \
90 inline Scalar func(const Scalar s) \
91 { \
92  return ::func##f(s); \
93 }
94 
95 
96 // Single-precision bessel functions.
97 // May not be available on all systems
98 #ifdef Foam_no_besselFunc
99  // Not available
100  #define besselFunc(func) \
101  inline Scalar func(const Scalar s) \
102  { \
103  std::cerr<< "No '" << #func << "' function\n"; \
104  return 0; \
105  }
106  #define besselFunc2(func) \
107  inline Scalar func(const int n, const Scalar s) \
108  { \
109  std::cerr<< "No '" << #func << "' function\n"; \
110  return 0; \
111  }
112 #elif defined(__APPLE__)
113  // Darwin: no float version (use a cast)
114  #define besselFunc(func) \
115  inline Scalar func(const Scalar s) \
116  { \
117  return ::func(s); \
118  }
119  #define besselFunc2(func) \
120  inline Scalar func(const int n, const Scalar s) \
121  { \
122  return Scalar(::func(n, double(s))); \
123  }
124 #elif defined(__MINGW32__)
125  // Mingw: with '_' prefix, no float version (use a cast)
126  #define besselFunc(func) \
127  inline Scalar func(const Scalar s) \
128  { \
129  return _##func(s); \
130  }
131  #define besselFunc2(func) \
132  inline Scalar func(const int n, const Scalar s) \
133  { \
134  return Scalar(_##func(n, double(s))); \
135  }
136 #else
137  // With 'f' (float) appended to the name
138  #define besselFunc(func) \
139  inline Scalar func(const Scalar s) \
140  { \
141  return ::func##f(s); \
142  }
143  #define besselFunc2(func) \
144  inline Scalar func(const int n, const Scalar s) \
145  { \
146  return ::func##f(n, s); \
147  }
148 #endif
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 #include "Scalar.H"
158 
159 #undef Scalar
160 #undef ScalarVGREAT
161 #undef ScalarVSMALL
162 #undef ScalarROOTVGREAT
163 #undef ScalarROOTVSMALL
164 #undef ScalarRead
165 #undef transFunc
166 #undef besselFunc
167 #undef besselFunc2
168 
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #endif
173 
174 // ************************************************************************* //
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
Definition: gmvOutputSpray.H:25
Foam::floatScalar
float floatScalar
Floating-point single precision scalar type.
Definition: floatScalar.H:52
doubleFloat.H
Foam::atan2
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
Definition: dimensionedScalar.C:312
Foam::floatScalarVSMALL
constexpr floatScalar floatScalarVSMALL
Definition: floatScalar.H:61
Foam::hypot
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
Definition: dimensionedScalar.C:327
Foam::floatScalarGREAT
constexpr floatScalar floatScalarGREAT
Definition: floatScalar.H:56
Foam::floatScalarROOTSMALL
constexpr floatScalar floatScalarROOTSMALL
Definition: floatScalar.H:60
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
direction.H
Direction is an 8-bit unsigned integer type used to represent the Cartesian directions etc.
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::floatScalarROOTVGREAT
constexpr floatScalar floatScalarROOTVGREAT
Definition: floatScalar.H:58
Scalar
#define Scalar
Definition: floatScalar.H:65
Foam::floatScalarROOTVSMALL
constexpr floatScalar floatScalarROOTVSMALL
Definition: floatScalar.H:62
word.H
Foam::floatScalarSMALL
constexpr floatScalar floatScalarSMALL
Definition: floatScalar.H:59
Foam::floatScalarVGREAT
constexpr floatScalar floatScalarVGREAT
Definition: floatScalar.H:57
Scalar.H
y
scalar y
Definition: LISASMDCalcMethod1.H:14