MAST3
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
sparse_matrix_initialization.hpp
Go to the documentation of this file.
1 /*
2 * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3 * Copyright (C) 2013-2020 Manav Bhatia and MAST authors
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 #ifndef __mast_libmesh_sparse_matrix_initialization_h__
21 #define __mast_libmesh_sparse_matrix_initialization_h__
22 
23 // MAST includes
25 #include <mast/base/exceptions.hpp>
26 
27 // libMesh includes
28 #include <libmesh/dof_map.h>
29 
30 namespace MAST {
31 namespace Numerics {
32 namespace libMeshWrapper {
33 
34 
35 template <typename P1, int P2, typename P3>
36 void init_sparse_matrix(const libMesh::DofMap& dof_map,
37  Eigen::SparseMatrix<P1, P2, P3>& m) {
38 
39  Assert1(dof_map.comm().size() == 1,
40  dof_map.comm().size(),
41  "Eigen matrix can only be used for MPI communicator with rank 1.");
42 
43  m.resize(dof_map.n_dofs(), dof_map.n_dofs());
44 
45  m.reserve(dof_map.get_n_nz());
46 }
47 
48 } // namespace libMeshWrapper
49 } // namespace Numerics
50 } // namespace MAST
51 
52 #endif // __mast_libmesh_sparse_matrix_initialization_h__
void init_sparse_matrix(const libMesh::DofMap &dof_map, Eigen::SparseMatrix< P1, P2, P3 > &m)
#define Assert1(cond, v1, msg)
Definition: exceptions.hpp:143