All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
label.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-2019 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::label
26 
27 Description
28  A label is an int32_t or int64_t as specified by the pre-processor macro
29  WM_LABEL_SIZE.
30 
31  A readLabel function is defined so that label can be constructed from
32  Istream.
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef label_H
37 #define label_H
38 
39 #include "int.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 #define INT_ADD_SIZE(x,s,y) x ## s ## y
44 #define INT_ADD_DEF_SIZE(x,s,y) INT_ADD_SIZE(x,s,y)
45 #define INT_SIZE(x,y) INT_ADD_DEF_SIZE(x,WM_LABEL_SIZE,y)
46 
47 #if WM_LABEL_SIZE != 32 && WM_LABEL_SIZE != 64
48  #error "label.H: WM_LABEL_SIZE must be set to either 32 or 64"
49 #endif
50 
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 typedef INT_SIZE(int, _t) label;
60 
61 static const label labelMin = INT_SIZE(INT, _MIN);
62 static const label labelMax = INT_SIZE(INT, _MAX);
63 
64 inline label readLabel(Istream& is)
65 {
66  return INT_SIZE(readInt,) (is);
67 }
68 
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 //- Raise one label to the power of another
73 label pow(label a, label b);
74 
75 //- Evaluate n! : 0 < n <= 12
76 label factorial(label n);
77 
78 
79 inline label& setComponent(label& l, const direction)
80 {
81  return l;
82 }
83 
84 inline label component(const label l, const direction)
85 {
86  return l;
87 }
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 } // End namespace Foam
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 #include "labelSpecific.H"
96 
97 #undef INT_ADD_SIZE
98 #undef INT_ADD_DEF_SIZE
99 #undef INT_SIZE
100 
101 #endif
102 
103 // ************************************************************************* //
System integer.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
int readInt(Istream &)
Definition: intIO.C:31
uint8_t direction
Definition: direction.H:45
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
Definition: createFields.H:27
label factorial(label n)
Evaluate n! : 0 < n <= 12.
Definition: label.C:63
static const label labelMax
Definition: label.H:62
label readLabel(Istream &is)
Definition: label.H:64
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
label n
label & setComponent(label &l, const direction)
Definition: label.H:79
#define INT_SIZE(x, y)
Definition: label.H:45
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
static const label labelMin
Definition: label.H:61
Namespace for OpenFOAM.