doubleScalar.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-2023 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::doubleScalar
26 
27 Description
28  Double precision floating point scalar type.
29 
30 SourceFiles
31  doubleScalar.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef doubleScalar_H
36 #define doubleScalar_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 double doubleScalar;
53 
54 // Largest and smallest scalar values allowed in certain parts of the code.
59 
63  = 1.0/doubleScalarSmall;
64 
67 
70 
72  = numeric_limits<doubleScalar>::signaling_NaN();
73 
74 //- Read whole of buf as a scalar. Return true if successful.
75 inline bool readScalar(const char* buf, doubleScalar& s)
76 {
77  char* endPtr;
78  s = strtod(buf, &endPtr);
79 
80  return (*endPtr == '\0');
81 }
82 
83 #define Scalar doubleScalar
84 #define ScalarVGreat doubleScalarVGreat
85 #define ScalarVSmall doubleScalarVSmall
86 #define ScalarRootVGreat doubleScalarRootVGreat
87 #define ScalarRootVSmall doubleScalarRootVSmall
88 #define ScalarNaN doubleScalarNaN
89 #define readScalar readDoubleScalar
90 
91 inline Scalar mag(const Scalar s)
92 {
93  return ::fabs(s);
94 }
95 
96 
97 #define MAXMINPOW(retType, type1, type2) \
98  \
99 MAXMIN(retType, type1, type2) \
100  \
101 inline double pow(const type1 s, const type2 e) \
102 { \
103  return ::pow(Scalar(s), Scalar(e)); \
104 }
105 
113 
114 #undef MAXMINPOW
115 
116 #define transFunc(func) \
117 inline Scalar func(const Scalar s) \
118 { \
119  return ::func(s); \
120 }
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 } // End namespace Foam
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 #include "Scalar.H"
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 namespace Foam
133 {
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 inline Scalar hypot(const Scalar x, const Scalar y)
138 {
139  return ::hypot(x, y);
140 }
141 
142 inline Scalar atan2(const Scalar y, const Scalar x)
143 {
144  return ::atan2(y, x);
145 }
146 
147 inline Scalar jn(const int n, const Scalar s)
148 {
149  return ::jn(n, s);
150 }
151 
152 inline Scalar yn(const int n, const Scalar s)
153 {
154  return ::yn(n, s);
155 }
156 
157 #undef Scalar
158 #undef ScalarVGreat
159 #undef ScalarVSmall
160 #undef ScalarRootVGreat
161 #undef ScalarRootVSmall
162 #undef ScalarNaN
163 #undef readScalar
164 #undef transFunc
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace Foam
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
scalar y
label n
Direction is an 8-bit unsigned integer type used to represent the Cartesian directions etc.
#define MAXMINPOW(retType, type1, type2)
Definition: doubleScalar.H:97
#define Scalar
Definition: doubleScalar.H:83
const scalar epsilon
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 doubleScalar doubleScalarRootVGreat
Definition: doubleScalar.H:65
doubleScalar jn(const int n, const doubleScalar s)
Definition: doubleScalar.H:147
double doubleScalar
Double precision floating point scalar type.
Definition: doubleScalar.H:52
static const doubleScalar doubleScalarSmall
Definition: doubleScalar.H:61
static const doubleScalar doubleScalarNaN
Definition: doubleScalar.H:72
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 doubleScalar doubleScalarRootGreat
Definition: doubleScalar.H:68
static const doubleScalar doubleScalarGreat
Definition: doubleScalar.H:63
dimensionedScalar jn(const int n, const dimensionedScalar &ds)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
doubleScalar yn(const int n, const doubleScalar s)
Definition: doubleScalar.H:152
doubleScalar atan2(const doubleScalar y, const doubleScalar x)
Definition: doubleScalar.H:142
doubleScalar hypot(const doubleScalar x, const doubleScalar y)
Definition: doubleScalar.H:137
static const doubleScalar doubleScalarVSmall
Definition: doubleScalar.H:58
static const doubleScalar doubleScalarVGreat
Definition: doubleScalar.H:56
static const doubleScalar doubleScalarRootSmall
Definition: doubleScalar.H:69
static const doubleScalar doubleScalarRootVSmall
Definition: doubleScalar.H:66