/[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 3103 by gross, Tue Aug 24 07:01:33 2010 UTC
# Line 1  Line 1 
1    # -*- coding: utf-8 -*-
2    
3  ########################################################  ########################################################
4  #  #
5  # Copyright (c) 2003-2009 by University of Queensland  # Copyright (c) 2003-2010 by University of Queensland
6  # Earth Systems Science Computational Center (ESSCC)  # Earth Systems Science Computational Center (ESSCC)
7  # http://www.uq.edu.au/esscc  # http://www.uq.edu.au/esscc
8  #  #
# Line 11  Line 12 
12  #  #
13  ########################################################  ########################################################
14    
15  __copyright__="""Copyright (c) 2003-2008 by University of Queensland  __copyright__="""Copyright (c) 2003-2010 by University of Queensland
16  Earth Systems Science Computational Center (ESSCC)  Earth Systems Science Computational Center (ESSCC)
17  http://www.uq.edu.au/esscc  http://www.uq.edu.au/esscc
18  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
# Line 34  The tests must be linked with a Domain c Line 35  The tests must be linked with a Domain c
35     suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley))     suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley))
36     unittest.TextTestRunner(verbosity=2).run(suite)     unittest.TextTestRunner(verbosity=2).run(suite)
37    
38  @var __author__: name of author  :var __author__: name of author
39  @var __copyright__: copyrights  :var __copyright__: copyrights
40  @var __license__: licence agreement  :var __license__: licence agreement
41  @var __url__: url entry point on documentation  :var __url__: url entry point on documentation
42  @var __version__: version  :var __version__: version
43  @var __date__: date of the version  :var __date__: date of the version
44  """  """
45    
46  __author__="Lutz Gross, l.gross@uq.edu.au"  __author__="Lutz Gross, l.gross@uq.edu.au"
# Line 57  class Test_linearPDEs(unittest.TestCase) Line 58  class Test_linearPDEs(unittest.TestCase)
58      VERBOSE=False      VERBOSE=False
59      def check(self,arg,ref_arg,tol=None):      def check(self,arg,ref_arg,tol=None):
60          """          """
61          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`
62          """          """
63          if tol==None: tol=self.TOL          if tol==None: tol=self.TOL
64          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 643  class Test_LinearPDE_noLumping(Test_line
643      N=4      N=4
644      def test_SolverOptions(self):      def test_SolverOptions(self):
645          so=SolverOptions()          so=SolverOptions()
646            
647            self.failUnless(so.getSmoother() == 28, "initial Smoother is wrong.")
648            self.failUnlessRaises(ValueError,so.setSmoother,-1)
649            so.setSmoother(so.GAUSS_SEIDEL)
650            self.failUnless(so.getSmoother() == 28, "Gauss-Seidel smoother is not set.")
651            so.setSmoother(so.JACOBI)
652            self.failUnless(so.getSmoother() == 10, "Jacobi smoother is not set.")
653    
654          self.failUnless(so.getLevelMax() == 10, "initial  LevelMax is wrong.")          self.failUnless(so.getLevelMax() == 5, "initial  LevelMax is wrong.")
655          self.failUnlessRaises(ValueError,so.setLevelMax,-1)          self.failUnlessRaises(ValueError,so.setLevelMax,-1)
656          so.setLevelMax(3)          so.setLevelMax(20)
657          self.failUnless(so.getLevelMax() == 3, "LevelMax is wrong.")          self.failUnless(so.getLevelMax() == 20, "LevelMax is wrong.")
658    
659          self.failUnless(so.getCoarseningThreshold() == 0.05, "initial  CoarseningThreshold is wrong.")          self.failUnless(so.getCoarseningThreshold() == 0.25, "initial  CoarseningThreshold is wrong.")
660          self.failUnlessRaises(ValueError,so.setCoarseningThreshold,-1)          self.failUnlessRaises(ValueError,so.setCoarseningThreshold,-1)
661          so.setCoarseningThreshold(0.1)          so.setCoarseningThreshold(0.1)
662          self.failUnless(so.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")          self.failUnless(so.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")
# Line 806  class Test_LinearPDE_noLumping(Test_line Line 814  class Test_LinearPDE_noLumping(Test_line
814          self.failUnless(so.getSolverMethod() == 5, "CGS is not set.")          self.failUnless(so.getSolverMethod() == 5, "CGS is not set.")
815          so.setSolverMethod(so.BICGSTAB)          so.setSolverMethod(so.BICGSTAB)
816          self.failUnless(so.getSolverMethod() == 6, "BICGSTAB is not set.")          self.failUnless(so.getSolverMethod() == 6, "BICGSTAB is not set.")
         so.setSolverMethod(so.SSOR)  
         self.failUnless(so.getSolverMethod() == 7, "SSOR is not set.")  
817          so.setSolverMethod(so.GMRES)          so.setSolverMethod(so.GMRES)
818          self.failUnless(so.getSolverMethod() == 11, "GMRES is not set.")          self.failUnless(so.getSolverMethod() == 11, "GMRES is not set.")
819          so.setSolverMethod(so.PRES20)          so.setSolverMethod(so.PRES20)
# Line 816  class Test_LinearPDE_noLumping(Test_line Line 822  class Test_LinearPDE_noLumping(Test_line
822          self.failUnless(so.getSolverMethod() == 13, "LUMPING is not set.")          self.failUnless(so.getSolverMethod() == 13, "LUMPING is not set.")
823          so.setSolverMethod(so.ITERATIVE)          so.setSolverMethod(so.ITERATIVE)
824          self.failUnless(so.getSolverMethod() == 20, "ITERATIVE is not set.")          self.failUnless(so.getSolverMethod() == 20, "ITERATIVE is not set.")
         so.setSolverMethod(so.AMG)  
         self.failUnless(so.getSolverMethod() == 22, "AMG is not set.")  
825          so.setSolverMethod(so.NONLINEAR_GMRES)          so.setSolverMethod(so.NONLINEAR_GMRES)
826          self.failUnless(so.getSolverMethod() == 25, "NONLINEAR_GMRES is not set.")          self.failUnless(so.getSolverMethod() == 25, "NONLINEAR_GMRES is not set.")
827          so.setSolverMethod(so.TFQMR)          so.setSolverMethod(so.TFQMR)
828          self.failUnless(so.getSolverMethod() == 26, "TFQMR is not set.")          self.failUnless(so.getSolverMethod() == 26, "TFQMR is not set.")
829          so.setSolverMethod(so.MINRES)          so.setSolverMethod(so.MINRES)
830          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.")  
831          so.setSolverMethod(so.DEFAULT)          so.setSolverMethod(so.DEFAULT)
832          self.failUnless(so.getSolverMethod() == 0, "DEFAULT is not set.")          self.failUnless(so.getSolverMethod() == 0, "DEFAULT is not set.")
833    
# Line 833  class Test_LinearPDE_noLumping(Test_line Line 835  class Test_LinearPDE_noLumping(Test_line
835          self.failUnlessRaises(ValueError,so.setPreconditioner,-1)          self.failUnlessRaises(ValueError,so.setPreconditioner,-1)
836          so.setPreconditioner(so.ILU0)          so.setPreconditioner(so.ILU0)
837          self.failUnless(so.getPreconditioner() == 8, "ILU0 is not set.")          self.failUnless(so.getPreconditioner() == 8, "ILU0 is not set.")
         so.setPreconditioner(so.SSOR)  
         self.failUnless(so.getPreconditioner() == 7, "SSOR is not set.")  
838          so.setPreconditioner(so.ILUT)          so.setPreconditioner(so.ILUT)
839          self.failUnless(so.getPreconditioner() == 9, "ILUT is not set.")          self.failUnless(so.getPreconditioner() == 9, "ILUT is not set.")
840          so.setPreconditioner(so.JACOBI)          so.setPreconditioner(so.JACOBI)
# Line 847  class Test_LinearPDE_noLumping(Test_line Line 847  class Test_LinearPDE_noLumping(Test_line
847          self.failUnless(so.getPreconditioner() == 28, "GAUSS_SEIDEL is not set.")          self.failUnless(so.getPreconditioner() == 28, "GAUSS_SEIDEL is not set.")
848          so.setPreconditioner(so.RILU)          so.setPreconditioner(so.RILU)
849          self.failUnless(so.getPreconditioner() == 29, "RILU is not set.")          self.failUnless(so.getPreconditioner() == 29, "RILU is not set.")
850            so.setPreconditioner(so.AMLI)
851            self.failUnless(so.getPreconditioner() == 38, "AMLI is not set.")
852          so.setPreconditioner(so.NO_PRECONDITIONER)          so.setPreconditioner(so.NO_PRECONDITIONER)
853          self.failUnless(so.getPreconditioner() == 36, "NO_PRECONDITIONER is not set.")                  self.failUnless(so.getPreconditioner() == 36, "NO_PRECONDITIONER is not set.")        
854    
# Line 858  class Test_LinearPDE_noLumping(Test_line Line 860  class Test_LinearPDE_noLumping(Test_line
860          self.failUnless(so.getCoarsening() == 34, "RUGE_STUEBEN_COARSENING is not set.")          self.failUnless(so.getCoarsening() == 34, "RUGE_STUEBEN_COARSENING is not set.")
861          so.setCoarsening(so.AGGREGATION_COARSENING)          so.setCoarsening(so.AGGREGATION_COARSENING)
862          self.failUnless(so.getCoarsening() == 35, "AGREGATION_COARSENING is not set.")          self.failUnless(so.getCoarsening() == 35, "AGREGATION_COARSENING is not set.")
863            so.setCoarsening(so.STANDARD_COARSENING)
864            self.failUnless(so.getCoarsening() == 39, "STANDARD_COARSENING is not set.")
865          so.setCoarsening(so.DEFAULT)          so.setCoarsening(so.DEFAULT)
866          self.failUnless(so.getCoarsening() == 0, "DEFAULT is not set.")          self.failUnless(so.getCoarsening() == 0, "DEFAULT is not set.")
867    
# Line 1586  class Test_LinearPDE_noLumping(Test_line Line 1590  class Test_LinearPDE_noLumping(Test_line
1590      mypde.getSolverOptions().setVerbosity(self.VERBOSE)      mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1591          u=mypde.getSolution()          u=mypde.getSolution()
1592          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1593        def test_PCG_GAUSS_SEIDEL(self):
1594            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1595            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1596            mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1597        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1598        mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1599            u=mypde.getSolution()
1600            self.failUnless(self.check(u,1.),'solution is wrong.')
1601        def test_PCG_AMG(self):
1602            if self.order!=2:
1603                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1604                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1605                mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1606                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1607                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1608                u=mypde.getSolution()
1609                self.failUnless(self.check(u,1.),'solution is wrong.')
1610      def test_PCG_ILU0(self):      def test_PCG_ILU0(self):
1611          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1612          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 1646  class Test_LinearPDE_noLumping(Test_line
1646          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1647          u=mypde.getSolution()          u=mypde.getSolution()
1648          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1649        def test_BICGSTAB_GAUSS_SEIDEL(self):
1650            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1651        mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1652        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1653            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1654            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1655            u=mypde.getSolution()
1656            self.failUnless(self.check(u,1.),'solution is wrong.')
1657        def test_BICGSTAB_AMG(self):
1658            if self.order!=2:
1659                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1660                mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1661                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1662                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1663                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1664                u=mypde.getSolution()
1665                self.failUnless(self.check(u,1.),'solution is wrong.')
1666      def test_BICGSTAB_ILU0(self):      def test_BICGSTAB_ILU0(self):
1667          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1668          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 1695  class Test_LinearPDE_noLumping(Test_line
1695          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1696          u=mypde.getSolution()          u=mypde.getSolution()
1697          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1698        def test_MINRES_GAUSS_SEIDEL(self):
1699            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1700        mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1701        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1702            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1703            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1704            u=mypde.getSolution()
1705            self.failUnless(self.check(u,1.),'solution is wrong.')
1706        def test_MINRES_AMG(self):
1707            if self.order!=2:
1708                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1709                mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1710                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1711                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1712                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1713                u=mypde.getSolution()
1714                self.failUnless(self.check(u,1.),'solution is wrong.')
1715      def test_MINRES_ILU0(self):      def test_MINRES_ILU0(self):
1716          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1717          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 1744  class Test_LinearPDE_noLumping(Test_line
1744          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1745          u=mypde.getSolution()          u=mypde.getSolution()
1746          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1747        def test_TFQMR_GAUSS_SEIDEL(self):
1748            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1749        mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1750        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1751            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1752            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1753            u=mypde.getSolution()
1754            self.failUnless(self.check(u,1.),'solution is wrong.')
1755        def test_TFQMR_AMG(self):
1756            if self.order!=2:
1757                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1758                mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1759                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1760                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1761                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1762                u=mypde.getSolution()
1763                self.failUnless(self.check(u,1.),'solution is wrong.')
1764      def test_TFQMR_ILU0(self):      def test_TFQMR_ILU0(self):
1765          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1766          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 1793  class Test_LinearPDE_noLumping(Test_line
1793          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1794          u=mypde.getSolution()          u=mypde.getSolution()
1795          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1796        def test_PRES20_GAUSS_SEIDEL(self):
1797            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1798            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1799        mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1800        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1801            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1802            u=mypde.getSolution()
1803            self.failUnless(self.check(u,1.),'solution is wrong.')
1804        def test_PRES20_AMG(self):
1805            if self.order!=2:
1806                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1807                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1808                mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1809                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1810                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1811                u=mypde.getSolution()
1812                self.failUnless(self.check(u,1.),'solution is wrong.')
1813      def test_PRES20_ILU0(self):      def test_PRES20_ILU0(self):
1814          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1815          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 1843  class Test_LinearPDE_noLumping(Test_line
1843      mypde.getSolverOptions().setTruncation(50)      mypde.getSolverOptions().setTruncation(50)
1844          u=mypde.getSolution()          u=mypde.getSolution()
1845          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1846        def test_GMRESnoRestart_GAUSS_SEIDEL(self):
1847            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1848            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1849        mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1850        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1851        mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1852        mypde.getSolverOptions().setTruncation(50)
1853            u=mypde.getSolution()
1854            self.failUnless(self.check(u,1.),'solution is wrong.')
1855        def test_GMRESnoRestart_AMG(self):
1856            if self.order!=2:
1857                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1858                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1859                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1860                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1861                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1862                mypde.getSolverOptions().setTruncation(50)
1863                u=mypde.getSolution()
1864                self.failUnless(self.check(u,1.),'solution is wrong.')
1865      def test_GMRESnoRestart_ILU0(self):      def test_GMRESnoRestart_ILU0(self):
1866          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1867          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 1897  class Test_LinearPDE_noLumping(Test_line
1897          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1898          u=mypde.getSolution()          u=mypde.getSolution()
1899          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1900        def test_GMRES_GAUSS_SEIDEL(self):
1901            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1902            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1903        mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1904        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1905            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1906            u=mypde.getSolution()
1907            self.failUnless(self.check(u,1.),'solution is wrong.')
1908        def test_GMRES_AMG(self):
1909            if self.order!=2:
1910                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1911                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1912                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1913                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1914                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1915                u=mypde.getSolution()
1916                self.failUnless(self.check(u,1.),'solution is wrong.')        
1917      def test_GMRES_ILU0(self):      def test_GMRES_ILU0(self):
1918          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1919          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 1948  class Test_LinearPDE_noLumping(Test_line
1948      mypde.getSolverOptions().setRestart(20)      mypde.getSolverOptions().setRestart(20)
1949          u=mypde.getSolution()          u=mypde.getSolution()
1950          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
1951        def test_GMRES_truncation_restart_GAUSS_SEIDEL(self):
1952            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1953            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1954        mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1955        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1956        mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1957        mypde.getSolverOptions().setTruncation(10)
1958        mypde.getSolverOptions().setRestart(20)
1959            u=mypde.getSolution()
1960            self.failUnless(self.check(u,1.),'solution is wrong.')
1961        def test_GMRES_truncation_restart_AMG(self):
1962            if self.order!=2:
1963                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1964                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1965                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1966                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1967                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1968                mypde.getSolverOptions().setTruncation(10)
1969                mypde.getSolverOptions().setRestart(20)
1970                u=mypde.getSolution()
1971                self.failUnless(self.check(u,1.),'solution is wrong.')
1972      def test_GMRES_truncation_restart_ILU0(self):      def test_GMRES_truncation_restart_ILU0(self):
1973          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1974          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 2044  class Test_LinearPDE_noLumping(Test_line
2044          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2045          u=mypde.getSolution()          u=mypde.getSolution()
2046          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
2047        def test_PCG_GAUSS_SEIDEL_System(self):
2048            A=Tensor4(0.,Function(self.domain))
2049            D=Tensor(1.,Function(self.domain))
2050            Y=Vector(self.domain.getDim(),Function(self.domain))
2051            for i in range(self.domain.getDim()):
2052                A[i,:,i,:]=kronecker(self.domain)
2053                D[i,i]+=i
2054                Y[i]+=i
2055            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2056            mypde.setValue(A=A,D=D,Y=Y)
2057            mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
2058        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2059            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2060            u=mypde.getSolution()
2061            self.failUnless(self.check(u,1.),'solution is wrong.')
2062        def test_PCG_AMG_System(self):
2063            if self.order!=2:
2064                A=Tensor4(0.,Function(self.domain))
2065                D=Tensor(1.,Function(self.domain))
2066                Y=Vector(self.domain.getDim(),Function(self.domain))
2067                for i in range(self.domain.getDim()):
2068                    A[i,:,i,:]=kronecker(self.domain)
2069                    D[i,i]+=i
2070                    Y[i]+=i
2071                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2072                mypde.setValue(A=A,D=D,Y=Y)
2073                mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
2074                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2075                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2076                u=mypde.getSolution()
2077                self.failUnless(self.check(u,1.),'solution is wrong.')
2078      def test_PCG_ILU0_System(self):      def test_PCG_ILU0_System(self):
2079          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2080          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1942  class Test_LinearPDE_noLumping(Test_line Line 2119  class Test_LinearPDE_noLumping(Test_line
2119          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2120          u=mypde.getSolution()          u=mypde.getSolution()
2121          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
2122        def test_BICGSTAB_GAUSS_SEIDEL_System(self):
2123            A=Tensor4(0.,Function(self.domain))
2124            D=Tensor(1.,Function(self.domain))
2125            Y=Vector(self.domain.getDim(),Function(self.domain))
2126            for i in range(self.domain.getDim()):
2127                A[i,:,i,:]=kronecker(self.domain)
2128                D[i,i]+=i
2129                Y[i]+=i
2130            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2131            mypde.setValue(A=A,D=D,Y=Y)
2132        mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
2133        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2134            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2135            u=mypde.getSolution()
2136            self.failUnless(self.check(u,1.),'solution is wrong.')
2137        def test_BICGSTAB_AMG_System(self):
2138            if self.order!=2:
2139                A=Tensor4(0.,Function(self.domain))
2140                D=Tensor(1.,Function(self.domain))
2141                Y=Vector(self.domain.getDim(),Function(self.domain))
2142                for i in range(self.domain.getDim()):
2143                    A[i,:,i,:]=kronecker(self.domain)
2144                    D[i,i]+=i
2145                    Y[i]+=i
2146                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2147                mypde.setValue(A=A,D=D,Y=Y)
2148                mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
2149                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2150                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2151                u=mypde.getSolution()
2152                self.failUnless(self.check(u,1.),'solution is wrong.')
2153      def test_BICGSTAB_ILU0_System(self):      def test_BICGSTAB_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 1972  class Test_LinearPDE_noLumping(Test_line Line 2180  class Test_LinearPDE_noLumping(Test_line
2180          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2181          u=mypde.getSolution()          u=mypde.getSolution()
2182          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
2183        def test_PRES20_GAUSS_SEIDEL_System(self):
2184            A=Tensor4(0.,Function(self.domain))
2185            D=Tensor(1.,Function(self.domain))
2186            Y=Vector(self.domain.getDim(),Function(self.domain))
2187            for i in range(self.domain.getDim()):
2188                A[i,:,i,:]=kronecker(self.domain)
2189                D[i,i]+=i
2190                Y[i]+=i
2191            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2192            mypde.setValue(A=A,D=D,Y=Y)
2193        mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
2194        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2195            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2196            u=mypde.getSolution()
2197            self.failUnless(self.check(u,1.),'solution is wrong.')
2198        def test_PRES20_AMG_System(self):
2199            if self.order!=2:
2200                A=Tensor4(0.,Function(self.domain))
2201                D=Tensor(1.,Function(self.domain))
2202                Y=Vector(self.domain.getDim(),Function(self.domain))
2203                for i in range(self.domain.getDim()):
2204                    A[i,:,i,:]=kronecker(self.domain)
2205                    D[i,i]+=i
2206                    Y[i]+=i
2207                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2208                mypde.setValue(A=A,D=D,Y=Y)
2209                mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
2210                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2211                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2212                u=mypde.getSolution()
2213                self.failUnless(self.check(u,1.),'solution is wrong.')
2214      def test_PRES20_ILU0_System(self):      def test_PRES20_ILU0_System(self):
2215          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2216          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2003  class Test_LinearPDE_noLumping(Test_line Line 2242  class Test_LinearPDE_noLumping(Test_line
2242          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2243          u=mypde.getSolution()          u=mypde.getSolution()
2244          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
2245        def test_GMRESnoRestart_GAUSS_SEIDEL_System(self):
2246            A=Tensor4(0.,Function(self.domain))
2247            D=Tensor(1.,Function(self.domain))
2248            Y=Vector(self.domain.getDim(),Function(self.domain))
2249            for i in range(self.domain.getDim()):
2250                A[i,:,i,:]=kronecker(self.domain)
2251                D[i,i]+=i
2252                Y[i]+=i
2253            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2254            mypde.setValue(A=A,D=D,Y=Y)
2255        mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2256        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2257            # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
2258            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2259            u=mypde.getSolution()
2260            self.failUnless(self.check(u,1.),'solution is wrong.')
2261        def test_GMRESnoRestart_AMG_System(self):
2262            if self.order!=2:
2263                A=Tensor4(0.,Function(self.domain))
2264                D=Tensor(1.,Function(self.domain))
2265                Y=Vector(self.domain.getDim(),Function(self.domain))
2266                for i in range(self.domain.getDim()):
2267                    A[i,:,i,:]=kronecker(self.domain)
2268                    D[i,i]+=i
2269                    Y[i]+=i
2270                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2271                mypde.setValue(A=A,D=D,Y=Y)
2272                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2273                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2274                # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
2275                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2276                u=mypde.getSolution()
2277                self.failUnless(self.check(u,1.),'solution is wrong.')
2278      def test_GMRESnoRestart_ILU0_System(self):      def test_GMRESnoRestart_ILU0_System(self):
2279          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2280          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2034  class Test_LinearPDE_noLumping(Test_line Line 2306  class Test_LinearPDE_noLumping(Test_line
2306          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2307          u=mypde.getSolution()          u=mypde.getSolution()
2308          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
2309        def test_GMRES_GAUSS_SEIDEL_System(self):
2310            A=Tensor4(0.,Function(self.domain))
2311            D=Tensor(1.,Function(self.domain))
2312            Y=Vector(self.domain.getDim(),Function(self.domain))
2313            for i in range(self.domain.getDim()):
2314                A[i,:,i,:]=kronecker(self.domain)
2315                D[i,i]+=i
2316                Y[i]+=i
2317            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2318            mypde.setValue(A=A,D=D,Y=Y)
2319        mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2320        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2321            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2322            u=mypde.getSolution()
2323            self.failUnless(self.check(u,1.),'solution is wrong.')
2324        def test_GMRES_AMG_System(self):
2325            if self.order!=2:
2326                A=Tensor4(0.,Function(self.domain))
2327                D=Tensor(1.,Function(self.domain))
2328                Y=Vector(self.domain.getDim(),Function(self.domain))
2329                for i in range(self.domain.getDim()):
2330                    A[i,:,i,:]=kronecker(self.domain)
2331                    D[i,i]+=i
2332                    Y[i]+=i
2333                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2334                mypde.setValue(A=A,D=D,Y=Y)
2335                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2336                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2337                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2338                u=mypde.getSolution()
2339                self.failUnless(self.check(u,1.),'solution is wrong.')
2340      def test_GMRES_ILU0_System(self):      def test_GMRES_ILU0_System(self):
2341          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2342          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2066  class Test_LinearPDE_noLumping(Test_line Line 2369  class Test_LinearPDE_noLumping(Test_line
2369      mypde.getSolverOptions().setRestart(20)      mypde.getSolverOptions().setRestart(20)
2370          u=mypde.getSolution()          u=mypde.getSolution()
2371          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
2372        def test_GMRES_truncation_restart_GAUSS_SEIDEL_System(self):
2373            A=Tensor4(0.,Function(self.domain))
2374            D=Tensor(1.,Function(self.domain))
2375            Y=Vector(self.domain.getDim(),Function(self.domain))
2376            for i in range(self.domain.getDim()):
2377                A[i,:,i,:]=kronecker(self.domain)
2378                D[i,i]+=i
2379                Y[i]+=i
2380            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2381            mypde.setValue(A=A,D=D,Y=Y)
2382        mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2383        mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2384            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2385        mypde.getSolverOptions().setTruncation(10)
2386        mypde.getSolverOptions().setRestart(20)
2387            u=mypde.getSolution()
2388            self.failUnless(self.check(u,1.),'solution is wrong.')
2389        def test_GMRES_truncation_restart_AMG_System(self):
2390            if self.order!=2:
2391                A=Tensor4(0.,Function(self.domain))
2392                D=Tensor(1.,Function(self.domain))
2393                Y=Vector(self.domain.getDim(),Function(self.domain))
2394                for i in range(self.domain.getDim()):
2395                    A[i,:,i,:]=kronecker(self.domain)
2396                    D[i,i]+=i
2397                    Y[i]+=i
2398                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2399                mypde.setValue(A=A,D=D,Y=Y)
2400                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2401                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2402                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2403                mypde.getSolverOptions().setTruncation(10)
2404                mypde.getSolverOptions().setRestart(20)
2405                u=mypde.getSolution()
2406                self.failUnless(self.check(u,1.),'solution is wrong.')
2407      def test_GMRES_truncation_restart_ILU0_System(self):      def test_GMRES_truncation_restart_ILU0_System(self):
2408          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2409          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2237  class Test_TransportPDE(Test_linearPDEs) Line 2575  class Test_TransportPDE(Test_linearPDEs)
2575          mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)          mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)
2576          mypde.setInitialSolution(1.)          mypde.setInitialSolution(1.)
2577    
     def test_setInitialSolution_scalar_negative(self):  
         mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)  
         self.failUnlessRaises(RuntimeError, mypde.setInitialSolution,-1.)  
   
2578      def test_setInitialSolution_scalar_WithWrongShape(self):      def test_setInitialSolution_scalar_WithWrongShape(self):
2579          mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)          mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)
2580          self.failUnlessRaises(ValueError,mypde.setInitialSolution,[1.,2.])          self.failUnlessRaises(ValueError,mypde.setInitialSolution,[1.,2.])
# Line 2249  class Test_TransportPDE(Test_linearPDEs) Line 2583  class Test_TransportPDE(Test_linearPDEs)
2583          mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)          mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)
2584          mypde.setInitialSolution([1.,2.])          mypde.setInitialSolution([1.,2.])
2585    
     def test_setInitialSolution_system(self):  
         mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)  
         self.failUnlessRaises(RuntimeError, mypde.setInitialSolution,[-1,2.])  
   
2586      def test_setInitialSolution_system_WithWrongShape(self):      def test_setInitialSolution_system_WithWrongShape(self):
2587          mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)          mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)
2588          self.failUnlessRaises(ValueError, mypde.setInitialSolution,1.)          self.failUnlessRaises(ValueError, mypde.setInitialSolution,1.)
2589    
   
2590      def test_attemptToChangeOrderAfterDefinedCoefficient(self):      def test_attemptToChangeOrderAfterDefinedCoefficient(self):
2591          mypde=TransportPDE(self.domain,debug=self.DEBUG)          mypde=TransportPDE(self.domain,debug=self.DEBUG)
2592          mypde.setValue(D=1.)          mypde.setValue(D=1.)

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

  ViewVC Help
Powered by ViewVC 1.1.26