libMesh
id_types.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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 
28 namespace libMesh
29 {
30 
31 // A useful way to debug:
32 #if 0
33 class TestClass {
34  //int _c;
35  unsigned int _c;
36 public:
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
51 typedef int8_t boundary_id_type;
52 #elif LIBMESH_BOUNDARY_ID_BYTES == 4
53 typedef int32_t boundary_id_type;
54 #elif LIBMESH_BOUNDARY_ID_BYTES == 8
55 typedef int64_t boundary_id_type;
56 #else // LIBMESH_BOUNDARY_ID_BYTES = 2 (default)
57 typedef 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 #if LIBMESH_DOF_ID_BYTES == 1
64 typedef uint8_t dof_id_type;
65 #elif LIBMESH_DOF_ID_BYTES == 2
66 typedef uint16_t dof_id_type;
67 #elif LIBMESH_DOF_ID_BYTES == 8
68 typedef uint64_t dof_id_type;
69 #else // LIBMESH_DOF_ID_BYTES = 4 (default)
70 typedef uint32_t dof_id_type;
71 #endif
72 
73 
74 
75 // How many bytes do we need to specify DoFObjects without ever
76 // renumbering? By default we'll allow for quintillions of
77 // one-time-use ids.
78 #if LIBMESH_UNIQUE_ID_BYTES == 1
79 typedef uint8_t unique_id_type;
80 #elif LIBMESH_UNIQUE_ID_BYTES == 2
81 typedef uint16_t unique_id_type;
82 #elif LIBMESH_UNIQUE_ID_BYTES == 4
83 typedef uint32_t unique_id_type;
84 #else // LIBMESH_UNIQUE_ID_BYTES == 8 (default)
85 typedef uint64_t unique_id_type;
86 
87 #endif
88 
89 
90 // We may want to specialize this later, but for now we'll assume
91 // numeric vector indices are the same as dof indices
93 
94 
95 // Define processor id storage type.
96 #if LIBMESH_PROCESSOR_ID_BYTES == 1
97 typedef uint8_t processor_id_type;
98 #elif LIBMESH_PROCESSOR_ID_BYTES == 2
99 typedef uint16_t processor_id_type;
100 #elif LIBMESH_PROCESSOR_ID_BYTES == 4
101 typedef uint32_t processor_id_type; // default
102 #elif LIBMESH_PROCESSOR_ID_BYTES == 8
103 typedef uint64_t processor_id_type;
104 #else
105 // We should not get here: it's not currently possible to set any
106 // other size.
107 DIE A HORRIBLE DEATH HERE...
108 #endif
109 
110 
111 // How many bytes do we need to specify subsets of the interior? By
112 // default we'll allow for tens of thousands of different subdomain
113 // ids.
114 #if LIBMESH_SUBDOMAIN_ID_BYTES == 1
115 typedef uint8_t subdomain_id_type;
116 #elif LIBMESH_SUBDOMAIN_ID_BYTES == 4
117 
123 typedef int32_t subdomain_id_type;
124 #elif LIBMESH_SUBDOMAIN_ID_BYTES == 8
125 
129 typedef int64_t subdomain_id_type;
130 #else // LIBMESH_SUBDOMAIN_ID_BYTES = 2 (default)
131 typedef uint16_t subdomain_id_type;
132 #endif
133 
134 
135 // For serialization purposes we often like to pack the different
136 // kinds of ids together; how large a data type do we need to hold an
137 // arbitrary id?
138 #if (LIBMESH_BOUNDARY_ID_BYTES > 4) || (LIBMESH_DOF_ID_BYTES > 4) || \
139  (LIBMESH_UNIQUE_ID_BYTES > 4) || (LIBMESH_PROCESSOR_ID_BYTES > 4) || \
140  (LIBMESH_SUBDOMAIN_ID_BYTES > 4)
141 typedef uint64_t largest_id_type;
142 #elif (LIBMESH_BOUNDARY_ID_BYTES > 2) || (LIBMESH_DOF_ID_BYTES > 2) || \
143  (LIBMESH_UNIQUE_ID_BYTES > 2) || (LIBMESH_PROCESSOR_ID_BYTES > 2) || \
144  (LIBMESH_SUBDOMAIN_ID_BYTES > 2)
145 typedef uint32_t largest_id_type;
146 #elif (LIBMESH_BOUNDARY_ID_BYTES > 1) || (LIBMESH_DOF_ID_BYTES > 1) || \
147  (LIBMESH_UNIQUE_ID_BYTES > 1) || (LIBMESH_PROCESSOR_ID_BYTES > 1) || \
148  (LIBMESH_SUBDOMAIN_ID_BYTES > 1)
149 typedef uint16_t largest_id_type;
150 #else
151 typedef uint8_t largest_id_type;
152 #endif
153 
154 } // namespace libMesh
155 
156 #endif // LIBMESH_ID_TYPES_H
bool operator<(const TestClass &l) const
Definition: id_types.h:40
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn&#39;t work with exodusII at all...
Definition: id_types.h:43
uint64_t largest_id_type
Definition: id_types.h:141
The libMesh namespace provides an interface to certain functionality in the library.
uint8_t processor_id_type
Definition: id_types.h:97
TestClass(unsigned int c)
Definition: id_types.h:38
unsigned int _c
Definition: id_types.h:35
int8_t boundary_id_type
Definition: id_types.h:51
dof_id_type numeric_index_type
Definition: id_types.h:92
TestClass & operator=(unsigned int c)
Definition: id_types.h:39
uint8_t unique_id_type
Definition: id_types.h:79
uint8_t dof_id_type
Definition: id_types.h:64