3
# ************************************************************************
5
# WebTrilinos: A Web Interface to Trilinos
6
# Copyright (2006) Sandia Corporation
8
# Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9
# license for use of this work by or on behalf of the U.S. Government.
11
# This library is free software; you can redistribute it and/or modify
12
# it under the terms of the GNU Lesser General Public License as
13
# published by the Free Software Foundation; either version 2.1 of the
14
# License, or (at your option) any later version.
16
# This library is distributed in the hope that it will be useful, but
17
# WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
# Lesser General Public License for more details.
21
# You should have received a copy of the GNU Lesser General Public
22
# License along with this library; if not, write to the Free Software
23
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25
# Questions? Contact Marzio Sala (marzio.sala _AT_ gmail.com)
27
# ************************************************************************
32
import Epetra, IFPACK, AztecOO
34
from PyTrilinos import Epetra, AztecOO, IFPACK
36
Comm = Epetra.PyComm()
38
NumGlobalElements = 10
39
Map = Epetra.Map(NumGlobalElements, 0, Comm)
40
MyGlobalElements = Map.MyGlobalElements()
42
Matrix = Epetra.CrsMatrix(Epetra.Copy, Map, 0)
44
for i in MyGlobalElements:
50
Factory = IFPACK.Factory()
51
Prec = Factory.Create("ILU", Matrix)
53
"fact: level-of-fill": 1
56
Prec.SetParameters(IFPACKList)
61
LHS = Epetra.Vector(Map); LHS.PutScalar(0.0)
62
RHS = Epetra.Vector(Map); RHS.Random()
64
Solver = AztecOO.AztecOO(Matrix, LHS, RHS)
66
Solver.SetPrecOperator(Prec)
67
Solver.SetAztecOption(AztecOO.AZ_output, 16)
68
Solver.Iterate(1550, 1e-5)
70
print Solver.NumIters(), Solver.TrueResidual()