PyTrilinos Logo PyTrilinos.ML


The most notable difference between ML and its Python module is in the construction of the preconditioner. Given an Epetra.RowMatrix object (say, A), first you need a set of parameters, specified in a Python dictionary:

MLList = {"max levels"        : 3,
          "output"            : 10,
          "smoother: type"    : "symmetric Gauss-Seidel",
          "aggregation: type" : "Uncoupled"

All parameters are specified as in C++; please check the ML page page for more details.

Then, you can create the preconditioner (derived from the Epetra.Operator class) as follows:

Prec = ML.MultiLevelPreconditioner(A, False)

Note that you first need to instantiate Prec using False, then let Prec parse the parameters contained in MLList, and finally build the preconditioner. Using Prec as a preconditioner for AztecOO may be done as simply as:

Solver = AztecOO.AztecOO(A, LHS, RHS)
Solver.SetAztecOption(AztecOO.AZ_solver, AztecOO.AZ_cg);
Solver.SetAztecOption(AztecOO.AZ_output, 16);
err = Solver.Iterate(1550, 1e-5)