10 #if !defined(KRATOS_EIGEN_DENSE_EIGENVALUE_SOLVER_H_INCLUDED)
11 #define KRATOS_EIGEN_DENSE_EIGENVALUE_SOLVER_H_INCLUDED
15 #include <Eigen/Eigenvalues>
25 template <
typename TScalar =
double,
26 class TSparseSpaceType = TUblasDenseSpace<TScalar>,
27 class TDenseSpaceType = TUblasDenseSpace<TScalar>>
46 "solver_type" : "dense_eigensolver",
47 "ascending_order" : true,
51 mParam.ValidateAndAssignDefaults(default_params);
53 mEchoLevel = mParam["echo_level"].GetInt();
74 KRATOS_INFO_IF(
"DenseEigenvalueSolver", mEchoLevel > 0) <<
"Start" << std::endl;
79 Eigen::Map<matrix_t>
A(rA.data().begin(), rA.size1(), rA.size2());
81 Eigen::SelfAdjointEigenSolver<matrix_t>
solver;
83 solver.compute(
A, Eigen::ComputeEigenvectors);
85 rEigenvalues.resize(rA.size1());
86 rEigenvectors.resize(rA.size1(), rA.size1());
88 Eigen::Map<vector_t> eigvals (rEigenvalues.data().begin(), rEigenvalues.size());
89 Eigen::Map<matrix_t> eigvecs (rEigenvectors.data().begin(), rEigenvectors.size1(), rEigenvectors.size2());
91 if( mParam[
"ascending_order"].GetBool() ){
92 eigvals =
solver.eigenvalues();
93 eigvecs =
solver.eigenvectors();
96 eigvals =
solver.eigenvalues().reverse();
97 eigvecs =
solver.eigenvectors().rowwise().reverse();
100 const bool success =
solver.info() == Eigen::Success;
103 KRATOS_INFO_IF(
"DenseEigenvalueSolver", mEchoLevel > 0) <<
"Completed in "
104 << eigensolver_timer << std::endl;
106 Eigen::IOFormat fmt(Eigen::StreamPrecision, Eigen::DontAlignCols,
", ",
", ",
"",
"",
"[ ",
" ]");
109 <<
" Eigenvalues = " << eigvals.transpose().format(fmt) << std::endl;
112 KRATOS_WARNING(
"DenseEigenvalueSolver") <<
"Decomposition failed!" << std::endl;
118 rOStream <<
"DenseEigenvalueSolver";
Definition: builtin_timer.h:26
Definition: eigen_dense_eigenvalue_solver.h:30
TDenseSpaceType::VectorType DenseVectorType
Definition: eigen_dense_eigenvalue_solver.h:40
KRATOS_CLASS_POINTER_DEFINITION(DenseEigenvalueSolver)
~DenseEigenvalueSolver() override
Definition: eigen_dense_eigenvalue_solver.h:56
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: eigen_dense_eigenvalue_solver.h:116
DenseEigenvalueSolver(Parameters param)
Definition: eigen_dense_eigenvalue_solver.h:42
TDenseSpaceType::MatrixType DenseMatrixType
Definition: eigen_dense_eigenvalue_solver.h:38
void Solve(DenseMatrixType &rA, DenseMatrixType &rDummy, DenseVectorType &rEigenvalues, DenseMatrixType &rEigenvectors) override
Dense eigenvalue solver.
Definition: eigen_dense_eigenvalue_solver.h:66
Base class for all the linear solvers in Kratos.
Definition: linear_solver.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
#define KRATOS_WARNING(label)
Definition: logger.h:265
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Eigen::Matrix< _Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > EigenDynamicMatrix
Definition: linear_solvers_define.h:32
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
Eigen::Matrix< _Scalar, Eigen::Dynamic, 1 > EigenDynamicVector
Definition: linear_solvers_define.h:33
solver
Definition: script.py:98
A
Definition: sensitivityMatrix.py:70