libMesh
eigen_core_support.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 
21 #ifndef LIBMESH_EIGEN_CORE_SUPPORT_H
22 #define LIBMESH_EIGEN_CORE_SUPPORT_H
23 
24 
25 
26 #include "libmesh/libmesh_common.h"
27 
28 #ifdef LIBMESH_HAVE_EIGEN
29 
30 // Local includes
31 #include "libmesh/id_types.h"
32 
33 // C++ includes
34 
35 // // hack to avoid MatType collision...
36 // #undef libMeshSaveMatType
37 // #ifdef MatType
38 // # define MatType libMeshSaveMatType
39 // # undef MatType
40 // #endif
41 
42 // Eigen uses deprecated std::binder1st/2nd classes, which GCC warns about.
43 // GCC 6.1 also warns about misleading indentation from if blocks in
44 // Eigen.
45 #include "libmesh/ignore_warnings.h"
46 
47 // Eigen includes
48 #include <Eigen/Core>
49 #include <Eigen/Sparse>
50 
51 #include "libmesh/restore_warnings.h"
52 
53 // #ifdef libMeshSaveMatType
54 // # define libMeshSaveMatType MatType
55 // # undef libMeshSaveMatType
56 // #endif
57 
58 
59 namespace libMesh
60 {
61 
62 // must be a signed type!!
63 #if LIBMESH_DOF_ID_BYTES == 1
64 // Workaround for Eigen bug
65 // typedef int8_t eigen_idx_type;
66 typedef int32_t eigen_idx_type;
67 #elif LIBMESH_DOF_ID_BYTES == 2
68 // Workaround for Eigen bug
69 // typedef int16_t eigen_idx_type;
70 typedef int32_t eigen_idx_type;
71 #elif LIBMESH_DOF_ID_BYTES == 8
72 typedef int64_t eigen_idx_type;
73 #else // LIBMESH_DOF_ID_BYTES = 4 (default)
74 typedef int32_t eigen_idx_type;
75 #endif
76 
77 // We have to use RowMajor SparseMatrix storage for our preallocation to work
78 typedef Eigen::SparseMatrix<Number, Eigen::RowMajor, eigen_idx_type> EigenSM;
79 typedef Eigen::Matrix<Number, Eigen::Dynamic, 1> EigenSV;
80 } // namespace libMesh
81 
82 
83 #endif // #ifdef LIBMESH_HAVE_EIGEN
84 #endif // LIBMESH_EIGEN_CORE_SUPPORT_H
int32_t eigen_idx_type
The libMesh namespace provides an interface to certain functionality in the library.
Eigen::Matrix< Number, Eigen::Dynamic, 1 > EigenSV
Eigen::SparseMatrix< Number, Eigen::RowMajor, eigen_idx_type > EigenSM