/[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 1859 - (hide annotations)
Wed Oct 8 03:03:37 2008 UTC (11 years, 1 month ago) by gross
File MIME type: text/x-python
File size: 112674 byte(s)
first version of testing for transport solver.
1 ksteube 1809
2     ########################################################
3 ksteube 1312 #
4 ksteube 1809 # Copyright (c) 2003-2008 by University of Queensland
5     # Earth Systems Science Computational Center (ESSCC)
6     # http://www.uq.edu.au/esscc
7 ksteube 1312 #
8 ksteube 1809 # Primary Business: Queensland, Australia
9     # Licensed under the Open Software License version 3.0
10     # http://www.opensource.org/licenses/osl-3.0.php
11 ksteube 1312 #
12 ksteube 1809 ########################################################
13 jgs 149
14 ksteube 1809 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15     Earth Systems Science Computational Center (ESSCC)
16     http://www.uq.edu.au/esscc
17     Primary Business: Queensland, Australia"""
18     __license__="""Licensed under the Open Software License version 3.0
19     http://www.opensource.org/licenses/osl-3.0.php"""
20     __url__="http://www.uq.edu.au/esscc/escript-finley"
21    
22 jgs 149 """
23     Test suite for linearPDEs class
24    
25     The tests must be linked with a Domain class object in the setUp method:
26    
27     from esys.finley import Rectangle
28     class Test_LinearPDEOnFinley(Test_LinearPDE):
29     def setUp(self):
30     self.domain = Rectangle(10,10,2)
31 gross 798 def tearDown(self):
32     del self.domain
33 jgs 149 suite = unittest.TestSuite()
34     suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley))
35     unittest.TextTestRunner(verbosity=2).run(suite)
36    
37 gross 637 @var __author__: name of author
38     @var __copyright__: copyrights
39     @var __license__: licence agreement
40     @var __url__: url entry point on documentation
41     @var __version__: version
42     @var __date__: date of the version
43 jgs 149 """
44    
45     __author__="Lutz Gross, l.gross@uq.edu.au"
46    
47 gross 304 from esys.escript.util import Lsup,kronecker,interpolate,whereZero
48 ksteube 1312 from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar, ReducedFunction,ReducedFunctionOnBoundary,ReducedFunctionOnContactZero,Data, Tensor4, Tensor
49 gross 1859 from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace, TransportPDE, IllegalCoefficient
50 jgs 149 import numarray
51     import unittest
52    
53     class Test_linearPDEs(unittest.TestCase):
54     TOL=1.e-6
55 jgs 153 SOLVER_TOL=1.e-10
56 jgs 149 DEBUG=False
57     VERBOSE=False
58     def check(self,arg,ref_arg,tol=None):
59     """
60     checks if arg and ref_arg are nearly identical using the L{Lsup<esys.escript.util.Lsup>}
61     """
62     if tol==None: tol=self.TOL
63     return Lsup(arg-ref_arg)<=tol*Lsup(ref_arg)
64    
65     class Test_Poisson(Test_linearPDEs):
66    
67     def test_config(self):
68     mypde=Poisson(self.domain,debug=self.DEBUG)
69     self.failUnlessEqual((mypde.getNumEquations(),mypde.getNumSolutions(),mypde.isSymmetric()),(1,1,True),"set up incorrect")
70     def test_setCoefficient_q(self):
71     mypde=Poisson(self.domain,debug=self.DEBUG)
72     x=self.domain.getX()
73 gross 304 q_ref=interpolate(whereZero(x[0]),Solution(self.domain))
74 jgs 149 A_ref=kronecker(self.domain)
75 gross 304 mypde.setValue(q=whereZero(x[0]))
76 gross 1841 self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
77     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
78     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
79     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
80     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
81     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
82     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
83     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
84     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
85     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
86     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
87     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
88     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
89     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
90     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
91     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
92     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
93     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
94     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
95     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
96     self.failUnless(self.check(mypde.getCoefficient("q"),q_ref),"q is not empty")
97     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
98 jgs 149 def test_setCoefficient_f(self):
99     mypde=Poisson(self.domain,debug=self.DEBUG)
100     x=self.domain.getX()
101     Y_ref=interpolate(x[0],Function(self.domain))
102     A_ref=kronecker(self.domain)
103     mypde.setValue(f=x[0])
104 gross 1841 self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
105     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
106     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
107     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
108     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
109     self.failUnless(self.check(mypde.getCoefficient("Y"),Y_ref),"Y is not x[0]")
110     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
111     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
112     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
113     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
114     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
115     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
116     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
117     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
118     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
119     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
120     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
121     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
122     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
123     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
124     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
125     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
126 gross 1072 def test_setCoefficient_f_reduced(self):
127     mypde=Poisson(self.domain,debug=self.DEBUG)
128     x=self.domain.getX()
129     Y_ref=interpolate(x[0],ReducedFunction(self.domain))
130     A_ref=kronecker(self.domain)
131     mypde.setValue(f_reduced=x[0])
132 gross 1841 self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
133     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
134     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
135     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
136     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
137     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
138     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
139     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
140     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
141     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
142     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
143     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
144     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
145     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
146     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
147     self.failUnless(self.check(mypde.getCoefficient("Y_reduced"),Y_ref),"Y_reduced is not x[0]")
148     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
149     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
150     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
151     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
152     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
153     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
154 jgs 149 def test_solve(self):
155     d=self.domain.getDim()
156     cf=ContinuousFunction(self.domain)
157     x=cf.getX()
158     #construct exact solution:
159     u_ex=Scalar(1.,cf)
160     for i in range(d):
161     u_ex*=x[i]*(2.-x[i])
162     #construct mask:
163     msk=Scalar(0.,cf)
164     for i in range(d):
165 gross 304 msk+=whereZero(x[i])
166 jgs 149 #construct right hand side
167     f=Scalar(0,cf)
168     for i in range(d):
169     f_p=Scalar(1,cf)
170     for j in range(d):
171     if i==j:
172     f_p*=2.
173     else:
174     f_p*=x[j]*(2-x[j])
175     f+=f_p
176     mypde=Poisson(self.domain)
177     mypde.setValue(f=f,q=msk)
178     u=mypde.getSolution()
179     self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution")
180    
181 gross 855 class Test_LinearPDE_noLumping(Test_linearPDEs):
182 jgs 149 N=4
183     def test_setCoefficient_WithIllegalFunctionSpace(self):
184     mypde=LinearPDE(self.domain,debug=self.DEBUG)
185 gross 1859 self.failUnlessRaises(IllegalCoefficientFunctionSpace,mypde.setValue, C=Vector(0.,FunctionOnBoundary(self.domain)))
186    
187     def test_setCoefficient_WithWrongName(self):
188     mypde=LinearPDE(self.domain,debug=self.DEBUG)
189     self.failUnlessRaises(IllegalCoefficient, mypde.setValue, ROMA=0.)
190    
191 jgs 149 def test_resetCoefficient_WithWrongShape(self):
192     mypde=LinearPDE(self.domain,numEquations=2,debug=self.DEBUG)
193 gross 1859 self.failUnlessRaises(IllegalCoefficientValue, mypde.setValue, C=0.)
194    
195 jgs 149 def test_reducedOn(self):
196     mypde=LinearPDE(self.domain,debug=self.DEBUG)
197     x=self.domain.getX()
198     mypde.setReducedOrderOn()
199     mypde.setValue(A=kronecker(self.domain),D=x[0],Y=x[0])
200     u=mypde.getSolution()
201     self.failUnless(self.check(u,1.),'solution is wrong.')
202    
203     def test_attemptToChangeOrderAfterDefinedCoefficient(self):
204     mypde=LinearPDE(self.domain,debug=self.DEBUG)
205     mypde.setValue(D=1.)
206 gross 1859 self.failUnlessRaises(RuntimeError,mypde.setReducedOrderOn)
207 jgs 149
208     def test_reducedOnConfig(self):
209     mypde=LinearPDE(self.domain,debug=self.DEBUG)
210     mypde.setReducedOrderOn()
211     self.failUnlessEqual((mypde.getFunctionSpaceForSolution(),mypde.getFunctionSpaceForEquation()),(ReducedSolution(self.domain),ReducedSolution(self.domain)),"reduced function spaces expected.")
212     #
213     # set coefficients for scalars:
214     #
215     def test_setCoefficient_A_Scalar(self):
216     d=self.domain.getDim()
217     mypde=LinearPDE(self.domain,debug=self.DEBUG)
218     mypde.setValue(A=numarray.ones((d,d)))
219 gross 1841 coeff=mypde.getCoefficient("A")
220 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),Function(self.domain),1,1))
221     def test_setCoefficient_B_Scalar(self):
222     d=self.domain.getDim()
223     mypde=LinearPDE(self.domain,debug=self.DEBUG)
224     mypde.setValue(B=numarray.ones((d,)))
225 gross 1841 coeff=mypde.getCoefficient("B")
226 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1))
227     def test_setCoefficient_C_Scalar(self):
228     d=self.domain.getDim()
229     mypde=LinearPDE(self.domain,debug=self.DEBUG)
230     mypde.setValue(C=numarray.ones((d,)))
231 gross 1841 coeff=mypde.getCoefficient("C")
232 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1))
233     def test_setCoefficient_D_Scalar(self):
234     d=self.domain.getDim()
235     mypde=LinearPDE(self.domain,debug=self.DEBUG)
236     mypde.setValue(D=1.)
237 gross 1841 coeff=mypde.getCoefficient("D")
238 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),Function(self.domain),1,1))
239     def test_setCoefficient_X_Scalar(self):
240     d=self.domain.getDim()
241     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
242     mypde.setValue(X=numarray.ones((d,)))
243 gross 1841 coeff=mypde.getCoefficient("X")
244 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),Function(self.domain),1))
245     def test_setCoefficient_Y_Scalar(self):
246     d=self.domain.getDim()
247     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
248     mypde.setValue(Y=1.)
249 gross 1841 coeff=mypde.getCoefficient("Y")
250 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),Function(self.domain),1))
251     def test_setCoefficient_y_Scalar(self):
252     d=self.domain.getDim()
253     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
254     mypde.setValue(y=1.)
255 gross 1841 coeff=mypde.getCoefficient("y")
256 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1))
257     def test_setCoefficient_d_Scalar(self):
258     d=self.domain.getDim()
259     mypde=LinearPDE(self.domain,debug=self.DEBUG)
260     mypde.setValue(d=1.)
261 gross 1841 coeff=mypde.getCoefficient("d")
262 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1))
263     def test_setCoefficient_d_contact_Scalar(self):
264     d=self.domain.getDim()
265     mypde=LinearPDE(self.domain,debug=self.DEBUG)
266     mypde.setValue(d_contact=1.)
267 gross 1841 coeff=mypde.getCoefficient("d_contact")
268 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1,1))
269     def test_setCoefficient_y_contact_Scalar(self):
270     d=self.domain.getDim()
271     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
272     mypde.setValue(y_contact=1.)
273 gross 1841 coeff=mypde.getCoefficient("y_contact")
274 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))
275 gross 1072 def test_setCoefficient_A_reduced_Scalar(self):
276     d=self.domain.getDim()
277     mypde=LinearPDE(self.domain,debug=self.DEBUG)
278     mypde.setValue(A_reduced=numarray.ones((d,d)))
279 gross 1841 coeff=mypde.getCoefficient("A_reduced")
280 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
281     def test_setCoefficient_B_reduced_Scalar(self):
282     d=self.domain.getDim()
283     mypde=LinearPDE(self.domain,debug=self.DEBUG)
284     mypde.setValue(B_reduced=numarray.ones((d,)))
285 gross 1841 coeff=mypde.getCoefficient("B_reduced")
286 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
287     def test_setCoefficient_C_reduced_Scalar(self):
288     d=self.domain.getDim()
289     mypde=LinearPDE(self.domain,debug=self.DEBUG)
290     mypde.setValue(C_reduced=numarray.ones((d,)))
291 gross 1841 coeff=mypde.getCoefficient("C_reduced")
292 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
293     def test_setCoefficient_D_reduced_Scalar(self):
294     d=self.domain.getDim()
295     mypde=LinearPDE(self.domain,debug=self.DEBUG)
296     mypde.setValue(D_reduced=1.)
297 gross 1841 coeff=mypde.getCoefficient("D_reduced")
298 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
299     def test_setCoefficient_X_reduced_Scalar(self):
300     d=self.domain.getDim()
301     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
302     mypde.setValue(X_reduced=numarray.ones((d,)))
303 gross 1841 coeff=mypde.getCoefficient("X_reduced")
304 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
305     def test_setCoefficient_Y_reduced_Scalar(self):
306     d=self.domain.getDim()
307     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
308     mypde.setValue(Y_reduced=1.)
309 gross 1841 coeff=mypde.getCoefficient("Y_reduced")
310 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
311     def test_setCoefficient_y_reduced_Scalar(self):
312     d=self.domain.getDim()
313     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
314     mypde.setValue(y_reduced=1.)
315 gross 1841 coeff=mypde.getCoefficient("y_reduced")
316 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
317     def test_setCoefficient_d_reduced_Scalar(self):
318     d=self.domain.getDim()
319     mypde=LinearPDE(self.domain,debug=self.DEBUG)
320     mypde.setValue(d_reduced=1.)
321 gross 1841 coeff=mypde.getCoefficient("d_reduced")
322 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
323     def test_setCoefficient_d_contact_reduced_Scalar(self):
324     d=self.domain.getDim()
325     mypde=LinearPDE(self.domain,debug=self.DEBUG)
326     mypde.setValue(d_contact_reduced=1.)
327 gross 1841 coeff=mypde.getCoefficient("d_contact_reduced")
328 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
329     def test_setCoefficient_y_contact_reduced_Scalar(self):
330     d=self.domain.getDim()
331     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
332     mypde.setValue(y_contact_reduced=1.)
333 gross 1841 coeff=mypde.getCoefficient("y_contact_reduced")
334 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
335 jgs 149 def test_setCoefficient_r_Scalar(self):
336     d=self.domain.getDim()
337     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
338     mypde.setValue(r=1.)
339 gross 1841 coeff=mypde.getCoefficient("r")
340 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1))
341     def test_setCoefficient_q_Scalar(self):
342     d=self.domain.getDim()
343     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
344     mypde.setValue(q=1.)
345 gross 1841 coeff=mypde.getCoefficient("q")
346 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1))
347     def test_setCoefficient_r_Scalar_reducedOn(self):
348     d=self.domain.getDim()
349     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
350     mypde.setReducedOrderOn()
351     mypde.setValue(r=1.)
352 gross 1841 coeff=mypde.getCoefficient("r")
353 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
354     def test_setCoefficient_q_Scalar_reducedOn(self):
355     d=self.domain.getDim()
356     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
357     mypde.setReducedOrderOn()
358     mypde.setValue(q=1.)
359 gross 1841 coeff=mypde.getCoefficient("q")
360 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
361    
362 gross 1072 def test_setCoefficient_A_reduced_Scalar_usingA(self):
363     d=self.domain.getDim()
364     mypde=LinearPDE(self.domain,debug=self.DEBUG)
365     mypde.setValue(A=Data(numarray.ones((d,d)),ReducedFunction(self.domain)))
366 gross 1841 coeff=mypde.getCoefficient("A_reduced")
367 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
368     def test_setCoefficient_B_reduced_Scalar_usingB(self):
369     d=self.domain.getDim()
370     mypde=LinearPDE(self.domain,debug=self.DEBUG)
371     mypde.setValue(B=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
372 gross 1841 coeff=mypde.getCoefficient("B_reduced")
373 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
374     def test_setCoefficient_C_reduced_Scalar_usingC(self):
375     d=self.domain.getDim()
376     mypde=LinearPDE(self.domain,debug=self.DEBUG)
377     mypde.setValue(C=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
378 gross 1841 coeff=mypde.getCoefficient("C_reduced")
379 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
380     def test_setCoefficient_D_reduced_Scalar_usingD(self):
381     d=self.domain.getDim()
382     mypde=LinearPDE(self.domain,debug=self.DEBUG)
383     mypde.setValue(D=Scalar(1.,ReducedFunction(self.domain)))
384 gross 1841 coeff=mypde.getCoefficient("D_reduced")
385 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
386     def test_setCoefficient_X_reduced_Scalar_usingX(self):
387     d=self.domain.getDim()
388     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
389     mypde.setValue(X_reduced=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
390 gross 1841 coeff=mypde.getCoefficient("X_reduced")
391 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
392     def test_setCoefficient_Y_reduced_Scalar_usingY(self):
393     d=self.domain.getDim()
394     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
395     mypde.setValue(Y=Scalar(1.,ReducedFunction(self.domain)))
396 gross 1841 coeff=mypde.getCoefficient("Y_reduced")
397 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
398     def test_setCoefficient_y_reduced_Scalar_using_y(self):
399     d=self.domain.getDim()
400     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
401     mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
402 gross 1841 coeff=mypde.getCoefficient("y_reduced")
403 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
404     def test_setCoefficient_d_reduced_Scalar_using_d(self):
405     d=self.domain.getDim()
406     mypde=LinearPDE(self.domain,debug=self.DEBUG)
407     mypde.setValue(d=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
408 gross 1841 coeff=mypde.getCoefficient("d_reduced")
409 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
410     def test_setCoefficient_d_contact_reduced_Scalar_using_d_contact(self):
411     d=self.domain.getDim()
412     mypde=LinearPDE(self.domain,debug=self.DEBUG)
413     mypde.setValue(d_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
414 gross 1841 coeff=mypde.getCoefficient("d_contact_reduced")
415 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
416     def test_setCoefficient_y_contact_reduced_Scalar_using_y_contact(self):
417     d=self.domain.getDim()
418     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
419     mypde.setValue(y_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
420 gross 1841 coeff=mypde.getCoefficient("y_contact_reduced")
421 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
422 jgs 149 #
423     # set coefficients for systems:
424     #
425     def test_setCoefficient_A_System(self):
426     d=self.domain.getDim()
427     mypde=LinearPDE(self.domain,debug=self.DEBUG)
428     mypde.setValue(A=numarray.ones((self.N,d,self.N,d)))
429 gross 1841 coeff=mypde.getCoefficient("A")
430 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),Function(self.domain),self.N,self.N))
431     def test_setCoefficient_B_System(self):
432     d=self.domain.getDim()
433     mypde=LinearPDE(self.domain,debug=self.DEBUG)
434     mypde.setValue(B=numarray.ones((self.N,d,self.N)))
435 gross 1841 coeff=mypde.getCoefficient("B")
436 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),Function(self.domain),self.N,self.N))
437     def test_setCoefficient_C_System(self):
438     d=self.domain.getDim()
439     mypde=LinearPDE(self.domain,debug=self.DEBUG)
440     mypde.setValue(C=numarray.ones((self.N,self.N,d)))
441 gross 1841 coeff=mypde.getCoefficient("C")
442 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),Function(self.domain),self.N,self.N))
443     def test_setCoefficient_D_System(self):
444     d=self.domain.getDim()
445     mypde=LinearPDE(self.domain,debug=self.DEBUG)
446     mypde.setValue(D=numarray.ones((self.N,self.N)))
447 gross 1841 coeff=mypde.getCoefficient("D")
448 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),Function(self.domain),self.N,self.N))
449     def test_setCoefficient_X_System(self):
450     d=self.domain.getDim()
451     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
452     mypde.setValue(X=numarray.ones((self.N,d)))
453 gross 1841 coeff=mypde.getCoefficient("X")
454 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),Function(self.domain),self.N))
455     def test_setCoefficient_Y_System(self):
456     d=self.domain.getDim()
457     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
458     mypde.setValue(Y=numarray.ones((self.N,)))
459 gross 1841 coeff=mypde.getCoefficient("Y")
460 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),Function(self.domain),self.N))
461     def test_setCoefficient_y_System(self):
462     d=self.domain.getDim()
463     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
464     mypde.setValue(y=numarray.ones((self.N,)))
465 gross 1841 coeff=mypde.getCoefficient("y")
466 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnBoundary(self.domain),self.N))
467     def test_setCoefficient_d_System(self):
468     d=self.domain.getDim()
469     mypde=LinearPDE(self.domain,debug=self.DEBUG)
470     mypde.setValue(d=numarray.ones((self.N,self.N)))
471 gross 1841 coeff=mypde.getCoefficient("d")
472 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnBoundary(self.domain),self.N,self.N))
473     def test_setCoefficient_d_contact_System(self):
474     d=self.domain.getDim()
475     mypde=LinearPDE(self.domain,debug=self.DEBUG)
476     mypde.setValue(d_contact=numarray.ones((self.N,self.N)))
477 gross 1841 coeff=mypde.getCoefficient("d_contact")
478 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnContactZero(self.domain),self.N,self.N))
479     def test_setCoefficient_y_contact_System(self):
480     d=self.domain.getDim()
481     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
482     mypde.setValue(y_contact=numarray.ones((self.N,)))
483 gross 1841 coeff=mypde.getCoefficient("y_contact")
484 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N))
485 gross 1072 def test_setCoefficient_A_reduced_System(self):
486     d=self.domain.getDim()
487     mypde=LinearPDE(self.domain,debug=self.DEBUG)
488     mypde.setValue(A_reduced=numarray.ones((self.N,d,self.N,d)))
489 gross 1841 coeff=mypde.getCoefficient("A_reduced")
490 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
491     def test_setCoefficient_B_reduced_System(self):
492     d=self.domain.getDim()
493     mypde=LinearPDE(self.domain,debug=self.DEBUG)
494     mypde.setValue(B_reduced=numarray.ones((self.N,d,self.N)))
495 gross 1841 coeff=mypde.getCoefficient("B_reduced")
496 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
497     def test_setCoefficient_C_reduced_System(self):
498     d=self.domain.getDim()
499     mypde=LinearPDE(self.domain,debug=self.DEBUG)
500     mypde.setValue(C_reduced=numarray.ones((self.N,self.N,d)))
501 gross 1841 coeff=mypde.getCoefficient("C_reduced")
502 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
503     def test_setCoefficient_D_System_reduced(self):
504     d=self.domain.getDim()
505     mypde=LinearPDE(self.domain,debug=self.DEBUG)
506     mypde.setValue(D_reduced=numarray.ones((self.N,self.N)))
507 gross 1841 coeff=mypde.getCoefficient("D_reduced")
508 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
509     def test_setCoefficient_X_System_reduced(self):
510     d=self.domain.getDim()
511     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
512     mypde.setValue(X_reduced=numarray.ones((self.N,d)))
513 gross 1841 coeff=mypde.getCoefficient("X_reduced")
514 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
515     def test_setCoefficient_Y_System_reduced(self):
516     d=self.domain.getDim()
517     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
518     mypde.setValue(Y_reduced=numarray.ones((self.N,)))
519 gross 1841 coeff=mypde.getCoefficient("Y_reduced")
520 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
521     def test_setCoefficient_y_System_reduced(self):
522     d=self.domain.getDim()
523     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
524     mypde.setValue(y_reduced=numarray.ones((self.N,)))
525 gross 1841 coeff=mypde.getCoefficient("y_reduced")
526 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
527     def test_setCoefficient_d_reduced_System(self):
528     d=self.domain.getDim()
529     mypde=LinearPDE(self.domain,debug=self.DEBUG)
530     mypde.setValue(d_reduced=numarray.ones((self.N,self.N)))
531 gross 1841 coeff=mypde.getCoefficient("d_reduced")
532 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
533     def test_setCoefficient_d_contact_reduced_System(self):
534     d=self.domain.getDim()
535     mypde=LinearPDE(self.domain,debug=self.DEBUG)
536     mypde.setValue(d_contact_reduced=numarray.ones((self.N,self.N)))
537 gross 1841 coeff=mypde.getCoefficient("d_contact_reduced")
538 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
539     def test_setCoefficient_y_contact_reduced_System(self):
540     d=self.domain.getDim()
541     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
542     mypde.setValue(y_contact_reduced=numarray.ones((self.N,)))
543 gross 1841 coeff=mypde.getCoefficient("y_contact_reduced")
544 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
545 jgs 149 def test_setCoefficient_r_System(self):
546     d=self.domain.getDim()
547     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
548     mypde.setValue(r=numarray.ones((self.N,)))
549 gross 1841 coeff=mypde.getCoefficient("r")
550 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
551     def test_setCoefficient_q_System(self):
552     d=self.domain.getDim()
553     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
554     mypde.setValue(q=numarray.ones((self.N,)))
555 gross 1841 coeff=mypde.getCoefficient("q")
556 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
557     def test_setCoefficient_r_System_reducedOn(self):
558     d=self.domain.getDim()
559     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
560     mypde.setReducedOrderOn()
561     mypde.setValue(r=numarray.ones((self.N,)))
562 gross 1841 coeff=mypde.getCoefficient("r")
563 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
564     def test_setCoefficient_q_System_reducedOn(self):
565     d=self.domain.getDim()
566     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
567     mypde.setReducedOrderOn()
568     mypde.setValue(q=numarray.ones((self.N,)))
569 gross 1841 coeff=mypde.getCoefficient("q")
570 jgs 149 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
571    
572 gross 1072 def test_setCoefficient_A_reduced_System_using_A(self):
573     d=self.domain.getDim()
574     mypde=LinearPDE(self.domain,debug=self.DEBUG)
575     mypde.setValue(A=Data(numarray.ones((self.N,d,self.N,d)),ReducedFunction(self.domain)))
576 gross 1841 coeff=mypde.getCoefficient("A_reduced")
577 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
578     def test_setCoefficient_B_reduced_System_using_B(self):
579     d=self.domain.getDim()
580     mypde=LinearPDE(self.domain,debug=self.DEBUG)
581     mypde.setValue(B=Data(numarray.ones((self.N,d,self.N)),ReducedFunction(self.domain)))
582 gross 1841 coeff=mypde.getCoefficient("B_reduced")
583 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
584     def test_setCoefficient_C_reduced_System_using_C(self):
585     d=self.domain.getDim()
586     mypde=LinearPDE(self.domain,debug=self.DEBUG)
587     mypde.setValue(C=Data(numarray.ones((self.N,self.N,d)),ReducedFunction(self.domain)))
588 gross 1841 coeff=mypde.getCoefficient("C_reduced")
589 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
590     def test_setCoefficient_D_System_reduced_using_D(self):
591     d=self.domain.getDim()
592     mypde=LinearPDE(self.domain,debug=self.DEBUG)
593     mypde.setValue(D=Data(numarray.ones((self.N,self.N)),ReducedFunction(self.domain)))
594 gross 1841 coeff=mypde.getCoefficient("D_reduced")
595 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
596     def test_setCoefficient_X_System_reduced_using_X(self):
597     d=self.domain.getDim()
598     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
599     mypde.setValue(X=Data(numarray.ones((self.N,d)),ReducedFunction(self.domain)))
600 gross 1841 coeff=mypde.getCoefficient("X_reduced")
601 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
602     def test_setCoefficient_Y_System_reduced_using_Y(self):
603     d=self.domain.getDim()
604     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
605     mypde.setValue(Y=Data(numarray.ones((self.N,)),ReducedFunction(self.domain)))
606 gross 1841 coeff=mypde.getCoefficient("Y_reduced")
607 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
608     def test_setCoefficient_y_reduced_System_using_y(self):
609     d=self.domain.getDim()
610     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
611     mypde.setValue(y=Data(numarray.ones((self.N,)),ReducedFunctionOnBoundary(self.domain)))
612 gross 1841 coeff=mypde.getCoefficient("y_reduced")
613 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
614     def test_setCoefficient_d_reduced_System_using_d(self):
615     d=self.domain.getDim()
616     mypde=LinearPDE(self.domain,debug=self.DEBUG)
617     mypde.setValue(d=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnBoundary(self.domain)))
618 gross 1841 coeff=mypde.getCoefficient("d_reduced")
619 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
620     def test_setCoefficient_d_contact_reduced_System_using_d_contact(self):
621     d=self.domain.getDim()
622     mypde=LinearPDE(self.domain,debug=self.DEBUG)
623     mypde.setValue(d_contact=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnContactZero(self.domain)))
624 gross 1841 coeff=mypde.getCoefficient("d_contact_reduced")
625 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
626     def test_setCoefficient_y_contact_reduced_System_using_y_contact(self):
627     d=self.domain.getDim()
628     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
629     mypde.setValue(y_contact=Data(numarray.ones((self.N,)),ReducedFunctionOnContactZero(self.domain)))
630 gross 1841 coeff=mypde.getCoefficient("y_contact_reduced")
631 gross 1072 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
632 jgs 149 def test_resetCoefficient_HomogeneousConstraint(self):
633     mypde=LinearPDE(self.domain,debug=self.DEBUG)
634     x=self.domain.getX()
635 gross 304 mypde.setValue(A=kronecker(self.domain),Y=1.,q=whereZero(x[0]))
636 jgs 149 u1=mypde.getSolution()
637     mypde.setValue(Y=2.)
638     u2=mypde.getSolution()
639     self.failUnless(self.check(u2,2*u1),'solution is wrong.')
640    
641     def test_resetCoefficient_InHomogeneousConstraint(self):
642     mypde=LinearPDE(self.domain,debug=self.DEBUG)
643 jgs 154 mypde.setSymmetryOn()
644 jgs 149 x=self.domain.getX()
645 gross 304 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.,r=1,q=whereZero(x[0]))
646 jgs 154 u1=mypde.getSolution(verbose=self.VERBOSE)
647 jgs 149 mypde.setValue(Y=2.,D=2)
648 jgs 154 u2=mypde.getSolution(verbose=self.VERBOSE)
649     self.failUnless(self.check(u2,u1),'first solution is wrong.')
650     u2=mypde.getSolution(verbose=self.VERBOSE)
651     self.failUnless(self.check(u2,u1),'first solution is wrong.')
652 jgs 149 mypde.setValue(r=2,Y=4.)
653 jgs 154 u2=mypde.getSolution(verbose=self.VERBOSE)
654     self.failUnless(self.check(u2,2*u1),'second solution is wrong.')
655 jgs 149
656     def test_symmetryCheckTrue_System(self):
657     d=self.domain.getDim()
658     mypde=LinearPDE(self.domain,debug=self.DEBUG)
659     A=numarray.ones((self.N,d,self.N,d))
660     C=2*numarray.ones((self.N,self.N,d))
661     B=2*numarray.ones((self.N,d,self.N))
662     D=3*numarray.ones((self.N,self.N))
663     d=4*numarray.ones((self.N,self.N))
664     d_contact=5*numarray.ones((self.N,self.N))
665 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)
666 jgs 149 self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
667    
668     def test_symmetryCheckFalse_A_System(self):
669     d=self.domain.getDim()
670     mypde=LinearPDE(self.domain,debug=self.DEBUG)
671     A=numarray.ones((self.N,d,self.N,d))
672     A[1,1,1,0]=0.
673     mypde.setValue(A=A)
674     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
675     def test_symmetryCheckFalse_BC_System(self):
676     d=self.domain.getDim()
677     mypde=LinearPDE(self.domain,debug=self.DEBUG)
678     C=2*numarray.ones((self.N,self.N,d))
679     B=2*numarray.ones((self.N,d,self.N))
680     B[0,0,1]=1.
681     mypde.setValue(B=B,C=C)
682     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
683    
684     def test_symmetryCheckFalse_D_System(self):
685     mypde=LinearPDE(self.domain,debug=self.DEBUG)
686     D=3*numarray.ones((self.N,self.N))
687     D[0,1]=0.
688     mypde.setValue(D=D)
689     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
690    
691     def test_symmetryCheckFalse_d_System(self):
692     mypde=LinearPDE(self.domain,debug=self.DEBUG)
693     d=4*numarray.ones((self.N,self.N))
694     d[0,1]=0.
695     mypde.setValue(d=d)
696     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
697    
698     def test_symmetryCheckFalse_d_contact_System(self):
699     mypde=LinearPDE(self.domain,debug=self.DEBUG)
700     d_contact=5*numarray.ones((self.N,self.N))
701     d_contact[0,1]=0.
702     mypde.setValue(d_contact=d_contact)
703     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
704    
705 gross 1072 def test_symmetryCheckFalse_A_reduced_System(self):
706     d=self.domain.getDim()
707     mypde=LinearPDE(self.domain,debug=self.DEBUG)
708     A=numarray.ones((self.N,d,self.N,d))
709     A[1,1,1,0]=0.
710     mypde.setValue(A_reduced=A)
711     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
712     def test_symmetryCheckFalse_BC_reduced_System(self):
713     d=self.domain.getDim()
714     mypde=LinearPDE(self.domain,debug=self.DEBUG)
715     C=2*numarray.ones((self.N,self.N,d))
716     B=2*numarray.ones((self.N,d,self.N))
717     B[0,0,1]=1.
718     mypde.setValue(B_reduced=B,C_reduced=C)
719     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
720    
721     def test_symmetryCheckFalse_D_reduced_System(self):
722     mypde=LinearPDE(self.domain,debug=self.DEBUG)
723     D=3*numarray.ones((self.N,self.N))
724     D[0,1]=0.
725     mypde.setValue(D_reduced=D)
726     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
727    
728     def test_symmetryCheckFalse_d_reduced_System(self):
729     mypde=LinearPDE(self.domain,debug=self.DEBUG)
730     d=4*numarray.ones((self.N,self.N))
731     d[0,1]=0.
732     mypde.setValue(d_reduced=d)
733     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
734    
735     def test_symmetryCheckFalse_d_contact_reduced_System(self):
736     mypde=LinearPDE(self.domain,debug=self.DEBUG)
737     d_contact=5*numarray.ones((self.N,self.N))
738     d_contact[0,1]=0.
739     mypde.setValue(d_contact_reduced=d_contact)
740     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
741    
742 jgs 149 def test_symmetryCheckTrue_Scalar(self):
743     d=self.domain.getDim()
744     mypde=LinearPDE(self.domain,debug=self.DEBUG)
745     A=numarray.ones((d,d))
746     C=2*numarray.ones((d,))
747     B=2*numarray.ones((d,))
748     D=3
749     d=4
750     d_contact=5
751 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)
752 jgs 149 self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
753    
754     def test_symmetryCheckFalse_A_Scalar(self):
755     d=self.domain.getDim()
756     mypde=LinearPDE(self.domain,debug=self.DEBUG)
757     A=numarray.ones((d,d))
758     A[1,0]=0.
759     mypde.setValue(A=A)
760     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
761     def test_symmetryCheckFalse_BC_Scalar(self):
762     d=self.domain.getDim()
763     mypde=LinearPDE(self.domain,debug=self.DEBUG)
764     C=2*numarray.ones((d,))
765     B=2*numarray.ones((d,))
766     B[0]=1.
767     mypde.setValue(B=B,C=C)
768     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
769 gross 1072 def test_symmetryCheckFalse_A_reduced_Scalar(self):
770     d=self.domain.getDim()
771     mypde=LinearPDE(self.domain,debug=self.DEBUG)
772     A=numarray.ones((d,d))
773     A[1,0]=0.
774     mypde.setValue(A_reduced=A)
775     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
776     def test_symmetryCheckFalse_BC_reduced_Scalar(self):
777     d=self.domain.getDim()
778     mypde=LinearPDE(self.domain,debug=self.DEBUG)
779     C=2*numarray.ones((d,))
780     B=2*numarray.ones((d,))
781     B[0]=1.
782     mypde.setValue(B_reduced=B,C_reduced=C)
783     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
784 jgs 149 #
785 ksteube 1312 # solver checks (single PDE)
786 jgs 149 #
787     def test_symmetryOnIterative(self):
788     mypde=LinearPDE(self.domain,debug=self.DEBUG)
789     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
790     u=mypde.getSolution(verbose=self.VERBOSE)
791     self.failUnless(self.check(u,1.),'solution is wrong.')
792     def test_symmetryOnDirect(self):
793     mypde=LinearPDE(self.domain,debug=self.DEBUG)
794     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
795     mypde.setSolverMethod(mypde.DIRECT)
796     u=mypde.getSolution(verbose=self.VERBOSE)
797     self.failUnless(self.check(u,1.),'solution is wrong.')
798     def test_PCG_JACOBI(self):
799     mypde=LinearPDE(self.domain,debug=self.DEBUG)
800     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
801 gross 387 mypde.setSolverMethod(mypde.PCG,mypde.JACOBI)
802     u=mypde.getSolution(verbose=self.VERBOSE)
803 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
804     def test_PCG_ILU0(self):
805     mypde=LinearPDE(self.domain,debug=self.DEBUG)
806     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
807 gross 387 mypde.setSolverMethod(mypde.PCG,mypde.ILU0)
808     u=mypde.getSolution(verbose=self.VERBOSE)
809 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
810 gross 1859 def test_PCG_RILU(self):
811     mypde=LinearPDE(self.domain,debug=self.DEBUG)
812     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
813     mypde.setSolverMethod(mypde.PCG,mypde.RILU)
814     u=mypde.getSolution(verbose=self.VERBOSE)
815     self.failUnless(self.check(u,1.),'solution is wrong.')
816 jgs 149 def test_DIRECT(self):
817     mypde=LinearPDE(self.domain,debug=self.DEBUG)
818     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
819     mypde.setSolverMethod(mypde.DIRECT)
820 jgs 154 u=mypde.getSolution(verbose=self.VERBOSE)
821 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
822     def test_BICGSTAB_JACOBI(self):
823     mypde=LinearPDE(self.domain,debug=self.DEBUG)
824 gross 387 mypde.setSolverMethod(mypde.BICGSTAB,mypde.JACOBI)
825 jgs 149 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
826 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
827 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
828     def test_BICGSTAB_ILU0(self):
829     mypde=LinearPDE(self.domain,debug=self.DEBUG)
830     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
831 gross 387 mypde.setSolverMethod(mypde.BICGSTAB,mypde.ILU0)
832     u=mypde.getSolution(verbose=self.VERBOSE)
833 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
834 gross 1859 def test_BICGSTAB_RILU(self):
835     mypde=LinearPDE(self.domain,debug=self.DEBUG)
836     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
837     mypde.setSolverMethod(mypde.BICGSTAB,mypde.RILU)
838     u=mypde.getSolution(verbose=self.VERBOSE)
839     self.failUnless(self.check(u,1.),'solution is wrong.')
840     def Off_test_MINRES_JACOBI(self):
841     mypde=LinearPDE(self.domain,debug=self.DEBUG)
842     mypde.setSolverMethod(mypde.MINRES,mypde.JACOBI)
843     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
844     u=mypde.getSolution(verbose=self.VERBOSE)
845     self.failUnless(self.check(u,1.),'solution is wrong.')
846     def Off_test_MINRES_ILU0(self):
847     mypde=LinearPDE(self.domain,debug=self.DEBUG)
848     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
849     mypde.setSolverMethod(mypde.MINRES,mypde.ILU0)
850     u=mypde.getSolution(verbose=self.VERBOSE)
851     self.failUnless(self.check(u,1.),'solution is wrong.')
852     def Off_test_MINRES_RILU(self):
853     mypde=LinearPDE(self.domain,debug=self.DEBUG)
854     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
855     mypde.setSolverMethod(mypde.MINRES,mypde.RILU)
856     u=mypde.getSolution(verbose=self.VERBOSE)
857     self.failUnless(self.check(u,1.),'solution is wrong.')
858     def test_TFQMR_JACOBI(self):
859     mypde=LinearPDE(self.domain,debug=self.DEBUG)
860     mypde.setSolverMethod(mypde.TFQMR,mypde.JACOBI)
861     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
862     u=mypde.getSolution(verbose=self.VERBOSE)
863     self.failUnless(self.check(u,1.),'solution is wrong.')
864     def test_TFQMR_ILU0(self):
865     mypde=LinearPDE(self.domain,debug=self.DEBUG)
866     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
867     mypde.setSolverMethod(mypde.TFQMR,mypde.ILU0)
868     u=mypde.getSolution(verbose=self.VERBOSE)
869     self.failUnless(self.check(u,1.),'solution is wrong.')
870     def test_TFQMR_RILU(self):
871     mypde=LinearPDE(self.domain,debug=self.DEBUG)
872     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
873     mypde.setSolverMethod(mypde.TFQMR,mypde.RILU)
874     u=mypde.getSolution(verbose=self.VERBOSE)
875     self.failUnless(self.check(u,1.),'solution is wrong.')
876 jgs 149 def test_PRES20_JACOBI(self):
877     mypde=LinearPDE(self.domain,debug=self.DEBUG)
878     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
879 gross 387 mypde.setSolverMethod(mypde.PRES20,mypde.JACOBI)
880     u=mypde.getSolution(verbose=self.VERBOSE)
881 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
882     def test_PRES20_ILU0(self):
883     mypde=LinearPDE(self.domain,debug=self.DEBUG)
884     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
885 gross 387 mypde.setSolverMethod(mypde.PRES20,mypde.ILU0)
886     u=mypde.getSolution(verbose=self.VERBOSE)
887 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
888 gross 1859 def test_PRES20_RILU(self):
889     mypde=LinearPDE(self.domain,debug=self.DEBUG)
890     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
891     mypde.setSolverMethod(mypde.PRES20,mypde.RILU)
892     u=mypde.getSolution(verbose=self.VERBOSE)
893     self.failUnless(self.check(u,1.),'solution is wrong.')
894 jgs 149 def test_GMRESnoRestart_JACOBI(self):
895     mypde=LinearPDE(self.domain,debug=self.DEBUG)
896     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
897 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
898 gross 1859 u=mypde.getSolution(verbose=self.VERBOSE,truncation=50)
899 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
900     def test_GMRESnoRestart_ILU0(self):
901     mypde=LinearPDE(self.domain,debug=self.DEBUG)
902     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
903 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
904 gross 1859 u=mypde.getSolution(verbose=self.VERBOSE,truncation=50)
905 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
906 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
907 gross 1859 def test_GMRESnoRestart_RILU(self):
908     mypde=LinearPDE(self.domain,debug=self.DEBUG)
909     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
910     mypde.setSolverMethod(mypde.GMRES,mypde.RILU)
911     u=mypde.getSolution(verbose=self.VERBOSE,truncation=50)
912     u=mypde.getSolution(verbose=self.VERBOSE)
913     self.failUnless(self.check(u,1.),'solution is wrong.')
914 jgs 149 def test_GMRES_JACOBI(self):
915     mypde=LinearPDE(self.domain,debug=self.DEBUG)
916     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
917 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
918     u=mypde.getSolution(verbose=self.VERBOSE)
919 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
920     def test_GMRES_ILU0(self):
921     mypde=LinearPDE(self.domain,debug=self.DEBUG)
922     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
923 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
924     u=mypde.getSolution(verbose=self.VERBOSE)
925 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
926 gross 1859 def test_GMRES_RILU(self):
927     mypde=LinearPDE(self.domain,debug=self.DEBUG)
928     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
929     mypde.setSolverMethod(mypde.GMRES,mypde.RILU)
930     u=mypde.getSolution(verbose=self.VERBOSE)
931     self.failUnless(self.check(u,1.),'solution is wrong.')
932 jgs 149 def test_GMRES_truncation_restart_JACOBI(self):
933     mypde=LinearPDE(self.domain,debug=self.DEBUG)
934     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
935 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
936     u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
937 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
938     def test_GMRES_truncation_restart_ILU0(self):
939     mypde=LinearPDE(self.domain,debug=self.DEBUG)
940     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
941 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
942     u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
943 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
944 gross 1859 def test_GMRES_truncation_restart_RILU(self):
945     mypde=LinearPDE(self.domain,debug=self.DEBUG)
946     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
947     mypde.setSolverMethod(mypde.GMRES,mypde.RILU)
948     u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
949     self.failUnless(self.check(u,1.),'solution is wrong.')
950 ksteube 1312 #
951     # solver checks (PDE system)
952     #
953     def test_symmetryOnIterative_System(self):
954     A=Tensor4(0.,Function(self.domain))
955     D=Tensor(1.,Function(self.domain))
956     Y=Vector(self.domain.getDim(),Function(self.domain))
957     for i in range(self.domain.getDim()):
958     A[i,:,i,:]=kronecker(self.domain)
959     D[i,i]+=i
960     Y[i]+=i
961     mypde=LinearPDE(self.domain,debug=self.DEBUG)
962     mypde.setValue(A=A,D=D,Y=Y)
963     u=mypde.getSolution(verbose=self.VERBOSE)
964     self.failUnless(self.check(u,1.),'solution is wrong.')
965     def test_symmetryOnDirect_System(self):
966     A=Tensor4(0.,Function(self.domain))
967     D=Tensor(1.,Function(self.domain))
968     Y=Vector(self.domain.getDim(),Function(self.domain))
969     for i in range(self.domain.getDim()):
970     A[i,:,i,:]=kronecker(self.domain)
971     D[i,i]+=i
972     Y[i]+=i
973     mypde=LinearPDE(self.domain,debug=self.DEBUG)
974     mypde.setValue(A=A,D=D,Y=Y)
975     mypde.setSolverMethod(mypde.DIRECT)
976     u=mypde.getSolution(verbose=self.VERBOSE)
977     self.failUnless(self.check(u,1.),'solution is wrong.')
978     def test_PCG_JACOBI_System(self):
979     A=Tensor4(0.,Function(self.domain))
980     D=Tensor(1.,Function(self.domain))
981     Y=Vector(self.domain.getDim(),Function(self.domain))
982     for i in range(self.domain.getDim()):
983     A[i,:,i,:]=kronecker(self.domain)
984     D[i,i]+=i
985     Y[i]+=i
986     mypde=LinearPDE(self.domain,debug=self.DEBUG)
987     mypde.setValue(A=A,D=D,Y=Y)
988     mypde.setSolverMethod(mypde.PCG,mypde.JACOBI)
989     u=mypde.getSolution(verbose=self.VERBOSE)
990     self.failUnless(self.check(u,1.),'solution is wrong.')
991     def test_PCG_ILU0_System(self):
992     A=Tensor4(0.,Function(self.domain))
993     D=Tensor(1.,Function(self.domain))
994     Y=Vector(self.domain.getDim(),Function(self.domain))
995     for i in range(self.domain.getDim()):
996     A[i,:,i,:]=kronecker(self.domain)
997     D[i,i]+=i
998     Y[i]+=i
999     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1000     mypde.setValue(A=A,D=D,Y=Y)
1001     mypde.setSolverMethod(mypde.PCG,mypde.ILU0)
1002     u=mypde.getSolution(verbose=self.VERBOSE)
1003     self.failUnless(self.check(u,1.),'solution is wrong.')
1004     def test_DIRECT_System(self):
1005     A=Tensor4(0.,Function(self.domain))
1006     D=Tensor(1.,Function(self.domain))
1007     Y=Vector(self.domain.getDim(),Function(self.domain))
1008     for i in range(self.domain.getDim()):
1009     A[i,:,i,:]=kronecker(self.domain)
1010     D[i,i]+=i
1011     Y[i]+=i
1012     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1013     mypde.setValue(A=A,D=D,Y=Y)
1014     mypde.setSolverMethod(mypde.DIRECT)
1015     u=mypde.getSolution(verbose=self.VERBOSE)
1016     self.failUnless(self.check(u,1.),'solution is wrong.')
1017     def test_BICGSTAB_JACOBI_System(self):
1018     A=Tensor4(0.,Function(self.domain))
1019     D=Tensor(1.,Function(self.domain))
1020     Y=Vector(self.domain.getDim(),Function(self.domain))
1021     for i in range(self.domain.getDim()):
1022     A[i,:,i,:]=kronecker(self.domain)
1023     D[i,i]+=i
1024     Y[i]+=i
1025     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1026     mypde.setValue(A=A,D=D,Y=Y)
1027     mypde.setSolverMethod(mypde.BICGSTAB,mypde.JACOBI)
1028     u=mypde.getSolution(verbose=self.VERBOSE)
1029     self.failUnless(self.check(u,1.),'solution is wrong.')
1030     def test_BICGSTAB_ILU0_System(self):
1031     A=Tensor4(0.,Function(self.domain))
1032     D=Tensor(1.,Function(self.domain))
1033     Y=Vector(self.domain.getDim(),Function(self.domain))
1034     for i in range(self.domain.getDim()):
1035     A[i,:,i,:]=kronecker(self.domain)
1036     D[i,i]+=i
1037     Y[i]+=i
1038     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1039     mypde.setValue(A=A,D=D,Y=Y)
1040     mypde.setSolverMethod(mypde.BICGSTAB,mypde.ILU0)
1041     u=mypde.getSolution(verbose=self.VERBOSE)
1042     self.failUnless(self.check(u,1.),'solution is wrong.')
1043     def test_PRES20_JACOBI_System(self):
1044     A=Tensor4(0.,Function(self.domain))
1045     D=Tensor(1.,Function(self.domain))
1046     Y=Vector(self.domain.getDim(),Function(self.domain))
1047     for i in range(self.domain.getDim()):
1048     A[i,:,i,:]=kronecker(self.domain)
1049     D[i,i]+=i
1050     Y[i]+=i
1051     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1052     mypde.setValue(A=A,D=D,Y=Y)
1053     mypde.setSolverMethod(mypde.PRES20,mypde.JACOBI)
1054     u=mypde.getSolution(verbose=self.VERBOSE)
1055     self.failUnless(self.check(u,1.),'solution is wrong.')
1056     def test_PRES20_ILU0_System(self):
1057     A=Tensor4(0.,Function(self.domain))
1058     D=Tensor(1.,Function(self.domain))
1059     Y=Vector(self.domain.getDim(),Function(self.domain))
1060     for i in range(self.domain.getDim()):
1061     A[i,:,i,:]=kronecker(self.domain)
1062     D[i,i]+=i
1063     Y[i]+=i
1064     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1065     mypde.setValue(A=A,D=D,Y=Y)
1066     mypde.setSolverMethod(mypde.PRES20,mypde.ILU0)
1067     u=mypde.getSolution(verbose=self.VERBOSE)
1068     self.failUnless(self.check(u,1.),'solution is wrong.')
1069     def test_GMRESnoRestart_JACOBI_System(self):
1070     A=Tensor4(0.,Function(self.domain))
1071     D=Tensor(1.,Function(self.domain))
1072     Y=Vector(self.domain.getDim(),Function(self.domain))
1073     for i in range(self.domain.getDim()):
1074     A[i,:,i,:]=kronecker(self.domain)
1075     D[i,i]+=i
1076     Y[i]+=i
1077     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1078     mypde.setValue(A=A,D=D,Y=Y)
1079     mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
1080     # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
1081     u=mypde.getSolution(verbose=self.VERBOSE)
1082     self.failUnless(self.check(u,1.),'solution is wrong.')
1083     def test_GMRESnoRestart_ILU0_System(self):
1084     A=Tensor4(0.,Function(self.domain))
1085     D=Tensor(1.,Function(self.domain))
1086     Y=Vector(self.domain.getDim(),Function(self.domain))
1087     for i in range(self.domain.getDim()):
1088     A[i,:,i,:]=kronecker(self.domain)
1089     D[i,i]+=i
1090     Y[i]+=i
1091     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1092     mypde.setValue(A=A,D=D,Y=Y)
1093     mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
1094     # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
1095     u=mypde.getSolution(verbose=self.VERBOSE)
1096     self.failUnless(self.check(u,1.),'solution is wrong.')
1097     def test_GMRES_JACOBI_System(self):
1098     A=Tensor4(0.,Function(self.domain))
1099     D=Tensor(1.,Function(self.domain))
1100     Y=Vector(self.domain.getDim(),Function(self.domain))
1101     for i in range(self.domain.getDim()):
1102     A[i,:,i,:]=kronecker(self.domain)
1103     D[i,i]+=i
1104     Y[i]+=i
1105     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1106     mypde.setValue(A=A,D=D,Y=Y)
1107     mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
1108     u=mypde.getSolution(verbose=self.VERBOSE)
1109     self.failUnless(self.check(u,1.),'solution is wrong.')
1110     def test_GMRES_ILU0_System(self):
1111     A=Tensor4(0.,Function(self.domain))
1112     D=Tensor(1.,Function(self.domain))
1113     Y=Vector(self.domain.getDim(),Function(self.domain))
1114     for i in range(self.domain.getDim()):
1115     A[i,:,i,:]=kronecker(self.domain)
1116     D[i,i]+=i
1117     Y[i]+=i
1118     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1119     mypde.setValue(A=A,D=D,Y=Y)
1120     mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
1121     u=mypde.getSolution(verbose=self.VERBOSE)
1122     self.failUnless(self.check(u,1.),'solution is wrong.')
1123     def test_GMRES_truncation_restart_JACOBI_System(self):
1124     A=Tensor4(0.,Function(self.domain))
1125     D=Tensor(1.,Function(self.domain))
1126     Y=Vector(self.domain.getDim(),Function(self.domain))
1127     for i in range(self.domain.getDim()):
1128     A[i,:,i,:]=kronecker(self.domain)
1129     D[i,i]+=i
1130     Y[i]+=i
1131     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1132     mypde.setValue(A=A,D=D,Y=Y)
1133     mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
1134     u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
1135     self.failUnless(self.check(u,1.),'solution is wrong.')
1136     def test_GMRES_truncation_restart_ILU0_System(self):
1137     A=Tensor4(0.,Function(self.domain))
1138     D=Tensor(1.,Function(self.domain))
1139     Y=Vector(self.domain.getDim(),Function(self.domain))
1140     for i in range(self.domain.getDim()):
1141     A[i,:,i,:]=kronecker(self.domain)
1142     D[i,i]+=i
1143     Y[i]+=i
1144     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1145     mypde.setValue(A=A,D=D,Y=Y)
1146     mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
1147     u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
1148     self.failUnless(self.check(u,1.),'solution is wrong.')
1149 gross 855
1150     class Test_LinearPDE(Test_LinearPDE_noLumping):
1151 jgs 149 def test_Lumping_attemptToSetA(self):
1152     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1153     try:
1154     success=True
1155     mypde.setSolverMethod(mypde.LUMPING)
1156     mypde.setValue(A=kronecker(self.domain))
1157     u=mypde.getSolution(verbose=self.VERBOSE)
1158 gross 531 except ValueError:
1159 jgs 149 success=False
1160 gross 531 self.failUnless(not success,'error should be issued')
1161 jgs 149 def test_Lumping_attemptToSetB(self):
1162     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1163     try:
1164     success=True
1165     mypde.setSolverMethod(mypde.LUMPING)
1166     mypde.setValue(B=kronecker(self.domain)[0])
1167     u=mypde.getSolution(verbose=self.VERBOSE)
1168 gross 531 except ValueError:
1169 jgs 149 success=False
1170 gross 531 self.failUnless(not success,'error should be issued')
1171 jgs 149 def test_Lumping_attemptToSetC(self):
1172     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1173     try:
1174     success=True
1175     mypde.setSolverMethod(mypde.LUMPING)
1176     mypde.setValue(C=kronecker(self.domain)[0])
1177     u=mypde.getSolution(verbose=self.VERBOSE)
1178 gross 531 except ValueError:
1179 jgs 149 success=False
1180 gross 531 self.failUnless(not success,'error should be issued')
1181 jgs 149
1182 gross 1072 def test_Lumping_attemptToSetA_reduced(self):
1183     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1184     try:
1185     success=True
1186     mypde.setSolverMethod(mypde.LUMPING)
1187     mypde.setValue(A_reduced=kronecker(self.domain))
1188     u=mypde.getSolution(verbose=self.VERBOSE)
1189     except ValueError:
1190     success=False
1191     self.failUnless(not success,'error should be issued')
1192     def test_Lumping_attemptToSetB_reduced(self):
1193     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1194     try:
1195     success=True
1196     mypde.setSolverMethod(mypde.LUMPING)
1197     mypde.setValue(B_reduced=kronecker(self.domain)[0])
1198     u=mypde.getSolution(verbose=self.VERBOSE)
1199     except ValueError:
1200     success=False
1201     self.failUnless(not success,'error should be issued')
1202     def test_Lumping_attemptToSetC_reduced(self):
1203     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1204     try:
1205     success=True
1206     mypde.setSolverMethod(mypde.LUMPING)
1207     mypde.setValue(C_reduced=kronecker(self.domain)[0])
1208     u=mypde.getSolution(verbose=self.VERBOSE)
1209     except ValueError:
1210     success=False
1211     self.failUnless(not success,'error should be issued')
1212    
1213 jgs 149 def test_Lumping(self):
1214     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1215     mypde.setSolverMethod(mypde.LUMPING)
1216     mypde.setValue(D=1.,Y=1.)
1217 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1218 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
1219     def test_Constrained_Lumping(self):
1220     x=self.domain.getX()
1221     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1222     mypde.setSolverMethod(mypde.LUMPING)
1223 gross 304 mypde.setValue(D=1.,Y=1.,q=whereZero(x[0]),r=1.)
1224 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1225 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
1226 gross 531
1227     def test_Lumping_System(self):
1228     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1229     mypde.setSolverMethod(mypde.LUMPING)
1230     mypde.setValue(D=numarray.array([[1.,0.],[0.,2.]]),Y=numarray.array([1.,2.]))
1231     u=mypde.getSolution(verbose=self.VERBOSE)
1232     self.failUnless(self.check(u,numarray.ones((2,))),'solution is wrong.')
1233     def test_Constrained_Lumping_System(self):
1234     x=self.domain.getX()
1235     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1236     mypde.setSolverMethod(mypde.LUMPING)
1237     mypde.setValue(D=numarray.array([[1.,0.],[0.,2.]]),Y=numarray.array([1.,2.]), \
1238     q=whereZero(x[0])*[0.,1],r=[0.,1.])
1239     u=mypde.getSolution(verbose=self.VERBOSE)
1240     self.failUnless(self.check(u,numarray.ones((2,))),'solution is wrong.')
1241    
1242 jgs 149 def test_Lumping_updateRHS(self):
1243     x=self.domain.getX()
1244     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1245     mypde.setSolverMethod(mypde.LUMPING)
1246     mypde.setValue(D=1.,Y=1.)
1247 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1248 jgs 149 self.failUnless(self.check(u,1.),'first solution is wrong.')
1249 gross 304 mypde.setValue(Y=2.,q=whereZero(x[0]),r=2.)
1250 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1251 jgs 149 self.failUnless(self.check(u,2.),'second solution is wrong.')
1252     def test_Lumping_updateOperator(self):
1253     x=self.domain.getX()
1254     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1255     mypde.setSolverMethod(mypde.LUMPING)
1256     mypde.setValue(D=1.,Y=1.)
1257 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1258 jgs 149 mypde.setValue(D=2.)
1259 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1260 jgs 149 self.failUnless(self.check(u,0.5),'second solution is wrong.')
1261    
1262 gross 1859
1263     class Test_TransportPDE(Test_linearPDEs):
1264     N=4
1265     def test_init_theta(self):
1266     mypde=TransportPDE(self.domain,debug=self.DEBUG, theta=1.)
1267     self.failUnless(mypde.getTheta()==1.,'wrong theta')
1268     def test_init_invalid_theta(self):
1269     self.failUnlessRaises(ValueError,TransportPDE,self.domain,debug=self.DEBUG, theta=-1.)
1270    
1271     def test_setCoefficient_WithWrongName(self):
1272     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1273     self.failUnlessRaises(IllegalCoefficient,mypde.setValue, ROMA=Vector(0.,FunctionOnBoundary(self.domain)))
1274    
1275     def test_setCoefficient_WithIllegalFunctionSpace(self):
1276     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1277     self.failUnlessRaises(IllegalCoefficientFunctionSpace,mypde.setValue,C=Vector(0.,FunctionOnBoundary(self.domain)))
1278    
1279     def test_resetCoefficient_WithWrongShape(self):
1280     mypde=TransportPDE(self.domain,numEquations=2,debug=self.DEBUG)
1281     self.failUnlessRaises(IllegalCoefficientValue, mypde.setValue, C=0.)
1282    
1283     def test_setInitialSolution_scalar(self):
1284     mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)
1285     mypde.setInitialSolution(1.)
1286    
1287     def test_setInitialSolution_scalar_negative(self):
1288     mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)
1289     self.failUnlessRaises(RuntimeError,mypde.setInitialSolution,-1.)
1290    
1291     def test_setInitialSolution_scalar_WithWrongShape(self):
1292     mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG)
1293     self.failUnlessRaises(ValueError,mypde.setInitialSolution,[1.,2.])
1294    
1295     def test_setInitialSolution_system(self):
1296     mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)
1297     mypde.setInitialSolution([1.,2.])
1298    
1299     def test_setInitialSolution_system(self):
1300     mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)
1301     self.failUnlessRaises(RuntimeError,mypde.setInitialSolution,[-1,2.])
1302    
1303     def test_setInitialSolution_system_WithWrongShape(self):
1304     mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG)
1305     self.failUnlessRaises(ValueError,mypde.setInitialSolution,1.)
1306    
1307    
1308     def test_attemptToChangeOrderAfterDefinedCoefficient(self):
1309     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1310     mypde.setValue(D=1.)
1311     self.failUnlessRaises(RuntimeError, mypde.setReducedOrderOn)
1312    
1313     def test_reducedOnConfig(self):
1314     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1315     mypde.setReducedOrderOn()
1316     self.failUnlessEqual((mypde.getFunctionSpaceForSolution(),mypde.getFunctionSpaceForEquation()),(ReducedSolution(self.domain),ReducedSolution(self.domain)),"reduced function spaces expected.")
1317     #
1318     # set coefficients for scalars:
1319     #
1320     def test_setCoefficient_M_Scalar(self):
1321     d=self.domain.getDim()
1322     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1323     mypde.setValue(M=1.)
1324     coeff=mypde.getCoefficient("M")
1325     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),Function(self.domain),1,1))
1326     def test_setCoefficient_A_Scalar(self):
1327     d=self.domain.getDim()
1328     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1329     mypde.setValue(A=numarray.ones((d,d)))
1330     coeff=mypde.getCoefficient("A")
1331     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),Function(self.domain),1,1))
1332     def test_setCoefficient_B_Scalar(self):
1333     d=self.domain.getDim()
1334     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1335     mypde.setValue(B=numarray.ones((d,)))
1336     coeff=mypde.getCoefficient("B")
1337     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1))
1338     def test_setCoefficient_C_Scalar(self):
1339     d=self.domain.getDim()
1340     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1341     mypde.setValue(C=numarray.ones((d,)))
1342     coeff=mypde.getCoefficient("C")
1343     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1))
1344     def test_setCoefficient_D_Scalar(self):
1345     d=self.domain.getDim()
1346     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1347     mypde.setValue(D=1.)
1348     coeff=mypde.getCoefficient("D")
1349     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),Function(self.domain),1,1))
1350     def test_setCoefficient_X_Scalar(self):
1351     d=self.domain.getDim()
1352     mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1353     mypde.setValue(X=numarray.ones((d,)))
1354     coeff=mypde.getCoefficient("X")
1355     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),Function(self.domain),1))
1356     def test_setCoefficient_Y_Scalar(self):
1357     d=self.domain.getDim()
1358     mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1359     mypde.setValue(Y=1.)
1360     coeff=mypde.getCoefficient("Y")
1361     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),Function(self.domain),1))
1362     def test_setCoefficient_y_Scalar(self):
1363     d=self.domain.getDim()
1364     mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1365     mypde.setValue(y=1.)
1366     coeff=mypde.getCoefficient("y")
1367     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1))
1368     def test_setCoefficient_d_Scalar(self):
1369     d=self.domain.getDim()
1370     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1371     mypde.setValue(d=1.)
1372     coeff=mypde.getCoefficient("d")
1373     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1))
1374     def test_setCoefficient_m_Scalar(self):
1375     d=self.domain.getDim()
1376     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1377     mypde.setValue(m=1.)
1378     coeff=mypde.getCoefficient("m")
1379     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1))
1380     def test_setCoefficient_d_contact_Scalar(self):
1381     d=self.domain.getDim()
1382     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1383     mypde.setValue(d_contact=1.)
1384     coeff=mypde.getCoefficient("d_contact")
1385     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1,1))
1386     def test_setCoefficient_y_contact_Scalar(self):
1387     d=self.domain.getDim()
1388     mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1389     mypde.setValue(y_contact=1.)
1390     coeff=mypde.getCoefficient("y_contact")
1391     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))
1392    
1393     def test_setCoefficient_M_reduced_Scalar(self):
1394     d=self.domain.getDim()
1395     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1396     mypde.setValue(M_reduced=1.)
1397     coeff=mypde.getCoefficient("M_reduced")
1398     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
1399     def test_setCoefficient_A_reduced_Scalar(self):
1400     d=self.domain.getDim()
1401     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1402     mypde.setValue(A_reduced=numarray.ones((d,d)))
1403     coeff=mypde.getCoefficient("A_reduced")
1404     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
1405     def test_setCoefficient_B_reduced_Scalar(self):
1406     d=self.domain.getDim()
1407     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1408     mypde.setValue(B_reduced=numarray.ones((d,)))
1409     coeff=mypde.getCoefficient("B_reduced")
1410     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1411     def test_setCoefficient_C_reduced_Scalar(self):
1412     d=self.domain.getDim()
1413     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1414     mypde.setValue(C_reduced=numarray.ones((d,)))
1415     coeff=mypde.getCoefficient("C_reduced")
1416     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1417     def test_setCoefficient_D_reduced_Scalar(self):
1418     d=self.domain.getDim()
1419     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1420     mypde.setValue(D_reduced=1.)
1421     coeff=mypde.getCoefficient("D_reduced")
1422     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
1423     def test_setCoefficient_X_reduced_Scalar(self):
1424     d=self.domain.getDim()
1425     mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1426     mypde.setValue(X_reduced=numarray.ones((d,)))
1427     coeff=mypde.getCoefficient("X_reduced")
1428     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
1429     def test_setCoefficient_Y_reduced_Scalar(self):
1430     d=self.domain.getDim()
1431     mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1432     mypde.setValue(Y_reduced=1.)
1433     coeff=mypde.getCoefficient("Y_reduced")
1434     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
1435     def test_setCoefficient_y_reduced_Scalar(self):
1436     d=self.domain.getDim()
1437     mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1438     mypde.setValue(y_reduced=1.)
1439     coeff=mypde.getCoefficient("y_reduced")
1440     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
1441     def test_setCoefficient_m_reduced_Scalar(self):
1442     d=self.domain.getDim()
1443     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1444     mypde.setValue(m_reduced=1.)
1445     coeff=mypde.getCoefficient("m_reduced")
1446     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
1447     def test_setCoefficient_d_reduced_Scalar(self):
1448     d=self.domain.getDim()
1449     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1450     mypde.setValue(d_reduced=1.)
1451     coeff=mypde.getCoefficient("d_reduced")
1452     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
1453     def test_setCoefficient_d_contact_reduced_Scalar(self):
1454     d=self.domain.getDim()
1455     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1456     mypde.setValue(d_contact_reduced=1.)
1457     coeff=mypde.getCoefficient("d_contact_reduced")
1458     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
1459     def test_setCoefficient_y_contact_reduced_Scalar(self):
1460     d=self.domain.getDim()
1461     mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1462     mypde.setValue(y_contact_reduced=1.)
1463     coeff=mypde.getCoefficient("y_contact_reduced")
1464     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
1465     def test_setCoefficient_r_Scalar(self):
1466     d=self.domain.getDim()
1467     mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG)
1468     mypde.setValue(r=1.)
1469     coeff=mypde.getCoefficient("r")
1470     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1))
1471     def test_setCoefficient_q_Scalar(self):
1472     d=self.domain.getDim()
1473     mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG)
1474     mypde.setValue(q=1.)
1475     coeff=mypde.getCoefficient("q")
1476     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1))
1477     def test_setCoefficient_r_Scalar_reducedOn(self):
1478     d=self.domain.getDim()
1479     mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG)
1480     mypde.setReducedOrderOn()
1481     mypde.setValue(r=1.)
1482     coeff=mypde.getCoefficient("r")
1483     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
1484     def test_setCoefficient_q_Scalar_reducedOn(self):
1485     d=self.domain.getDim()
1486     mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG)
1487     mypde.setReducedOrderOn()
1488     mypde.setValue(q=1.)
1489     coeff=mypde.getCoefficient("q")
1490     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
1491    
1492     def test_setCoefficient_M_reduced_Scalar_usingM(self):
1493     d=self.domain.getDim()
1494     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1495     mypde.setValue(M=Scalar(1.,ReducedFunction(self.domain)))
1496     coeff=mypde.getCoefficient("M_reduced")
1497     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
1498     def test_setCoefficient_A_reduced_Scalar_usingA(self):
1499     d=self.domain.getDim()
1500     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1501     mypde.setValue(A=Data(numarray.ones((d,d)),ReducedFunction(self.domain)))
1502     coeff=mypde.getCoefficient("A_reduced")
1503     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
1504     def test_setCoefficient_B_reduced_Scalar_usingB(self):
1505     d=self.domain.getDim()
1506     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1507     mypde.setValue(B=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
1508     coeff=mypde.getCoefficient("B_reduced")
1509     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1510     def test_setCoefficient_C_reduced_Scalar_usingC(self):
1511     d=self.domain.getDim()
1512     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1513     mypde.setValue(C=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
1514     coeff=mypde.getCoefficient("C_reduced")
1515     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1516     def test_setCoefficient_D_reduced_Scalar_usingD(self):
1517     d=self.domain.getDim()
1518     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1519     mypde.setValue(D=Scalar(1.,ReducedFunction(self.domain)))
1520     coeff=mypde.getCoefficient("D_reduced")
1521     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
1522     def test_setCoefficient_X_reduced_Scalar_usingX(self):
1523     d=self.domain.getDim()
1524     mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1525     mypde.setValue(X_reduced=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
1526     coeff=mypde.getCoefficient("X_reduced")
1527     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
1528     def test_setCoefficient_Y_reduced_Scalar_usingY(self):
1529     d=self.domain.getDim()
1530     mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1531     mypde.setValue(Y=Scalar(1.,ReducedFunction(self.domain)))
1532     coeff=mypde.getCoefficient("Y_reduced")
1533     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
1534     def test_setCoefficient_y_reduced_Scalar_using_y(self):
1535     d=self.domain.getDim()
1536     mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1537     mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
1538     coeff=mypde.getCoefficient("y_reduced")
1539     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
1540     def test_setCoefficient_m_reduced_Scalar_using_m(self):
1541     d=self.domain.getDim()
1542     mypde=TransportPDE(self.domain,debug=self.DEBUG)
1543     mypde.setValue(d=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
1544     coeff=mypde.getCoefficient(