VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
NumericConstants.h
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
32//=======================================================================================
33#ifndef BASICS_NUMERIC_CONSTANT_H
34#define BASICS_NUMERIC_CONSTANT_H
35
36#ifndef __CUDACC__
37#include <cmath>
38#endif
39
41{
42
43#ifdef VF_DOUBLE_ACCURACY
44static constexpr double c1o2 = 1. / 2.;
45static constexpr double c3o2 = 3. / 2.;
46static constexpr double c1o3 = 1. / 3.;
47static constexpr double c2o3 = 2. / 3.;
48static constexpr double c1o4 = 1. / 4.;
49static constexpr double c3o4 = 3. / 4.;
50static constexpr double c1o6 = 1. / 6.;
51static constexpr double c1o7 = 1. / 7.;
52static constexpr double c1o8 = 1. / 8.;
53static constexpr double c1o9 = 1. / 9.;
54static constexpr double c2o9 = 2. / 9.;
55static constexpr double c4o9 = 4. / 9.;
56static constexpr double c4o10 = 4. / 10.;
57static constexpr double c1o10 = 1. / 10.;
58static constexpr double c1o12 = 1. / 12.;
59static constexpr double c1o16 = 1. / 16.;
60static constexpr double c3o16 = 3. / 16.;
61static constexpr double c9o16 = 9. / 16.;
62static constexpr double c1o18 = 1. / 18.;
63static constexpr double c1o20 = 1. / 20.;
64static constexpr double c19o20 = 19. / 20.;
65static constexpr double c21o20 = 21. / 20.;
66static constexpr double c1o24 = 1. / 24.;
67static constexpr double c1o27 = 1. / 27.;
68static constexpr double c3o32 = 3. / 32.;
69static constexpr double c4o32 = 4. / 32.;
70static constexpr double c1o36 = 1. / 36.;
71static constexpr double c1o48 = 1. / 48.;
72static constexpr double c1o64 = 1. / 64.;
73static constexpr double c3o64 = 3. / 64.;
74static constexpr double c9o64 = 9. / 64.;
75static constexpr double c27o64 = 27. / 64.;
76static constexpr double c1o66 = 1. / 66.;
77static constexpr double c1o72 = 1. / 72.;
78static constexpr double c1o264 = 1. / 264.;
79static constexpr double c8o27 = 8. / 27.;
80static constexpr double c2o27 = 2. / 27.;
81static constexpr double c1o54 = 1. / 54.;
82static constexpr double c1o100 = 1. / 100.;
83static constexpr double c99o100 = 99. / 100;
84static constexpr double c1o126 = 1. / 126.;
85static constexpr double c1o216 = 1. / 216.;
86static constexpr double c5o4 = 5. / 4.;
87static constexpr double c4o3 = 4. / 3.;
88static constexpr double c9o4 = 9. / 4.;
89static constexpr double c5o2 = 5. / 2.;
90static constexpr double c9o2 = 9. / 2.;
91
92static constexpr double c0o1 = 0.;
93static constexpr double c1o1 = 1.;
94static constexpr double c2o1 = 2.;
95static constexpr double c3o1 = 3.;
96static constexpr double c4o1 = 4.;
97static constexpr double c5o1 = 5.;
98static constexpr double c6o1 = 6.;
99static constexpr double c7o1 = 7.;
100static constexpr double c8o1 = 8.;
101static constexpr double c9o1 = 9.;
102static constexpr double c10o1 = 10.;
103static constexpr double c11o1 = 11.;
104static constexpr double c12o1 = 12.;
105static constexpr double c13o1 = 13.;
106static constexpr double c14o1 = 14.;
107static constexpr double c15o1 = 15.;
108static constexpr double c16o1 = 16.;
109static constexpr double c17o1 = 17.;
110static constexpr double c18o1 = 18.;
111static constexpr double c20o1 = 20.;
112static constexpr double c21o1 = 21.;
113static constexpr double c24o1 = 24.;
114static constexpr double c25o1 = 25.;
115static constexpr double c26o1 = 26.;
116static constexpr double c27o1 = 27.;
117static constexpr double c28o1 = 28.;
118static constexpr double c29o1 = 29.;
119static constexpr double c30o1 = 30.;
120static constexpr double c32o1 = 32.;
121static constexpr double c33o1 = 33.;
122static constexpr double c34o1 = 34.;
123static constexpr double c36o1 = 36.;
124static constexpr double c40o1 = 40.;
125static constexpr double c42o1 = 42.;
126static constexpr double c46o1 = 46.;
127static constexpr double c48o1 = 48.;
128static constexpr double c50o1 = 50.;
129static constexpr double c52o1 = 52.;
130static constexpr double c54o1 = 54.;
131static constexpr double c56o1 = 56.;
132static constexpr double c64o1 = 64.;
133static constexpr double c66o1 = 66.;
134static constexpr double c68o1 = 68.;
135static constexpr double c69o1 = 69.;
136static constexpr double c72o1 = 72.;
137static constexpr double c84o1 = 84.;
138static constexpr double c88o1 = 88.;
139static constexpr double c96o1 = 96.;
140static constexpr double c100o1 = 100.;
141static constexpr double c130o1 = 130.;
142static constexpr double c152o1 = 152.;
143static constexpr double c166o1 = 166.;
144static constexpr double c195o1 = 195.;
145static constexpr double c216o1 = 216.;
146static constexpr double c264o1 = 264.;
147static constexpr double c290o1 = 290.;
148static constexpr double c367o1 = 367.;
149static constexpr double c76o10 = 7.6;
150static constexpr double c76o100 = 0.76;
151
152
153static constexpr double c0p0000002 = 0.0000002;
154static constexpr double c10eM30 = 1e-30;
155static constexpr double c10eM12 = 1e-12;
156static constexpr double c10eM10 = 1e-10;
157static constexpr double cSmallSingle = 0.0000000002;
158
159#ifndef __CUDACC__
160static const double cPi = 4.0 * std::atan(1.0); // 3.1415926535
161static const double c2Pi = 8.0 * std::atan(1.0); // 6.2831853071
162static const double cPio180 = 4.0 * std::atan(1.0) / 180.0; // 1.74532925199e-2
163static const double c180oPi = 180.0 / (4.0 * std::atan(1.0)); // 57.2957795131
164#else
165static constexpr double cPi = 3.1415926535;
166static constexpr double c2Pi = 6.28318530717;
167static constexpr double cPio180 = 1.74532925199e-2;
168static constexpr double c180oPi = 57.2957795131;
169#endif
170
171static const double c1oSqrt2 = 1.0 / sqrt(2.0); // 0.707106781
172static const double c1oSqrt3 = 1.0 / sqrt(3.0); // 0.577350269
173static const double cSqrt2 = sqrt(2.0); // 1.4142135
174static const double cSqrt3 = sqrt(3.0); // 1.7320508
175
176#else
177static constexpr float c1o2 = 1.0f / 2.0f;
178static constexpr float c3o2 = 3.0f / 2.0f;
179static constexpr float c1o3 = 1.0f / 3.0f;
180static constexpr float c2o3 = 2.0f / 3.0f;
181static constexpr float c1o4 = 1.0f / 4.0f;
182static constexpr float c3o4 = 3.0f / 4.0f;
183static constexpr float c1o6 = 1.0f / 6.0f;
184static constexpr float c1o7 = 1.0f / 7.0f;
185static constexpr float c1o8 = 1.0f / 8.0f;
186static constexpr float c1o9 = 1.0f / 9.0f;
187static constexpr float c2o9 = 2.0f / 9.0f;
188static constexpr float c4o9 = 4.0f / 9.0f;
189static constexpr float c4o10 = 4.0f / 10.0f;
190static constexpr float c1o10 = 1.0f / 10.0f;
191static constexpr float c1o12 = 1.0f / 12.0f;
192static constexpr float c1o16 = 1.0f / 16.0f;
193static constexpr float c3o16 = 3.0f / 16.0f;
194static constexpr float c9o16 = 9.0f / 16.0f;
195static constexpr float c1o18 = 1.0f / 18.0f;
196static constexpr float c1o20 = 1.0f / 20.0f;
197static constexpr float c19o20 = 19.0f / 20.0f;
198static constexpr float c21o20 = 21.0f / 20.0f;
199static constexpr float c1o24 = 1.0f / 24.0f;
200static constexpr float c1o27 = 1.0f / 27.0f;
201static constexpr float c3o32 = 3.0f / 32.0f;
202static constexpr float c4o32 = 4.0f / 32.0f;
203static constexpr float c1o36 = 1.0f / 36.0f;
204static constexpr float c1o48 = 1.0f / 48.0f;
205static constexpr float c1o64 = 1.0f / 64.0f;
206static constexpr float c3o64 = 3.0f / 64.0f;
207static constexpr float c9o64 = 9.0f / 64.0f;
208static constexpr float c27o64 = 27.0f / 64.0f;
209static constexpr float c1o66 = 1.0f / 66.0f;
210static constexpr float c1o72 = 1.0f / 72.0f;
211static constexpr float c1o264 = 1.0f / 264.0f;
212static constexpr float c8o27 = 8.0f / 27.0f;
213static constexpr float c2o27 = 2.0f / 27.0f;
214static constexpr float c1o54 = 1.0f / 54.0f;
215static constexpr float c1o100 = 1.0f / 100.0f;
216static constexpr float c99o100 = 99.0f / 100.0f;
217static constexpr float c1o126 = 1.0f / 126.0f;
218static constexpr float c1o216 = 1.0f / 216.0f;
219static constexpr float c5o4 = 5.0f / 4.0f;
220static constexpr float c4o3 = 4.0f / 3.0f;
221static constexpr float c9o4 = 9.0f / 4.0f;
222static constexpr float c5o2 = 5.0f / 2.0f;
223static constexpr float c9o2 = 9.0f / 2.0f;
224static constexpr float c76o10 = 7.6f;
225static constexpr float c76o100 = 0.76f;
226
227static constexpr float c0o1 = 0.f;
228static constexpr float c1o1 = 1.f;
229static constexpr float c2o1 = 2.f;
230static constexpr float c3o1 = 3.f;
231static constexpr float c4o1 = 4.f;
232static constexpr float c5o1 = 5.f;
233static constexpr float c6o1 = 6.f;
234static constexpr float c7o1 = 7.f;
235static constexpr float c8o1 = 8.f;
236static constexpr float c9o1 = 9.f;
237static constexpr float c10o1 = 10.f;
238static constexpr float c11o1 = 11.f;
239static constexpr float c12o1 = 12.f;
240static constexpr float c13o1 = 13.f;
241static constexpr float c14o1 = 14.f;
242static constexpr float c15o1 = 15.f;
243static constexpr float c16o1 = 16.f;
244static constexpr float c17o1 = 17.f;
245static constexpr float c18o1 = 18.f;
246static constexpr float c20o1 = 20.f;
247static constexpr float c21o1 = 21.f;
248static constexpr float c24o1 = 24.f;
249static constexpr float c25o1 = 25.f;
250static constexpr float c26o1 = 26.f;
251static constexpr float c27o1 = 27.f;
252static constexpr float c28o1 = 28.f;
253static constexpr float c29o1 = 29.f;
254static constexpr float c30o1 = 30.f;
255static constexpr float c32o1 = 32.f;
256static constexpr float c33o1 = 33.f;
257static constexpr float c34o1 = 34.f;
258static constexpr float c36o1 = 36.f;
259static constexpr float c40o1 = 40.f;
260static constexpr float c42o1 = 42.f;
261static constexpr float c46o1 = 46.f;
262static constexpr float c48o1 = 48.f;
263static constexpr float c50o1 = 50.f;
264static constexpr float c52o1 = 52.f;
265static constexpr float c54o1 = 54.f;
266static constexpr float c56o1 = 56.f;
267static constexpr float c64o1 = 64.f;
268static constexpr float c66o1 = 66.f;
269static constexpr float c68o1 = 68.f;
270static constexpr float c69o1 = 69.f;
271static constexpr float c72o1 = 72.f;
272static constexpr float c84o1 = 84.f;
273static constexpr float c88o1 = 88.f;
274static constexpr float c96o1 = 96.f;
275static constexpr float c100o1 = 100.0f;
276static constexpr float c130o1 = 130.0f;
277static constexpr float c152o1 = 152.0f;
278static constexpr float c166o1 = 166.0f;
279static constexpr float c195o1 = 195.0f;
280static constexpr float c216o1 = 216.0f;
281static constexpr float c264o1 = 264.0f;
282static constexpr float c290o1 = 290.0f;
283static constexpr float c367o1 = 367.0f;
284
285static constexpr float c0p0000002 = 0.0000002f;
286static constexpr float c10eM30 = 1e-30f;
287static constexpr float c10eM12 = 1e-12f;
288static constexpr float c10eM10 = 1e-10f;
289static constexpr float cSmallSingle = 0.0000000002f;
290
291#ifndef __CUDACC__
292static const float cPi = 4.0f * std::atan(1.0f); // 3.1415926535
293static const float c2Pi = 8.0f * std::atan(1.0f); // 6.2831853071
294static const float cPio180 = 4.0f * std::atan(1.0f) / 180.0f; // 1.74532925199e-2
295static const float c180oPi = 180.0f / (4.0f * std::atan(1.0f)); // 57.2957795131
296#else
297static constexpr float cPi = 3.1415926535f;
298static constexpr float c2Pi = 6.28318530717f;
299static constexpr float cPio180 = 1.74532925199e-2f;
300static constexpr float c180oPi = 57.2957795131f;
301#endif
302
303static const float c1oSqrt2 = 1.0 / sqrtf(2.0); // 0.707106781
304static const float c1oSqrt3 = 1.0 / sqrtf(3.0); // 0.577350269
305static const float cSqrt2 = sqrtf(2.0); // 1.4142135
306static const float cSqrt3 = sqrtf(3.0); // 1.7320508
307
308#endif
309
310}
311
312#endif
313
std::shared_ptr< T > SPtr