13 #if !defined(KRATOS_COND_NUMBER_UTILITY )
14 #define KRATOS_COND_NUMBER_UTILITY
135 LinearSolverType::Pointer pEigenSolverMax,
136 LinearSolverType::Pointer pEigenSolverMin
137 ) :mpEigenSolverMax(pEigenSolverMax),
138 mpEigenSolverMin(pEigenSolverMin)
155 KRATOS_ERROR_IF(mpEigenSolverMax ==
nullptr || mpEigenSolverMin ==
nullptr) <<
"ERROR:: PLEASE DEFINE THE EigenSolvers" << std::endl;
168 LinearSolverType::Pointer pEigenSolverMax,
169 LinearSolverType::Pointer pEigenSolverMin
176 const SizeType size_matrix = rInputMatrix.size1();
180 identity_matrix.push_back(
i,
i, 1.0);
182 pEigenSolverMax->Solve(rInputMatrix, identity_matrix, eigen_values, eigen_vectors);
183 const double max_lambda = eigen_values[0];
185 pEigenSolverMin->Solve(rInputMatrix, identity_matrix, eigen_values, eigen_vectors);
186 const double min_lambda = eigen_values[0];
188 KRATOS_ERROR_IF(min_lambda < std::numeric_limits<double>::epsilon()) <<
"ERROR:: NOT POSSIBLE TO COMPUTE CONDITION NUMBER. ZERO EIGENVALUE" << std::endl;
190 const double condition_number = std::abs(max_lambda)/std::abs(min_lambda);
192 return condition_number;
222 LinearSolverType::Pointer mpEigenSolverMax;
223 LinearSolverType::Pointer mpEigenSolverMin;
Utility to compute the condition number.
Definition: condition_number_utility.h:60
std::size_t IndexType
The index type.
Definition: condition_number_utility.h:73
PowerIterationHighestEigenvalueSolver< SparseSpaceType, LocalSpaceType, LinearSolverType > PowerIterationHighestEigenvalueSolverType
Power iteration solver for the highest eigenvalue.
Definition: condition_number_utility.h:103
SkylineLUFactorizationSolver< SparseSpaceType, LocalSpaceType, ReordererType > SkylineLUFactorizationSolverType
Skyline solver definion.
Definition: condition_number_utility.h:100
ConditionNumberUtility()
Default constructor.
Definition: condition_number_utility.h:120
SparseSpaceType::VectorType VectorType
The vector considered.
Definition: condition_number_utility.h:85
KRATOS_CLASS_POINTER_DEFINITION(ConditionNumberUtility)
Pointer definition of ConditionNumberUtility.
virtual ~ConditionNumberUtility()
Destructor.
Definition: condition_number_utility.h:142
PowerIterationEigenvalueSolver< SparseSpaceType, LocalSpaceType, LinearSolverType > PowerIterationEigenvalueSolverType
Power iteration solver for the lowest eigenvalue.
Definition: condition_number_utility.h:106
LinearSolver< SparseSpaceType, LocalSpaceType > LinearSolverType
The definion of the linear solver.
Definition: condition_number_utility.h:94
SparseSpaceType::MatrixType SparseMatrixType
The compressed matrix.
Definition: condition_number_utility.h:82
ConditionNumberUtility(LinearSolverType::Pointer pEigenSolverMax, LinearSolverType::Pointer pEigenSolverMin)
Default constructor.
Definition: condition_number_utility.h:134
UblasSpace< double, Matrix, Vector > LocalSpaceType
The dense space considered.
Definition: condition_number_utility.h:79
double GetConditionNumber(SparseMatrixType &rInputMatrix)
This function computes using the inverse power method the minimal eigenvalue.
Definition: condition_number_utility.h:153
Reorderer< SparseSpaceType, LocalSpaceType > ReordererType
The reorder considered.
Definition: condition_number_utility.h:97
LocalSpaceType::VectorType DenseVectorType
The dense vector.
Definition: condition_number_utility.h:91
UblasSpace< double, CompressedMatrix, boost::numeric::ublas::vector< double > > SparseSpaceType
The sparse space considered (the one containing the compressed matrix)
Definition: condition_number_utility.h:76
LocalSpaceType::MatrixType DenseMatrixType
The dense matrix.
Definition: condition_number_utility.h:88
std::size_t SizeType
The sisze type.
Definition: condition_number_utility.h:70
double GetConditionNumber(SparseMatrixType &rInputMatrix, LinearSolverType::Pointer pEigenSolverMax, LinearSolverType::Pointer pEigenSolverMin)
This function computes using the inverse power method the minimal eigenvalue.
Definition: condition_number_utility.h:166
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
This class uses the inverted power iteration method to obtain the lowest eigenvalue of a system.
Definition: power_iteration_eigenvalue_solver.h:64
This class uses the inverted power iteration method to obtain the lowest eigenvalue of a system.
Definition: power_iteration_highest_eigenvalue_solver.h:63
Base class for all reorderer objects in Kratos used in linear solvers.
Definition: reorderer.h:60
Definition: skyline_lu_factorization_solver.h:562
A class template for handling data types, matrices, and vectors in a Ublas space.
Definition: ublas_space.h:121
TMatrixType MatrixType
The matrix type considered.
Definition: ublas_space.h:133
TVectorType VectorType
The vector type considered.
Definition: ublas_space.h:136
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
integer i
Definition: TensorModule.f:17