~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: 2015-03-17 07:57:11 UTC
  • mfrom: (1.1.18) (19.1.24 experimental)
  • Revision ID: package-import@ubuntu.com-20150317075711-1v207zbty9qmygow
Tags: 1.5.0-1
* New upstream release (closes: #780359).
* debian/control:
  - Bump Standards-Version to 3.9.6 (no changes needed).
  - Bump X-Python-Version to >= 2.7.
  - Update package names for new SONAME 1.5 (libdolfin1.4 ->
    libdolfin1.5, libdolfin1.4-dbg -> libdolfin1.5-dbg and
    libdolfin1.4-dev -> libdolfin1.5-dev).
  - Bump minimum required version for python-instant, python-ufl and
    python-ffc to 1.5.0.
  - Add python-sympy and python-six to Depends for binary package
    python-dolfin.
  - Add dh-python to Build-Depends.
  - Remove libcgal-dev from {Build-}Depends.
* Remove CSGCGALMeshGenerator3D-oom.patch since CGAL is no longer used
  by DOLFIN.
* Move debian/libdolfin1.4.install -> debian/libdolfin1.5.install.
* debian/rules: No longer any non DFSG-free stuff to remove, so update
  get-orig-source target (update debian/watch accordingly).
* Update debian/copyright and debian/copyright_hints.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""Unit tests for the KrylovSolver interface"""
2
 
 
3
 
# Copyright (C) 2012 Johan Hake
4
 
#
5
 
# This file is part of DOLFIN.
6
 
#
7
 
# DOLFIN is free software: you can redistribute it and/or modify
8
 
# it under the terms of the GNU Lesser General Public License as published by
9
 
# the Free Software Foundation, either version 3 of the License, or
10
 
# (at your option) any later version.
11
 
#
12
 
# DOLFIN is distributed in the hope that it will be useful,
13
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 
# GNU Lesser General Public License for more details.
16
 
#
17
 
# You should have received a copy of the GNU Lesser General Public License
18
 
# along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
19
 
#
20
 
# Modified by Anders Logg 2012
21
 
#
22
 
# First added:  2012-02-21
23
 
# Last changed: 2014-05-30
24
 
 
25
 
import unittest
26
 
from dolfin import *
27
 
 
28
 
# Assemble system
29
 
mesh = UnitSquareMesh(32, 32)
30
 
V = FunctionSpace(mesh, 'CG', 1)
31
 
bc = DirichletBC(V, Constant(0.0), lambda x, on_boundary: on_boundary)
32
 
u = TrialFunction(V)
33
 
v = TestFunction(V)
34
 
u1 = Function(V)
35
 
 
36
 
# Forms
37
 
a, L = inner(grad(u), grad(v))*dx, Constant(1.0)*v*dx
38
 
a_L = inner(grad(u1), grad(v))*dx
39
 
 
40
 
# Assemble linear algebra objects
41
 
A = assemble(a)
42
 
b = assemble(L)
43
 
bc.apply(A, b)
44
 
 
45
 
if has_linear_algebra_backend("PETSc"):
46
 
    class PETScKrylovSolverTester(unittest.TestCase):
47
 
 
48
 
        def test_krylov_solver(self):
49
 
            "Test PETScKrylovSolver"
50
 
            # Get solution vector
51
 
            tmp = Function(V)
52
 
            #x = tmp.vector()
53
 
 
54
 
            # Solve first using direct solver
55
 
            #solve(A, x, b, "lu")
56
 
 
57
 
            #direct_norm = x.norm("l2")
58
 
 
59
 
            # Get solution vector
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)
71
 
 
72
 
if __name__ == "__main__":
73
 
 
74
 
    # Turn off DOLFIN output
75
 
    set_log_active(False)
76
 
 
77
 
    print ""
78
 
    print "Testing DOLFIN la/KrylovSolver interface"
79
 
    print "----------------------------------------"
80
 
    unittest.main()