14 #if !defined (KRATOS_AMESOS_SOLVER_H_INCLUDED)
15 #define KRATOS_AMESOS_SOLVER_H_INCLUDED
25 #include "Epetra_LinearProblem.h"
39 template<
class TSparseSpaceType,
class TDenseSpaceType,
40 class TReordererType = Reorderer<TSparseSpaceType, TDenseSpaceType> >
42 TDenseSpaceType, TReordererType>
65 "solver_type" : "amesos",
66 "amesos_solver_type" : "Amesos_Klu",
67 "trilinos_amesos_parameter_list" : { }
71 if (settings[
"solver_type"].GetString() ==
"klu") {
72 if (settings.
Has(
"amesos_solver_type")) {
73 KRATOS_INFO(
"Amesos-Solver") <<
"Ignoring setting \"amesos_solver_type\"" << std::endl;
77 settings[
"amesos_solver_type"].
SetString(
"Amesos_Klu");
79 else if (settings[
"solver_type"].GetString() ==
"super_lu_dist") {
80 if (settings.
Has(
"amesos_solver_type")) {
81 KRATOS_INFO(
"Amesos-Solver") <<
"Ignoring setting \"amesos_solver_type\"" << std::endl;
86 settings[
"amesos_solver_type"].
SetString(
"Amesos_Superludist");
88 else if (settings[
"solver_type"].GetString() ==
"mumps") {
89 if (settings.
Has(
"amesos_solver_type")) {
90 KRATOS_INFO(
"Amesos-Solver") <<
"Ignoring setting \"amesos_solver_type\"" << std::endl;
95 settings[
"amesos_solver_type"].
SetString(
"Amesos_Mumps");
97 else if (settings[
"solver_type"].GetString() ==
"amesos") {
102 KRATOS_ERROR <<
"The solver type specified: \"" << settings[
"solver_type"].
GetString() <<
"\" is not supported";
108 mParameterList = Teuchos::ParameterList();
109 for(
auto it = settings[
"trilinos_amesos_parameter_list"].begin(); it != settings[
"trilinos_amesos_parameter_list"].
end(); it++) {
110 if(it->IsString()) mParameterList.set(it.name(), it->GetString());
111 else if(it->IsInt()) mParameterList.set(it.name(), it->GetInt());
112 else if(it->IsBool()) mParameterList.set(it.name(), it->GetBool());
113 else if(it->IsDouble()) mParameterList.set(it.name(), it->GetDouble());
116 mSolverName = settings[
"amesos_solver_type"].
GetString();
119 <<
"\" unfortunately the current compilation of Trilinos does not include it" << std::endl;
123 AmesosSolver(
const std::string& SolverName, Teuchos::ParameterList& rParameterList)
125 mParameterList = rParameterList;
126 mSolverName = SolverName;
129 <<
"\" unfortunately the current compilation of Trilinos does not include it" << std::endl;
161 Epetra_LinearProblem linear_problem(&rA,&rX,&rB);
162 Amesos_BaseSolver* p_amesos_solver;
163 Amesos amesos_factory;
164 p_amesos_solver = amesos_factory.Create(mSolverName, linear_problem);
166 p_amesos_solver->SetParameters( mParameterList );
168 p_amesos_solver->SymbolicFactorization();
169 p_amesos_solver->NumericFactorization();
170 p_amesos_solver->Solve();
172 delete p_amesos_solver;
202 static bool HasSolver(
const std::string& rAmesosSolverName)
204 Amesos amesos_factory;
205 return amesos_factory.Query(rAmesosSolverName);
215 rOStream <<
"Trilinos Amesos-Solver";
224 Teuchos::ParameterList mParameterList;
225 std::string mSolverName;
232 template<
class TSparseSpaceType,
class TDenseSpaceType,
class TReordererType>
235 TDenseSpaceType, TReordererType>& rThis)
237 rThis.PrintInfo(rOStream);
238 rOStream << std::endl;
239 rThis.PrintData(rOStream);
Wrapper for Trilinos-Amesos Direct Solvers.
Definition: amesos_solver.h:43
AmesosSolver(Parameters settings)
Constructor with Parameters.
Definition: amesos_solver.h:62
KRATOS_CLASS_POINTER_DEFINITION(AmesosSolver)
Pointer definition of AmesosSolver.
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: amesos_solver.h:213
AmesosSolver(const AmesosSolver &Other)=delete
Copy constructor.
TSparseSpaceType::VectorType VectorType
Definition: amesos_solver.h:53
AmesosSolver & operator=(const AmesosSolver &Other)=delete
Assignment operator.
bool Solve(SparseMatrixType &rA, DenseMatrixType &rX, DenseMatrixType &rB) override
Definition: amesos_solver.h:188
AmesosSolver(const std::string &SolverName, Teuchos::ParameterList &rParameterList)
Constructor with solver-name and Teuchos::ParameterList.
Definition: amesos_solver.h:123
static bool HasSolver(const std::string &rAmesosSolverName)
Definition: amesos_solver.h:202
bool Solve(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Definition: amesos_solver.h:157
TDenseSpaceType::MatrixType DenseMatrixType
Definition: amesos_solver.h:55
~AmesosSolver() override=default
Destructor.
TSparseSpaceType::MatrixType SparseMatrixType
Definition: amesos_solver.h:51
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
void SetString(const std::string &rValue)
This method sets the string contained in the current Parameter.
Definition: kratos_parameters.cpp:811
iterator end()
This returns the end iterator.
Definition: kratos_parameters.cpp:969
Parameters AddEmptyValue(const std::string &rEntry)
This method adds an empty parameter.
Definition: kratos_parameters.cpp:471
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
bool Has(const std::string &rEntry) const
This method checks if the Parameter contains a certain entry.
Definition: kratos_parameters.cpp:520
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
#define KRATOS_INFO(label)
Definition: logger.h:250
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432