/[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

revision 1071 by gross, Fri Sep 22 09:30:06 2006 UTC revision 1072 by gross, Thu Mar 29 06:44:30 2007 UTC
# Line 36  __date__="$Date$" Line 36  __date__="$Date$"
36    
37    
38  from esys.escript.util import Lsup,kronecker,interpolate,whereZero  from esys.escript.util import Lsup,kronecker,interpolate,whereZero
39  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
40  from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson  from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace
41  import numarray  import numarray
42  import unittest  import unittest
43    
# Line 74  class Test_Poisson(Test_linearPDEs): Line 74  class Test_Poisson(Test_linearPDEs):
74          self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")
75          self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")
76          self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")
77            self.failUnless(mypde.getCoefficientOfGeneralPDE("A_reduced").isEmpty(),"A_reduced is not empty")
78            self.failUnless(mypde.getCoefficientOfGeneralPDE("B_reduced").isEmpty(),"B_reduced is not empty")
79            self.failUnless(mypde.getCoefficientOfGeneralPDE("C_reduced").isEmpty(),"C_reduced is not empty")
80            self.failUnless(mypde.getCoefficientOfGeneralPDE("D_reduced").isEmpty(),"D_reduced is not empty")
81            self.failUnless(mypde.getCoefficientOfGeneralPDE("X_reduced").isEmpty(),"X_reduced is not empty")
82            self.failUnless(mypde.getCoefficientOfGeneralPDE("Y_reduced").isEmpty(),"Y_reduced is not empty")
83            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_reduced").isEmpty(),"y_reduced is not empty")
84            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_reduced").isEmpty(),"d_reduced is not empty")
85            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
86            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
87          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")
88          self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
89      def test_setCoefficient_f(self):      def test_setCoefficient_f(self):
# Line 92  class Test_Poisson(Test_linearPDEs): Line 102  class Test_Poisson(Test_linearPDEs):
102          self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")
103          self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")
104          self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")
105            self.failUnless(mypde.getCoefficientOfGeneralPDE("A_reduced").isEmpty(),"A_reduced is not empty")
106            self.failUnless(mypde.getCoefficientOfGeneralPDE("B_reduced").isEmpty(),"B_reduced is not empty")
107            self.failUnless(mypde.getCoefficientOfGeneralPDE("C_reduced").isEmpty(),"C_reduced is not empty")
108            self.failUnless(mypde.getCoefficientOfGeneralPDE("D_reduced").isEmpty(),"D_reduced is not empty")
109            self.failUnless(mypde.getCoefficientOfGeneralPDE("X_reduced").isEmpty(),"X_reduced is not empty")
110            self.failUnless(mypde.getCoefficientOfGeneralPDE("Y_reduced").isEmpty(),"Y_reduced is not empty")
111            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_reduced").isEmpty(),"y_reduced is not empty")
112            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_reduced").isEmpty(),"d_reduced is not empty")
113            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
114            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
115            self.failUnless(mypde.getCoefficientOfGeneralPDE("q").isEmpty(),"q is not empty")
116            self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
117        def test_setCoefficient_f_reduced(self):
118            mypde=Poisson(self.domain,debug=self.DEBUG)
119            x=self.domain.getX()
120            Y_ref=interpolate(x[0],ReducedFunction(self.domain))
121            A_ref=kronecker(self.domain)
122            mypde.setValue(f_reduced=x[0])
123            self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("A"),A_ref),"A is not kronecker")
124            self.failUnless(mypde.getCoefficientOfGeneralPDE("B").isEmpty(),"B is not empty")
125            self.failUnless(mypde.getCoefficientOfGeneralPDE("C").isEmpty(),"C is not empty")
126            self.failUnless(mypde.getCoefficientOfGeneralPDE("D").isEmpty(),"D is not empty")
127            self.failUnless(mypde.getCoefficientOfGeneralPDE("X").isEmpty(),"X is not empty")
128            self.failUnless(mypde.getCoefficientOfGeneralPDE("Y").isEmpty(),"Y is not empty")
129            self.failUnless(mypde.getCoefficientOfGeneralPDE("y").isEmpty(),"y is not empty")
130            self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")
131            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")
132            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")
133            self.failUnless(mypde.getCoefficientOfGeneralPDE("A_reduced").isEmpty(),"A_reduced is not empty")
134            self.failUnless(mypde.getCoefficientOfGeneralPDE("B_reduced").isEmpty(),"B_reduced is not empty")
135            self.failUnless(mypde.getCoefficientOfGeneralPDE("C_reduced").isEmpty(),"C_reduced is not empty")
136            self.failUnless(mypde.getCoefficientOfGeneralPDE("D_reduced").isEmpty(),"D_reduced is not empty")
137            self.failUnless(mypde.getCoefficientOfGeneralPDE("X_reduced").isEmpty(),"X_reduced is not empty")
138            self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("Y_reduced"),Y_ref),"Y_reduced is not x[0]")
139            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_reduced").isEmpty(),"y_reduced is not empty")
140            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_reduced").isEmpty(),"d_reduced is not empty")
141            self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
142            self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
143          self.failUnless(mypde.getCoefficientOfGeneralPDE("q").isEmpty(),"q is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("q").isEmpty(),"q is not empty")
144          self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")          self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
145      def test_solve(self):      def test_solve(self):
# Line 128  class Test_LinearPDE_noLumping(Test_line Line 176  class Test_LinearPDE_noLumping(Test_line
176          try:          try:
177             success=True             success=True
178             mypde.setValue(C=Vector(0.,FunctionOnBoundary(self.domain)))             mypde.setValue(C=Vector(0.,FunctionOnBoundary(self.domain)))
179          except IllegalCoefficientValue:          except IllegalCoefficientFunctionSpace:
180             success=False             success=False
181          self.failUnless(not success,'inapropraite function space accepted')          self.failUnless(not success,'inapropraite function space accepted')
182                    
# Line 225  class Test_LinearPDE_noLumping(Test_line Line 273  class Test_LinearPDE_noLumping(Test_line
273          mypde.setValue(y_contact=1.)          mypde.setValue(y_contact=1.)
274          coeff=mypde.getCoefficientOfGeneralPDE("y_contact")          coeff=mypde.getCoefficientOfGeneralPDE("y_contact")
275          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))
276        def test_setCoefficient_A_reduced_Scalar(self):
277            d=self.domain.getDim()
278            mypde=LinearPDE(self.domain,debug=self.DEBUG)
279            mypde.setValue(A_reduced=numarray.ones((d,d)))
280            coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
281            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
282        def test_setCoefficient_B_reduced_Scalar(self):
283            d=self.domain.getDim()
284            mypde=LinearPDE(self.domain,debug=self.DEBUG)
285            mypde.setValue(B_reduced=numarray.ones((d,)))
286            coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
287            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
288        def test_setCoefficient_C_reduced_Scalar(self):
289            d=self.domain.getDim()
290            mypde=LinearPDE(self.domain,debug=self.DEBUG)
291            mypde.setValue(C_reduced=numarray.ones((d,)))
292            coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
293            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
294        def test_setCoefficient_D_reduced_Scalar(self):
295            d=self.domain.getDim()
296            mypde=LinearPDE(self.domain,debug=self.DEBUG)
297            mypde.setValue(D_reduced=1.)
298            coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
299            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
300        def test_setCoefficient_X_reduced_Scalar(self):
301            d=self.domain.getDim()
302            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
303            mypde.setValue(X_reduced=numarray.ones((d,)))
304            coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
305            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
306        def test_setCoefficient_Y_reduced_Scalar(self):
307            d=self.domain.getDim()
308            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
309            mypde.setValue(Y_reduced=1.)
310            coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
311            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
312        def test_setCoefficient_y_reduced_Scalar(self):
313            d=self.domain.getDim()
314            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
315            mypde.setValue(y_reduced=1.)
316            coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
317            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
318        def test_setCoefficient_d_reduced_Scalar(self):
319            d=self.domain.getDim()
320            mypde=LinearPDE(self.domain,debug=self.DEBUG)
321            mypde.setValue(d_reduced=1.)
322            coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
323            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
324        def test_setCoefficient_d_contact_reduced_Scalar(self):
325            d=self.domain.getDim()
326            mypde=LinearPDE(self.domain,debug=self.DEBUG)
327            mypde.setValue(d_contact_reduced=1.)
328            coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
329            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
330        def test_setCoefficient_y_contact_reduced_Scalar(self):
331            d=self.domain.getDim()
332            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
333            mypde.setValue(y_contact_reduced=1.)
334            coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
335            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
336      def test_setCoefficient_r_Scalar(self):      def test_setCoefficient_r_Scalar(self):
337          d=self.domain.getDim()          d=self.domain.getDim()
338          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
# Line 252  class Test_LinearPDE_noLumping(Test_line Line 360  class Test_LinearPDE_noLumping(Test_line
360          coeff=mypde.getCoefficientOfGeneralPDE("q")          coeff=mypde.getCoefficientOfGeneralPDE("q")
361          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
362    
363        def test_setCoefficient_A_reduced_Scalar_usingA(self):
364            d=self.domain.getDim()
365            mypde=LinearPDE(self.domain,debug=self.DEBUG)
366            mypde.setValue(A=Data(numarray.ones((d,d)),ReducedFunction(self.domain)))
367            coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
368            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
369        def test_setCoefficient_B_reduced_Scalar_usingB(self):
370            d=self.domain.getDim()
371            mypde=LinearPDE(self.domain,debug=self.DEBUG)
372            mypde.setValue(B=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
373            coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
374            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
375        def test_setCoefficient_C_reduced_Scalar_usingC(self):
376            d=self.domain.getDim()
377            mypde=LinearPDE(self.domain,debug=self.DEBUG)
378            mypde.setValue(C=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
379            coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
380            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
381        def test_setCoefficient_D_reduced_Scalar_usingD(self):
382            d=self.domain.getDim()
383            mypde=LinearPDE(self.domain,debug=self.DEBUG)
384            mypde.setValue(D=Scalar(1.,ReducedFunction(self.domain)))
385            coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
386            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
387        def test_setCoefficient_X_reduced_Scalar_usingX(self):
388            d=self.domain.getDim()
389            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
390            mypde.setValue(X_reduced=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
391            coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
392            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
393        def test_setCoefficient_Y_reduced_Scalar_usingY(self):
394            d=self.domain.getDim()
395            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
396            mypde.setValue(Y=Scalar(1.,ReducedFunction(self.domain)))
397            coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
398            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
399        def test_setCoefficient_y_reduced_Scalar_using_y(self):
400            d=self.domain.getDim()
401            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
402            mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
403            coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
404            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
405        def test_setCoefficient_d_reduced_Scalar_using_d(self):
406            d=self.domain.getDim()
407            mypde=LinearPDE(self.domain,debug=self.DEBUG)
408            mypde.setValue(d=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
409            coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
410            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
411        def test_setCoefficient_d_contact_reduced_Scalar_using_d_contact(self):
412            d=self.domain.getDim()
413            mypde=LinearPDE(self.domain,debug=self.DEBUG)
414            mypde.setValue(d_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
415            coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
416            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
417        def test_setCoefficient_y_contact_reduced_Scalar_using_y_contact(self):
418            d=self.domain.getDim()
419            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
420            mypde.setValue(y_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
421            coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
422            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
423      #      #
424      #  set coefficients for systems:      #  set coefficients for systems:
425      #      #
# Line 315  class Test_LinearPDE_noLumping(Test_line Line 483  class Test_LinearPDE_noLumping(Test_line
483          mypde.setValue(y_contact=numarray.ones((self.N,)))          mypde.setValue(y_contact=numarray.ones((self.N,)))
484          coeff=mypde.getCoefficientOfGeneralPDE("y_contact")          coeff=mypde.getCoefficientOfGeneralPDE("y_contact")
485          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))
486        def test_setCoefficient_A_reduced_System(self):
487            d=self.domain.getDim()
488            mypde=LinearPDE(self.domain,debug=self.DEBUG)
489            mypde.setValue(A_reduced=numarray.ones((self.N,d,self.N,d)))
490            coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
491            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
492        def test_setCoefficient_B_reduced_System(self):
493            d=self.domain.getDim()
494            mypde=LinearPDE(self.domain,debug=self.DEBUG)
495            mypde.setValue(B_reduced=numarray.ones((self.N,d,self.N)))
496            coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
497            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
498        def test_setCoefficient_C_reduced_System(self):
499            d=self.domain.getDim()
500            mypde=LinearPDE(self.domain,debug=self.DEBUG)
501            mypde.setValue(C_reduced=numarray.ones((self.N,self.N,d)))
502            coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
503            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
504        def test_setCoefficient_D_System_reduced(self):
505            d=self.domain.getDim()
506            mypde=LinearPDE(self.domain,debug=self.DEBUG)
507            mypde.setValue(D_reduced=numarray.ones((self.N,self.N)))
508            coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
509            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
510        def test_setCoefficient_X_System_reduced(self):
511            d=self.domain.getDim()
512            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
513            mypde.setValue(X_reduced=numarray.ones((self.N,d)))
514            coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
515            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
516        def test_setCoefficient_Y_System_reduced(self):
517            d=self.domain.getDim()
518            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
519            mypde.setValue(Y_reduced=numarray.ones((self.N,)))
520            coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
521            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
522        def test_setCoefficient_y_System_reduced(self):
523            d=self.domain.getDim()
524            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
525            mypde.setValue(y_reduced=numarray.ones((self.N,)))
526            coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
527            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
528        def test_setCoefficient_d_reduced_System(self):
529            d=self.domain.getDim()
530            mypde=LinearPDE(self.domain,debug=self.DEBUG)
531            mypde.setValue(d_reduced=numarray.ones((self.N,self.N)))
532            coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
533            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
534        def test_setCoefficient_d_contact_reduced_System(self):
535            d=self.domain.getDim()
536            mypde=LinearPDE(self.domain,debug=self.DEBUG)
537            mypde.setValue(d_contact_reduced=numarray.ones((self.N,self.N)))
538            coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
539            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
540        def test_setCoefficient_y_contact_reduced_System(self):
541            d=self.domain.getDim()
542            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
543            mypde.setValue(y_contact_reduced=numarray.ones((self.N,)))
544            coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
545            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
546      def test_setCoefficient_r_System(self):      def test_setCoefficient_r_System(self):
547          d=self.domain.getDim()          d=self.domain.getDim()
548          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
# Line 342  class Test_LinearPDE_noLumping(Test_line Line 570  class Test_LinearPDE_noLumping(Test_line
570          coeff=mypde.getCoefficientOfGeneralPDE("q")          coeff=mypde.getCoefficientOfGeneralPDE("q")
571          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))
572    
573        def test_setCoefficient_A_reduced_System_using_A(self):
574            d=self.domain.getDim()
575            mypde=LinearPDE(self.domain,debug=self.DEBUG)
576            mypde.setValue(A=Data(numarray.ones((self.N,d,self.N,d)),ReducedFunction(self.domain)))
577            coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
578            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
579        def test_setCoefficient_B_reduced_System_using_B(self):
580            d=self.domain.getDim()
581            mypde=LinearPDE(self.domain,debug=self.DEBUG)
582            mypde.setValue(B=Data(numarray.ones((self.N,d,self.N)),ReducedFunction(self.domain)))
583            coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
584            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
585        def test_setCoefficient_C_reduced_System_using_C(self):
586            d=self.domain.getDim()
587            mypde=LinearPDE(self.domain,debug=self.DEBUG)
588            mypde.setValue(C=Data(numarray.ones((self.N,self.N,d)),ReducedFunction(self.domain)))
589            coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
590            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
591        def test_setCoefficient_D_System_reduced_using_D(self):
592            d=self.domain.getDim()
593            mypde=LinearPDE(self.domain,debug=self.DEBUG)
594            mypde.setValue(D=Data(numarray.ones((self.N,self.N)),ReducedFunction(self.domain)))
595            coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
596            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
597        def test_setCoefficient_X_System_reduced_using_X(self):
598            d=self.domain.getDim()
599            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
600            mypde.setValue(X=Data(numarray.ones((self.N,d)),ReducedFunction(self.domain)))
601            coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
602            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
603        def test_setCoefficient_Y_System_reduced_using_Y(self):
604            d=self.domain.getDim()
605            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
606            mypde.setValue(Y=Data(numarray.ones((self.N,)),ReducedFunction(self.domain)))
607            coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
608            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
609        def test_setCoefficient_y_reduced_System_using_y(self):
610            d=self.domain.getDim()
611            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
612            mypde.setValue(y=Data(numarray.ones((self.N,)),ReducedFunctionOnBoundary(self.domain)))
613            coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
614            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
615        def test_setCoefficient_d_reduced_System_using_d(self):
616            d=self.domain.getDim()
617            mypde=LinearPDE(self.domain,debug=self.DEBUG)
618            mypde.setValue(d=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnBoundary(self.domain)))
619            coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
620            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
621        def test_setCoefficient_d_contact_reduced_System_using_d_contact(self):
622            d=self.domain.getDim()
623            mypde=LinearPDE(self.domain,debug=self.DEBUG)
624            mypde.setValue(d_contact=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnContactZero(self.domain)))
625            coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
626            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
627        def test_setCoefficient_y_contact_reduced_System_using_y_contact(self):
628            d=self.domain.getDim()
629            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
630            mypde.setValue(y_contact=Data(numarray.ones((self.N,)),ReducedFunctionOnContactZero(self.domain)))
631            coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
632            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
633      def test_resetCoefficient_HomogeneousConstraint(self):      def test_resetCoefficient_HomogeneousConstraint(self):
634          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
635          x=self.domain.getX()          x=self.domain.getX()
# Line 375  class Test_LinearPDE_noLumping(Test_line Line 663  class Test_LinearPDE_noLumping(Test_line
663          D=3*numarray.ones((self.N,self.N))          D=3*numarray.ones((self.N,self.N))
664          d=4*numarray.ones((self.N,self.N))          d=4*numarray.ones((self.N,self.N))
665          d_contact=5*numarray.ones((self.N,self.N))          d_contact=5*numarray.ones((self.N,self.N))
666          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)
667          self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")          self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
668    
669      def test_symmetryCheckFalse_A_System(self):      def test_symmetryCheckFalse_A_System(self):
# Line 415  class Test_LinearPDE_noLumping(Test_line Line 703  class Test_LinearPDE_noLumping(Test_line
703          mypde.setValue(d_contact=d_contact)          mypde.setValue(d_contact=d_contact)
704          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
705    
706        def test_symmetryCheckFalse_A_reduced_System(self):
707            d=self.domain.getDim()
708            mypde=LinearPDE(self.domain,debug=self.DEBUG)
709            A=numarray.ones((self.N,d,self.N,d))
710            A[1,1,1,0]=0.
711            mypde.setValue(A_reduced=A)
712            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
713        def test_symmetryCheckFalse_BC_reduced_System(self):
714            d=self.domain.getDim()
715            mypde=LinearPDE(self.domain,debug=self.DEBUG)
716            C=2*numarray.ones((self.N,self.N,d))
717            B=2*numarray.ones((self.N,d,self.N))
718            B[0,0,1]=1.
719            mypde.setValue(B_reduced=B,C_reduced=C)
720            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
721    
722        def test_symmetryCheckFalse_D_reduced_System(self):
723            mypde=LinearPDE(self.domain,debug=self.DEBUG)
724            D=3*numarray.ones((self.N,self.N))
725            D[0,1]=0.
726            mypde.setValue(D_reduced=D)
727            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
728    
729        def test_symmetryCheckFalse_d_reduced_System(self):
730            mypde=LinearPDE(self.domain,debug=self.DEBUG)
731            d=4*numarray.ones((self.N,self.N))
732            d[0,1]=0.
733            mypde.setValue(d_reduced=d)
734            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
735    
736        def test_symmetryCheckFalse_d_contact_reduced_System(self):
737            mypde=LinearPDE(self.domain,debug=self.DEBUG)
738            d_contact=5*numarray.ones((self.N,self.N))
739            d_contact[0,1]=0.
740            mypde.setValue(d_contact_reduced=d_contact)
741            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
742    
743      def test_symmetryCheckTrue_Scalar(self):      def test_symmetryCheckTrue_Scalar(self):
744          d=self.domain.getDim()          d=self.domain.getDim()
745          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
# Line 424  class Test_LinearPDE_noLumping(Test_line Line 749  class Test_LinearPDE_noLumping(Test_line
749          D=3          D=3
750          d=4          d=4
751          d_contact=5          d_contact=5
752          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)
753          self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")          self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
754    
755      def test_symmetryCheckFalse_A_Scalar(self):      def test_symmetryCheckFalse_A_Scalar(self):
# Line 442  class Test_LinearPDE_noLumping(Test_line Line 767  class Test_LinearPDE_noLumping(Test_line
767          B[0]=1.          B[0]=1.
768          mypde.setValue(B=B,C=C)          mypde.setValue(B=B,C=C)
769          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
770        def test_symmetryCheckFalse_A_reduced_Scalar(self):
771            d=self.domain.getDim()
772            mypde=LinearPDE(self.domain,debug=self.DEBUG)
773            A=numarray.ones((d,d))
774            A[1,0]=0.
775            mypde.setValue(A_reduced=A)
776            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
777        def test_symmetryCheckFalse_BC_reduced_Scalar(self):
778            d=self.domain.getDim()
779            mypde=LinearPDE(self.domain,debug=self.DEBUG)
780            C=2*numarray.ones((d,))
781            B=2*numarray.ones((d,))
782            B[0]=1.
783            mypde.setValue(B_reduced=B,C_reduced=C)
784            self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
785      #      #
786      #   solver checks:      #   solver checks:
787      #      #
# Line 567  class Test_LinearPDE(Test_LinearPDE_noLu Line 907  class Test_LinearPDE(Test_LinearPDE_noLu
907             u=mypde.getSolution(verbose=self.VERBOSE)             u=mypde.getSolution(verbose=self.VERBOSE)
908          except ValueError:          except ValueError:
909             success=False             success=False
910            self.failUnless(not success,'error should be issued')
911            
912        def test_Lumping_attemptToSetA_reduced(self):
913            mypde=LinearPDE(self.domain,debug=self.DEBUG)
914            try:
915               success=True
916           mypde.setSolverMethod(mypde.LUMPING)
917               mypde.setValue(A_reduced=kronecker(self.domain))
918               u=mypde.getSolution(verbose=self.VERBOSE)
919            except ValueError:
920               success=False
921            self.failUnless(not success,'error should be issued')
922        def test_Lumping_attemptToSetB_reduced(self):
923            mypde=LinearPDE(self.domain,debug=self.DEBUG)
924            try:
925               success=True
926           mypde.setSolverMethod(mypde.LUMPING)
927               mypde.setValue(B_reduced=kronecker(self.domain)[0])
928               u=mypde.getSolution(verbose=self.VERBOSE)
929            except ValueError:
930               success=False
931            self.failUnless(not success,'error should be issued')
932        def test_Lumping_attemptToSetC_reduced(self):
933            mypde=LinearPDE(self.domain,debug=self.DEBUG)
934            try:
935               success=True
936           mypde.setSolverMethod(mypde.LUMPING)
937               mypde.setValue(C_reduced=kronecker(self.domain)[0])
938               u=mypde.getSolution(verbose=self.VERBOSE)
939            except ValueError:
940               success=False
941          self.failUnless(not success,'error should be issued')          self.failUnless(not success,'error should be issued')
942                    
943      def test_Lumping(self):      def test_Lumping(self):

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

  ViewVC Help
Powered by ViewVC 1.1.26