$extrastylesheet
id_types.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 #ifndef LIBMESH_ID_TYPES_H
00021 #define LIBMESH_ID_TYPES_H
00022 
00023 #include <limits>
00024 #include <stdint.h>
00025 
00026 #include "libmesh/libmesh_config.h"
00027 
00028 namespace libMesh
00029 {
00030 
00031 // A useful way to debug:
00032 #if 0
00033 class TestClass {
00034   //int _c;
00035   unsigned int _c;
00036 public:
00037   TestClass() : _c(0) {}
00038   TestClass(unsigned int c) : _c(c) {}
00039   TestClass& operator=(unsigned int c) { _c = c; return *this; }
00040   bool operator<(const TestClass &l) const { return _c < l._c; }
00041   operator int() const { return _c; }
00042 };
00043 typedef TestClass subdomain_id_type;
00044 #endif
00045 
00046 
00047 // How many bytes do we need to specify subsets of the boundary?  By
00048 // default we'll allow for tens of thousands of different boundary
00049 // ids.
00050 #if LIBMESH_BOUNDARY_ID_BYTES == 1
00051 typedef int8_t boundary_id_type;
00052 #elif LIBMESH_BOUNDARY_ID_BYTES == 4
00053 typedef int32_t boundary_id_type;
00054 #elif LIBMESH_BOUNDARY_ID_BYTES == 8
00055 typedef int64_t boundary_id_type;
00056 #else // LIBMESH_BOUNDARY_ID_BYTES = 2 (default)
00057 typedef int16_t boundary_id_type;
00058 #endif
00059 
00060 
00061 // How many bytes do we need to specify DoFObjects?  By default we'll
00062 // allow for a few billion (each) nodes & elements.
00063 #if LIBMESH_DOF_ID_BYTES == 1
00064 typedef uint8_t dof_id_type;
00065 #elif LIBMESH_DOF_ID_BYTES == 2
00066 typedef uint16_t dof_id_type;
00067 #elif LIBMESH_DOF_ID_BYTES == 8
00068 typedef uint64_t dof_id_type;
00069 #else // LIBMESH_DOF_ID_BYTES = 4 (default)
00070 typedef uint32_t dof_id_type;
00071 #endif
00072 
00073 
00074 
00075 // How many bytes do we need to specify DoFObjects without ever
00076 // renumbering?  By default we'll allow for quintillions of
00077 // one-time-use ids.
00078 #if LIBMESH_UNIQUE_ID_BYTES == 1
00079 typedef uint8_t unique_id_type;
00080 #elif LIBMESH_UNIQUE_ID_BYTES == 2
00081 typedef uint16_t unique_id_type;
00082 #elif LIBMESH_UNIQUE_ID_BYTES == 4
00083 typedef uint32_t unique_id_type;
00084 #else // LIBMESH_UNIQUE_ID_BYTES == 8 (default)
00085 typedef uint64_t unique_id_type;
00086 
00087 #endif
00088 
00089 
00090 // We may want to specialize this later, but for now we'll assume
00091 // numeric vector indices are the same as dof indices
00092 typedef dof_id_type numeric_index_type;
00093 
00094 
00095 // Define processor id storage type.  We default to short to save
00096 // space, but expanding to support more than 2^16-2 procs should work
00097 // too.
00098 #if LIBMESH_PROCESSOR_ID_BYTES == 1
00099 typedef uint8_t processor_id_type;
00100 #elif LIBMESH_PROCESSOR_ID_BYTES == 4
00101 typedef uint32_t processor_id_type;
00102 #elif LIBMESH_PROCESSOR_ID_BYTES == 8
00103 typedef uint64_t processor_id_type;
00104 #else // LIBMESH_PROCESSOR_ID_BYTES = 2 (default)
00105 typedef uint16_t processor_id_type;
00106 #endif
00107 
00108 
00109 // How many bytes do we need to specify subsets of the interior?  By
00110 // default we'll allow for tens of thousands of different subdomain
00111 // ids.
00112 #if LIBMESH_SUBDOMAIN_ID_BYTES == 1
00113 typedef uint8_t subdomain_id_type;
00114 #elif LIBMESH_SUBDOMAIN_ID_BYTES == 4
00115 
00120 typedef int32_t subdomain_id_type;
00121 #elif LIBMESH_SUBDOMAIN_ID_BYTES == 8
00122 
00126 typedef int64_t subdomain_id_type;
00127 #else // LIBMESH_SUBDOMAIN_ID_BYTES = 2 (default)
00128 typedef uint16_t subdomain_id_type;
00129 #endif
00130 
00131 
00132 // For serialization purposes we often like to pack the different
00133 // kinds of ids together; how large a data type do we need to hold an
00134 // arbitrary id?
00135 #if (LIBMESH_BOUNDARY_ID_BYTES > 4) || (LIBMESH_DOF_ID_BYTES > 4) ||    \
00136   (LIBMESH_UNIQUE_ID_BYTES > 4) || (LIBMESH_PROCESSOR_ID_BYTES > 4) ||  \
00137   (LIBMESH_SUBDOMAIN_ID_BYTES > 4)
00138 typedef uint64_t largest_id_type;
00139 #elif (LIBMESH_BOUNDARY_ID_BYTES > 2) || (LIBMESH_DOF_ID_BYTES > 2) ||  \
00140   (LIBMESH_UNIQUE_ID_BYTES > 2) || (LIBMESH_PROCESSOR_ID_BYTES > 2) ||  \
00141   (LIBMESH_SUBDOMAIN_ID_BYTES > 2)
00142 typedef uint32_t largest_id_type;
00143 #elif (LIBMESH_BOUNDARY_ID_BYTES > 1) || (LIBMESH_DOF_ID_BYTES > 1) ||  \
00144   (LIBMESH_UNIQUE_ID_BYTES > 1) || (LIBMESH_PROCESSOR_ID_BYTES > 1) ||  \
00145   (LIBMESH_SUBDOMAIN_ID_BYTES > 1)
00146 typedef uint16_t largest_id_type;
00147 #else
00148 typedef uint8_t largest_id_type;
00149 #endif
00150 
00151 } // namespace libMesh
00152 
00153 #endif // LIBMESH_ID_TYPES_H