# Kratos Multiphysics Forums

## General => Proposals and Complaints => Topic started by: DanielB on February 18, 2016, 11:23:43 AM

Title: Solving a given linear system with solvers in Kratos
Post by: DanielB on February 18, 2016, 11:23:43 AM
Dear all,

since this forum is new, I am not quite sure whether this is the right place to pose this question. So if not I would be happy for any hints towards what to do better.

​I have a linear system with a large sparse, positive definite matrix that I want to solve. It has nothing to do with finite elements (in fact it comes from a radial basis interpolation). Can I use the solvers in Kratos (e.g. CG) to solve that system? If yes, how?

Thanks for any help!

Best,
Daniel
Title: Re: Solving a given linear system with solvers in Kratos
Post by: MikeA on February 19, 2016, 01:00:35 PM
I'll post my response here now that I am a forum member.

I just committed a new trilinos solver for solving large linear elastic problems. It is intended for structural problems but would probably be suitable for your problem.

To use it, copy the

trilinos_mesh_solver_structural_similarity.py

and rename it to something suitable for your application. The script imports the new linear solver called

trilinos_linear_elastic_ml_solver.py.

This solver is set by default to solve linear elastic problems where only the right hand side changes between solves. So it only computes the preconditioner the first time solve() is called. If your left hand side matrix is changing between solves, you can replace the line

self.linear_solver = trilinos_linear_elastic_ml_solver.MultilevelLinearSolver(linear_tol, nit_max)

with the lines

self.linear_solver = trilinos_linear_elastic_ml_solver.MultilevelLinearSolver(linear_tol, nit_max)
self.linear_solver.SetReformPrecAtEachStep(True)
Title: Re: Solving a given linear system with solvers in Kratos
Post by: MikeA on February 19, 2016, 01:52:09 PM
I should add here that you also need to change the strategy because the structural mesh moving strategy will not work for your problem. I posted further info about the trilinos case in a new thread under Structural Application.
Title: Re: Solving a given linear system with solvers in Kratos
Post by: riccardo on February 19, 2016, 06:40:06 PM
Hi Daniel,

The big question is: how is the system stored? In ublas? Plane CSR? Do you have access in python to the underlying arrays?

Cheers
Riccardo