OpenFOAM
11
The OpenFOAM Foundation
uLabel.C
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-2018 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
\*---------------------------------------------------------------------------*/
25
26
#include "
error.H
"
27
#include "
uLabel.H
"
28
29
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30
31
#if WM_LABEL_SIZE == 32
32
const
char
*
const
Foam::pTraits<uint64_t>::typeName
=
"uint64"
;
33
const
char
*
const
Foam::pTraits<uint32_t>::typeName
=
"uLabel"
;
34
#elif WM_LABEL_SIZE == 64
35
const
char
*
const
Foam::pTraits<uint64_t>::typeName
=
"uLabel"
;
36
const
char
*
const
Foam::pTraits<uint32_t>::typeName
=
"uint32"
;
37
#endif
38
39
40
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41
42
Foam::uLabel
Foam::pow
(
uLabel
a,
uLabel
b
)
43
{
44
uLabel
ans = 1;
45
for
(
uLabel
i=0; i<
b
; i++)
46
{
47
ans *= a;
48
}
49
50
return
ans;
51
}
52
53
54
Foam::uLabel
Foam::factorial
(
uLabel
n
)
55
{
56
static
uLabel
factTable[13] =
57
{
58
1, 1, 2, 6, 24, 120, 720, 5040, 40320,
59
362880, 3628800, 39916800, 479001600
60
};
61
62
#ifdef FULLDEBUG
63
if
(
n
> 12)
64
{
65
FatalErrorInFunction
66
<<
"n value out of range (> 12)"
67
<<
abort
(
FatalError
);
68
}
69
#endif
70
71
return
factTable[
n
];
72
}
73
74
75
// ************************************************************************* //
n
label n
Definition:
TABSMDCalcMethod2.H:31
Foam::pTraits
Traits class for primitives.
Definition:
pTraits.H:53
error.H
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition:
error.H:306
b
volScalarField & b
Definition:
createFields.H:27
Foam::abort
errorManip< error > abort(error &err)
Definition:
errorManip.H:131
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition:
dimensionedScalar.C:73
Foam::uLabel
uintWM_LABEL_SIZE_t uLabel
A uLabel is an uint32_t or uint64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition:
uLabel.H:59
Foam::factorial
label factorial(label n)
Return n! : 0 < n <= 12.
Definition:
label.C:63
Foam::FatalError
error FatalError
uLabel.H
src
OpenFOAM
primitives
ints
uLabel
uLabel.C
Generated by
1.9.1