~ubuntu-branches/ubuntu/wily/dolfin/wily-proposed

« back to all changes in this revision

Viewing changes to test/unit/la/python/KrylovSolver.py

  • Committer: Package Import Robot
  • Author(s): Johannes Ring
  • Date: 2014-09-22 14:35:34 UTC
  • mfrom: (1.1.17) (19.1.23 sid)
  • Revision ID: package-import@ubuntu.com-20140922143534-0yi89jyuqbgdxwm9
Tags: 1.4.0+dfsg-4
* debian/control: Disable libcgal-dev on i386, mipsel and sparc.
* debian/rules: Remove bad directives in pkg-config file dolfin.pc
  (closes: #760658).
* Remove debian/libdolfin-dev.lintian-overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# Modified by Anders Logg 2012
21
21
#
22
22
# First added:  2012-02-21
23
 
# Last changed: 2012-08-27
 
23
# Last changed: 2014-05-30
24
24
 
25
25
import unittest
26
26
from dolfin import *
29
29
mesh = UnitSquareMesh(32, 32)
30
30
V = FunctionSpace(mesh, 'CG', 1)
31
31
bc = DirichletBC(V, Constant(0.0), lambda x, on_boundary: on_boundary)
32
 
u = TrialFunction(V); v = TestFunction(V);
 
32
u = TrialFunction(V)
 
33
v = TestFunction(V)
33
34
u1 = Function(V)
34
35
 
35
36
# Forms
48
49
            "Test PETScKrylovSolver"
49
50
            # Get solution vector
50
51
            tmp = Function(V)
51
 
            x = tmp.vector()
 
52
            #x = tmp.vector()
52
53
 
53
54
            # Solve first using direct solver
54
 
            solve(A, x, b, "lu")
 
55
            #solve(A, x, b, "lu")
55
56
 
56
 
            direct_norm = x.norm("l2")
 
57
            #direct_norm = x.norm("l2")
57
58
 
58
59
            # Get solution vector
59
 
            x_petsc = as_backend_type(x)
60
 
 
61
 
            for prec, descr in krylov_solver_preconditioners():
62
 
                if MPI.num_processes() > 1 and prec in ["ilu", "icc", "jacobi", "hypre_amg"]:
63
 
                    print "FIXME: Preconditioner '%s' does not work in parallel,"\
64
 
                          " skipping" % prec
65
 
                    continue
66
 
 
67
 
                # With simple interface
68
 
                solver = PETScKrylovSolver("gmres", prec)
69
 
                solver.solve(A, x_petsc, as_backend_type(b))
70
 
                self.assertAlmostEqual(x_petsc.norm("l2"), direct_norm, 5)
71
 
 
72
 
 
73
 
                # With PETScPreconditioner interface
74
 
                solver = PETScKrylovSolver("gmres", PETScPreconditioner(prec))
75
 
                solver.solve(A, x_petsc, as_backend_type(b))
76
 
                self.assertAlmostEqual(x_petsc.norm("l2"), direct_norm, 5)
 
60
            #x_petsc = as_backend_type(x)
 
61
 
 
62
            # With simple interface
 
63
            #solver = PETScKrylovSolver("gmres", prec)
 
64
            #solver.solve(A, x_petsc, as_backend_type(b))
 
65
            #self.assertAlmostEqual(x_petsc.norm("l2"), direct_norm, 5)
 
66
 
 
67
            # With PETScPreconditioner interface
 
68
            #solver = PETScKrylovSolver("gmres", PETScPreconditioner(prec))
 
69
            #solver.solve(A, x_petsc, as_backend_type(b))
 
70
            #self.assertAlmostEqual(x_petsc.norm("l2"), direct_norm, 5)
77
71
 
78
72
if __name__ == "__main__":
79
73