Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
27Typedef
28 Foam::floatScalar
29
30Description
31 Floating-point single precision scalar type.
32
33SourceFiles
34 floatScalar.cxx
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef Foam_primitives_float_H
39#define Foam_primitives_float_H
40
41#include "scalarFwd.H"
42#include "doubleFloat.H"
43#include "direction.H"
44#include "pTraits.H"
45#include "word.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49// Typedef (floatScalar) in scalarFwd.H
50
51namespace Foam
52{
53
54// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56// Largest and smallest scalar values allowed in certain parts of the code.
57// See std::numeric_limits max(), min(), epsilon()
58constexpr floatScalar floatScalarGREAT = 1.0e+6;
60constexpr floatScalar floatScalarVGREAT = 1.0e+37;
62constexpr floatScalar floatScalarSMALL = 1.0e-6;
63constexpr floatScalar floatScalarROOTSMALL = 1.0e-3;
64constexpr floatScalar floatScalarVSMALL = 1.0e-37;
68#define Scalar floatScalar
69#define ScalarVGREAT floatScalarVGREAT
70#define ScalarVSMALL floatScalarVSMALL
71#define ScalarROOTVGREAT floatScalarROOTVGREAT
72#define ScalarROOTVSMALL floatScalarROOTVSMALL
73#define ScalarRead readFloat
74
75
76inline Scalar mag(const Scalar s)
78 return ::fabsf(s);
79}
80
81inline Scalar hypot(const Scalar x, const Scalar y)
83 return ::hypotf(x, y);
84}
85
86inline Scalar atan2(const Scalar y, const Scalar x)
87{
88 return ::atan2f(y, x);
89}
90
91// Single-precision transcendental functions (with 'f' appended to the name)
92#define transFunc(func) \
93inline Scalar func(const Scalar s) \
94{ \
95 return ::func##f(s); \
96}
97
98
99// Single-precision bessel functions.
100// May not be available on all systems
101#ifdef Foam_no_besselFunc
102 // Not available
103 #define besselFunc(func) \
104 inline Scalar func(const Scalar s) \
105 { \
106 std::cerr<< "No '" << #func << "' function\n"; \
107 return 0; \
108 }
109 #define besselFunc2(func) \
110 inline Scalar func(const int n, const Scalar s) \
111 { \
112 std::cerr<< "No '" << #func << "' function\n"; \
113 return 0; \
114 }
115#elif defined(__APPLE__)
116 // Darwin: no float version (use a cast)
117 #define besselFunc(func) \
118 inline Scalar func(const Scalar s) \
119 { \
120 return ::func(s); \
121 }
122 #define besselFunc2(func) \
123 inline Scalar func(const int n, const Scalar s) \
124 { \
125 return Scalar(::func(n, double(s))); \
126 }
127#elif defined(__MINGW32__)
128 // Mingw: with '_' prefix, no float version (use a cast)
129 #define besselFunc(func) \
130 inline Scalar func(const Scalar s) \
131 { \
132 return _##func(s); \
133 }
134 #define besselFunc2(func) \
135 inline Scalar func(const int n, const Scalar s) \
136 { \
137 return Scalar(_##func(n, double(s))); \
138 }
139#else
140 // With 'f' (float) appended to the name
141 #define besselFunc(func) \
142 inline Scalar func(const Scalar s) \
143 { \
144 return ::func##f(s); \
145 }
146 #define besselFunc2(func) \
147 inline Scalar func(const int n, const Scalar s) \
148 { \
149 return ::func##f(n, s); \
150 }
151#endif
152
153
154// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155
156} // End namespace Foam
157
158// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159
160// scalarImpl.H is used for template-like substitution (but using macros)
161
162#define Foam_use_scalarImpl_header
163#include "scalarImpl.H"
164#undef Foam_use_scalarImpl_header
165
166#undef Scalar
167#undef ScalarVGREAT
168#undef ScalarVSMALL
169#undef ScalarROOTVGREAT
170#undef ScalarROOTVSMALL
171#undef ScalarRead
172#undef transFunc
173#undef besselFunc
174#undef besselFunc2
175
176
177// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178
179#endif
180
181// ************************************************************************* //
scalar y
Direction is an 8-bit unsigned integer type used to represent Cartesian directions,...
#define Scalar
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))
Namespace for OpenFOAM.
constexpr floatScalar floatScalarVGREAT
Definition floatScalar.H:56
constexpr floatScalar floatScalarGREAT
Definition floatScalar.H:54
constexpr floatScalar floatScalarROOTVGREAT
Definition floatScalar.H:57
constexpr floatScalar floatScalarROOTVSMALL
Definition floatScalar.H:61
constexpr floatScalar floatScalarSMALL
Definition floatScalar.H:58
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
float floatScalar
A typedef for float.
Definition scalarFwd.H:43
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
constexpr floatScalar floatScalarROOTSMALL
Definition floatScalar.H:59
constexpr floatScalar floatScalarVSMALL
Definition floatScalar.H:60
constexpr floatScalar floatScalarROOTGREAT
Definition floatScalar.H:55
Typedefs for float/double/scalar without requiring scalar.H.