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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2881 - (hide annotations)
Thu Jan 28 02:03:15 2010 UTC (9 years, 7 months ago) by jfenwick
Original Path: trunk/escript/test/python/test_linearPDEs.py
File MIME type: text/x-python
File size: 182890 byte(s)
Don't panic.
Updating copyright stamps

1 ksteube 1809
2     ########################################################
3 ksteube 1312 #
4 jfenwick 2881 # Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1809 # 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 jfenwick 2881 __copyright__="""Copyright (c) 2003-2010 by University of Queensland
15 ksteube 1809 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 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
21 ksteube 1809
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 jfenwick 2625 :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 2325 from esys.escript.util import Lsup,kronecker,interpolate,whereZero, outer, swap_axes
48 ksteube 1312 from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar, ReducedFunction,ReducedFunctionOnBoundary,ReducedFunctionOnContactZero,Data, Tensor4, Tensor
49 gross 2470 from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace, TransportPDE, IllegalCoefficient, Helmholtz, LameEquation, SolverOptions
50 jfenwick 2455 import numpy
51 jgs 149 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 jfenwick 2625 checks if arg and ref_arg are nearly identical using the `Lsup`
61 jgs 149 """
62     if tol==None: tol=self.TOL
63     return Lsup(arg-ref_arg)<=tol*Lsup(ref_arg)
64    
65 gross 2325 class Test_LameEquation(Test_linearPDEs):
66    
67     def test_config(self):
68     mypde=LameEquation(self.domain,debug=self.DEBUG)
69     d=self.domain.getDim()
70 gross 2474 self.failUnlessEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(d,d,True),"set up incorrect")
71 gross 2325
72     def test_setCoefficient_q(self):
73     mypde=LameEquation(self.domain,debug=self.DEBUG)
74     x=self.domain.getX()
75     mypde.setValue(q=x)
76    
77     q_ref=interpolate(x,Solution(self.domain))
78     self.failUnless(self.check(mypde.getCoefficient("A"),0),"A is not 0")
79     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
80     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
81     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
82     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
83     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
84     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
85     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
86     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
87     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
88     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
89     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
90     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
91     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
92     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
93     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
94     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
95     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
96     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
97     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
98     self.failUnless(self.check(mypde.getCoefficient("q"),q_ref),"q is not empty")
99     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
100    
101     def test_setCoefficient_r(self):
102     mypde=LameEquation(self.domain,debug=self.DEBUG)
103     x=self.domain.getX()
104     mypde.setValue(r=x)
105    
106     r_ref=interpolate(x,Solution(self.domain))
107     self.failUnless(self.check(mypde.getCoefficient("A"),0),"A is not 0")
108     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
109     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
110     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
111     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
112     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
113     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
114     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
115     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
116     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
117     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
118     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
119     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
120     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
121     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
122     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
123     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
124     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
125     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
126     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
127     self.failUnless(self.check(mypde.getCoefficient("r"),r_ref),"r is nor x")
128     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
129    
130    
131     def test_setCoefficient_F(self):
132     mypde=LameEquation(self.domain,debug=self.DEBUG)
133     x=self.domain.getX()
134     mypde.setValue(F=x)
135    
136     Y_ref=interpolate(x,Function(self.domain))
137     self.failUnless(self.check(mypde.getCoefficient("A"),0),"A is not 0")
138     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
139     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
140     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
141     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
142     self.failUnless(self.check(mypde.getCoefficient("Y"),Y_ref),"Y is not x")
143     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
144     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
145     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
146     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
147     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
148     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
149     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
150     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
151     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
152     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
153     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
154     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
155     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
156     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
157     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
158     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
159    
160     def test_setCoefficient_f(self):
161     mypde=LameEquation(self.domain,debug=self.DEBUG)
162     x=self.domain.getX()
163     mypde.setValue(f=x)
164    
165     y_ref=interpolate(x,FunctionOnBoundary(self.domain))
166     self.failUnless(self.check(mypde.getCoefficient("A"),0),"A is not 0")
167     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
168     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
169     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
170     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
171     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
172     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
173     self.failUnless(self.check(mypde.getCoefficient("y"),y_ref),"d is not x[0]")
174     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
175     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
176     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
177     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
178     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
179     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
180     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
181     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"X_reduced is not empty")
182     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
183     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
184     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
185     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
186     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
187     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
188    
189     def test_setCoefficient_sigma(self):
190     mypde=LameEquation(self.domain,debug=self.DEBUG)
191     x=self.domain.getX()
192     mypde.setValue(sigma=outer(x,x))
193    
194     X_ref=interpolate(outer(x,x),Function(self.domain))
195     self.failUnless(self.check(mypde.getCoefficient("A"),0),"A is not 0")
196     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
197     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
198     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
199     self.failUnless(self.check(mypde.getCoefficient("X"),X_ref),"X is not x X x")
200     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
201     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
202     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
203     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
204     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
205     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
206     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
207     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
208     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
209     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
210     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"X_reduced is not empty")
211     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
212     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
213     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
214     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
215     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
216     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
217    
218     def test_setCoefficient_lambda(self):
219     mypde=LameEquation(self.domain,debug=self.DEBUG)
220     x=self.domain.getX()
221     mypde.setValue(lame_lambda=x[0])
222    
223    
224     k3=kronecker(Function(self.domain))
225     k3Xk3=outer(k3,k3)
226     A_ref=x[0]*k3Xk3
227    
228     self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
229     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
230     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
231     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
232     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
233     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
234     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
235     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
236     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
237     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
238     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
239     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
240     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
241     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
242     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
243     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
244     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
245     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
246     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
247     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
248     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
249     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
250    
251     def test_setCoefficient_mu(self):
252     mypde=LameEquation(self.domain,debug=self.DEBUG)
253     x=self.domain.getX()
254     mypde.setValue(lame_mu=x[0])
255    
256    
257     k3=kronecker(Function(self.domain))
258     k3Xk3=outer(k3,k3)
259     A_ref=x[0]*(swap_axes(k3Xk3,0,3)+swap_axes(k3Xk3,1,3))
260    
261     self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
262     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
263     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
264     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
265     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
266     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
267     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
268     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
269     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
270     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
271     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
272     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
273     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
274     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
275     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
276     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
277     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
278     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
279     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
280     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
281     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
282     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
283    
284     def test_setCoefficient_lambdamu(self):
285     mypde=LameEquation(self.domain,debug=self.DEBUG)
286     x=self.domain.getX()
287     mypde.setValue(lame_lambda=x[0], lame_mu=x[1])
288    
289     k3=kronecker(Function(self.domain))
290     k3Xk3=outer(k3,k3)
291     A_ref=x[0]*k3Xk3+x[1]*(swap_axes(k3Xk3,0,3)+swap_axes(k3Xk3,1,3))
292    
293     self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
294     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
295     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
296     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
297     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
298     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
299     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
300     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
301     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
302     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
303     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
304     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
305     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
306     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
307     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
308     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
309     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
310     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
311     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
312     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
313     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
314     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
315    
316     def test_solve(self):
317     d=self.domain.getDim()
318     mypde=LameEquation(self.domain)
319     cf=ContinuousFunction(self.domain)
320     x=cf.getX()
321     u_ex=x
322     msk=Vector(0.,cf)
323     for i in range(d): msk[i]=whereZero(x[i])
324     mypde.setValue(q=msk,r=u_ex,lame_mu=3,lame_lambda=50,f=(2*3+50*d)*FunctionOnBoundary(self.domain).getNormal())
325    
326     u=mypde.getSolution()
327     self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution")
328    
329 gross 2323 class Test_Helmholtz(Test_linearPDEs):
330    
331     def test_config(self):
332     mypde=Helmholtz(self.domain,debug=self.DEBUG)
333 gross 2474 self.failUnlessEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(1,1,True),"set up incorrect")
334 gross 2323 def test_setCoefficient_q(self):
335     mypde=Helmholtz(self.domain,debug=self.DEBUG)
336     x=self.domain.getX()
337     mypde.setValue(q=whereZero(x[0]))
338    
339     q_ref=interpolate(whereZero(x[0]),Solution(self.domain))
340     A_ref=kronecker(self.domain)
341    
342     self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
343     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
344     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
345     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
346     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
347     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
348     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
349     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
350     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
351     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
352     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
353     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
354     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
355     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
356     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
357     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
358     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
359     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
360     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
361     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
362     self.failUnless(self.check(mypde.getCoefficient("q"),q_ref),"q is not empty")
363     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
364    
365     def test_setCoefficient_r(self):
366     mypde=Helmholtz(self.domain,debug=self.DEBUG)
367     x=self.domain.getX()
368     mypde.setValue(r=x[0])
369    
370     r_ref=interpolate(x[0],Solution(self.domain))
371     A_ref=kronecker(self.domain)
372     self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
373     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
374     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
375     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
376     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
377     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
378     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
379     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
380     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
381     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
382     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
383     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
384     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
385     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
386     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
387     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
388     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
389     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
390     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
391     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
392     self.failUnless(self.check(mypde.getCoefficient("r"),r_ref),"r is nor x[0]")
393     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
394    
395    
396     def test_setCoefficient_f(self):
397     mypde=Helmholtz(self.domain,debug=self.DEBUG)
398     x=self.domain.getX()
399     mypde.setValue(f=x[0])
400    
401     Y_ref=interpolate(x[0],Function(self.domain))
402     A_ref=kronecker(self.domain)
403     self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
404     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
405     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
406     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
407     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
408     self.failUnless(self.check(mypde.getCoefficient("Y"),Y_ref),"Y is not x[0]")
409     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
410     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
411     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
412     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
413     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
414     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
415     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
416     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
417     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
418     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
419     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
420     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
421     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
422     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
423     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
424     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
425    
426     def test_setCoefficient_alpha(self):
427     mypde=Helmholtz(self.domain,debug=self.DEBUG)
428     x=self.domain.getX()
429     mypde.setValue(alpha=x[0])
430    
431     d_ref=interpolate(x[0],FunctionOnBoundary(self.domain))
432     A_ref=kronecker(self.domain)
433     self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
434     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
435     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
436     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
437     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
438     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
439     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
440     self.failUnless(self.check(mypde.getCoefficient("d"),d_ref),"d is not x[0]")
441     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
442     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
443     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
444     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
445     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
446     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
447     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
448     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"X_reduced is not empty")
449     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
450     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
451     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
452     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
453     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
454     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
455    
456     def test_setCoefficient_g(self):
457     mypde=Helmholtz(self.domain,debug=self.DEBUG)
458     x=self.domain.getX()
459     mypde.setValue(g=x[0])
460    
461     y_ref=interpolate(x[0],FunctionOnBoundary(self.domain))
462     A_ref=kronecker(self.domain)
463     self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
464     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
465     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
466     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
467     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
468     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
469     self.failUnless(self.check(mypde.getCoefficient("y"),y_ref),"y is not x[0]")
470     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
471     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
472     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
473     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
474     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
475     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
476     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
477     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
478     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
479     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
480     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
481     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
482     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
483     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
484     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
485    
486     def test_setCoefficient_omega(self):
487     mypde=Helmholtz(self.domain,debug=self.DEBUG)
488     x=self.domain.getX()
489     mypde.setValue(omega=x[0])
490    
491     D_ref=interpolate(x[0],Function(self.domain))
492     A_ref=kronecker(self.domain)
493     self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
494     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
495     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
496     self.failUnless(self.check(mypde.getCoefficient("D"),D_ref),"D is not x[0]")
497     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
498     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
499     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
500     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
501     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
502     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
503     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
504     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
505     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
506     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
507     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
508     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
509     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
510     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
511     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
512     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
513     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
514     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
515    
516     def test_solve(self):
517     d=self.domain.getDim()
518     cf=ContinuousFunction(self.domain)
519     u_ex=Scalar(1.,cf)
520     mypde=Helmholtz(self.domain)
521     mypde.setValue(f=3,omega=3,alpha=2,g=2)
522     u=mypde.getSolution()
523     self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution")
524    
525 jgs 149 class Test_Poisson(Test_linearPDEs):
526    
527     def test_config(self):
528     mypde=Poisson(self.domain,debug=self.DEBUG)
529 gross 2474 self.failUnlessEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(1,1,True),"set up incorrect")
530 jgs 149 def test_setCoefficient_q(self):
531     mypde=Poisson(self.domain,debug=self.DEBUG)
532     x=self.domain.getX()
533 gross 304 q_ref=interpolate(whereZero(x[0]),Solution(self.domain))
534 jgs 149 A_ref=kronecker(self.domain)
535 gross 304 mypde.setValue(q=whereZero(x[0]))
536 gross 1841 self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
537     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
538     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
539     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
540     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
541     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
542     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
543     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
544     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
545     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
546     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
547     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
548     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
549     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
550     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
551     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
552     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
553     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
554     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
555     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
556     self.failUnless(self.check(mypde.getCoefficient("q"),q_ref),"q is not empty")
557     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
558 jgs 149 def test_setCoefficient_f(self):
559     mypde=Poisson(self.domain,debug=self.DEBUG)
560     x=self.domain.getX()
561     Y_ref=interpolate(x[0],Function(self.domain))
562     A_ref=kronecker(self.domain)
563     mypde.setValue(f=x[0])
564 gross 1841 self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
565     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
566     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
567     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
568     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
569     self.failUnless(self.check(mypde.getCoefficient("Y"),Y_ref),"Y is not x[0]")
570     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
571     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
572     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
573     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
574     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
575     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
576     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
577     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
578     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
579     self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
580     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
581     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
582     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
583     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
584     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
585     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
586 gross 1072 def test_setCoefficient_f_reduced(self):
587     mypde=Poisson(self.domain,debug=self.DEBUG)
588     x=self.domain.getX()
589     Y_ref=interpolate(x[0],ReducedFunction(self.domain))
590     A_ref=kronecker(self.domain)
591     mypde.setValue(f_reduced=x[0])
592 gross 1841 self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
593     self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")
594     self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")
595     self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")
596     self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")
597     self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
598     self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")
599     self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")
600     self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
601     self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
602     self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
603     self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
604     self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
605     self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
606     self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
607     self.failUnless(self.check(mypde.getCoefficient("Y_reduced"),Y_ref),"Y_reduced is not x[0]")
608     self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
609     self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
610     self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
611     self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
612     self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")
613     self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")
614 jgs 149 def test_solve(self):
615     d=self.domain.getDim()
616     cf=ContinuousFunction(self.domain)
617     x=cf.getX()
618     #construct exact solution:
619     u_ex=Scalar(1.,cf)
620     for i in range(d):
621     u_ex*=x[i]*(2.-x[i])
622     #construct mask:
623     msk=Scalar(0.,cf)
624     for i in range(d):
625 gross 304 msk+=whereZero(x[i])
626 jgs 149 #construct right hand side
627     f=Scalar(0,cf)
628     for i in range(d):
629     f_p=Scalar(1,cf)
630     for j in range(d):
631     if i==j:
632     f_p*=2.
633     else:
634     f_p*=x[j]*(2-x[j])
635     f+=f_p
636     mypde=Poisson(self.domain)
637     mypde.setValue(f=f,q=msk)
638     u=mypde.getSolution()
639     self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution")
640    
641 gross 855 class Test_LinearPDE_noLumping(Test_linearPDEs):
642 jgs 149 N=4
643 gross 2470 def test_SolverOptions(self):
644     so=SolverOptions()
645 artak 2828
646 artak 2835 self.failUnless(so.getSmoother() == 28, "initial Smoother is wrong.")
647 artak 2828 self.failUnlessRaises(ValueError,so.setSmoother,-1)
648     so.setSmoother(so.GAUSS_SEIDEL)
649     self.failUnless(so.getSmoother() == 28, "Gauss-Seidel smoother is not set.")
650 artak 2835 so.setSmoother(so.JACOBI)
651     self.failUnless(so.getSmoother() == 10, "Jacobi smoother is not set.")
652 gross 2470
653 artak 2688 self.failUnless(so.getLevelMax() == 3, "initial LevelMax is wrong.")
654 gross 2470 self.failUnlessRaises(ValueError,so.setLevelMax,-1)
655 artak 2688 so.setLevelMax(20)
656     self.failUnless(so.getLevelMax() == 20, "LevelMax is wrong.")
657 gross 2470
658 artak 2688 self.failUnless(so.getCoarseningThreshold() == 0.25, "initial CoarseningThreshold is wrong.")
659 gross 2470 self.failUnlessRaises(ValueError,so.setCoarseningThreshold,-1)
660     so.setCoarseningThreshold(0.1)
661     self.failUnless(so.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")
662 artak 2524
663     self.failUnless(so.getMinCoarseMatrixSize() == 500, "initial Minimum Coarse Matrix Size is wrong.")
664     self.failUnlessRaises(ValueError,so.setMinCoarseMatrixSize,-1)
665     so.setMinCoarseMatrixSize(1000)
666     self.failUnless(so.getMinCoarseMatrixSize() == 1000, "Minimum Coarse Matrix Size is wrong.")
667 gross 2470
668     self.failUnless(so.getNumSweeps() == 2, "initial Sweeps is wrong.")
669     self.failUnlessRaises(ValueError,so.setNumSweeps,-1)
670     so.setNumSweeps(3)
671     self.failUnless(so.getNumSweeps() == 3, "Sweeps is wrong.")
672    
673     self.failUnless(so.getNumPreSweeps() == 2, "initial PreSweeps is wrong.")
674     self.failUnlessRaises(ValueError,so.setNumPreSweeps,-1)
675     so.setNumPreSweeps(4)
676     self.failUnless(so.getNumPreSweeps() == 4, "PreSweeps is wrong.")
677    
678     self.failUnless(so.getNumPostSweeps() == 2, "initial PreSweeps is wrong.")
679     self.failUnlessRaises(ValueError,so.setNumPostSweeps,-1)
680     so.setNumPostSweeps(5)
681     self.failUnless(so.getNumPostSweeps() == 5, "PreSweeps is wrong.")
682    
683     self.failUnless(so.getTolerance() == 1.e-8, "initial Tolerance is wrong.")
684     self.failUnlessRaises(ValueError,so.setTolerance,-1)
685     so.setTolerance(0.2)
686     self.failUnless(so.getTolerance() == 0.2, "Tolerance is wrong.")
687    
688     self.failUnless(so.getAbsoluteTolerance() == 0., "initial AbsoluteTolerance is wrong.")
689     self.failUnlessRaises(ValueError,so.setAbsoluteTolerance,-1)
690     so.setAbsoluteTolerance(0.3)
691     self.failUnless(so.getAbsoluteTolerance() == 0.3, "AbsoluteTolerance is wrong.")
692    
693     self.failUnless(so.getInnerTolerance() == 0.9, "initial InnerTolerance is wrong.")
694     self.failUnlessRaises(ValueError,so.setInnerTolerance,-1)
695     so.setInnerTolerance(0.4)
696     self.failUnless(so.getInnerTolerance() == 0.4, "InnerTolerance is wrong.")
697    
698     self.failUnless(so.getDropTolerance() == 0.01, "initial DropTolerance is wrong.")
699     self.failUnlessRaises(ValueError,so.setDropTolerance,-1)
700     so.setDropTolerance(0.5)
701     self.failUnless(so.getDropTolerance() == 0.5, "DropDropTolerance is wrong.")
702    
703     self.failUnless(so.getDropStorage() == 2., "initial DropStorage is wrong.")
704     self.failUnlessRaises(ValueError,so.setDropStorage,-1)
705     so.setDropStorage(10)
706     self.failUnless(so.getDropStorage() == 10, "DropStorage is wrong.")
707    
708     self.failUnless(so.getRelaxationFactor() == 0.3, "initial RelaxationFactor is wrong.")
709     self.failUnlessRaises(ValueError,so.setRelaxationFactor,-1)
710     so.setRelaxationFactor(0.1)
711     self.failUnless(so.getRelaxationFactor() == 0.1, "Relaxation is wrong.")
712    
713    
714 gross 2480 self.failUnless(so.getIterMax() == 100000, "initial IterMax is wrong.")
715 gross 2470 self.failUnlessRaises(ValueError,so.setIterMax,0)
716     so.setIterMax(11)
717     self.failUnless(so.getIterMax() == 11, "IterMax is wrong.")
718    
719     self.failUnless(so.getInnerIterMax() == 10, "initial InnerIterMax is wrong.")
720     self.failUnlessRaises(ValueError,so.setInnerIterMax,0)
721     so.setInnerIterMax(12)
722     self.failUnless(so.getInnerIterMax() == 12, "InnerIterMax is wrong.")
723    
724     self.failUnless(so.getTruncation() == 20, "initial Truncation is wrong.")
725     self.failUnlessRaises(ValueError,so.setTruncation,0)
726     so.setTruncation(13)
727     self.failUnless(so.getTruncation() == 13, "Truncation is wrong.")
728    
729     self.failUnless(so.getRestart() == None, "initial Truncation is wrong.")
730     self.failUnlessRaises(ValueError,so.setTruncation,0)
731     so.setRestart(14)
732     self.failUnless(so.getRestart() == 14, "Truncation is wrong.")
733     so.setRestart(None)
734     self.failUnless(so.getRestart() == None, "Truncation is wrong.")
735 gross 2474
736     self.failUnless(not so.isVerbose(), "initial verbosity flag is wrong.")
737     so.setVerbosityOn()
738     self.failUnless(so.isVerbose(), "verbosity (1) flag is wrong.")
739     so.setVerbosityOff()
740     self.failUnless(not so.isVerbose(), "verbosity (2) flag is wrong.")
741     so.setVerbosity(verbose=True)
742     self.failUnless(so.isVerbose(), "verbosity (3) flag is wrong.")
743     so.setVerbosity(verbose=False)
744     self.failUnless(not so.isVerbose(), "verbosity (4) flag is wrong.")
745    
746 gross 2470 self.failUnless(not so.isSymmetric(), "initial symmetry flag is wrong.")
747     so.setSymmetryOn()
748     self.failUnless(so.isSymmetric(), "symmetry (1) flag is wrong.")
749     so.setSymmetryOff()
750     self.failUnless(not so.isSymmetric(), "symmetry (2) flag is wrong.")
751     so.setSymmetry(flag=True)
752     self.failUnless(so.isSymmetric(), "symmetry (3) flag is wrong.")
753     so.setSymmetry(flag=False)
754     self.failUnless(not so.isSymmetric(), "symmetry (4) flag is wrong.")
755    
756     self.failUnless(so.adaptInnerTolerance(), "initial InnerToleranceAdaption flag is wrong.")
757     so.setInnerToleranceAdaptionOn()
758     self.failUnless(so.adaptInnerTolerance(), "InnerToleranceAdaption (1) flag is wrong.")
759     so.setInnerToleranceAdaptionOff()
760     self.failUnless(not so.adaptInnerTolerance(), "InnerToleranceAdaption (2) flag is wrong.")
761     so.setInnerToleranceAdaption(adapt=True)
762     self.failUnless(so.adaptInnerTolerance(), "InnerToleranceAdaption (3) flag is wrong.")
763     so.setInnerToleranceAdaption(adapt=False)
764     self.failUnless(not so.adaptInnerTolerance(), "InnerToleranceAdaption (4) flag is wrong.")
765    
766     self.failUnless(not so.acceptConvergenceFailure(), "initial acceptConvergenceFailure flag is wrong.")
767     so.setAcceptanceConvergenceFailureOn()
768     self.failUnless(so.acceptConvergenceFailure(), "acceptConvergenceFailure (1) flag is wrong.")
769     so.setAcceptanceConvergenceFailureOff()
770     self.failUnless(not so.acceptConvergenceFailure(), "acceptConvergenceFailure (2) flag is wrong.")
771     so.setAcceptanceConvergenceFailure(accept=True)
772     self.failUnless(so.acceptConvergenceFailure(), "acceptConvergenceFailure (3) flag is wrong.")
773     so.setAcceptanceConvergenceFailure(accept=False)
774     self.failUnless(not so.acceptConvergenceFailure(), "acceptConvergenceFailure (4) flag is wrong.")
775    
776     self.failUnless(so.getReordering() == 30, "initial Reordering is wrong.")
777     self.failUnlessRaises(ValueError,so.setReordering,-1)
778     so.setReordering(so.NO_REORDERING)
779     self.failUnless(so.getReordering() == 17, "NO_REORDERING is not set.")
780     so.setReordering(so.MINIMUM_FILL_IN)
781     self.failUnless(so.getReordering() == 18, "MINIMUM_FILL_IN is not set.")
782     so.setReordering(so.NESTED_DISSECTION)
783     self.failUnless(so.getReordering() == 19, "NESTED_DISSECTION is not set.")
784     so.setReordering(so.DEFAULT_REORDERING)
785     self.failUnless(so.getReordering() == 30, "DEFAULT_REORDERING is not set.")
786    
787     self.failUnless(so.getPackage() == 0, "initial solver package is wrong.")
788     self.failUnlessRaises(ValueError,so.setPackage,-1)
789     so.setPackage(so.PASO)
790     self.failUnless(so.getPackage() == 21, "PASO is not set.")
791     so.setPackage(so.SUPER_LU)
792     self.failUnless(so.getPackage() == 31, "SUPER_LU is not set.")
793     so.setPackage(so.PASTIX)
794     self.failUnless(so.getPackage() == 32, "PASTIX is not set.")
795     so.setPackage(so.MKL)
796     self.failUnless(so.getPackage() == 15, "MKL is not set.")
797     so.setPackage(so.UMFPACK)
798     self.failUnless(so.getPackage() == 16, "UMFPACK is not set.")
799     so.setPackage(so.TRILINOS)
800     self.failUnless(so.getPackage() == 24, "TRILINOS is not set.")
801    
802     self.failUnless(so.getSolverMethod() == 0, "initial SolverMethod is wrong.")
803     self.failUnlessRaises(ValueError,so.setSolverMethod,-1)
804     so.setSolverMethod(so.DIRECT)
805     self.failUnless(so.getSolverMethod() == 1, "DIRECT is not set.")
806     so.setSolverMethod(so.CHOLEVSKY)
807     self.failUnless(so.getSolverMethod() == 2, "CHOLEVSKY is not set.")
808     so.setSolverMethod(so.PCG)
809     self.failUnless(so.getSolverMethod() == 3, "PCG is not set.")
810     so.setSolverMethod(so.CR)
811     self.failUnless(so.getSolverMethod() == 4, "CR is not set.")
812     so.setSolverMethod(so.CGS)
813     self.failUnless(so.getSolverMethod() == 5, "CGS is not set.")
814     so.setSolverMethod(so.BICGSTAB)
815     self.failUnless(so.getSolverMethod() == 6, "BICGSTAB is not set.")
816     so.setSolverMethod(so.SSOR)
817     self.failUnless(so.getSolverMethod() == 7, "SSOR is not set.")
818     so.setSolverMethod(so.GMRES)
819     self.failUnless(so.getSolverMethod() == 11, "GMRES is not set.")
820     so.setSolverMethod(so.PRES20)
821     self.failUnless(so.getSolverMethod() == 12, "PRES20 is not set.")
822     so.setSolverMethod(so.LUMPING)
823     self.failUnless(so.getSolverMethod() == 13, "LUMPING is not set.")
824     so.setSolverMethod(so.ITERATIVE)
825     self.failUnless(so.getSolverMethod() == 20, "ITERATIVE is not set.")
826     so.setSolverMethod(so.AMG)
827     self.failUnless(so.getSolverMethod() == 22, "AMG is not set.")
828     so.setSolverMethod(so.NONLINEAR_GMRES)
829     self.failUnless(so.getSolverMethod() == 25, "NONLINEAR_GMRES is not set.")
830     so.setSolverMethod(so.TFQMR)
831     self.failUnless(so.getSolverMethod() == 26, "TFQMR is not set.")
832     so.setSolverMethod(so.MINRES)
833     self.failUnless(so.getSolverMethod() == 27, "MINRES is not set.")
834     so.setSolverMethod(so.GAUSS_SEIDEL)
835     self.failUnless(so.getSolverMethod() == 28, "GAUSS_SEIDEL is not set.")
836     so.setSolverMethod(so.DEFAULT)
837     self.failUnless(so.getSolverMethod() == 0, "DEFAULT is not set.")
838    
839     self.failUnless(so.getPreconditioner() == 10, "initial Preconditioner is wrong.")
840     self.failUnlessRaises(ValueError,so.setPreconditioner,-1)
841     so.setPreconditioner(so.ILU0)
842     self.failUnless(so.getPreconditioner() == 8, "ILU0 is not set.")
843     so.setPreconditioner(so.SSOR)
844     self.failUnless(so.getPreconditioner() == 7, "SSOR is not set.")
845     so.setPreconditioner(so.ILUT)
846     self.failUnless(so.getPreconditioner() == 9, "ILUT is not set.")
847     so.setPreconditioner(so.JACOBI)
848     self.failUnless(so.getPreconditioner() == 10, "JACOBI is not set.")
849     so.setPreconditioner(so.AMG)
850     self.failUnless(so.getPreconditioner() == 22, "AMG is not set.")
851     so.setPreconditioner(so.REC_ILU)
852     self.failUnless(so.getPreconditioner() == 23, "REC_ILU is not set.")
853     so.setPreconditioner(so.GAUSS_SEIDEL)
854     self.failUnless(so.getPreconditioner() == 28, "GAUSS_SEIDEL is not set.")
855     so.setPreconditioner(so.RILU)
856     self.failUnless(so.getPreconditioner() == 29, "RILU is not set.")
857     so.setPreconditioner(so.NO_PRECONDITIONER)
858     self.failUnless(so.getPreconditioner() == 36, "NO_PRECONDITIONER is not set.")
859    
860     self.failUnless(so.getCoarsening() == 0, "initial Coarseningr is wrong.")
861     self.failUnlessRaises(ValueError,so.setCoarsening,-1)
862     so.setCoarsening(so.YAIR_SHAPIRA_COARSENING)
863     self.failUnless(so.getCoarsening() == 33, "YAIR_SHAPIRA_COARSENING is not set.")
864     so.setCoarsening(so.RUGE_STUEBEN_COARSENING)
865     self.failUnless(so.getCoarsening() == 34, "RUGE_STUEBEN_COARSENING is not set.")
866     so.setCoarsening(so.AGGREGATION_COARSENING)
867     self.failUnless(so.getCoarsening() == 35, "AGREGATION_COARSENING is not set.")
868 artak 2817 so.setCoarsening(so.STANDARD_COARSENING)
869     self.failUnless(so.getCoarsening() == 39, "STANDARD_COARSENING is not set.")
870 gross 2470 so.setCoarsening(so.DEFAULT)
871     self.failUnless(so.getCoarsening() == 0, "DEFAULT is not set.")
872    
873     self.failUnless(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")
874     self.failUnless(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")
875     self.failUnless(so.getDiagnostics("time") == None, "initial time is wrong.")
876     self.failUnless(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")
877     self.failUnless(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")
878     self.failUnless(so.getDiagnostics("converged") == None, "initial converged is wrong.")
879     self.failUnless(so.hasConverged() == None, "initial convergence flag is wrong.")
880     self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")
881     self.failUnless(so.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")
882     self.failUnless(so.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")
883     self.failUnless(so.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")
884    
885     so._updateDiagnostics("num_iter",1)
886     so._updateDiagnostics("num_inner_iter",2)
887     so._updateDiagnostics("time",3)
888     so._updateDiagnostics("set_up_time",4)
889     so._updateDiagnostics("residual_norm",5)
890     so._updateDiagnostics("converged",True)
891    
892     self.failUnless(so.getDiagnostics("num_iter") == 1, "num_iter is wrong.")
893     self.failUnless(so.getDiagnostics("num_inner_iter") == 2, "num_inner_iter is wrong.")
894     self.failUnless(so.getDiagnostics("time") == 3, "time is wrong.")
895     self.failUnless(so.getDiagnostics("set_up_time") == 4, "set_up_time is wrong.")
896     self.failUnless(so.getDiagnostics("residual_norm") == 5, "residual_norm is wrong.")
897     self.failUnless(so.getDiagnostics("converged"), "converged is wrong.")
898     self.failUnless(so.hasConverged(), "convergence flag is wrong.")
899     self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")
900     self.failUnless(so.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")
901     self.failUnless(so.getDiagnostics("cum_time") ==3, "cum_time is wrong.")
902     self.failUnless(so.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")
903    
904     so.resetDiagnostics()
905     self.failUnless(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")
906     self.failUnless(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")
907     self.failUnless(so.getDiagnostics("time") == None, "initial time is wrong.")
908     self.failUnless(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")
909     self.failUnless(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")
910     self.failUnless(so.getDiagnostics("converged") == None, "initial converged is wrong.")
911     self.failUnless(so.hasConverged() == None, "initial convergence flag is wrong")
912     self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")
913     self.failUnless(so.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")
914     self.failUnless(so.getDiagnostics("cum_time") ==3, "cum_time is wrong.")
915     self.failUnless(so.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")
916    
917     so._updateDiagnostics("num_iter",10)
918     so._updateDiagnostics("num_inner_iter",20)
919     so._updateDiagnostics("time",30)
920     so._updateDiagnostics("set_up_time",40)
921     so._updateDiagnostics("residual_norm",50)
922     so._updateDiagnostics("converged",False)
923    
924     self.failUnless(so.getDiagnostics("num_iter") == 10, "num_iter is wrong.")
925     self.failUnless(so.getDiagnostics("num_inner_iter") == 20, "num_inner_iter is wrong.")
926     self.failUnless(so.getDiagnostics("time") == 30, "time is wrong.")
927     self.failUnless(so.getDiagnostics("set_up_time") == 40, "set_up_time is wrong.")
928     self.failUnless(so.getDiagnostics("residual_norm") == 50, "residual_norm is wrong.")
929     self.failUnless(not so.getDiagnostics("converged"), "converged is wrong.")
930     self.failUnless(not so.hasConverged(), "convergence flag is wrong.")
931     self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 22, "cum_num_inner_iter is wrong.")
932     self.failUnless(so.getDiagnostics("cum_num_iter") == 11, "cum_num_iter is wrong.")
933     self.failUnless(so.getDiagnostics("cum_time") ==33, "cum_time is wrong.")
934     self.failUnless(so.getDiagnostics("cum_set_up_time") == 44, "cum_set_up_time is wrong.")
935    
936     so.resetDiagnostics(all=True)
937     self.failUnless(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")
938     self.failUnless(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")
939     self.failUnless(so.getDiagnostics("time") == None, "initial time is wrong.")
940     self.failUnless(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")
941     self.failUnless(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")
942     self.failUnless(so.getDiagnostics("converged") == None, "initial converged is wrong.")
943     self.failUnless(so.hasConverged() == None, "initial convergence flag is wrong.")
944     self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")
945     self.failUnless(so.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")
946     self.failUnless(so.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")
947     self.failUnless(so.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")
948    
949 jgs 149 def test_setCoefficient_WithIllegalFunctionSpace(self):
950     mypde=LinearPDE(self.domain,debug=self.DEBUG)
951 gross 2474 self.failUnlessRaises(IllegalCoefficientFunctionSpace, mypde.setValue, C=Vector(0.,FunctionOnBoundary(self.domain)))
952 gross 1859
953     def test_setCoefficient_WithWrongName(self):
954     mypde=LinearPDE(self.domain,debug=self.DEBUG)
955     self.failUnlessRaises(IllegalCoefficient, mypde.setValue, ROMA=0.)
956    
957 jgs 149 def test_resetCoefficient_WithWrongShape(self):
958     mypde=LinearPDE(self.domain,numEquations=2,debug=self.DEBUG)
959 gross 1859 self.failUnlessRaises(IllegalCoefficientValue, mypde.setValue, C=0.)
960    
961 jgs 149 def test_reducedOn(self):
962     mypde=LinearPDE(self.domain,debug=self.DEBUG)
963     x=self.domain.getX()
964     mypde.setReducedOrderOn()
965     mypde.setValue(A=kronecker(self.domain),D=x[0],Y=x[0])
966     u=mypde.getSolution()
967     self.failUnless(self.check(u,1.),'solution is wrong.')
968    
969     def test_attemptToChangeOrderAfterDefinedCoefficient(self):
970     mypde=LinearPDE(self.domain,debug=self.DEBUG)
971     mypde.setValue(D=1.)
972 gross 2474 self.failUnlessRaises(RuntimeError, mypde.setReducedOrderOn)
973 jgs 149
974     def test_reducedOnConfig(self):
975     mypde=LinearPDE(self.domain,debug=self.DEBUG)
976     mypde.setReducedOrderOn()
977 gross 2474 self.failUnlessEqual((mypde.getFunctionSpaceForSolution(), mypde.getFunctionSpaceForEquation()),(ReducedSolution(self.domain),ReducedSolution(self.domain)),"reduced function spaces expected.")
978 jgs 149 #
979     # set coefficients for scalars:
980     #
981     def test_setCoefficient_A_Scalar(self):
982     d=self.domain.getDim()
983     mypde=LinearPDE(self.domain,debug=self.DEBUG)
984 jfenwick 2455 mypde.setValue(A=numpy.ones((d,d)))
985 gross 1841 coeff=mypde.getCoefficient("A")
986 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),Function(self.domain),1,1))
987 jgs 149 def test_setCoefficient_B_Scalar(self):
988     d=self.domain.getDim()
989     mypde=LinearPDE(self.domain,debug=self.DEBUG)
990 jfenwick 2455 mypde.setValue(B=numpy.ones((d,)))
991 gross 1841 coeff=mypde.getCoefficient("B")
992 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),Function(self.domain),1,1))
993 jgs 149 def test_setCoefficient_C_Scalar(self):
994     d=self.domain.getDim()
995     mypde=LinearPDE(self.domain,debug=self.DEBUG)
996 jfenwick 2455 mypde.setValue(C=numpy.ones((d,)))
997 gross 1841 coeff=mypde.getCoefficient("C")
998 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),Function(self.domain),1,1))
999 jgs 149 def test_setCoefficient_D_Scalar(self):
1000     d=self.domain.getDim()
1001     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1002     mypde.setValue(D=1.)
1003 gross 1841 coeff=mypde.getCoefficient("D")
1004 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),Function(self.domain),1,1))
1005 jgs 149 def test_setCoefficient_X_Scalar(self):
1006     d=self.domain.getDim()
1007     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1008 jfenwick 2455 mypde.setValue(X=numpy.ones((d,)))
1009 gross 1841 coeff=mypde.getCoefficient("X")
1010 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),Function(self.domain),1))
1011 jgs 149 def test_setCoefficient_Y_Scalar(self):
1012     d=self.domain.getDim()
1013     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1014     mypde.setValue(Y=1.)
1015 gross 1841 coeff=mypde.getCoefficient("Y")
1016 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),Function(self.domain),1))
1017 jgs 149 def test_setCoefficient_y_Scalar(self):
1018     d=self.domain.getDim()
1019     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1020     mypde.setValue(y=1.)
1021 gross 1841 coeff=mypde.getCoefficient("y")
1022 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1))
1023 jgs 149 def test_setCoefficient_d_Scalar(self):
1024     d=self.domain.getDim()
1025     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1026     mypde.setValue(d=1.)
1027 gross 1841 coeff=mypde.getCoefficient("d")
1028 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1))
1029 jgs 149 def test_setCoefficient_d_contact_Scalar(self):
1030     d=self.domain.getDim()
1031     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1032     mypde.setValue(d_contact=1.)
1033 gross 1841 coeff=mypde.getCoefficient("d_contact")
1034 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1,1))
1035 jgs 149 def test_setCoefficient_y_contact_Scalar(self):
1036     d=self.domain.getDim()
1037     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1038     mypde.setValue(y_contact=1.)
1039 gross 1841 coeff=mypde.getCoefficient("y_contact")
1040 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))
1041 gross 1072 def test_setCoefficient_A_reduced_Scalar(self):
1042     d=self.domain.getDim()
1043     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1044 jfenwick 2455 mypde.setValue(A_reduced=numpy.ones((d,d)))
1045 gross 1841 coeff=mypde.getCoefficient("A_reduced")
1046 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
1047 gross 1072 def test_setCoefficient_B_reduced_Scalar(self):
1048     d=self.domain.getDim()
1049     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1050 jfenwick 2455 mypde.setValue(B_reduced=numpy.ones((d,)))
1051 gross 1841 coeff=mypde.getCoefficient("B_reduced")
1052 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1053 gross 1072 def test_setCoefficient_C_reduced_Scalar(self):
1054     d=self.domain.getDim()
1055     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1056 jfenwick 2455 mypde.setValue(C_reduced=numpy.ones((d,)))
1057 gross 1841 coeff=mypde.getCoefficient("C_reduced")
1058 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1059 gross 1072 def test_setCoefficient_D_reduced_Scalar(self):
1060     d=self.domain.getDim()
1061     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1062     mypde.setValue(D_reduced=1.)
1063 gross 1841 coeff=mypde.getCoefficient("D_reduced")
1064 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
1065 gross 1072 def test_setCoefficient_X_reduced_Scalar(self):
1066     d=self.domain.getDim()
1067     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1068 jfenwick 2455 mypde.setValue(X_reduced=numpy.ones((d,)))
1069 gross 1841 coeff=mypde.getCoefficient("X_reduced")
1070 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
1071 gross 1072 def test_setCoefficient_Y_reduced_Scalar(self):
1072     d=self.domain.getDim()
1073     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1074     mypde.setValue(Y_reduced=1.)
1075 gross 1841 coeff=mypde.getCoefficient("Y_reduced")
1076 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
1077 gross 1072 def test_setCoefficient_y_reduced_Scalar(self):
1078     d=self.domain.getDim()
1079     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1080     mypde.setValue(y_reduced=1.)
1081 gross 1841 coeff=mypde.getCoefficient("y_reduced")
1082 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
1083 gross 1072 def test_setCoefficient_d_reduced_Scalar(self):
1084     d=self.domain.getDim()
1085     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1086     mypde.setValue(d_reduced=1.)
1087 gross 1841 coeff=mypde.getCoefficient("d_reduced")
1088 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
1089 gross 1072 def test_setCoefficient_d_contact_reduced_Scalar(self):
1090     d=self.domain.getDim()
1091     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1092     mypde.setValue(d_contact_reduced=1.)
1093 gross 1841 coeff=mypde.getCoefficient("d_contact_reduced")
1094 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
1095 gross 1072 def test_setCoefficient_y_contact_reduced_Scalar(self):
1096     d=self.domain.getDim()
1097     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1098     mypde.setValue(y_contact_reduced=1.)
1099 gross 1841 coeff=mypde.getCoefficient("y_contact_reduced")
1100 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
1101 jgs 149 def test_setCoefficient_r_Scalar(self):
1102     d=self.domain.getDim()
1103     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1104     mypde.setValue(r=1.)
1105 gross 1841 coeff=mypde.getCoefficient("r")
1106 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),Solution(self.domain),1))
1107 jgs 149 def test_setCoefficient_q_Scalar(self):
1108     d=self.domain.getDim()
1109     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1110     mypde.setValue(q=1.)
1111 gross 1841 coeff=mypde.getCoefficient("q")
1112 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),Solution(self.domain),1))
1113 jgs 149 def test_setCoefficient_r_Scalar_reducedOn(self):
1114     d=self.domain.getDim()
1115     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1116     mypde.setReducedOrderOn()
1117     mypde.setValue(r=1.)
1118 gross 1841 coeff=mypde.getCoefficient("r")
1119 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
1120 jgs 149 def test_setCoefficient_q_Scalar_reducedOn(self):
1121     d=self.domain.getDim()
1122     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1123     mypde.setReducedOrderOn()
1124     mypde.setValue(q=1.)
1125 gross 1841 coeff=mypde.getCoefficient("q")
1126 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
1127 jgs 149
1128 gross 1072 def test_setCoefficient_A_reduced_Scalar_usingA(self):
1129     d=self.domain.getDim()
1130     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1131 jfenwick 2455 mypde.setValue(A=Data(numpy.ones((d,d)),ReducedFunction(self.domain)))
1132 gross 1841 coeff=mypde.getCoefficient("A_reduced")
1133 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
1134 gross 1072 def test_setCoefficient_B_reduced_Scalar_usingB(self):
1135     d=self.domain.getDim()
1136     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1137 jfenwick 2455 mypde.setValue(B=Data(numpy.ones((d,)),ReducedFunction(self.domain)))
1138 gross 1841 coeff=mypde.getCoefficient("B_reduced")
1139 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1140 gross 1072 def test_setCoefficient_C_reduced_Scalar_usingC(self):
1141     d=self.domain.getDim()
1142     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1143 jfenwick 2455 mypde.setValue(C=Data(numpy.ones((d,)),ReducedFunction(self.domain)))
1144 gross 1841 coeff=mypde.getCoefficient("C_reduced")
1145 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1146 gross 1072 def test_setCoefficient_D_reduced_Scalar_usingD(self):
1147     d=self.domain.getDim()
1148     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1149     mypde.setValue(D=Scalar(1.,ReducedFunction(self.domain)))
1150 gross 1841 coeff=mypde.getCoefficient("D_reduced")
1151 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
1152 gross 1072 def test_setCoefficient_X_reduced_Scalar_usingX(self):
1153     d=self.domain.getDim()
1154     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1155 jfenwick 2455 mypde.setValue(X_reduced=Data(numpy.ones((d,)),ReducedFunction(self.domain)))
1156 gross 1841 coeff=mypde.getCoefficient("X_reduced")
1157 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
1158 gross 1072 def test_setCoefficient_Y_reduced_Scalar_usingY(self):
1159     d=self.domain.getDim()
1160     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1161     mypde.setValue(Y=Scalar(1.,ReducedFunction(self.domain)))
1162 gross 1841 coeff=mypde.getCoefficient("Y_reduced")
1163 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
1164 gross 1072 def test_setCoefficient_y_reduced_Scalar_using_y(self):
1165     d=self.domain.getDim()
1166     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1167     mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
1168 gross 1841 coeff=mypde.getCoefficient("y_reduced")
1169 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
1170 gross 1072 def test_setCoefficient_d_reduced_Scalar_using_d(self):
1171     d=self.domain.getDim()
1172     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1173     mypde.setValue(d=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
1174 gross 1841 coeff=mypde.getCoefficient("d_reduced")
1175 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
1176 gross 1072 def test_setCoefficient_d_contact_reduced_Scalar_using_d_contact(self):
1177     d=self.domain.getDim()
1178     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1179     mypde.setValue(d_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
1180 gross 1841 coeff=mypde.getCoefficient("d_contact_reduced")
1181 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
1182 gross 1072 def test_setCoefficient_y_contact_reduced_Scalar_using_y_contact(self):
1183     d=self.domain.getDim()
1184     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1185     mypde.setValue(y_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
1186 gross 1841 coeff=mypde.getCoefficient("y_contact_reduced")
1187 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
1188 jgs 149 #
1189     # set coefficients for systems:
1190     #
1191     def test_setCoefficient_A_System(self):
1192     d=self.domain.getDim()
1193     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1194 jfenwick 2455 mypde.setValue(A=numpy.ones((self.N,d,self.N,d)))
1195 gross 1841 coeff=mypde.getCoefficient("A")
1196 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),Function(self.domain),self.N,self.N))
1197 jgs 149 def test_setCoefficient_B_System(self):
1198     d=self.domain.getDim()
1199     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1200 jfenwick 2455 mypde.setValue(B=numpy.ones((self.N,d,self.N)))
1201 gross 1841 coeff=mypde.getCoefficient("B")
1202 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),Function(self.domain),self.N,self.N))
1203 jgs 149 def test_setCoefficient_C_System(self):
1204     d=self.domain.getDim()
1205     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1206 jfenwick 2455 mypde.setValue(C=numpy.ones((self.N,self.N,d)))
1207 gross 1841 coeff=mypde.getCoefficient("C")
1208 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),Function(self.domain),self.N,self.N))
1209 jgs 149 def test_setCoefficient_D_System(self):
1210     d=self.domain.getDim()
1211     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1212 jfenwick 2455 mypde.setValue(D=numpy.ones((self.N,self.N)))
1213 gross 1841 coeff=mypde.getCoefficient("D")
1214 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),Function(self.domain),self.N,self.N))
1215 jgs 149 def test_setCoefficient_X_System(self):
1216     d=self.domain.getDim()
1217     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1218 jfenwick 2455 mypde.setValue(X=numpy.ones((self.N,d)))
1219 gross 1841 coeff=mypde.getCoefficient("X")
1220 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),Function(self.domain),self.N))
1221 jgs 149 def test_setCoefficient_Y_System(self):
1222     d=self.domain.getDim()
1223     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1224 jfenwick 2455 mypde.setValue(Y=numpy.ones((self.N,)))
1225 gross 1841 coeff=mypde.getCoefficient("Y")
1226 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),Function(self.domain),self.N))
1227 jgs 149 def test_setCoefficient_y_System(self):
1228     d=self.domain.getDim()
1229     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1230 jfenwick 2455 mypde.setValue(y=numpy.ones((self.N,)))
1231 gross 1841 coeff=mypde.getCoefficient("y")
1232 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),FunctionOnBoundary(self.domain),self.N))
1233 jgs 149 def test_setCoefficient_d_System(self):
1234     d=self.domain.getDim()
1235     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1236 jfenwick 2455 mypde.setValue(d=numpy.ones((self.N,self.N)))
1237 gross 1841 coeff=mypde.getCoefficient("d")
1238 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),FunctionOnBoundary(self.domain),self.N,self.N))
1239 jgs 149 def test_setCoefficient_d_contact_System(self):
1240     d=self.domain.getDim()
1241     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1242 jfenwick 2455 mypde.setValue(d_contact=numpy.ones((self.N,self.N)))
1243 gross 1841 coeff=mypde.getCoefficient("d_contact")
1244 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),FunctionOnContactZero(self.domain),self.N,self.N))
1245 jgs 149 def test_setCoefficient_y_contact_System(self):
1246     d=self.domain.getDim()
1247     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1248 jfenwick 2455 mypde.setValue(y_contact=numpy.ones((self.N,)))
1249 gross 1841 coeff=mypde.getCoefficient("y_contact")
1250 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N))
1251 gross 1072 def test_setCoefficient_A_reduced_System(self):
1252     d=self.domain.getDim()
1253     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1254 jfenwick 2455 mypde.setValue(A_reduced=numpy.ones((self.N,d,self.N,d)))
1255 gross 1841 coeff=mypde.getCoefficient("A_reduced")
1256 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1257 gross 1072 def test_setCoefficient_B_reduced_System(self):
1258     d=self.domain.getDim()
1259     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1260 jfenwick 2455 mypde.setValue(B_reduced=numpy.ones((self.N,d,self.N)))
1261 gross 1841 coeff=mypde.getCoefficient("B_reduced")
1262 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
1263 gross 1072 def test_setCoefficient_C_reduced_System(self):
1264     d=self.domain.getDim()
1265     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1266 jfenwick 2455 mypde.setValue(C_reduced=numpy.ones((self.N,self.N,d)))
1267 gross 1841 coeff=mypde.getCoefficient("C_reduced")
1268 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1269 gross 1072 def test_setCoefficient_D_System_reduced(self):
1270     d=self.domain.getDim()
1271     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1272 jfenwick 2455 mypde.setValue(D_reduced=numpy.ones((self.N,self.N)))
1273 gross 1841 coeff=mypde.getCoefficient("D_reduced")
1274 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
1275 gross 1072 def test_setCoefficient_X_System_reduced(self):
1276     d=self.domain.getDim()
1277     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1278 jfenwick 2455 mypde.setValue(X_reduced=numpy.ones((self.N,d)))
1279 gross 1841 coeff=mypde.getCoefficient("X_reduced")
1280 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
1281 gross 1072 def test_setCoefficient_Y_System_reduced(self):
1282     d=self.domain.getDim()
1283     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1284 jfenwick 2455 mypde.setValue(Y_reduced=numpy.ones((self.N,)))
1285 gross 1841 coeff=mypde.getCoefficient("Y_reduced")
1286 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
1287 gross 1072 def test_setCoefficient_y_System_reduced(self):
1288     d=self.domain.getDim()
1289     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1290 jfenwick 2455 mypde.setValue(y_reduced=numpy.ones((self.N,)))
1291 gross 1841 coeff=mypde.getCoefficient("y_reduced")
1292 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
1293 gross 1072 def test_setCoefficient_d_reduced_System(self):
1294     d=self.domain.getDim()
1295     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1296 jfenwick 2455 mypde.setValue(d_reduced=numpy.ones((self.N,self.N)))
1297 gross 1841 coeff=mypde.getCoefficient("d_reduced")
1298 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
1299 gross 1072 def test_setCoefficient_d_contact_reduced_System(self):
1300     d=self.domain.getDim()
1301     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1302 jfenwick 2455 mypde.setValue(d_contact_reduced=numpy.ones((self.N,self.N)))
1303 gross 1841 coeff=mypde.getCoefficient("d_contact_reduced")
1304 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
1305 gross 1072 def test_setCoefficient_y_contact_reduced_System(self):
1306     d=self.domain.getDim()
1307     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1308 jfenwick 2455 mypde.setValue(y_contact_reduced=numpy.ones((self.N,)))
1309 gross 1841 coeff=mypde.getCoefficient("y_contact_reduced")
1310 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
1311 jgs 149 def test_setCoefficient_r_System(self):
1312     d=self.domain.getDim()
1313     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1314 jfenwick 2455 mypde.setValue(r=numpy.ones((self.N,)))
1315 gross 1841 coeff=mypde.getCoefficient("r")
1316 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
1317 jgs 149 def test_setCoefficient_q_System(self):
1318     d=self.domain.getDim()
1319     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1320 jfenwick 2455 mypde.setValue(q=numpy.ones((self.N,)))
1321 gross 1841 coeff=mypde.getCoefficient("q")
1322 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
1323 jgs 149 def test_setCoefficient_r_System_reducedOn(self):
1324     d=self.domain.getDim()
1325     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1326     mypde.setReducedOrderOn()
1327 jfenwick 2455 mypde.setValue(r=numpy.ones((self.N,)))
1328 gross 1841 coeff=mypde.getCoefficient("r")
1329 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
1330 jgs 149 def test_setCoefficient_q_System_reducedOn(self):
1331     d=self.domain.getDim()
1332     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1333     mypde.setReducedOrderOn()
1334 jfenwick 2455 mypde.setValue(q=numpy.ones((self.N,)))
1335 gross 1841 coeff=mypde.getCoefficient("q")
1336 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
1337 jgs 149
1338 gross 1072 def test_setCoefficient_A_reduced_System_using_A(self):
1339     d=self.domain.getDim()
1340     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1341 jfenwick 2455 mypde.setValue(A=Data(numpy.ones((self.N,d,self.N,d)),ReducedFunction(self.domain)))
1342 gross 1841 coeff=mypde.getCoefficient("A_reduced")
1343 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1344 gross 1072 def test_setCoefficient_B_reduced_System_using_B(self):
1345     d=self.domain.getDim()
1346     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1347 jfenwick 2455 mypde.setValue(B=Data(numpy.ones((self.N,d,self.N)),ReducedFunction(self.domain)))
1348 gross 1841 coeff=mypde.getCoefficient("B_reduced")
1349 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
1350 gross 1072 def test_setCoefficient_C_reduced_System_using_C(self):
1351     d=self.domain.getDim()
1352     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1353 jfenwick 2455 mypde.setValue(C=Data(numpy.ones((self.N,self.N,d)),ReducedFunction(self.domain)))
1354 gross 1841 coeff=mypde.getCoefficient("C_reduced")
1355 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1356 gross 1072 def test_setCoefficient_D_System_reduced_using_D(self):
1357     d=self.domain.getDim()
1358     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1359 jfenwick 2455 mypde.setValue(D=Data(numpy.ones((self.N,self.N)),ReducedFunction(self.domain)))
1360 gross 1841 coeff=mypde.getCoefficient("D_reduced")
1361 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
1362 gross 1072 def test_setCoefficient_X_System_reduced_using_X(self):
1363     d=self.domain.getDim()
1364     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1365 jfenwick 2455 mypde.setValue(X=Data(numpy.ones((self.N,d)),ReducedFunction(self.domain)))
1366 gross 1841 coeff=mypde.getCoefficient("X_reduced")
1367 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
1368 gross 1072 def test_setCoefficient_Y_System_reduced_using_Y(self):
1369     d=self.domain.getDim()
1370     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1371 jfenwick 2455 mypde.setValue(Y=Data(numpy.ones((self.N,)),ReducedFunction(self.domain)))
1372 gross 1841 coeff=mypde.getCoefficient("Y_reduced")
1373 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
1374 gross 1072 def test_setCoefficient_y_reduced_System_using_y(self):
1375     d=self.domain.getDim()
1376     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1377 jfenwick 2455 mypde.setValue(y=Data(numpy.ones((self.N,)),ReducedFunctionOnBoundary(self.domain)))
1378 gross 1841 coeff=mypde.getCoefficient("y_reduced")
1379 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
1380 gross 1072 def test_setCoefficient_d_reduced_System_using_d(self):
1381     d=self.domain.getDim()
1382     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1383 jfenwick 2455 mypde.setValue(d=Data(numpy.ones((self.N,self.N)),ReducedFunctionOnBoundary(self.domain)))
1384 gross 1841 coeff=mypde.getCoefficient("d_reduced")
1385 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
1386 gross 1072 def test_setCoefficient_d_contact_reduced_System_using_d_contact(self):
1387     d=self.domain.getDim()
1388     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1389 jfenwick 2455 mypde.setValue(d_contact=Data(numpy.ones((self.N,self.N)),ReducedFunctionOnContactZero(self.domain)))
1390 gross 1841 coeff=mypde.getCoefficient("d_contact_reduced")
1391 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
1392 gross 1072 def test_setCoefficient_y_contact_reduced_System_using_y_contact(self):
1393     d=self.domain.getDim()
1394     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1395 jfenwick 2455 mypde.setValue(y_contact=Data(numpy.ones((self.N,)),ReducedFunctionOnContactZero(self.domain)))
1396 gross 1841 coeff=mypde.getCoefficient("y_contact_reduced")
1397 gross 2474 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
1398 jgs 149 def test_resetCoefficient_HomogeneousConstraint(self):
1399     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1400     x=self.domain.getX()
1401 gross 304 mypde.setValue(A=kronecker(self.domain),Y=1.,q=whereZero(x[0]))
1402 jgs 149 u1=mypde.getSolution()
1403     mypde.setValue(Y=2.)
1404     u2=mypde.getSolution()
1405     self.failUnless(self.check(u2,2*u1),'solution is wrong.')
1406    
1407     def test_resetCoefficient_InHomogeneousConstraint(self):
1408     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1409 jgs 154 mypde.setSymmetryOn()
1410 gross 2474 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1411 jgs 149 x=self.domain.getX()
1412 gross 304 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.,r=1,q=whereZero(x[0]))
1413 gross 2474 u1=mypde.getSolution()
1414 jgs 149 mypde.setValue(Y=2.,D=2)
1415 gross 2474 u2=mypde.getSolution()
1416 jgs 154 self.failUnless(self.check(u2,u1),'first solution is wrong.')
1417 gross 2474 u2=mypde.getSolution()
1418 jgs 154 self.failUnless(self.check(u2,u1),'first solution is wrong.')
1419 jgs 149 mypde.setValue(r=2,Y=4.)
1420 gross 2474 u2=mypde.getSolution()
1421 jgs 154 self.failUnless(self.check(u2,2*u1),'second solution is wrong.')
1422 jgs 149
1423 gross 2535 def test_Status(self):
1424     DIM=self.domain.getDim()
1425     x=self.domain.getX()
1426     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1427     mypde.getSolverOptions().setSymmetryOn()
1428     mypde.getSolverOptions().setTolerance(self.RES_TOL)
1429     mypde.setValue(A=kronecker(self.domain), q=whereZero(x[0])+whereZero(x[0]-1.), Y=2.)
1430     x1=self.domain.getX()
1431     u1_ref=x1[0]*(1.-x1[0])
1432     u1=mypde.getSolution()
1433     error1=Lsup(u1-u1_ref)/Lsup(u1_ref)
1434     self.failUnless(mypde.getDomainStatus() == mypde.getSystemStatus(), "status of first pde does not match domain status.")
1435    
1436     self.domain.setX(x*5)
1437    
1438     self.failUnless(mypde.getDomainStatus() != mypde.getSystemStatus(), "status of first pde matches updated domain status.")
1439     x2=self.domain.getX()
1440     u2_ref=x2[0]*(5.-x2[0])
1441     u2=mypde.getSolution()
1442     error2=Lsup(u2-u2_ref)/Lsup(u2_ref)
1443     self.failUnless(error2 <= max(error1,self.RES_TOL)*10., "solution of second PDE wrong.")
1444     self.failUnless(mypde.getDomainStatus() == mypde.getSystemStatus(), "status of second pde does not match domain status.")
1445    
1446 jgs 149 def test_symmetryCheckTrue_System(self):
1447     d=self.domain.getDim()
1448     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1449 jfenwick 2455 A=numpy.ones((self.N,d,self.N,d))
1450     C=2*numpy.ones((self.N,self.N,d))
1451     B=2*numpy.ones((self.N,d,self.N))
1452     D=3*numpy.ones((self.N,self.N))
1453     d=4*numpy.ones((self.N,self.N))
1454     d_contact=5*numpy.ones((self.N,self.N))
1455 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)
1456 jgs 149 self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
1457    
1458     def test_symmetryCheckFalse_A_System(self):
1459     d=self.domain.getDim()
1460     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1461 jfenwick 2455 A=numpy.ones((self.N,d,self.N,d))
1462 jgs 149 A[1,1,1,0]=0.
1463     mypde.setValue(A=A)
1464     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1465     def test_symmetryCheckFalse_BC_System(self):
1466     d=self.domain.getDim()
1467     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1468 jfenwick 2455 C=2*numpy.ones((self.N,self.N,d))
1469     B=2*numpy.ones((self.N,d,self.N))
1470 jgs 149 B[0,0,1]=1.
1471     mypde.setValue(B=B,C=C)
1472     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1473    
1474     def test_symmetryCheckFalse_D_System(self):
1475     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1476 jfenwick 2455 D=3*numpy.ones((self.N,self.N))
1477 jgs 149 D[0,1]=0.
1478     mypde.setValue(D=D)
1479     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1480    
1481