/[escript]/trunk/escriptcore/test/python/test_linearPDEs.py
ViewVC logotype

Diff of /trunk/escriptcore/test/python/test_linearPDEs.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2548 by jfenwick, Mon Jul 20 06:20:06 2009 UTC revision 2995 by artak, Tue Mar 23 06:14:26 2010 UTC
# Line 1  Line 1 
1    
2  ########################################################  ########################################################
3  #  #
4  # Copyright (c) 2003-2009 by University of Queensland  # Copyright (c) 2003-2010 by University of Queensland
5  # Earth Systems Science Computational Center (ESSCC)  # Earth Systems Science Computational Center (ESSCC)
6  # http://www.uq.edu.au/esscc  # http://www.uq.edu.au/esscc
7  #  #
# Line 11  Line 11 
11  #  #
12  ########################################################  ########################################################
13    
14  __copyright__="""Copyright (c) 2003-2008 by University of Queensland  __copyright__="""Copyright (c) 2003-2010 by University of Queensland
15  Earth Systems Science Computational Center (ESSCC)  Earth Systems Science Computational Center (ESSCC)
16  http://www.uq.edu.au/esscc  http://www.uq.edu.au/esscc
17  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
# Line 34  The tests must be linked with a Domain c Line 34  The tests must be linked with a Domain c
34     suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley))     suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley))
35     unittest.TextTestRunner(verbosity=2).run(suite)     unittest.TextTestRunner(verbosity=2).run(suite)
36    
37  @var __author__: name of author  :var __author__: name of author
38  @var __copyright__: copyrights  :var __copyright__: copyrights
39  @var __license__: licence agreement  :var __license__: licence agreement
40  @var __url__: url entry point on documentation  :var __url__: url entry point on documentation
41  @var __version__: version  :var __version__: version
42  @var __date__: date of the version  :var __date__: date of the version
43  """  """
44    
45  __author__="Lutz Gross, l.gross@uq.edu.au"  __author__="Lutz Gross, l.gross@uq.edu.au"
# Line 57  class Test_linearPDEs(unittest.TestCase) Line 57  class Test_linearPDEs(unittest.TestCase)
57      VERBOSE=False      VERBOSE=False
58      def check(self,arg,ref_arg,tol=None):      def check(self,arg,ref_arg,tol=None):
59          """          """
60          checks if arg and ref_arg are nearly identical using the L{Lsup<esys.escript.util.Lsup>}          checks if arg and ref_arg are nearly identical using the `Lsup`
61          """          """
62          if tol==None: tol=self.TOL          if tol==None: tol=self.TOL
63          return Lsup(arg-ref_arg)<=tol*Lsup(ref_arg)          return Lsup(arg-ref_arg)<=tol*Lsup(ref_arg)
# Line 642  class Test_LinearPDE_noLumping(Test_line Line 642  class Test_LinearPDE_noLumping(Test_line
642      N=4      N=4
643      def test_SolverOptions(self):      def test_SolverOptions(self):
644          so=SolverOptions()          so=SolverOptions()
645            
646            self.failUnless(so.getSmoother() == 28, "initial Smoother is wrong.")
647            self.failUnlessRaises(ValueError,so.setSmoother,-1)
648            so.setSmoother(so.GAUSS_SEIDEL)
649            self.failUnless(so.getSmoother() == 28, "Gauss-Seidel smoother is not set.")
650            so.setSmoother(so.JACOBI)
651            self.failUnless(so.getSmoother() == 10, "Jacobi smoother is not set.")
652    
653          self.failUnless(so.getLevelMax() == 10, "initial  LevelMax is wrong.")          self.failUnless(so.getLevelMax() == 5, "initial  LevelMax is wrong.")
654          self.failUnlessRaises(ValueError,so.setLevelMax,-1)          self.failUnlessRaises(ValueError,so.setLevelMax,-1)
655          so.setLevelMax(3)          so.setLevelMax(20)
656          self.failUnless(so.getLevelMax() == 3, "LevelMax is wrong.")          self.failUnless(so.getLevelMax() == 20, "LevelMax is wrong.")
657    
658          self.failUnless(so.getCoarseningThreshold() == 0.05, "initial  CoarseningThreshold is wrong.")          self.failUnless(so.getCoarseningThreshold() == 0.25, "initial  CoarseningThreshold is wrong.")
659          self.failUnlessRaises(ValueError,so.setCoarseningThreshold,-1)          self.failUnlessRaises(ValueError,so.setCoarseningThreshold,-1)
660          so.setCoarseningThreshold(0.1)          so.setCoarseningThreshold(0.1)
661          self.failUnless(so.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")          self.failUnless(so.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")
# Line 824  class Test_LinearPDE_noLumping(Test_line Line 831  class Test_LinearPDE_noLumping(Test_line
831          self.failUnless(so.getSolverMethod() == 26, "TFQMR is not set.")          self.failUnless(so.getSolverMethod() == 26, "TFQMR is not set.")
832          so.setSolverMethod(so.MINRES)          so.setSolverMethod(so.MINRES)
833          self.failUnless(so.getSolverMethod() == 27, "MINRES is not set.")          self.failUnless(so.getSolverMethod() == 27, "MINRES is not set.")
         so.setSolverMethod(so.GAUSS_SEIDEL)  
         self.failUnless(so.getSolverMethod() == 28, "GAUSS_SEIDEL is not set.")  
834          so.setSolverMethod(so.DEFAULT)          so.setSolverMethod(so.DEFAULT)
835          self.failUnless(so.getSolverMethod() == 0, "DEFAULT is not set.")          self.failUnless(so.getSolverMethod() == 0, "DEFAULT is not set.")
836    
# Line 858  class Test_LinearPDE_noLumping(Test_line Line 863  class Test_LinearPDE_noLumping(Test_line
863          self.failUnless(so.getCoarsening() == 34, "RUGE_STUEBEN_COARSENING is not set.")          self.failUnless(so.getCoarsening() == 34, "RUGE_STUEBEN_COARSENING is not set.")
864          so.setCoarsening(so.AGGREGATION_COARSENING)          so.setCoarsening(so.AGGREGATION_COARSENING)
865          self.failUnless(so.getCoarsening() == 35, "AGREGATION_COARSENING is not set.")          self.failUnless(so.getCoarsening() == 35, "AGREGATION_COARSENING is not set.")
866            so.setCoarsening(so.STANDARD_COARSENING)
867            self.failUnless(so.getCoarsening() == 39, "STANDARD_COARSENING is not set.")
868          so.setCoarsening(so.DEFAULT)          so.setCoarsening(so.DEFAULT)
869          self.failUnless(so.getCoarsening() == 0, "DEFAULT is not set.")          self.failUnless(so.getCoarsening() == 0, "DEFAULT is not set.")
870    
# Line 1586  class Test_LinearPDE_noLumping(Test_line Line 1593  class Test_LinearPDE_noLumping(Test_line
1593      mypde.getSolverOptions().setVerbosity(self.VERBOSE)      mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1594          u=mypde.getSolution()          u=mypde.getSolution()
1595          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1596        def test_PCG_AMG(self):
1597            if self.order!=2:
1598                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1599                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1600                mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1601                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1602                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1603                u=mypde.getSolution()
1604                self.failUnless(self.check(u,1.),'solution is wrong.')
1605      def test_PCG_ILU0(self):      def test_PCG_ILU0(self):
1606          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1607          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
# Line 1625  class Test_LinearPDE_noLumping(Test_line Line 1641  class Test_LinearPDE_noLumping(Test_line
1641          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1642          u=mypde.getSolution()          u=mypde.getSolution()
1643          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1644        def test_BICGSTAB_AMG(self):
1645            if self.order!=2:
1646                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1647                mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1648                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1649                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1650                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1651                u=mypde.getSolution()
1652                self.failUnless(self.check(u,1.),'solution is wrong.')
1653      def test_BICGSTAB_ILU0(self):      def test_BICGSTAB_ILU0(self):
1654          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1655          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
# Line 1657  class Test_LinearPDE_noLumping(Test_line Line 1682  class Test_LinearPDE_noLumping(Test_line
1682          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1683          u=mypde.getSolution()          u=mypde.getSolution()
1684          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1685        def test_MINRES_AMG(self):
1686            if self.order!=2:
1687                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1688                mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1689                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1690                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1691                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1692                u=mypde.getSolution()
1693                self.failUnless(self.check(u,1.),'solution is wrong.')
1694      def test_MINRES_ILU0(self):      def test_MINRES_ILU0(self):
1695          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1696          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
# Line 1689  class Test_LinearPDE_noLumping(Test_line Line 1723  class Test_LinearPDE_noLumping(Test_line
1723          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1724          u=mypde.getSolution()          u=mypde.getSolution()
1725          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1726        def test_TFQMR_AMG(self):
1727            if self.order!=2:
1728                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1729                mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1730                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1731                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1732                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1733                u=mypde.getSolution()
1734                self.failUnless(self.check(u,1.),'solution is wrong.')
1735      def test_TFQMR_ILU0(self):      def test_TFQMR_ILU0(self):
1736          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1737          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
# Line 1721  class Test_LinearPDE_noLumping(Test_line Line 1764  class Test_LinearPDE_noLumping(Test_line
1764          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1765          u=mypde.getSolution()          u=mypde.getSolution()
1766          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1767        def test_PRES20_AMG(self):
1768            if self.order!=2:
1769                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1770                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1771                mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1772                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1773                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1774                u=mypde.getSolution()
1775                self.failUnless(self.check(u,1.),'solution is wrong.')
1776      def test_PRES20_ILU0(self):      def test_PRES20_ILU0(self):
1777          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1778          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
# Line 1754  class Test_LinearPDE_noLumping(Test_line Line 1806  class Test_LinearPDE_noLumping(Test_line
1806      mypde.getSolverOptions().setTruncation(50)      mypde.getSolverOptions().setTruncation(50)
1807          u=mypde.getSolution()          u=mypde.getSolution()
1808          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1809        def test_GMRESnoRestart_AMG(self):
1810            if self.order!=2:
1811                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1812                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1813                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1814                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1815                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1816                mypde.getSolverOptions().setTruncation(50)
1817                u=mypde.getSolution()
1818                self.failUnless(self.check(u,1.),'solution is wrong.')
1819      def test_GMRESnoRestart_ILU0(self):      def test_GMRESnoRestart_ILU0(self):
1820          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1821          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
# Line 1789  class Test_LinearPDE_noLumping(Test_line Line 1851  class Test_LinearPDE_noLumping(Test_line
1851          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1852          u=mypde.getSolution()          u=mypde.getSolution()
1853          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1854        def test_GMRES_AMG(self):
1855            if self.order!=2:
1856                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1857                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1858                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1859                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1860                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1861                u=mypde.getSolution()
1862                self.failUnless(self.check(u,1.),'solution is wrong.')        
1863      def test_GMRES_ILU0(self):      def test_GMRES_ILU0(self):
1864          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1865          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
# Line 1823  class Test_LinearPDE_noLumping(Test_line Line 1894  class Test_LinearPDE_noLumping(Test_line
1894      mypde.getSolverOptions().setRestart(20)      mypde.getSolverOptions().setRestart(20)
1895          u=mypde.getSolution()          u=mypde.getSolution()
1896          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1897        def test_GMRES_truncation_restart_AMG(self):
1898            if self.order!=2:
1899                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1900                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1901                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1902                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1903                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1904                mypde.getSolverOptions().setTruncation(10)
1905                mypde.getSolverOptions().setRestart(20)
1906                u=mypde.getSolution()
1907                self.failUnless(self.check(u,1.),'solution is wrong.')
1908      def test_GMRES_truncation_restart_ILU0(self):      def test_GMRES_truncation_restart_ILU0(self):
1909          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1910          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
# Line 1898  class Test_LinearPDE_noLumping(Test_line Line 1980  class Test_LinearPDE_noLumping(Test_line
1980          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1981          u=mypde.getSolution()          u=mypde.getSolution()
1982          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1983        def test_PCG_AMG_System(self):
1984            if self.order!=2:
1985                A=Tensor4(0.,Function(self.domain))
1986                D=Tensor(1.,Function(self.domain))
1987                Y=Vector(self.domain.getDim(),Function(self.domain))
1988                for i in range(self.domain.getDim()):
1989                    A[i,:,i,:]=kronecker(self.domain)
1990                    D[i,i]+=i
1991                    Y[i]+=i
1992                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1993                mypde.setValue(A=A,D=D,Y=Y)
1994                mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1995                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1996                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1997                u=mypde.getSolution()
1998                self.failUnless(self.check(u,1.),'solution is wrong.')
1999      def test_PCG_ILU0_System(self):      def test_PCG_ILU0_System(self):
2000          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2001          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1942  class Test_LinearPDE_noLumping(Test_line Line 2040  class Test_LinearPDE_noLumping(Test_line
2040          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2041          u=mypde.getSolution()          u=mypde.getSolution()
2042          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
2043        def test_BICGSTAB_AMG_System(self):
2044            if self.order!=2:
2045                A=Tensor4(0.,Function(self.domain))
2046                D=Tensor(1.,Function(self.domain))
2047                Y=Vector(self.domain.getDim(),Function(self.domain))
2048                for i in range(self.domain.getDim()):
2049                    A[i,:,i,:]=kronecker(self.domain)
2050                    D[i,i]+=i
2051                    Y[i]+=i
2052                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2053                mypde.setValue(A=A,D=D,Y=Y)
2054                mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
2055                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2056                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2057                u=mypde.getSolution()
2058                self.failUnless(self.check(u,1.),'solution is wrong.')
2059      def test_BICGSTAB_ILU0_System(self):      def test_BICGSTAB_ILU0_System(self):
2060          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2061          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1972  class Test_LinearPDE_noLumping(Test_line Line 2086  class Test_LinearPDE_noLumping(Test_line
2086          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2087          u=mypde.getSolution()          u=mypde.getSolution()
2088          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
2089        def test_PRES20_AMG_System(self):
2090            if self.order!=2:
2091                A=Tensor4(0.,Function(self.domain))
2092                D=Tensor(1.,Function(self.domain))
2093                Y=Vector(self.domain.getDim(),Function(self.domain))
2094                for i in range(self.domain.getDim()):
2095                    A[i,:,i,:]=kronecker(self.domain)
2096                    D[i,i]+=i
2097                    Y[i]+=i
2098                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2099                mypde.setValue(A=A,D=D,Y=Y)
2100                mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
2101                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2102                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2103                u=mypde.getSolution()
2104                self.failUnless(self.check(u,1.),'solution is wrong.')
2105      def test_PRES20_ILU0_System(self):      def test_PRES20_ILU0_System(self):
2106          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2107          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2003  class Test_LinearPDE_noLumping(Test_line Line 2133  class Test_LinearPDE_noLumping(Test_line
2133          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2134          u=mypde.getSolution()          u=mypde.getSolution()
2135          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
2136        def test_GMRESnoRestart_AMG_System(self):
2137            if self.order!=2:
2138                A=Tensor4(0.,Function(self.domain))
2139                D=Tensor(1.,Function(self.domain))
2140                Y=Vector(self.domain.getDim(),Function(self.domain))
2141                for i in range(self.domain.getDim()):
2142                    A[i,:,i,:]=kronecker(self.domain)
2143                    D[i,i]+=i
2144                    Y[i]+=i
2145                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2146                mypde.setValue(A=A,D=D,Y=Y)
2147                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2148                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2149                # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
2150                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2151                u=mypde.getSolution()
2152                self.failUnless(self.check(u,1.),'solution is wrong.')
2153      def test_GMRESnoRestart_ILU0_System(self):      def test_GMRESnoRestart_ILU0_System(self):
2154          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2155          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2034  class Test_LinearPDE_noLumping(Test_line Line 2181  class Test_LinearPDE_noLumping(Test_line
2181          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2182          u=mypde.getSolution()          u=mypde.getSolution()
2183          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
2184        def test_GMRES_AMG_System(self):
2185            if self.order!=2:
2186                A=Tensor4(0.,Function(self.domain))
2187                D=Tensor(1.,Function(self.domain))
2188                Y=Vector(self.domain.getDim(),Function(self.domain))
2189                for i in range(self.domain.getDim()):
2190                    A[i,:,i,:]=kronecker(self.domain)
2191                    D[i,i]+=i
2192                    Y[i]+=i
2193                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2194                mypde.setValue(A=A,D=D,Y=Y)
2195                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2196                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2197                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2198                u=mypde.getSolution()
2199                self.failUnless(self.check(u,1.),'solution is wrong.')
2200      def test_GMRES_ILU0_System(self):      def test_GMRES_ILU0_System(self):
2201          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2202          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2066  class Test_LinearPDE_noLumping(Test_line Line 2229  class Test_LinearPDE_noLumping(Test_line
2229      mypde.getSolverOptions().setRestart(20)      mypde.getSolverOptions().setRestart(20)
2230          u=mypde.getSolution()          u=mypde.getSolution()
2231          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
2232        def test_GMRES_truncation_restart_AMG_System(self):
2233            if self.order!=2:
2234                A=Tensor4(0.,Function(self.domain))
2235                D=Tensor(1.,Function(self.domain))
2236                Y=Vector(self.domain.getDim(),Function(self.domain))
2237                for i in range(self.domain.getDim()):
2238                    A[i,:,i,:]=kronecker(self.domain)
2239                    D[i,i]+=i
2240                    Y[i]+=i
2241                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2242                mypde.setValue(A=A,D=D,Y=Y)
2243                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2244                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2245                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2246                mypde.getSolverOptions().setTruncation(10)
2247                mypde.getSolverOptions().setRestart(20)
2248                u=mypde.getSolution()
2249                self.failUnless(self.check(u,1.),'solution is wrong.')
2250      def test_GMRES_truncation_restart_ILU0_System(self):      def test_GMRES_truncation_restart_ILU0_System(self):
2251          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2252          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2237  class Test_TransportPDE(Test_linearPDEs) Line 2418  class Test_TransportPDE(Test_linearPDEs)
2418          mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)          mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)
2419          mypde.setInitialSolution(1.)          mypde.setInitialSolution(1.)
2420    
     def test_setInitialSolution_scalar_negative(self):  
         mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)  
         self.failUnlessRaises(RuntimeError, mypde.setInitialSolution,-1.)  
   
2421      def test_setInitialSolution_scalar_WithWrongShape(self):      def test_setInitialSolution_scalar_WithWrongShape(self):
2422          mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)          mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)
2423          self.failUnlessRaises(ValueError,mypde.setInitialSolution,[1.,2.])          self.failUnlessRaises(ValueError,mypde.setInitialSolution,[1.,2.])
# Line 2249  class Test_TransportPDE(Test_linearPDEs) Line 2426  class Test_TransportPDE(Test_linearPDEs)
2426          mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)          mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)
2427          mypde.setInitialSolution([1.,2.])          mypde.setInitialSolution([1.,2.])
2428    
     def test_setInitialSolution_system(self):  
         mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)  
         self.failUnlessRaises(RuntimeError, mypde.setInitialSolution,[-1,2.])  
   
2429      def test_setInitialSolution_system_WithWrongShape(self):      def test_setInitialSolution_system_WithWrongShape(self):
2430          mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)          mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)
2431          self.failUnlessRaises(ValueError, mypde.setInitialSolution,1.)          self.failUnlessRaises(ValueError, mypde.setInitialSolution,1.)
2432    
   
2433      def test_attemptToChangeOrderAfterDefinedCoefficient(self):      def test_attemptToChangeOrderAfterDefinedCoefficient(self):
2434          mypde=TransportPDE(self.domain,debug=self.DEBUG)          mypde=TransportPDE(self.domain,debug=self.DEBUG)
2435          mypde.setValue(D=1.)          mypde.setValue(D=1.)

Legend:
Removed from v.2548  
changed lines
  Added in v.2995

  ViewVC Help
Powered by ViewVC 1.1.26