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-2020 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 "scalarFwd.H"
42 #include "doubleFloat.H"
43 #include "direction.H"
44 #include "word.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 // Typedef (floatScalar) in scalarFwd.H
49 
50 namespace Foam
51 {
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 // Largest and smallest scalar values allowed in certain parts of the code.
56 // See std::numeric_limits max(), min(), epsilon()
57 constexpr floatScalar floatScalarGREAT = 1.0e+6;
58 constexpr floatScalar floatScalarVGREAT = 1.0e+37;
59 constexpr floatScalar floatScalarROOTVGREAT = 1.0e+18;
60 constexpr floatScalar floatScalarSMALL = 1.0e-6;
61 constexpr floatScalar floatScalarROOTSMALL = 1.0e-3;
62 constexpr floatScalar floatScalarVSMALL = 1.0e-37;
63 constexpr floatScalar floatScalarROOTVSMALL = 1.0e-18;
64 
65 
66 #define Scalar floatScalar
67 #define ScalarVGREAT floatScalarVGREAT
68 #define ScalarVSMALL floatScalarVSMALL
69 #define ScalarROOTVGREAT floatScalarROOTVGREAT
70 #define ScalarROOTVSMALL floatScalarROOTVSMALL
71 #define ScalarRead readFloat
72 
73 
74 inline Scalar mag(const Scalar s)
75 {
76  return ::fabsf(s);
77 }
78 
79 inline Scalar hypot(const Scalar x, const Scalar y)
80 {
81  return ::hypotf(x, y);
82 }
83 
84 inline Scalar atan2(const Scalar y, const Scalar x)
85 {
86  return ::atan2f(y, x);
87 }
88 
89 // Single-precision transcendental functions (with 'f' appended to the name)
90 #define transFunc(func) \
91 inline Scalar func(const Scalar s) \
92 { \
93  return ::func##f(s); \
94 }
95 
96 
97 // Single-precision bessel functions.
98 // May not be available on all systems
99 #ifdef Foam_no_besselFunc
100  // Not available
101  #define besselFunc(func) \
102  inline Scalar func(const Scalar s) \
103  { \
104  std::cerr<< "No '" << #func << "' function\n"; \
105  return 0; \
106  }
107  #define besselFunc2(func) \
108  inline Scalar func(const int n, const Scalar s) \
109  { \
110  std::cerr<< "No '" << #func << "' function\n"; \
111  return 0; \
112  }
113 #elif defined(__APPLE__)
114  // Darwin: no float version (use a cast)
115  #define besselFunc(func) \
116  inline Scalar func(const Scalar s) \
117  { \
118  return ::func(s); \
119  }
120  #define besselFunc2(func) \
121  inline Scalar func(const int n, const Scalar s) \
122  { \
123  return Scalar(::func(n, double(s))); \
124  }
125 #elif defined(__MINGW32__)
126  // Mingw: with '_' prefix, no float version (use a cast)
127  #define besselFunc(func) \
128  inline Scalar func(const Scalar s) \
129  { \
130  return _##func(s); \
131  }
132  #define besselFunc2(func) \
133  inline Scalar func(const int n, const Scalar s) \
134  { \
135  return Scalar(_##func(n, double(s))); \
136  }
137 #else
138  // With 'f' (float) appended to the name
139  #define besselFunc(func) \
140  inline Scalar func(const Scalar s) \
141  { \
142  return ::func##f(s); \
143  }
144  #define besselFunc2(func) \
145  inline Scalar func(const int n, const Scalar s) \
146  { \
147  return ::func##f(n, s); \
148  }
149 #endif
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace Foam
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #include "Scalar.H"
159 
160 #undef Scalar
161 #undef ScalarVGREAT
162 #undef ScalarVSMALL
163 #undef ScalarROOTVGREAT
164 #undef ScalarROOTVSMALL
165 #undef ScalarRead
166 #undef transFunc
167 #undef besselFunc
168 #undef besselFunc2
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
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
A typedef for float.
Definition: scalarFwd.H:45
doubleFloat.H
Foam::atan2
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
Definition: dimensionedScalar.C:312
Foam::floatScalarVSMALL
constexpr floatScalar floatScalarVSMALL
Definition: floatScalar.H:62
Foam::hypot
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
Definition: dimensionedScalar.C:327
Foam::floatScalarGREAT
constexpr floatScalar floatScalarGREAT
Definition: floatScalar.H:57
scalarFwd.H
Typedefs for float/double/scalar without requiring scalar.H.
Foam::floatScalarROOTSMALL
constexpr floatScalar floatScalarROOTSMALL
Definition: floatScalar.H:61
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:59
Scalar
#define Scalar
Definition: floatScalar.H:66
Foam::floatScalarROOTVSMALL
constexpr floatScalar floatScalarROOTVSMALL
Definition: floatScalar.H:63
word.H
Foam::floatScalarSMALL
constexpr floatScalar floatScalarSMALL
Definition: floatScalar.H:60
Foam::floatScalarVGREAT
constexpr floatScalar floatScalarVGREAT
Definition: floatScalar.H:58
Scalar.H
y
scalar y
Definition: LISASMDCalcMethod1.H:14