uLabel.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-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 Typedef
25  Foam::uLabel
26 
27 Description
28  A uLabel is an uint32_t or uint64_t as specified by the pre-processor macro
29  WM_LABEL_SIZE.
30 
31  A readLabel function is defined so that uLabel can be constructed from
32  Istream.
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef uLabel_H
37 #define uLabel_H
38 
39 #include "uint.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 #define UINT_ADD_SIZE(x,s,y) x ## s ## y
44 #define UINT_ADD_DEF_SIZE(x,s,y) UINT_ADD_SIZE(x,s,y)
45 #define UINT_SIZE(x,y) UINT_ADD_DEF_SIZE(x,WM_LABEL_SIZE,y)
46 
47 #if WM_LABEL_SIZE != 32 && WM_LABEL_SIZE != 64
48  #error "uLabel.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 UINT_SIZE(uint, _t) uLabel;
60 
61 static const uLabel uLabelMax = UINT_SIZE(UINT, _MAX);
62 
64 {
65  return UINT_SIZE(readUint,) (is);
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 //- Raise one uLabel to the power of another
73 
74 //- Evaluate n! : 0 < n <= 12
76 
77 
78 inline uLabel& setComponent(uLabel& l, const direction)
79 {
80  return l;
81 }
82 
83 inline uLabel component(const uLabel l, const direction)
84 {
85  return l;
86 }
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 } // End namespace Foam
91 
92 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
93 
94 #undef UINT_ADD_SIZE
95 #undef UINT_ADD_DEF_SIZE
96 #undef UINT_SIZE
97 
98 #endif
99 
100 // ************************************************************************* //
label n
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
volScalarField & b
Definition: createFields.H:25
Namespace for OpenFOAM.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
label & setComponent(label &l, const direction)
Definition: label.H:86
uLabel readULabel(Istream &is)
Definition: uLabel.H:63
static const uLabel uLabelMax
Definition: uLabel.H:61
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
unsigned int readUint(Istream &)
Definition: uintIO.C:31
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
label factorial(label n)
Return n! : 0 < n <= 12.
Definition: label.C:63
uint8_t direction
Definition: direction.H:45
#define UINT_SIZE(x, y)
Definition: uLabel.H:45
System uinteger.