# How to construct a linear solver using the "Linear Solver Factory"

(→Direct solvers included in the Kratos) |
(→"External" Iterative Solvers (available in some of the applications)) |
||

Line 52: | Line 52: | ||

DropTol=1e-4 | DropTol=1e-4 | ||

FillTol = 1e-2 | FillTol = 1e-2 | ||

− | FillFactor= | + | FillFactor=5 |

the user is invited to check the SuperLU documentation [[http://crd-legacy.lbl.gov/~xiaoye/SuperLU/]] for an explanation of the meaning of the different parameters | the user is invited to check the SuperLU documentation [[http://crd-legacy.lbl.gov/~xiaoye/SuperLU/]] for an explanation of the meaning of the different parameters |

## Revision as of 08:30, 4 July 2013

The class "LinearSolverFactory" is designed to help in the construction of the Kratos Linear Solvers, and makes an attempt to unify the construction mechanism.

the essential idea is that the "settings" to be used in the construction of a linear solver are defined by constructing a new python class (with arbitrary name) which contains the settings needed for the construction of the solver

Within kratos there exist different classes of linear solvers.

## Contents |

## Iterative Solvers available in the Kratos Core

A first group of iterative solvers is included within the Kratos core and is always available to the user. Available choices for "solver_type"

BiConjugate gradient stabilized Conjugate gradient GMRES

This solvers can be used with or without a preconditioner, which is also available within the Kratos core. Available options for "preconditioner_type" are

None DiagonalPreconditioner ILU0

in order to construct a "BiConjugate gradient stabilized" together with an ILU0 preconditioner using the factory class one shall write

##here we specify the settings to be used in the construction class custom_settings: solver_type = "BiConjugate gradient stabilized" scaling = True preconditioner_type = "DiagonalPreconditioner" max_iteration = 500 tolerance = 1e-6 ##here we actually construct a new linear solver using the "custom settings" just defined import linear_solver_factory new_linear_solver = linear_solver_factory.ConstructSolver(custom_settings)

Note that specifying "True" at the scaling option implies that the matrix coefficients is normalized prior to the solution step

## "External" Iterative Solvers (available in some of the applications)

The Kratos also provides interface to external libraries which provide more advanced preconditioners than the ones provided in the Kratos core. Available options are

SuperLUIterativeSolver Pastix

SuperLU solver (available in the ExternalSolversApplication) provides a gmres + ILUT preconditioner can be used by creating a configure of the type

class solver_configure solver_type = "SuperLUIterativeSolver" scaling = False tolerance = 1e-7 max_iteration = 300 gmres_krylov_space_dimension=100 DropTol=1e-4 FillTol = 1e-2 FillFactor=5

the user is invited to check the SuperLU documentation [[1]] for an explanation of the meaning of the different parameters

Iterative Pastix solver (available in the ExternalSolversApplication provided that compilation enabled it) can be obtained with a configure of the type

class solver_configure solver_type = "PastixIterative" scaling = False tolerance = 1e-7 max_iteration = 300 gmres_krylov_space_dimension = 100 ilu_level_of_fill = 3 verbosity = 0 is_symmetric = False

note that by setting the is_symmetric=True, incomplete Cholesky is used instead of ILU. Pastix solver is OpenMP parallel

## Direct solvers included in the Kratos

Admissible values for "solver_type" are

Skyline LU factorization SuperLUSolver --> requires the ExternalSolversApplication Parallel MKL Pardiso --> requires kratos to be compiled with Intel MKL and MKLSolversApplication PastixDirect --> requires the ExternalSolversApplication to be compiled together with the Pastix solver

such solvers are appropriate for the solution of relatively small systems of equations which can be conveniently solved by employing a direct solver technology. The Pardiso solver and the Pastix are OpenMP parallel. Since these solvers are direct, tolerance, preconditioner_type and max_iterations make no sense and are not required. a new solver of this type could be constructed as

##here we specify the settings to be used in the construction class other_settings: solver_type = "SuperLUSolver" scaling = False

An error is thrown if the required application is not loaded.

Pastix solver is a little specific in that it allows specifying more parameters to handle the case of symmetric matrices and to

##here we specify the settings to be used in the construction class other_settings: solver_type = "PastixDirect" scaling = False verbosity = 0 is_symmetric = False

## Algebraic Multigrid Solver

The kratos contains an interface to the AMGCL solver (courtesy of Dr. Denis Demidov). Such solver combines Algebraic Multigrid with krylov methods.

the configuration of the solver is as follows:

class solver_configuration: solver_type = "AMGCL" scaling = True max_iteration = 50 tolerance = 1e-5 smoother_type = "ILU0" #other options are "DAMPED_JACOBI" and "SPAI0" krylov_type = "GMRES" #other options are "BICGSTAB" and "CG" verbosity = 0 #OPTIONAL! set to 1 to have some output gmres_krylov_space_dimension = 50 #OPTIONAL! only read in case GMRES is chosen.

and the construction is as in the other cases.
**The solver automatically detect block structure in the unkowns, and can be used effecitively for multidimensional problems.**

## Specialized Solvers

The kratos core also provides more advanced solvers, specialized to the case of mixed formulations. An example of this is the

Mixed UP

solver which implements a SIMPLE-like preconditioner for the monolithic Navier-Stokes equations combined with a GMRES solver. This solver combines different linear solvers to be used for the "U block" and for the "P block" and shall be in some sense optimal in the case of dominating intertia