/[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 1072 by gross, Thu Mar 29 06:44:30 2007 UTC revision 1312 by ksteube, Mon Sep 24 06:18:44 2007 UTC
# Line 1  Line 1 
1    #
2  # $Id$  # $Id$
3    #
4    #######################################################
5    #
6    #           Copyright 2003-2007 by ACceSS MNRF
7    #       Copyright 2007 by University of Queensland
8    #
9    #                http://esscc.uq.edu.au
10    #        Primary Business: Queensland, Australia
11    #  Licensed under the Open Software License version 3.0
12    #     http://www.opensource.org/licenses/osl-3.0.php
13    #
14    #######################################################
15    #
16    
17  """  """
18  Test suite for linearPDEs class  Test suite for linearPDEs class
# Line 36  __date__="$Date$" Line 50  __date__="$Date$"
50    
51    
52  from esys.escript.util import Lsup,kronecker,interpolate,whereZero  from esys.escript.util import Lsup,kronecker,interpolate,whereZero
53  from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar, ReducedFunction,ReducedFunctionOnBoundary,ReducedFunctionOnContactZero,Data  from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar, ReducedFunction,ReducedFunctionOnBoundary,ReducedFunctionOnContactZero,Data, Tensor4, Tensor
54  from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace  from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace
55  import numarray  import numarray
56  import unittest  import unittest
# Line 783  class Test_LinearPDE_noLumping(Test_line Line 797  class Test_LinearPDE_noLumping(Test_line
797          mypde.setValue(B_reduced=B,C_reduced=C)          mypde.setValue(B_reduced=B,C_reduced=C)
798          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
799      #      #
800      #   solver checks:      #   solver checks (single PDE)
801      #      #
802      def test_symmetryOnIterative(self):      def test_symmetryOnIterative(self):
803          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
# Line 876  class Test_LinearPDE_noLumping(Test_line Line 890  class Test_LinearPDE_noLumping(Test_line
890      mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)      mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
891          u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)          u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
892          self.failUnless(self.check(u,1.),'solution is wrong.')          self.failUnless(self.check(u,1.),'solution is wrong.')
893        #
894        #   solver checks (PDE system)
895        #
896        def test_symmetryOnIterative_System(self):
897            A=Tensor4(0.,Function(self.domain))
898            D=Tensor(1.,Function(self.domain))
899            Y=Vector(self.domain.getDim(),Function(self.domain))
900            for i in range(self.domain.getDim()):
901                A[i,:,i,:]=kronecker(self.domain)
902                D[i,i]+=i
903                Y[i]+=i
904            mypde=LinearPDE(self.domain,debug=self.DEBUG)
905            mypde.setValue(A=A,D=D,Y=Y)
906            u=mypde.getSolution(verbose=self.VERBOSE)
907            self.failUnless(self.check(u,1.),'solution is wrong.')
908        def test_symmetryOnDirect_System(self):
909            A=Tensor4(0.,Function(self.domain))
910            D=Tensor(1.,Function(self.domain))
911            Y=Vector(self.domain.getDim(),Function(self.domain))
912            for i in range(self.domain.getDim()):
913                A[i,:,i,:]=kronecker(self.domain)
914                D[i,i]+=i
915                Y[i]+=i
916            mypde=LinearPDE(self.domain,debug=self.DEBUG)
917            mypde.setValue(A=A,D=D,Y=Y)
918            mypde.setSolverMethod(mypde.DIRECT)
919            u=mypde.getSolution(verbose=self.VERBOSE)
920            self.failUnless(self.check(u,1.),'solution is wrong.')
921        def test_PCG_JACOBI_System(self):
922            A=Tensor4(0.,Function(self.domain))
923            D=Tensor(1.,Function(self.domain))
924            Y=Vector(self.domain.getDim(),Function(self.domain))
925            for i in range(self.domain.getDim()):
926                A[i,:,i,:]=kronecker(self.domain)
927                D[i,i]+=i
928                Y[i]+=i
929            mypde=LinearPDE(self.domain,debug=self.DEBUG)
930            mypde.setValue(A=A,D=D,Y=Y)
931            mypde.setSolverMethod(mypde.PCG,mypde.JACOBI)
932            u=mypde.getSolution(verbose=self.VERBOSE)
933            self.failUnless(self.check(u,1.),'solution is wrong.')
934        def test_PCG_ILU0_System(self):
935            A=Tensor4(0.,Function(self.domain))
936            D=Tensor(1.,Function(self.domain))
937            Y=Vector(self.domain.getDim(),Function(self.domain))
938            for i in range(self.domain.getDim()):
939                A[i,:,i,:]=kronecker(self.domain)
940                D[i,i]+=i
941                Y[i]+=i
942            mypde=LinearPDE(self.domain,debug=self.DEBUG)
943            mypde.setValue(A=A,D=D,Y=Y)
944            mypde.setSolverMethod(mypde.PCG,mypde.ILU0)
945            u=mypde.getSolution(verbose=self.VERBOSE)
946            self.failUnless(self.check(u,1.),'solution is wrong.')
947        def test_DIRECT_System(self):
948            A=Tensor4(0.,Function(self.domain))
949            D=Tensor(1.,Function(self.domain))
950            Y=Vector(self.domain.getDim(),Function(self.domain))
951            for i in range(self.domain.getDim()):
952                A[i,:,i,:]=kronecker(self.domain)
953                D[i,i]+=i
954                Y[i]+=i
955            mypde=LinearPDE(self.domain,debug=self.DEBUG)
956            mypde.setValue(A=A,D=D,Y=Y)
957            mypde.setSolverMethod(mypde.DIRECT)
958            u=mypde.getSolution(verbose=self.VERBOSE)
959            self.failUnless(self.check(u,1.),'solution is wrong.')
960        def test_BICGSTAB_JACOBI_System(self):
961            A=Tensor4(0.,Function(self.domain))
962            D=Tensor(1.,Function(self.domain))
963            Y=Vector(self.domain.getDim(),Function(self.domain))
964            for i in range(self.domain.getDim()):
965                A[i,:,i,:]=kronecker(self.domain)
966                D[i,i]+=i
967                Y[i]+=i
968            mypde=LinearPDE(self.domain,debug=self.DEBUG)
969            mypde.setValue(A=A,D=D,Y=Y)
970        mypde.setSolverMethod(mypde.BICGSTAB,mypde.JACOBI)
971            u=mypde.getSolution(verbose=self.VERBOSE)
972            self.failUnless(self.check(u,1.),'solution is wrong.')
973        def test_BICGSTAB_ILU0_System(self):
974            A=Tensor4(0.,Function(self.domain))
975            D=Tensor(1.,Function(self.domain))
976            Y=Vector(self.domain.getDim(),Function(self.domain))
977            for i in range(self.domain.getDim()):
978                A[i,:,i,:]=kronecker(self.domain)
979                D[i,i]+=i
980                Y[i]+=i
981            mypde=LinearPDE(self.domain,debug=self.DEBUG)
982            mypde.setValue(A=A,D=D,Y=Y)
983        mypde.setSolverMethod(mypde.BICGSTAB,mypde.ILU0)
984            u=mypde.getSolution(verbose=self.VERBOSE)
985            self.failUnless(self.check(u,1.),'solution is wrong.')
986        def test_PRES20_JACOBI_System(self):
987            A=Tensor4(0.,Function(self.domain))
988            D=Tensor(1.,Function(self.domain))
989            Y=Vector(self.domain.getDim(),Function(self.domain))
990            for i in range(self.domain.getDim()):
991                A[i,:,i,:]=kronecker(self.domain)
992                D[i,i]+=i
993                Y[i]+=i
994            mypde=LinearPDE(self.domain,debug=self.DEBUG)
995            mypde.setValue(A=A,D=D,Y=Y)
996        mypde.setSolverMethod(mypde.PRES20,mypde.JACOBI)
997            u=mypde.getSolution(verbose=self.VERBOSE)
998            self.failUnless(self.check(u,1.),'solution is wrong.')
999        def test_PRES20_ILU0_System(self):
1000            A=Tensor4(0.,Function(self.domain))
1001            D=Tensor(1.,Function(self.domain))
1002            Y=Vector(self.domain.getDim(),Function(self.domain))
1003            for i in range(self.domain.getDim()):
1004                A[i,:,i,:]=kronecker(self.domain)
1005                D[i,i]+=i
1006                Y[i]+=i
1007            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1008            mypde.setValue(A=A,D=D,Y=Y)
1009        mypde.setSolverMethod(mypde.PRES20,mypde.ILU0)
1010            u=mypde.getSolution(verbose=self.VERBOSE)
1011            self.failUnless(self.check(u,1.),'solution is wrong.')
1012        def test_GMRESnoRestart_JACOBI_System(self):
1013            A=Tensor4(0.,Function(self.domain))
1014            D=Tensor(1.,Function(self.domain))
1015            Y=Vector(self.domain.getDim(),Function(self.domain))
1016            for i in range(self.domain.getDim()):
1017                A[i,:,i,:]=kronecker(self.domain)
1018                D[i,i]+=i
1019                Y[i]+=i
1020            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1021            mypde.setValue(A=A,D=D,Y=Y)
1022        mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
1023            # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
1024            u=mypde.getSolution(verbose=self.VERBOSE)
1025            self.failUnless(self.check(u,1.),'solution is wrong.')
1026        def test_GMRESnoRestart_ILU0_System(self):
1027            A=Tensor4(0.,Function(self.domain))
1028            D=Tensor(1.,Function(self.domain))
1029            Y=Vector(self.domain.getDim(),Function(self.domain))
1030            for i in range(self.domain.getDim()):
1031                A[i,:,i,:]=kronecker(self.domain)
1032                D[i,i]+=i
1033                Y[i]+=i
1034            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1035            mypde.setValue(A=A,D=D,Y=Y)
1036        mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
1037            # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
1038            u=mypde.getSolution(verbose=self.VERBOSE)
1039            self.failUnless(self.check(u,1.),'solution is wrong.')
1040        def test_GMRES_JACOBI_System(self):
1041            A=Tensor4(0.,Function(self.domain))
1042            D=Tensor(1.,Function(self.domain))
1043            Y=Vector(self.domain.getDim(),Function(self.domain))
1044            for i in range(self.domain.getDim()):
1045                A[i,:,i,:]=kronecker(self.domain)
1046                D[i,i]+=i
1047                Y[i]+=i
1048            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1049            mypde.setValue(A=A,D=D,Y=Y)
1050        mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
1051            u=mypde.getSolution(verbose=self.VERBOSE)
1052            self.failUnless(self.check(u,1.),'solution is wrong.')
1053        def test_GMRES_ILU0_System(self):
1054            A=Tensor4(0.,Function(self.domain))
1055            D=Tensor(1.,Function(self.domain))
1056            Y=Vector(self.domain.getDim(),Function(self.domain))
1057            for i in range(self.domain.getDim()):
1058                A[i,:,i,:]=kronecker(self.domain)
1059                D[i,i]+=i
1060                Y[i]+=i
1061            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1062            mypde.setValue(A=A,D=D,Y=Y)
1063        mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
1064            u=mypde.getSolution(verbose=self.VERBOSE)
1065            self.failUnless(self.check(u,1.),'solution is wrong.')
1066        def test_GMRES_truncation_restart_JACOBI_System(self):
1067            A=Tensor4(0.,Function(self.domain))
1068            D=Tensor(1.,Function(self.domain))
1069            Y=Vector(self.domain.getDim(),Function(self.domain))
1070            for i in range(self.domain.getDim()):
1071                A[i,:,i,:]=kronecker(self.domain)
1072                D[i,i]+=i
1073                Y[i]+=i
1074            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1075            mypde.setValue(A=A,D=D,Y=Y)
1076        mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
1077            u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
1078            self.failUnless(self.check(u,1.),'solution is wrong.')
1079        def test_GMRES_truncation_restart_ILU0_System(self):
1080            A=Tensor4(0.,Function(self.domain))
1081            D=Tensor(1.,Function(self.domain))
1082            Y=Vector(self.domain.getDim(),Function(self.domain))
1083            for i in range(self.domain.getDim()):
1084                A[i,:,i,:]=kronecker(self.domain)
1085                D[i,i]+=i
1086                Y[i]+=i
1087            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1088            mypde.setValue(A=A,D=D,Y=Y)
1089        mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
1090            u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
1091            self.failUnless(self.check(u,1.),'solution is wrong.')
1092    
1093  class Test_LinearPDE(Test_LinearPDE_noLumping):  class Test_LinearPDE(Test_LinearPDE_noLumping):
1094      def test_Lumping_attemptToSetA(self):      def test_Lumping_attemptToSetA(self):

Legend:
Removed from v.1072  
changed lines
  Added in v.1312

  ViewVC Help
Powered by ViewVC 1.1.26