doubleScalar.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::doubleScalar
29 
30 Description
31  Floating-point double precision scalar type.
32 
33 SourceFiles
34  doubleScalar.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_primitives_double_H
39 #define Foam_primitives_double_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 (doubleScalar) in scalarFwd.H
50 
51 namespace Foam
52 {
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 // Largest and smallest scalar values allowed in certain parts of the code.
57 // See std::numeric_limits max(), min(), epsilon()
58 constexpr doubleScalar doubleScalarGREAT = 1.0e+15;
60 constexpr doubleScalar doubleScalarVGREAT = 1.0e+300;
61 constexpr doubleScalar doubleScalarROOTVGREAT = 1.0e+150;
62 constexpr doubleScalar doubleScalarSMALL = 1.0e-15;
63 constexpr doubleScalar doubleScalarROOTSMALL = 3.0e-8;
64 constexpr doubleScalar doubleScalarVSMALL = 1.0e-300;
65 constexpr doubleScalar doubleScalarROOTVSMALL = 1.0e-150;
66 
67 
68 #define Scalar doubleScalar
69 #define ScalarVGREAT doubleScalarVGREAT
70 #define ScalarVSMALL doubleScalarVSMALL
71 #define ScalarROOTVGREAT doubleScalarROOTVGREAT
72 #define ScalarROOTVSMALL doubleScalarROOTVSMALL
73 #define ScalarRead readDouble
74 
75 
76 inline Scalar mag(const Scalar s)
77 {
78  return ::fabs(s);
79 }
80 
81 inline Scalar hypot(const Scalar x, const Scalar y)
82 {
83  return ::hypot(x, y);
84 }
85 
86 inline Scalar atan2(const Scalar y, const Scalar x)
87 {
88  return ::atan2(y, x);
89 }
90 
91 
92 // Normal (double-precision) transcendental functions
93 #define transFunc(func) \
94 inline Scalar func(const Scalar s) \
95 { \
96  return ::func(s); \
97 }
98 
99 // Normal (double-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(__MINGW32__)
116  // Mingw: with '_' prefix
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 _##func(n, s); \
126  }
127 #else
128  #define besselFunc(func) \
129  inline Scalar func(const Scalar s) \
130  { \
131  return ::func(s); \
132  }
133  #define besselFunc2(func) \
134  inline Scalar func(const int n, const Scalar s) \
135  { \
136  return ::func(n, s); \
137  }
138 #endif
139 
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 } // End namespace Foam
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #include "Scalar.H"
148 
149 #undef Scalar
150 #undef ScalarVGREAT
151 #undef ScalarVSMALL
152 #undef ScalarROOTVGREAT
153 #undef ScalarROOTVSMALL
154 #undef ScalarRead
155 #undef transFunc
156 #undef besselFunc
157 #undef besselFunc2
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************************************************************* //
#define Scalar
Definition: doubleScalar.H:64
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
constexpr doubleScalar doubleScalarVSMALL
Definition: doubleScalar.H:60
scalar y
constexpr doubleScalar doubleScalarROOTVSMALL
Definition: doubleScalar.H:61
constexpr doubleScalar doubleScalarROOTVGREAT
Definition: doubleScalar.H:57
double doubleScalar
A typedef for double.
Definition: scalarFwd.H:48
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
constexpr doubleScalar doubleScalarGREAT
Definition: doubleScalar.H:54
Typedefs for float/double/scalar without requiring scalar.H.
doubleScalar atan2(const doubleScalar y, const doubleScalar x)
Definition: doubleScalar.H:82
constexpr doubleScalar doubleScalarVGREAT
Definition: doubleScalar.H:56
doubleScalar hypot(const doubleScalar x, const doubleScalar y)
Definition: doubleScalar.H:77
Direction is an 8-bit unsigned integer type used to represent Cartesian directions, components etc.
constexpr doubleScalar doubleScalarSMALL
Definition: doubleScalar.H:58
constexpr doubleScalar doubleScalarROOTSMALL
Definition: doubleScalar.H:59
constexpr doubleScalar doubleScalarROOTGREAT
Definition: doubleScalar.H:55
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))
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
Namespace for OpenFOAM.