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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1072 - (hide annotations)
Thu Mar 29 06:44:30 2007 UTC (12 years, 1 month ago) by gross
File MIME type: text/x-python
File size: 57450 byte(s)
PDE assemblage for reduced integration order + tests added.


1 jgs 149 # $Id$
2    
3     """
4     Test suite for linearPDEs class
5    
6     The tests must be linked with a Domain class object in the setUp method:
7    
8     from esys.finley import Rectangle
9     class Test_LinearPDEOnFinley(Test_LinearPDE):
10     def setUp(self):
11     self.domain = Rectangle(10,10,2)
12 gross 798 def tearDown(self):
13     del self.domain
14 jgs 149 suite = unittest.TestSuite()
15     suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley))
16     unittest.TextTestRunner(verbosity=2).run(suite)
17    
18 gross 637 @var __author__: name of author
19     @var __copyright__: copyrights
20     @var __license__: licence agreement
21     @var __url__: url entry point on documentation
22     @var __version__: version
23     @var __date__: date of the version
24 jgs 149 """
25    
26     __author__="Lutz Gross, l.gross@uq.edu.au"
27 elspeth 609 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
28     http://www.access.edu.au
29     Primary Business: Queensland, Australia"""
30 elspeth 614 __license__="""Licensed under the Open Software License version 3.0
31     http://www.opensource.org/licenses/osl-3.0.php"""
32 jgs 149 __url__="http://www.iservo.edu.au/esys/escript"
33     __version__="$Revision$"
34     __date__="$Date$"
35    
36    
37    
38 gross 304 from esys.escript.util import Lsup,kronecker,interpolate,whereZero
39 gross 1072 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, IllegalCoefficientFunctionSpace
41 jgs 149 import numarray
42     import unittest
43    
44     class Test_linearPDEs(unittest.TestCase):
45     TOL=1.e-6
46 jgs 153 SOLVER_TOL=1.e-10
47 jgs 149 DEBUG=False
48     VERBOSE=False
49     def check(self,arg,ref_arg,tol=None):
50     """
51     checks if arg and ref_arg are nearly identical using the L{Lsup<esys.escript.util.Lsup>}
52     """
53     if tol==None: tol=self.TOL
54     return Lsup(arg-ref_arg)<=tol*Lsup(ref_arg)
55    
56     class Test_Poisson(Test_linearPDEs):
57    
58     def test_config(self):
59     mypde=Poisson(self.domain,debug=self.DEBUG)
60     self.failUnlessEqual((mypde.getNumEquations(),mypde.getNumSolutions(),mypde.isSymmetric()),(1,1,True),"set up incorrect")
61     def test_setCoefficient_q(self):
62     mypde=Poisson(self.domain,debug=self.DEBUG)
63     x=self.domain.getX()
64 gross 304 q_ref=interpolate(whereZero(x[0]),Solution(self.domain))
65 jgs 149 A_ref=kronecker(self.domain)
66 gross 304 mypde.setValue(q=whereZero(x[0]))
67 jgs 149 self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("A"),A_ref),"A is not kronecker")
68     self.failUnless(mypde.getCoefficientOfGeneralPDE("B").isEmpty(),"B is not empty")
69     self.failUnless(mypde.getCoefficientOfGeneralPDE("C").isEmpty(),"C is not empty")
70     self.failUnless(mypde.getCoefficientOfGeneralPDE("D").isEmpty(),"D is not empty")
71     self.failUnless(mypde.getCoefficientOfGeneralPDE("X").isEmpty(),"X is not empty")
72     self.failUnless(mypde.getCoefficientOfGeneralPDE("Y").isEmpty(),"Y is not empty")
73     self.failUnless(mypde.getCoefficientOfGeneralPDE("y").isEmpty(),"y is not empty")
74     self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")
75     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")
77 gross 1072 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 jgs 149 self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("q"),q_ref),"q is not empty")
88     self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
89     def test_setCoefficient_f(self):
90     mypde=Poisson(self.domain,debug=self.DEBUG)
91     x=self.domain.getX()
92     Y_ref=interpolate(x[0],Function(self.domain))
93     A_ref=kronecker(self.domain)
94     mypde.setValue(f=x[0])
95     self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("A"),A_ref),"A is not kronecker")
96     self.failUnless(mypde.getCoefficientOfGeneralPDE("B").isEmpty(),"B is not empty")
97     self.failUnless(mypde.getCoefficientOfGeneralPDE("C").isEmpty(),"C is not empty")
98     self.failUnless(mypde.getCoefficientOfGeneralPDE("D").isEmpty(),"D is not empty")
99     self.failUnless(mypde.getCoefficientOfGeneralPDE("X").isEmpty(),"X is not empty")
100     self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("Y"),Y_ref),"Y is not x[0]")
101     self.failUnless(mypde.getCoefficientOfGeneralPDE("y").isEmpty(),"y is not empty")
102     self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")
103     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")
105 gross 1072 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 jgs 149 self.failUnless(mypde.getCoefficientOfGeneralPDE("q").isEmpty(),"q is not empty")
116     self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
117 gross 1072 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")
144     self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
145 jgs 149 def test_solve(self):
146     d=self.domain.getDim()
147     cf=ContinuousFunction(self.domain)
148     x=cf.getX()
149     #construct exact solution:
150     u_ex=Scalar(1.,cf)
151     for i in range(d):
152     u_ex*=x[i]*(2.-x[i])
153     #construct mask:
154     msk=Scalar(0.,cf)
155     for i in range(d):
156 gross 304 msk+=whereZero(x[i])
157 jgs 149 #construct right hand side
158     f=Scalar(0,cf)
159     for i in range(d):
160     f_p=Scalar(1,cf)
161     for j in range(d):
162     if i==j:
163     f_p*=2.
164     else:
165     f_p*=x[j]*(2-x[j])
166     f+=f_p
167     mypde=Poisson(self.domain)
168     mypde.setValue(f=f,q=msk)
169     u=mypde.getSolution()
170     self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution")
171    
172 gross 855 class Test_LinearPDE_noLumping(Test_linearPDEs):
173 jgs 149 N=4
174     def test_setCoefficient_WithIllegalFunctionSpace(self):
175     mypde=LinearPDE(self.domain,debug=self.DEBUG)
176     try:
177     success=True
178     mypde.setValue(C=Vector(0.,FunctionOnBoundary(self.domain)))
179 gross 1072 except IllegalCoefficientFunctionSpace:
180 jgs 149 success=False
181     self.failUnless(not success,'inapropraite function space accepted')
182    
183     def test_resetCoefficient_WithWrongShape(self):
184     mypde=LinearPDE(self.domain,numEquations=2,debug=self.DEBUG)
185     try:
186     success=True
187     mypde.setValue(C=0.)
188     except IllegalCoefficientValue:
189     success=False
190     self.failUnless(not success,'illegal shape accepted')
191     def test_reducedOn(self):
192     mypde=LinearPDE(self.domain,debug=self.DEBUG)
193     x=self.domain.getX()
194     mypde.setReducedOrderOn()
195     mypde.setValue(A=kronecker(self.domain),D=x[0],Y=x[0])
196     u=mypde.getSolution()
197     self.failUnless(self.check(u,1.),'solution is wrong.')
198    
199     def test_attemptToChangeOrderAfterDefinedCoefficient(self):
200     mypde=LinearPDE(self.domain,debug=self.DEBUG)
201     mypde.setValue(D=1.)
202     try:
203     success=True
204     mypde.setReducedOrderOn()
205     except RuntimeError:
206     success=False
207     self.failUnless(not success,'alterion of order after coefficient is changed not detected.')
208    
209     def test_reducedOnConfig(self):
210     mypde=LinearPDE(self.domain,debug=self.DEBUG)
211     mypde.setReducedOrderOn()
212     self.failUnlessEqual((mypde.getFunctionSpaceForSolution(),mypde.getFunctionSpaceForEquation()),(ReducedSolution(self.domain),ReducedSolution(self.domain)),"reduced function spaces expected.")
213     #
214     # set coefficients for scalars:
215     #
216     def test_setCoefficient_A_Scalar(self):
217     d=self.domain.getDim()
218     mypde=LinearPDE(self.domain,debug=self.DEBUG)
219     mypde.setValue(A=numarray.ones((d,d)))
220     coeff=mypde.getCoefficientOfGeneralPDE("A")
221     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),Function(self.domain),1,1))
222     def test_setCoefficient_B_Scalar(self):
223     d=self.domain.getDim()
224     mypde=LinearPDE(self.domain,debug=self.DEBUG)
225     mypde.setValue(B=numarray.ones((d,)))
226     coeff=mypde.getCoefficientOfGeneralPDE("B")
227     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1))
228     def test_setCoefficient_C_Scalar(self):
229     d=self.domain.getDim()
230     mypde=LinearPDE(self.domain,debug=self.DEBUG)
231     mypde.setValue(C=numarray.ones((d,)))
232     coeff=mypde.getCoefficientOfGeneralPDE("C")
233     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1))
234     def test_setCoefficient_D_Scalar(self):
235     d=self.domain.getDim()
236     mypde=LinearPDE(self.domain,debug=self.DEBUG)
237     mypde.setValue(D=1.)
238     coeff=mypde.getCoefficientOfGeneralPDE("D")
239     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),Function(self.domain),1,1))
240     def test_setCoefficient_X_Scalar(self):
241     d=self.domain.getDim()
242     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
243     mypde.setValue(X=numarray.ones((d,)))
244     coeff=mypde.getCoefficientOfGeneralPDE("X")
245     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),Function(self.domain),1))
246     def test_setCoefficient_Y_Scalar(self):
247     d=self.domain.getDim()
248     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
249     mypde.setValue(Y=1.)
250     coeff=mypde.getCoefficientOfGeneralPDE("Y")
251     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),Function(self.domain),1))
252     def test_setCoefficient_y_Scalar(self):
253     d=self.domain.getDim()
254     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
255     mypde.setValue(y=1.)
256     coeff=mypde.getCoefficientOfGeneralPDE("y")
257     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1))
258     def test_setCoefficient_d_Scalar(self):
259     d=self.domain.getDim()
260     mypde=LinearPDE(self.domain,debug=self.DEBUG)
261     mypde.setValue(d=1.)
262     coeff=mypde.getCoefficientOfGeneralPDE("d")
263     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1))
264     def test_setCoefficient_d_contact_Scalar(self):
265     d=self.domain.getDim()
266     mypde=LinearPDE(self.domain,debug=self.DEBUG)
267     mypde.setValue(d_contact=1.)
268     coeff=mypde.getCoefficientOfGeneralPDE("d_contact")
269     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1,1))
270     def test_setCoefficient_y_contact_Scalar(self):
271     d=self.domain.getDim()
272     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
273     mypde.setValue(y_contact=1.)
274     coeff=mypde.getCoefficientOfGeneralPDE("y_contact")
275     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))
276 gross 1072 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 jgs 149 def test_setCoefficient_r_Scalar(self):
337     d=self.domain.getDim()
338     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
339     mypde.setValue(r=1.)
340     coeff=mypde.getCoefficientOfGeneralPDE("r")
341     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1))
342     def test_setCoefficient_q_Scalar(self):
343     d=self.domain.getDim()
344     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
345     mypde.setValue(q=1.)
346     coeff=mypde.getCoefficientOfGeneralPDE("q")
347     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1))
348     def test_setCoefficient_r_Scalar_reducedOn(self):
349     d=self.domain.getDim()
350     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
351     mypde.setReducedOrderOn()
352     mypde.setValue(r=1.)
353     coeff=mypde.getCoefficientOfGeneralPDE("r")
354     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
355     def test_setCoefficient_q_Scalar_reducedOn(self):
356     d=self.domain.getDim()
357     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
358     mypde.setReducedOrderOn()
359     mypde.setValue(q=1.)
360     coeff=mypde.getCoefficientOfGeneralPDE("q")
361     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
362    
363 gross 1072 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 jgs 149 #
424     # set coefficients for systems:
425     #
426     def test_setCoefficient_A_System(self):
427     d=self.domain.getDim()
428     mypde=LinearPDE(self.domain,debug=self.DEBUG)
429     mypde.setValue(A=numarray.ones((self.N,d,self.N,d)))
430     coeff=mypde.getCoefficientOfGeneralPDE("A")
431     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),Function(self.domain),self.N,self.N))
432     def test_setCoefficient_B_System(self):
433     d=self.domain.getDim()
434     mypde=LinearPDE(self.domain,debug=self.DEBUG)
435     mypde.setValue(B=numarray.ones((self.N,d,self.N)))
436     coeff=mypde.getCoefficientOfGeneralPDE("B")
437     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),Function(self.domain),self.N,self.N))
438     def test_setCoefficient_C_System(self):
439     d=self.domain.getDim()
440     mypde=LinearPDE(self.domain,debug=self.DEBUG)
441     mypde.setValue(C=numarray.ones((self.N,self.N,d)))
442     coeff=mypde.getCoefficientOfGeneralPDE("C")
443     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),Function(self.domain),self.N,self.N))
444     def test_setCoefficient_D_System(self):
445     d=self.domain.getDim()
446     mypde=LinearPDE(self.domain,debug=self.DEBUG)
447     mypde.setValue(D=numarray.ones((self.N,self.N)))
448     coeff=mypde.getCoefficientOfGeneralPDE("D")
449     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),Function(self.domain),self.N,self.N))
450     def test_setCoefficient_X_System(self):
451     d=self.domain.getDim()
452     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
453     mypde.setValue(X=numarray.ones((self.N,d)))
454     coeff=mypde.getCoefficientOfGeneralPDE("X")
455     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),Function(self.domain),self.N))
456     def test_setCoefficient_Y_System(self):
457     d=self.domain.getDim()
458     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
459     mypde.setValue(Y=numarray.ones((self.N,)))
460     coeff=mypde.getCoefficientOfGeneralPDE("Y")
461     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),Function(self.domain),self.N))
462     def test_setCoefficient_y_System(self):
463     d=self.domain.getDim()
464     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
465     mypde.setValue(y=numarray.ones((self.N,)))
466     coeff=mypde.getCoefficientOfGeneralPDE("y")
467     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnBoundary(self.domain),self.N))
468     def test_setCoefficient_d_System(self):
469     d=self.domain.getDim()
470     mypde=LinearPDE(self.domain,debug=self.DEBUG)
471     mypde.setValue(d=numarray.ones((self.N,self.N)))
472     coeff=mypde.getCoefficientOfGeneralPDE("d")
473     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnBoundary(self.domain),self.N,self.N))
474     def test_setCoefficient_d_contact_System(self):
475     d=self.domain.getDim()
476     mypde=LinearPDE(self.domain,debug=self.DEBUG)
477     mypde.setValue(d_contact=numarray.ones((self.N,self.N)))
478     coeff=mypde.getCoefficientOfGeneralPDE("d_contact")
479     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnContactZero(self.domain),self.N,self.N))
480     def test_setCoefficient_y_contact_System(self):
481     d=self.domain.getDim()
482     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
483     mypde.setValue(y_contact=numarray.ones((self.N,)))
484     coeff=mypde.getCoefficientOfGeneralPDE("y_contact")
485     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N))
486 gross 1072 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 jgs 149 def test_setCoefficient_r_System(self):
547     d=self.domain.getDim()
548     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
549     mypde.setValue(r=numarray.ones((self.N,)))
550     coeff=mypde.getCoefficientOfGeneralPDE("r")
551     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
552     def test_setCoefficient_q_System(self):
553     d=self.domain.getDim()
554     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
555     mypde.setValue(q=numarray.ones((self.N,)))
556     coeff=mypde.getCoefficientOfGeneralPDE("q")
557     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
558     def test_setCoefficient_r_System_reducedOn(self):
559     d=self.domain.getDim()
560     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
561     mypde.setReducedOrderOn()
562     mypde.setValue(r=numarray.ones((self.N,)))
563     coeff=mypde.getCoefficientOfGeneralPDE("r")
564     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
565     def test_setCoefficient_q_System_reducedOn(self):
566     d=self.domain.getDim()
567     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
568     mypde.setReducedOrderOn()
569     mypde.setValue(q=numarray.ones((self.N,)))
570     coeff=mypde.getCoefficientOfGeneralPDE("q")
571     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
572    
573 gross 1072 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 jgs 149 def test_resetCoefficient_HomogeneousConstraint(self):
634     mypde=LinearPDE(self.domain,debug=self.DEBUG)
635     x=self.domain.getX()
636 gross 304 mypde.setValue(A=kronecker(self.domain),Y=1.,q=whereZero(x[0]))
637 jgs 149 u1=mypde.getSolution()
638     mypde.setValue(Y=2.)
639     u2=mypde.getSolution()
640     self.failUnless(self.check(u2,2*u1),'solution is wrong.')
641    
642     def test_resetCoefficient_InHomogeneousConstraint(self):
643     mypde=LinearPDE(self.domain,debug=self.DEBUG)
644 jgs 154 mypde.setSymmetryOn()
645 jgs 149 x=self.domain.getX()
646 gross 304 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.,r=1,q=whereZero(x[0]))
647 jgs 154 u1=mypde.getSolution(verbose=self.VERBOSE)
648 jgs 149 mypde.setValue(Y=2.,D=2)
649 jgs 154 u2=mypde.getSolution(verbose=self.VERBOSE)
650     self.failUnless(self.check(u2,u1),'first solution is wrong.')
651     u2=mypde.getSolution(verbose=self.VERBOSE)
652     self.failUnless(self.check(u2,u1),'first solution is wrong.')
653 jgs 149 mypde.setValue(r=2,Y=4.)
654 jgs 154 u2=mypde.getSolution(verbose=self.VERBOSE)
655     self.failUnless(self.check(u2,2*u1),'second solution is wrong.')
656 jgs 149
657     def test_symmetryCheckTrue_System(self):
658     d=self.domain.getDim()
659     mypde=LinearPDE(self.domain,debug=self.DEBUG)
660     A=numarray.ones((self.N,d,self.N,d))
661     C=2*numarray.ones((self.N,self.N,d))
662     B=2*numarray.ones((self.N,d,self.N))
663     D=3*numarray.ones((self.N,self.N))
664     d=4*numarray.ones((self.N,self.N))
665     d_contact=5*numarray.ones((self.N,self.N))
666 gross 1072 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 jgs 149 self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
668    
669     def test_symmetryCheckFalse_A_System(self):
670     d=self.domain.getDim()
671     mypde=LinearPDE(self.domain,debug=self.DEBUG)
672     A=numarray.ones((self.N,d,self.N,d))
673     A[1,1,1,0]=0.
674     mypde.setValue(A=A)
675     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
676     def test_symmetryCheckFalse_BC_System(self):
677     d=self.domain.getDim()
678     mypde=LinearPDE(self.domain,debug=self.DEBUG)
679     C=2*numarray.ones((self.N,self.N,d))
680     B=2*numarray.ones((self.N,d,self.N))
681     B[0,0,1]=1.
682     mypde.setValue(B=B,C=C)
683     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
684    
685     def test_symmetryCheckFalse_D_System(self):
686     mypde=LinearPDE(self.domain,debug=self.DEBUG)
687     D=3*numarray.ones((self.N,self.N))
688     D[0,1]=0.
689     mypde.setValue(D=D)
690     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
691    
692     def test_symmetryCheckFalse_d_System(self):
693     mypde=LinearPDE(self.domain,debug=self.DEBUG)
694     d=4*numarray.ones((self.N,self.N))
695     d[0,1]=0.
696     mypde.setValue(d=d)
697     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
698    
699     def test_symmetryCheckFalse_d_contact_System(self):
700     mypde=LinearPDE(self.domain,debug=self.DEBUG)
701     d_contact=5*numarray.ones((self.N,self.N))
702     d_contact[0,1]=0.
703     mypde.setValue(d_contact=d_contact)
704     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
705    
706 gross 1072 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 jgs 149 def test_symmetryCheckTrue_Scalar(self):
744     d=self.domain.getDim()
745     mypde=LinearPDE(self.domain,debug=self.DEBUG)
746     A=numarray.ones((d,d))
747     C=2*numarray.ones((d,))
748     B=2*numarray.ones((d,))
749     D=3
750     d=4
751     d_contact=5
752 gross 1072 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 jgs 149 self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
754    
755     def test_symmetryCheckFalse_A_Scalar(self):
756     d=self.domain.getDim()
757     mypde=LinearPDE(self.domain,debug=self.DEBUG)
758     A=numarray.ones((d,d))
759     A[1,0]=0.
760     mypde.setValue(A=A)
761     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
762     def test_symmetryCheckFalse_BC_Scalar(self):
763     d=self.domain.getDim()
764     mypde=LinearPDE(self.domain,debug=self.DEBUG)
765     C=2*numarray.ones((d,))
766     B=2*numarray.ones((d,))
767     B[0]=1.
768     mypde.setValue(B=B,C=C)
769     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
770 gross 1072 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 jgs 149 #
786     # solver checks:
787     #
788     def test_symmetryOnIterative(self):
789     mypde=LinearPDE(self.domain,debug=self.DEBUG)
790     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
791     u=mypde.getSolution(verbose=self.VERBOSE)
792     self.failUnless(self.check(u,1.),'solution is wrong.')
793     def test_symmetryOnDirect(self):
794     mypde=LinearPDE(self.domain,debug=self.DEBUG)
795     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
796     mypde.setSolverMethod(mypde.DIRECT)
797     u=mypde.getSolution(verbose=self.VERBOSE)
798     self.failUnless(self.check(u,1.),'solution is wrong.')
799     def test_PCG_JACOBI(self):
800     mypde=LinearPDE(self.domain,debug=self.DEBUG)
801     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
802 gross 387 mypde.setSolverMethod(mypde.PCG,mypde.JACOBI)
803     u=mypde.getSolution(verbose=self.VERBOSE)
804 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
805     def test_PCG_ILU0(self):
806     mypde=LinearPDE(self.domain,debug=self.DEBUG)
807     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
808 gross 387 mypde.setSolverMethod(mypde.PCG,mypde.ILU0)
809     u=mypde.getSolution(verbose=self.VERBOSE)
810 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
811     def test_DIRECT(self):
812     mypde=LinearPDE(self.domain,debug=self.DEBUG)
813     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
814     mypde.setSolverMethod(mypde.DIRECT)
815 jgs 154 u=mypde.getSolution(verbose=self.VERBOSE)
816 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
817     def test_BICGSTAB_JACOBI(self):
818     mypde=LinearPDE(self.domain,debug=self.DEBUG)
819 gross 387 mypde.setSolverMethod(mypde.BICGSTAB,mypde.JACOBI)
820 jgs 149 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
821 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
822 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
823     def test_BICGSTAB_ILU0(self):
824     mypde=LinearPDE(self.domain,debug=self.DEBUG)
825     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
826 gross 387 mypde.setSolverMethod(mypde.BICGSTAB,mypde.ILU0)
827     u=mypde.getSolution(verbose=self.VERBOSE)
828 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
829     def test_PRES20_JACOBI(self):
830     mypde=LinearPDE(self.domain,debug=self.DEBUG)
831     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
832 gross 387 mypde.setSolverMethod(mypde.PRES20,mypde.JACOBI)
833     u=mypde.getSolution(verbose=self.VERBOSE)
834 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
835     def test_PRES20_ILU0(self):
836     mypde=LinearPDE(self.domain,debug=self.DEBUG)
837     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
838 gross 387 mypde.setSolverMethod(mypde.PRES20,mypde.ILU0)
839     u=mypde.getSolution(verbose=self.VERBOSE)
840 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
841     def test_GMRESnoRestart_JACOBI(self):
842     mypde=LinearPDE(self.domain,debug=self.DEBUG)
843     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
844 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
845     # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
846     u=mypde.getSolution(verbose=self.VERBOSE)
847 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
848     def test_GMRESnoRestart_ILU0(self):
849     mypde=LinearPDE(self.domain,debug=self.DEBUG)
850     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
851 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
852     # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
853     u=mypde.getSolution(verbose=self.VERBOSE)
854 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
855     def test_GMRES_JACOBI(self):
856     mypde=LinearPDE(self.domain,debug=self.DEBUG)
857     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
858 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
859     u=mypde.getSolution(verbose=self.VERBOSE)
860 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
861     def test_GMRES_ILU0(self):
862     mypde=LinearPDE(self.domain,debug=self.DEBUG)
863     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
864 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
865     u=mypde.getSolution(verbose=self.VERBOSE)
866 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
867     def test_GMRES_truncation_restart_JACOBI(self):
868     mypde=LinearPDE(self.domain,debug=self.DEBUG)
869     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
870 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
871     u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
872 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
873     def test_GMRES_truncation_restart_ILU0(self):
874     mypde=LinearPDE(self.domain,debug=self.DEBUG)
875     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
876 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
877     u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
878 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
879 gross 855
880     class Test_LinearPDE(Test_LinearPDE_noLumping):
881 jgs 149 def test_Lumping_attemptToSetA(self):
882     mypde=LinearPDE(self.domain,debug=self.DEBUG)
883     try:
884     success=True
885     mypde.setSolverMethod(mypde.LUMPING)
886     mypde.setValue(A=kronecker(self.domain))
887     u=mypde.getSolution(verbose=self.VERBOSE)
888 gross 531 except ValueError:
889 jgs 149 success=False
890 gross 531 self.failUnless(not success,'error should be issued')
891 jgs 149 def test_Lumping_attemptToSetB(self):
892     mypde=LinearPDE(self.domain,debug=self.DEBUG)
893     try:
894     success=True
895     mypde.setSolverMethod(mypde.LUMPING)
896     mypde.setValue(B=kronecker(self.domain)[0])
897     u=mypde.getSolution(verbose=self.VERBOSE)
898 gross 531 except ValueError:
899 jgs 149 success=False
900 gross 531 self.failUnless(not success,'error should be issued')
901 jgs 149 def test_Lumping_attemptToSetC(self):
902     mypde=LinearPDE(self.domain,debug=self.DEBUG)
903     try:
904     success=True
905     mypde.setSolverMethod(mypde.LUMPING)
906     mypde.setValue(C=kronecker(self.domain)[0])
907     u=mypde.getSolution(verbose=self.VERBOSE)
908 gross 531 except ValueError:
909 jgs 149 success=False
910 gross 531 self.failUnless(not success,'error should be issued')
911 jgs 149
912 gross 1072 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')
942    
943 jgs 149 def test_Lumping(self):
944     mypde=LinearPDE(self.domain,debug=self.DEBUG)
945     mypde.setSolverMethod(mypde.LUMPING)
946     mypde.setValue(D=1.,Y=1.)
947 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
948 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
949     def test_Constrained_Lumping(self):
950     x=self.domain.getX()
951     mypde=LinearPDE(self.domain,debug=self.DEBUG)
952     mypde.setSolverMethod(mypde.LUMPING)
953 gross 304 mypde.setValue(D=1.,Y=1.,q=whereZero(x[0]),r=1.)
954 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
955 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
956 gross 531
957     def test_Lumping_System(self):
958     mypde=LinearPDE(self.domain,debug=self.DEBUG)
959     mypde.setSolverMethod(mypde.LUMPING)
960     mypde.setValue(D=numarray.array([[1.,0.],[0.,2.]]),Y=numarray.array([1.,2.]))
961     u=mypde.getSolution(verbose=self.VERBOSE)
962     self.failUnless(self.check(u,numarray.ones((2,))),'solution is wrong.')
963     def test_Constrained_Lumping_System(self):
964     x=self.domain.getX()
965     mypde=LinearPDE(self.domain,debug=self.DEBUG)
966     mypde.setSolverMethod(mypde.LUMPING)
967     mypde.setValue(D=numarray.array([[1.,0.],[0.,2.]]),Y=numarray.array([1.,2.]), \
968     q=whereZero(x[0])*[0.,1],r=[0.,1.])
969     u=mypde.getSolution(verbose=self.VERBOSE)
970     self.failUnless(self.check(u,numarray.ones((2,))),'solution is wrong.')
971    
972 jgs 149 def test_Lumping_updateRHS(self):
973     x=self.domain.getX()
974     mypde=LinearPDE(self.domain,debug=self.DEBUG)
975     mypde.setSolverMethod(mypde.LUMPING)
976     mypde.setValue(D=1.,Y=1.)
977 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
978 jgs 149 self.failUnless(self.check(u,1.),'first solution is wrong.')
979 gross 304 mypde.setValue(Y=2.,q=whereZero(x[0]),r=2.)
980 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
981 jgs 149 self.failUnless(self.check(u,2.),'second solution is wrong.')
982     def test_Lumping_updateOperator(self):
983     x=self.domain.getX()
984     mypde=LinearPDE(self.domain,debug=self.DEBUG)
985     mypde.setSolverMethod(mypde.LUMPING)
986     mypde.setValue(D=1.,Y=1.)
987 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
988 jgs 149 mypde.setValue(D=2.)
989 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
990 jgs 149 self.failUnless(self.check(u,0.5),'second solution is wrong.')
991    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26