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

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

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

trunk/escript/py_src/test_linearPDEs.py revision 531 by gross, Wed Feb 15 08:11:10 2006 UTC trunk/escript/test/python/test_linearPDEs.py revision 1388 by trankine, Fri Jan 11 07:45:58 2008 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 9  The tests must be linked with a Domain c Line 23  The tests must be linked with a Domain c
23     class Test_LinearPDEOnFinley(Test_LinearPDE):     class Test_LinearPDEOnFinley(Test_LinearPDE):
24         def setUp(self):         def setUp(self):
25             self.domain = Rectangle(10,10,2)             self.domain = Rectangle(10,10,2)
26           def tearDown(self):
27               del self.domain
28     suite = unittest.TestSuite()     suite = unittest.TestSuite()
29     suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley))     suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley))
30     unittest.TextTestRunner(verbosity=2).run(suite)     unittest.TextTestRunner(verbosity=2).run(suite)
31    
32    @var __author__: name of author
33    @var __copyright__: copyrights
34    @var __license__: licence agreement
35    @var __url__: url entry point on documentation
36    @var __version__: version
37    @var __date__: date of the version
38  """  """
39    
40  __author__="Lutz Gross, l.gross@uq.edu.au"  __author__="Lutz Gross, l.gross@uq.edu.au"
41  __licence__="contact: esys@access.uq.edu.au"  __copyright__="""  Copyright (c) 2006 by ACcESS MNRF
42                        http://www.access.edu.au
43                    Primary Business: Queensland, Australia"""
44    __license__="""Licensed under the Open Software License version 3.0
45                 http://www.opensource.org/licenses/osl-3.0.php"""
46  __url__="http://www.iservo.edu.au/esys/escript"  __url__="http://www.iservo.edu.au/esys/escript"
47  __version__="$Revision$"  __version__="$Revision$"
48  __date__="$Date$"  __date__="$Date$"
# Line 24  __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  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  from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace
55  import numarray  import numarray
56  import unittest  import unittest
57    
# Line 62  class Test_Poisson(Test_linearPDEs): Line 88  class Test_Poisson(Test_linearPDEs):
88          self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")
89          self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")
90          self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")
91            self.failUnless(mypde.getCoefficientOfGeneralPDE("A_reduced").isEmpty(),"A_reduced is not empty")
92            self.failUnless(mypde.getCoefficientOfGeneralPDE("B_reduced").isEmpty(),"B_reduced is not empty")
93            self.failUnless(mypde.getCoefficientOfGeneralPDE("C_reduced").isEmpty(),"C_reduced is not empty")
94            self.failUnless(mypde.getCoefficientOfGeneralPDE("D_reduced").isEmpty(),"D_reduced is not empty")
95            self.failUnless(mypde.getCoefficientOfGeneralPDE("X_reduced").isEmpty(),"X_reduced is not empty")
96            self.failUnless(mypde.getCoefficientOfGeneralPDE("Y_reduced").isEmpty(),"Y_reduced is not empty")
97            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_reduced").isEmpty(),"y_reduced is not empty")
98            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_reduced").isEmpty(),"d_reduced is not empty")
99            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
100            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
101          self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("q"),q_ref),"q is not empty")          self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("q"),q_ref),"q is not empty")
102          self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
103      def test_setCoefficient_f(self):      def test_setCoefficient_f(self):
# Line 80  class Test_Poisson(Test_linearPDEs): Line 116  class Test_Poisson(Test_linearPDEs):
116          self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")
117          self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")
118          self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")
119            self.failUnless(mypde.getCoefficientOfGeneralPDE("A_reduced").isEmpty(),"A_reduced is not empty")
120            self.failUnless(mypde.getCoefficientOfGeneralPDE("B_reduced").isEmpty(),"B_reduced is not empty")
121            self.failUnless(mypde.getCoefficientOfGeneralPDE("C_reduced").isEmpty(),"C_reduced is not empty")
122            self.failUnless(mypde.getCoefficientOfGeneralPDE("D_reduced").isEmpty(),"D_reduced is not empty")
123            self.failUnless(mypde.getCoefficientOfGeneralPDE("X_reduced").isEmpty(),"X_reduced is not empty")
124            self.failUnless(mypde.getCoefficientOfGeneralPDE("Y_reduced").isEmpty(),"Y_reduced is not empty")
125            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_reduced").isEmpty(),"y_reduced is not empty")
126            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_reduced").isEmpty(),"d_reduced is not empty")
127            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
128            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
129            self.failUnless(mypde.getCoefficientOfGeneralPDE("q").isEmpty(),"q is not empty")
130            self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
131        def test_setCoefficient_f_reduced(self):
132            mypde=Poisson(self.domain,debug=self.DEBUG)
133            x=self.domain.getX()
134            Y_ref=interpolate(x[0],ReducedFunction(self.domain))
135            A_ref=kronecker(self.domain)
136            mypde.setValue(f_reduced=x[0])
137            self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("A"),A_ref),"A is not kronecker")
138            self.failUnless(mypde.getCoefficientOfGeneralPDE("B").isEmpty(),"B is not empty")
139            self.failUnless(mypde.getCoefficientOfGeneralPDE("C").isEmpty(),"C is not empty")
140            self.failUnless(mypde.getCoefficientOfGeneralPDE("D").isEmpty(),"D is not empty")
141            self.failUnless(mypde.getCoefficientOfGeneralPDE("X").isEmpty(),"X is not empty")
142            self.failUnless(mypde.getCoefficientOfGeneralPDE("Y").isEmpty(),"Y is not empty")
143            self.failUnless(mypde.getCoefficientOfGeneralPDE("y").isEmpty(),"y is not empty")
144            self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")
145            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")
146            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")
147            self.failUnless(mypde.getCoefficientOfGeneralPDE("A_reduced").isEmpty(),"A_reduced is not empty")
148            self.failUnless(mypde.getCoefficientOfGeneralPDE("B_reduced").isEmpty(),"B_reduced is not empty")
149            self.failUnless(mypde.getCoefficientOfGeneralPDE("C_reduced").isEmpty(),"C_reduced is not empty")
150            self.failUnless(mypde.getCoefficientOfGeneralPDE("D_reduced").isEmpty(),"D_reduced is not empty")
151            self.failUnless(mypde.getCoefficientOfGeneralPDE("X_reduced").isEmpty(),"X_reduced is not empty")
152            self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("Y_reduced"),Y_ref),"Y_reduced is not x[0]")
153            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_reduced").isEmpty(),"y_reduced is not empty")
154            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_reduced").isEmpty(),"d_reduced is not empty")
155            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
156            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
157          self.failUnless(mypde.getCoefficientOfGeneralPDE("q").isEmpty(),"q is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("q").isEmpty(),"q is not empty")
158          self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
159      def test_solve(self):      def test_solve(self):
# Line 109  class Test_Poisson(Test_linearPDEs): Line 183  class Test_Poisson(Test_linearPDEs):
183         u=mypde.getSolution()         u=mypde.getSolution()
184         self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution")         self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution")
185    
186  class Test_LinearPDE(Test_linearPDEs):  class Test_LinearPDE_noLumping(Test_linearPDEs):
187      N=4      N=4
188      def test_setCoefficient_WithIllegalFunctionSpace(self):      def test_setCoefficient_WithIllegalFunctionSpace(self):
189          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
190          try:          try:
191             success=True             success=True
192             mypde.setValue(C=Vector(0.,FunctionOnBoundary(self.domain)))             mypde.setValue(C=Vector(0.,FunctionOnBoundary(self.domain)))
193          except IllegalCoefficientValue:          except IllegalCoefficientFunctionSpace:
194             success=False             success=False
195          self.failUnless(not success,'inapropraite function space accepted')          self.failUnless(not success,'inapropraite function space accepted')
196                    
# Line 213  class Test_LinearPDE(Test_linearPDEs): Line 287  class Test_LinearPDE(Test_linearPDEs):
287          mypde.setValue(y_contact=1.)          mypde.setValue(y_contact=1.)
288          coeff=mypde.getCoefficientOfGeneralPDE("y_contact")          coeff=mypde.getCoefficientOfGeneralPDE("y_contact")
289          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))
290        def test_setCoefficient_A_reduced_Scalar(self):
291            d=self.domain.getDim()
292            mypde=LinearPDE(self.domain,debug=self.DEBUG)
293            mypde.setValue(A_reduced=numarray.ones((d,d)))
294            coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
295            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
296        def test_setCoefficient_B_reduced_Scalar(self):
297            d=self.domain.getDim()
298            mypde=LinearPDE(self.domain,debug=self.DEBUG)
299            mypde.setValue(B_reduced=numarray.ones((d,)))
300            coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
301            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
302        def test_setCoefficient_C_reduced_Scalar(self):
303            d=self.domain.getDim()
304            mypde=LinearPDE(self.domain,debug=self.DEBUG)
305            mypde.setValue(C_reduced=numarray.ones((d,)))
306            coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
307            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
308        def test_setCoefficient_D_reduced_Scalar(self):
309            d=self.domain.getDim()
310            mypde=LinearPDE(self.domain,debug=self.DEBUG)
311            mypde.setValue(D_reduced=1.)
312            coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
313            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
314        def test_setCoefficient_X_reduced_Scalar(self):
315            d=self.domain.getDim()
316            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
317            mypde.setValue(X_reduced=numarray.ones((d,)))
318            coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
319            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
320        def test_setCoefficient_Y_reduced_Scalar(self):
321            d=self.domain.getDim()
322            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
323            mypde.setValue(Y_reduced=1.)
324            coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
325            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
326        def test_setCoefficient_y_reduced_Scalar(self):
327            d=self.domain.getDim()
328            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
329            mypde.setValue(y_reduced=1.)
330            coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
331            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
332        def test_setCoefficient_d_reduced_Scalar(self):
333            d=self.domain.getDim()
334            mypde=LinearPDE(self.domain,debug=self.DEBUG)
335            mypde.setValue(d_reduced=1.)
336            coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
337            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
338        def test_setCoefficient_d_contact_reduced_Scalar(self):
339            d=self.domain.getDim()
340            mypde=LinearPDE(self.domain,debug=self.DEBUG)
341            mypde.setValue(d_contact_reduced=1.)
342            coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
343            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
344        def test_setCoefficient_y_contact_reduced_Scalar(self):
345            d=self.domain.getDim()
346            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
347            mypde.setValue(y_contact_reduced=1.)
348            coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
349            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
350      def test_setCoefficient_r_Scalar(self):      def test_setCoefficient_r_Scalar(self):
351          d=self.domain.getDim()          d=self.domain.getDim()
352          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
# Line 240  class Test_LinearPDE(Test_linearPDEs): Line 374  class Test_LinearPDE(Test_linearPDEs):
374          coeff=mypde.getCoefficientOfGeneralPDE("q")          coeff=mypde.getCoefficientOfGeneralPDE("q")
375          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
376    
377        def test_setCoefficient_A_reduced_Scalar_usingA(self):
378            d=self.domain.getDim()
379            mypde=LinearPDE(self.domain,debug=self.DEBUG)
380            mypde.setValue(A=Data(numarray.ones((d,d)),ReducedFunction(self.domain)))
381            coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
382            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
383        def test_setCoefficient_B_reduced_Scalar_usingB(self):
384            d=self.domain.getDim()
385            mypde=LinearPDE(self.domain,debug=self.DEBUG)
386            mypde.setValue(B=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
387            coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
388            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
389        def test_setCoefficient_C_reduced_Scalar_usingC(self):
390            d=self.domain.getDim()
391            mypde=LinearPDE(self.domain,debug=self.DEBUG)
392            mypde.setValue(C=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
393            coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
394            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
395        def test_setCoefficient_D_reduced_Scalar_usingD(self):
396            d=self.domain.getDim()
397            mypde=LinearPDE(self.domain,debug=self.DEBUG)
398            mypde.setValue(D=Scalar(1.,ReducedFunction(self.domain)))
399            coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
400            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
401        def test_setCoefficient_X_reduced_Scalar_usingX(self):
402            d=self.domain.getDim()
403            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
404            mypde.setValue(X_reduced=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
405            coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
406            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
407        def test_setCoefficient_Y_reduced_Scalar_usingY(self):
408            d=self.domain.getDim()
409            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
410            mypde.setValue(Y=Scalar(1.,ReducedFunction(self.domain)))
411            coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
412            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
413        def test_setCoefficient_y_reduced_Scalar_using_y(self):
414            d=self.domain.getDim()
415            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
416            mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
417            coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
418            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
419        def test_setCoefficient_d_reduced_Scalar_using_d(self):
420            d=self.domain.getDim()
421            mypde=LinearPDE(self.domain,debug=self.DEBUG)
422            mypde.setValue(d=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
423            coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
424            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
425        def test_setCoefficient_d_contact_reduced_Scalar_using_d_contact(self):
426            d=self.domain.getDim()
427            mypde=LinearPDE(self.domain,debug=self.DEBUG)
428            mypde.setValue(d_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
429            coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
430            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
431        def test_setCoefficient_y_contact_reduced_Scalar_using_y_contact(self):
432            d=self.domain.getDim()
433            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
434            mypde.setValue(y_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
435            coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
436            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
437      #      #
438      #  set coefficients for systems:      #  set coefficients for systems:
439      #      #
# Line 303  class Test_LinearPDE(Test_linearPDEs): Line 497  class Test_LinearPDE(Test_linearPDEs):
497          mypde.setValue(y_contact=numarray.ones((self.N,)))          mypde.setValue(y_contact=numarray.ones((self.N,)))
498          coeff=mypde.getCoefficientOfGeneralPDE("y_contact")          coeff=mypde.getCoefficientOfGeneralPDE("y_contact")
499          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N))          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N))
500        def test_setCoefficient_A_reduced_System(self):
501            d=self.domain.getDim()
502            mypde=LinearPDE(self.domain,debug=self.DEBUG)
503            mypde.setValue(A_reduced=numarray.ones((self.N,d,self.N,d)))
504            coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
505            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
506        def test_setCoefficient_B_reduced_System(self):
507            d=self.domain.getDim()
508            mypde=LinearPDE(self.domain,debug=self.DEBUG)
509            mypde.setValue(B_reduced=numarray.ones((self.N,d,self.N)))
510            coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
511            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
512        def test_setCoefficient_C_reduced_System(self):
513            d=self.domain.getDim()
514            mypde=LinearPDE(self.domain,debug=self.DEBUG)
515            mypde.setValue(C_reduced=numarray.ones((self.N,self.N,d)))
516            coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
517            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
518        def test_setCoefficient_D_System_reduced(self):
519            d=self.domain.getDim()
520            mypde=LinearPDE(self.domain,debug=self.DEBUG)
521            mypde.setValue(D_reduced=numarray.ones((self.N,self.N)))
522            coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
523            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
524        def test_setCoefficient_X_System_reduced(self):
525            d=self.domain.getDim()
526            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
527            mypde.setValue(X_reduced=numarray.ones((self.N,d)))
528            coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
529            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
530        def test_setCoefficient_Y_System_reduced(self):
531            d=self.domain.getDim()
532            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
533            mypde.setValue(Y_reduced=numarray.ones((self.N,)))
534            coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
535            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
536        def test_setCoefficient_y_System_reduced(self):
537            d=self.domain.getDim()
538            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
539            mypde.setValue(y_reduced=numarray.ones((self.N,)))
540            coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
541            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
542        def test_setCoefficient_d_reduced_System(self):
543            d=self.domain.getDim()
544            mypde=LinearPDE(self.domain,debug=self.DEBUG)
545            mypde.setValue(d_reduced=numarray.ones((self.N,self.N)))
546            coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
547            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
548        def test_setCoefficient_d_contact_reduced_System(self):
549            d=self.domain.getDim()
550            mypde=LinearPDE(self.domain,debug=self.DEBUG)
551            mypde.setValue(d_contact_reduced=numarray.ones((self.N,self.N)))
552            coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
553            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
554        def test_setCoefficient_y_contact_reduced_System(self):
555            d=self.domain.getDim()
556            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
557            mypde.setValue(y_contact_reduced=numarray.ones((self.N,)))
558            coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
559            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
560      def test_setCoefficient_r_System(self):      def test_setCoefficient_r_System(self):
561          d=self.domain.getDim()          d=self.domain.getDim()
562          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
# Line 330  class Test_LinearPDE(Test_linearPDEs): Line 584  class Test_LinearPDE(Test_linearPDEs):
584          coeff=mypde.getCoefficientOfGeneralPDE("q")          coeff=mypde.getCoefficientOfGeneralPDE("q")
585          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
586    
587        def test_setCoefficient_A_reduced_System_using_A(self):
588            d=self.domain.getDim()
589            mypde=LinearPDE(self.domain,debug=self.DEBUG)
590            mypde.setValue(A=Data(numarray.ones((self.N,d,self.N,d)),ReducedFunction(self.domain)))
591            coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
592            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
593        def test_setCoefficient_B_reduced_System_using_B(self):
594            d=self.domain.getDim()
595            mypde=LinearPDE(self.domain,debug=self.DEBUG)
596            mypde.setValue(B=Data(numarray.ones((self.N,d,self.N)),ReducedFunction(self.domain)))
597            coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
598            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
599        def test_setCoefficient_C_reduced_System_using_C(self):
600            d=self.domain.getDim()
601            mypde=LinearPDE(self.domain,debug=self.DEBUG)
602            mypde.setValue(C=Data(numarray.ones((self.N,self.N,d)),ReducedFunction(self.domain)))
603            coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
604            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
605        def test_setCoefficient_D_System_reduced_using_D(self):
606            d=self.domain.getDim()
607            mypde=LinearPDE(self.domain,debug=self.DEBUG)
608            mypde.setValue(D=Data(numarray.ones((self.N,self.N)),ReducedFunction(self.domain)))
609            coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
610            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
611        def test_setCoefficient_X_System_reduced_using_X(self):
612            d=self.domain.getDim()
613            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
614            mypde.setValue(X=Data(numarray.ones((self.N,d)),ReducedFunction(self.domain)))
615            coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
616            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
617        def test_setCoefficient_Y_System_reduced_using_Y(self):
618            d=self.domain.getDim()
619            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
620            mypde.setValue(Y=Data(numarray.ones((self.N,)),ReducedFunction(self.domain)))
621            coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
622            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
623        def test_setCoefficient_y_reduced_System_using_y(self):
624            d=self.domain.getDim()
625            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
626            mypde.setValue(y=Data(numarray.ones((self.N,)),ReducedFunctionOnBoundary(self.domain)))
627            coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
628            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
629        def test_setCoefficient_d_reduced_System_using_d(self):
630            d=self.domain.getDim()
631            mypde=LinearPDE(self.domain,debug=self.DEBUG)
632            mypde.setValue(d=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnBoundary(self.domain)))
633            coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
634            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
635        def test_setCoefficient_d_contact_reduced_System_using_d_contact(self):
636            d=self.domain.getDim()
637            mypde=LinearPDE(self.domain,debug=self.DEBUG)
638            mypde.setValue(d_contact=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnContactZero(self.domain)))
639            coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
640            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
641        def test_setCoefficient_y_contact_reduced_System_using_y_contact(self):
642            d=self.domain.getDim()
643            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
644            mypde.setValue(y_contact=Data(numarray.ones((self.N,)),ReducedFunctionOnContactZero(self.domain)))
645            coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
646            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
647      def test_resetCoefficient_HomogeneousConstraint(self):      def test_resetCoefficient_HomogeneousConstraint(self):
648          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
649          x=self.domain.getX()          x=self.domain.getX()
# Line 363  class Test_LinearPDE(Test_linearPDEs): Line 677  class Test_LinearPDE(Test_linearPDEs):
677          D=3*numarray.ones((self.N,self.N))          D=3*numarray.ones((self.N,self.N))
678          d=4*numarray.ones((self.N,self.N))          d=4*numarray.ones((self.N,self.N))
679          d_contact=5*numarray.ones((self.N,self.N))          d_contact=5*numarray.ones((self.N,self.N))
680          mypde.setValue(A=A,B=B,C=C,D=D,d=d,d_contact=d_contact)          mypde.setValue(A=A,B=B,C=C,D=D,d=d,d_contact=d_contact,A_reduced=-A,B_reduced=-B,C_reduced=-C,D_reduced=-D,d_reduced=-d,d_contact_reduced=-d_contact)
681          self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")          self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
682    
683      def test_symmetryCheckFalse_A_System(self):      def test_symmetryCheckFalse_A_System(self):
# Line 403  class Test_LinearPDE(Test_linearPDEs): Line 717  class Test_LinearPDE(Test_linearPDEs):
717          mypde.setValue(d_contact=d_contact)          mypde.setValue(d_contact=d_contact)
718          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
719    
720        def test_symmetryCheckFalse_A_reduced_System(self):
721            d=self.domain.getDim()
722            mypde=LinearPDE(self.domain,debug=self.DEBUG)
723            A=numarray.ones((self.N,d,self.N,d))
724            A[1,1,1,0]=0.
725            mypde.setValue(A_reduced=A)
726            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
727        def test_symmetryCheckFalse_BC_reduced_System(self):
728            d=self.domain.getDim()
729            mypde=LinearPDE(self.domain,debug=self.DEBUG)
730            C=2*numarray.ones((self.N,self.N,d))
731            B=2*numarray.ones((self.N,d,self.N))
732            B[0,0,1]=1.
733            mypde.setValue(B_reduced=B,C_reduced=C)
734            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
735    
736        def test_symmetryCheckFalse_D_reduced_System(self):
737            mypde=LinearPDE(self.domain,debug=self.DEBUG)
738            D=3*numarray.ones((self.N,self.N))
739            D[0,1]=0.
740            mypde.setValue(D_reduced=D)
741            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
742    
743        def test_symmetryCheckFalse_d_reduced_System(self):
744            mypde=LinearPDE(self.domain,debug=self.DEBUG)
745            d=4*numarray.ones((self.N,self.N))
746            d[0,1]=0.
747            mypde.setValue(d_reduced=d)
748            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
749    
750        def test_symmetryCheckFalse_d_contact_reduced_System(self):
751            mypde=LinearPDE(self.domain,debug=self.DEBUG)
752            d_contact=5*numarray.ones((self.N,self.N))
753            d_contact[0,1]=0.
754            mypde.setValue(d_contact_reduced=d_contact)
755            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
756    
757      def test_symmetryCheckTrue_Scalar(self):      def test_symmetryCheckTrue_Scalar(self):
758          d=self.domain.getDim()          d=self.domain.getDim()
759          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
# Line 412  class Test_LinearPDE(Test_linearPDEs): Line 763  class Test_LinearPDE(Test_linearPDEs):
763          D=3          D=3
764          d=4          d=4
765          d_contact=5          d_contact=5
766          mypde.setValue(A=A,B=B,C=C,D=D,d=d,d_contact=d_contact)          mypde.setValue(A=A,B=B,C=C,D=D,d=d,d_contact=d_contact,A_reduced=-A,B_reduced=-B,C_reduced=-C,D_reduced=-D,d_reduced=-d,d_contact_reduced=-d_contact)
767          self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")          self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
768    
769      def test_symmetryCheckFalse_A_Scalar(self):      def test_symmetryCheckFalse_A_Scalar(self):
# Line 430  class Test_LinearPDE(Test_linearPDEs): Line 781  class Test_LinearPDE(Test_linearPDEs):
781          B[0]=1.          B[0]=1.
782          mypde.setValue(B=B,C=C)          mypde.setValue(B=B,C=C)
783          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
784        def test_symmetryCheckFalse_A_reduced_Scalar(self):
785            d=self.domain.getDim()
786            mypde=LinearPDE(self.domain,debug=self.DEBUG)
787            A=numarray.ones((d,d))
788            A[1,0]=0.
789            mypde.setValue(A_reduced=A)
790            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
791        def test_symmetryCheckFalse_BC_reduced_Scalar(self):
792            d=self.domain.getDim()
793            mypde=LinearPDE(self.domain,debug=self.DEBUG)
794            C=2*numarray.ones((d,))
795            B=2*numarray.ones((d,))
796            B[0]=1.
797            mypde.setValue(B_reduced=B,C_reduced=C)
798            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 524  class Test_LinearPDE(Test_linearPDEs): Line 890  class Test_LinearPDE(Test_linearPDEs):
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):
1094      def test_Lumping_attemptToSetA(self):      def test_Lumping_attemptToSetA(self):
1095          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1096          try:          try:
# Line 553  class Test_LinearPDE(Test_linearPDEs): Line 1120  class Test_LinearPDE(Test_linearPDEs):
1120             u=mypde.getSolution(verbose=self.VERBOSE)             u=mypde.getSolution(verbose=self.VERBOSE)
1121          except ValueError:          except ValueError:
1122             success=False             success=False
1123            self.failUnless(not success,'error should be issued')
1124            
1125        def test_Lumping_attemptToSetA_reduced(self):
1126            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1127            try:
1128               success=True
1129           mypde.setSolverMethod(mypde.LUMPING)
1130               mypde.setValue(A_reduced=kronecker(self.domain))
1131               u=mypde.getSolution(verbose=self.VERBOSE)
1132            except ValueError:
1133               success=False
1134            self.failUnless(not success,'error should be issued')
1135        def test_Lumping_attemptToSetB_reduced(self):
1136            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1137            try:
1138               success=True
1139           mypde.setSolverMethod(mypde.LUMPING)
1140               mypde.setValue(B_reduced=kronecker(self.domain)[0])
1141               u=mypde.getSolution(verbose=self.VERBOSE)
1142            except ValueError:
1143               success=False
1144            self.failUnless(not success,'error should be issued')
1145        def test_Lumping_attemptToSetC_reduced(self):
1146            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1147            try:
1148               success=True
1149           mypde.setSolverMethod(mypde.LUMPING)
1150               mypde.setValue(C_reduced=kronecker(self.domain)[0])
1151               u=mypde.getSolution(verbose=self.VERBOSE)
1152            except ValueError:
1153               success=False
1154          self.failUnless(not success,'error should be issued')          self.failUnless(not success,'error should be issued')
1155                    
1156      def test_Lumping(self):      def test_Lumping(self):

Legend:
Removed from v.531  
changed lines
  Added in v.1388

  ViewVC Help
Powered by ViewVC 1.1.26