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 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, x, y)
solver.SetAztecOption(AztecOO.AZ_solver, AztecOO.AZ_cg);
solver.SetAztecOption(AztecOO.AZ_output, 16);
err = solver.Iterate(1550, 1e-5)