libMesh
Loading...
Searching...
No Matches
id_types.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19
20#ifndef LIBMESH_ID_TYPES_H
21#define LIBMESH_ID_TYPES_H
22
23#include <limits>
24#include <stdint.h>
25
26#include "libmesh/libmesh_config.h"
27
28namespace libMesh
29{
30
31// A useful way to debug:
32#if 0
33class TestClass {
34 //int _c;
35 unsigned int _c;
36public:
37 TestClass() : _c(0) {}
38 TestClass(unsigned int c) : _c(c) {}
39 TestClass & operator=(unsigned int c) { _c = c; return *this; }
40 bool operator<(const TestClass & l) const { return _c < l._c; }
41 operator int() const { return _c; }
42};
44#endif
45
46
47// How many bytes do we need to specify subsets of the boundary? By
48// default we'll allow for tens of thousands of different boundary
49// ids.
50#if LIBMESH_BOUNDARY_ID_BYTES == 1
51typedef int8_t boundary_id_type;
52#elif LIBMESH_BOUNDARY_ID_BYTES == 4
53typedef int32_t boundary_id_type;
54#elif LIBMESH_BOUNDARY_ID_BYTES == 8
55typedef int64_t boundary_id_type;
56#else // LIBMESH_BOUNDARY_ID_BYTES = 2 (default)
57typedef int16_t boundary_id_type;
58#endif
59
60
61// How many bytes do we need to specify DoFObjects? By default we'll
62// allow for a few billion (each) nodes & elements.
63//
64// We'll need a sign bit in some internal buffers, so let's also
65// define a signed type that we can convert to without loss.
66#if LIBMESH_DOF_ID_BYTES == 1
67typedef uint8_t dof_id_type;
68typedef int8_t dof_id_signed_type;
69#elif LIBMESH_DOF_ID_BYTES == 2
70typedef uint16_t dof_id_type;
71typedef int16_t dof_id_signed_type;
72#elif LIBMESH_DOF_ID_BYTES == 8
73typedef uint64_t dof_id_type;
74typedef int64_t dof_id_signed_type;
75#else // LIBMESH_DOF_ID_BYTES = 4 (default)
76typedef uint32_t dof_id_type;
77typedef int32_t dof_id_signed_type;
78#endif
79
80
81
82// How many bytes do we need to specify DoFObjects without ever
83// renumbering? By default we'll allow for quintillions of
84// one-time-use ids.
85#if LIBMESH_UNIQUE_ID_BYTES == 1
86typedef uint8_t unique_id_type;
87#elif LIBMESH_UNIQUE_ID_BYTES == 2
88typedef uint16_t unique_id_type;
89#elif LIBMESH_UNIQUE_ID_BYTES == 4
90typedef uint32_t unique_id_type;
91#else // LIBMESH_UNIQUE_ID_BYTES == 8 (default)
92typedef uint64_t unique_id_type;
93
94#endif
95
96
97// We may want to specialize this later, but for now we'll assume
98// numeric vector indices are the same as dof indices
100
101
102// Define processor id storage type.
103#if LIBMESH_PROCESSOR_ID_BYTES == 1
104typedef uint8_t processor_id_type;
105#elif LIBMESH_PROCESSOR_ID_BYTES == 2
106typedef uint16_t processor_id_type;
107#elif LIBMESH_PROCESSOR_ID_BYTES == 4
108typedef uint32_t processor_id_type; // default
109#elif LIBMESH_PROCESSOR_ID_BYTES == 8
110typedef uint64_t processor_id_type;
111#else
112// We should not get here: it's not currently possible to set any
113// other size.
114DIE A HORRIBLE DEATH HERE...
115#endif
116
117
118// How many bytes do we need to specify subsets of the interior? By
119// default we'll allow for tens of thousands of different subdomain
120// ids.
121#if LIBMESH_SUBDOMAIN_ID_BYTES == 1
122typedef uint8_t subdomain_id_type;
123#elif LIBMESH_SUBDOMAIN_ID_BYTES == 4
130typedef int32_t subdomain_id_type;
131#elif LIBMESH_SUBDOMAIN_ID_BYTES == 8
136typedef int64_t subdomain_id_type;
137#else // LIBMESH_SUBDOMAIN_ID_BYTES = 2 (default)
138typedef uint16_t subdomain_id_type;
139#endif
140
141
142// For serialization purposes we often like to pack the different
143// kinds of ids together; how large a data type do we need to hold an
144// arbitrary id?
145#if (LIBMESH_BOUNDARY_ID_BYTES > 4) || (LIBMESH_DOF_ID_BYTES > 4) || \
146 (LIBMESH_UNIQUE_ID_BYTES > 4) || (LIBMESH_PROCESSOR_ID_BYTES > 4) || \
147 (LIBMESH_SUBDOMAIN_ID_BYTES > 4)
148typedef uint64_t largest_id_type;
149#elif (LIBMESH_BOUNDARY_ID_BYTES > 2) || (LIBMESH_DOF_ID_BYTES > 2) || \
150 (LIBMESH_UNIQUE_ID_BYTES > 2) || (LIBMESH_PROCESSOR_ID_BYTES > 2) || \
151 (LIBMESH_SUBDOMAIN_ID_BYTES > 2)
152typedef uint32_t largest_id_type;
153#elif (LIBMESH_BOUNDARY_ID_BYTES > 1) || (LIBMESH_DOF_ID_BYTES > 1) || \
154 (LIBMESH_UNIQUE_ID_BYTES > 1) || (LIBMESH_PROCESSOR_ID_BYTES > 1) || \
155 (LIBMESH_SUBDOMAIN_ID_BYTES > 1)
156typedef uint16_t largest_id_type;
157#else
158typedef uint8_t largest_id_type;
159#endif
160
161// elemset ids have something in common with both boundary ids and
162// subdomain ids, but are not used for exactly the purposes as
163// either. To try and avoid confusion, we define here a custom type
164// for elemset ids, but for simplicity we just typedef it to be the
165// same as whatever the subdomain_id_type is.
167
168} // namespace libMesh
169
170#endif // LIBMESH_ID_TYPES_H
void ErrorVector unsigned int
unsigned int _c
Definition id_types.h:35
TestClass & operator=(unsigned int c)
Definition id_types.h:39
bool operator<(const TestClass &l) const
Definition id_types.h:40
TestClass(unsigned int c)
Definition id_types.h:38
The libMesh namespace provides an interface to certain functionality in the library.
subdomain_id_type elemset_id_type
Definition id_types.h:166
uint8_t unique_id_type
Definition id_types.h:86
int8_t boundary_id_type
Definition id_types.h:51
int8_t dof_id_signed_type
Definition id_types.h:68
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn't work with exodusII at all....
Definition id_types.h:43
uint64_t largest_id_type
Definition id_types.h:148
dof_id_type numeric_index_type
Definition id_types.h:99
uint8_t dof_id_type
Definition id_types.h:67
uint8_t processor_id_type
Definition id_types.h:104