KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
ublas_wrapper.h
Go to the documentation of this file.
1 /* KRATOS _ _ ____ _
2 // | | (_)_ __ ___ __ _ _ __/ ___| ___ | |_ _____ _ __ ___
3 // | | | | '_ \ / _ \/ _` | '__\___ \ / _ \| \ \ / / _ \ '__/ __|
4 // | |___| | | | | __/ (_| | | ___) | (_) | |\ V / __/ | \__ |
5 // |_____|_|_| |_|\___|\__,_|_| |____/ \___/|_| \_/ \___|_| |___/ Application
6 //
7 // Authors: Thomas Oberbichler
8 */
9 
10 #if !defined(KRATOS_UBLAS_WRAPPER_H_INCLUDED)
11 #define KRATOS_UBLAS_WRAPPER_H_INCLUDED
12 
13 // System includes
14 #include <vector>
15 
16 // External includes
17 #include <Eigen/Core>
18 #include <Eigen/Sparse>
19 
20 // Project includes
21 #include "includes/define.h"
22 #include "linear_solvers_define.h"
23 
24 
25 namespace Kratos
26 {
27 
28 template <
29  typename TScalar = double,
30  typename TEigenSparseMatrix = Kratos::EigenSparseMatrix<TScalar>>
32 {
33  std::vector<int> m_index1;
34  std::vector<int> m_index2;
35  Eigen::Map<const TEigenSparseMatrix> m_map;
36 
37 public:
39  : m_index1(),
40  m_index2(),
41  m_map(0, 0, 0, nullptr, nullptr, nullptr)
42  {
43  }
44 
45  template <typename TUblasSparseMatrix>
46  UblasWrapper(const TUblasSparseMatrix& matrix)
47  : m_index1(matrix.index1_data().begin(), matrix.index1_data().end()),
48  m_index2(matrix.index2_data().begin(), matrix.index2_data().end()),
49  m_map(matrix.size1(), matrix.size2(), matrix.nnz(), m_index1.data(), m_index2.data(), matrix.value_data().begin())
50  {
51  }
52 
53  const Eigen::Map<const TEigenSparseMatrix>& matrix() const
54  {
55  return m_map;
56  }
57 };
58 
59 } // namespace Kratos
60 
61 #endif // defined(KRATOS_UBLAS_WRAPPER_H_INCLUDED)
Definition: ublas_wrapper.h:32
UblasWrapper()
Definition: ublas_wrapper.h:38
UblasWrapper(const TUblasSparseMatrix &matrix)
Definition: ublas_wrapper.h:46
const Eigen::Map< const TEigenSparseMatrix > & matrix() const
Definition: ublas_wrapper.h:53
end
Definition: DEM_benchmarks.py:180
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Eigen::SparseMatrix< _Scalar, Eigen::RowMajor, int > EigenSparseMatrix
Definition: linear_solvers_define.h:35
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
data
Definition: mesh_to_mdpa_converter.py:59