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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2549 - (show annotations)
Mon Jul 20 06:43:47 2009 UTC (10 years, 2 months ago) by jfenwick
Original Path: trunk/escript/test/python/test_linearPDEs.py
File MIME type: text/x-python
File size: 173353 byte(s)
Remainder of copyright date fixes
1
2 ########################################################
3 #
4 # Copyright (c) 2003-2009 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # 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 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2009 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 """
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 def tearDown(self):
32 del self.domain
33 suite = unittest.TestSuite()
34 suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley))
35 unittest.TextTestRunner(verbosity=2).run(suite)
36
37 @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 """
44
45 __author__="Lutz Gross, l.gross@uq.edu.au"
46
47 from esys.escript.util import Lsup,kronecker,interpolate,whereZero, outer, swap_axes
48 from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar, ReducedFunction,ReducedFunctionOnBoundary,ReducedFunctionOnContactZero,Data, Tensor4, Tensor
49 from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace, TransportPDE, IllegalCoefficient, Helmholtz, LameEquation, SolverOptions
50 import numpy
51 import unittest
52
53 class Test_linearPDEs(unittest.TestCase):
54 TOL=1.e-6
55 SOLVER_TOL=1.e-10
56 DEBUG=False
57 VERBOSE=False
58 def check(self,arg,ref_arg,tol=None):
59 """
60 checks if arg and ref_arg are nearly identical using the L{Lsup<esys.escript.util.Lsup>}
61 """
62 if tol==None: tol=self.TOL
63 return Lsup(arg-ref_arg)<=tol*Lsup(ref_arg)
64
65 class Test_LameEquation(Test_linearPDEs):
66
67 def test_config(self):
68 mypde=LameEquation(self.domain,debug=self.DEBUG)
69 d=self.domain.getDim()
70 self.failUnlessEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(d,d,True),"set up incorrect")
71
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 class Test_Helmholtz(Test_linearPDEs):
330
331 def test_config(self):
332 mypde=Helmholtz(self.domain,debug=self.DEBUG)
333 self.failUnlessEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(1,1,True),"set up incorrect")
334 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 class Test_Poisson(Test_linearPDEs):
526
527 def test_config(self):
528 mypde=Poisson(self.domain,debug=self.DEBUG)
529 self.failUnlessEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(1,1,True),"set up incorrect")
530 def test_setCoefficient_q(self):
531 mypde=Poisson(self.domain,debug=self.DEBUG)
532 x=self.domain.getX()
533 q_ref=interpolate(whereZero(x[0]),Solution(self.domain))
534 A_ref=kronecker(self.domain)
535 mypde.setValue(q=whereZero(x[0]))
536 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 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 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 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 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 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 msk+=whereZero(x[i])
626 #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 class Test_LinearPDE_noLumping(Test_linearPDEs):
642 N=4
643 def test_SolverOptions(self):
644 so=SolverOptions()
645
646 self.failUnless(so.getLevelMax() == 10, "initial LevelMax is wrong.")
647 self.failUnlessRaises(ValueError,so.setLevelMax,-1)
648 so.setLevelMax(3)
649 self.failUnless(so.getLevelMax() == 3, "LevelMax is wrong.")
650
651 self.failUnless(so.getCoarseningThreshold() == 0.05, "initial CoarseningThreshold is wrong.")
652 self.failUnlessRaises(ValueError,so.setCoarseningThreshold,-1)
653 so.setCoarseningThreshold(0.1)
654 self.failUnless(so.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")
655
656 self.failUnless(so.getMinCoarseMatrixSize() == 500, "initial Minimum Coarse Matrix Size is wrong.")
657 self.failUnlessRaises(ValueError,so.setMinCoarseMatrixSize,-1)
658 so.setMinCoarseMatrixSize(1000)
659 self.failUnless(so.getMinCoarseMatrixSize() == 1000, "Minimum Coarse Matrix Size is wrong.")
660
661 self.failUnless(so.getNumSweeps() == 2, "initial Sweeps is wrong.")
662 self.failUnlessRaises(ValueError,so.setNumSweeps,-1)
663 so.setNumSweeps(3)
664 self.failUnless(so.getNumSweeps() == 3, "Sweeps is wrong.")
665
666 self.failUnless(so.getNumPreSweeps() == 2, "initial PreSweeps is wrong.")
667 self.failUnlessRaises(ValueError,so.setNumPreSweeps,-1)
668 so.setNumPreSweeps(4)
669 self.failUnless(so.getNumPreSweeps() == 4, "PreSweeps is wrong.")
670
671 self.failUnless(so.getNumPostSweeps() == 2, "initial PreSweeps is wrong.")
672 self.failUnlessRaises(ValueError,so.setNumPostSweeps,-1)
673 so.setNumPostSweeps(5)
674 self.failUnless(so.getNumPostSweeps() == 5, "PreSweeps is wrong.")
675
676 self.failUnless(so.getTolerance() == 1.e-8, "initial Tolerance is wrong.")
677 self.failUnlessRaises(ValueError,so.setTolerance,-1)
678 so.setTolerance(0.2)
679 self.failUnless(so.getTolerance() == 0.2, "Tolerance is wrong.")
680
681 self.failUnless(so.getAbsoluteTolerance() == 0., "initial AbsoluteTolerance is wrong.")
682 self.failUnlessRaises(ValueError,so.setAbsoluteTolerance,-1)
683 so.setAbsoluteTolerance(0.3)
684 self.failUnless(so.getAbsoluteTolerance() == 0.3, "AbsoluteTolerance is wrong.")
685
686 self.failUnless(so.getInnerTolerance() == 0.9, "initial InnerTolerance is wrong.")
687 self.failUnlessRaises(ValueError,so.setInnerTolerance,-1)
688 so.setInnerTolerance(0.4)
689 self.failUnless(so.getInnerTolerance() == 0.4, "InnerTolerance is wrong.")
690
691 self.failUnless(so.getDropTolerance() == 0.01, "initial DropTolerance is wrong.")
692 self.failUnlessRaises(ValueError,so.setDropTolerance,-1)
693 so.setDropTolerance(0.5)
694 self.failUnless(so.getDropTolerance() == 0.5, "DropDropTolerance is wrong.")
695
696 self.failUnless(so.getDropStorage() == 2., "initial DropStorage is wrong.")
697 self.failUnlessRaises(ValueError,so.setDropStorage,-1)
698 so.setDropStorage(10)
699 self.failUnless(so.getDropStorage() == 10, "DropStorage is wrong.")
700
701 self.failUnless(so.getRelaxationFactor() == 0.3, "initial RelaxationFactor is wrong.")
702 self.failUnlessRaises(ValueError,so.setRelaxationFactor,-1)
703 so.setRelaxationFactor(0.1)
704 self.failUnless(so.getRelaxationFactor() == 0.1, "Relaxation is wrong.")
705
706
707 self.failUnless(so.getIterMax() == 100000, "initial IterMax is wrong.")
708 self.failUnlessRaises(ValueError,so.setIterMax,0)
709 so.setIterMax(11)
710 self.failUnless(so.getIterMax() == 11, "IterMax is wrong.")
711
712 self.failUnless(so.getInnerIterMax() == 10, "initial InnerIterMax is wrong.")
713 self.failUnlessRaises(ValueError,so.setInnerIterMax,0)
714 so.setInnerIterMax(12)
715 self.failUnless(so.getInnerIterMax() == 12, "InnerIterMax is wrong.")
716
717 self.failUnless(so.getTruncation() == 20, "initial Truncation is wrong.")
718 self.failUnlessRaises(ValueError,so.setTruncation,0)
719 so.setTruncation(13)
720 self.failUnless(so.getTruncation() == 13, "Truncation is wrong.")
721
722 self.failUnless(so.getRestart() == None, "initial Truncation is wrong.")
723 self.failUnlessRaises(ValueError,so.setTruncation,0)
724 so.setRestart(14)
725 self.failUnless(so.getRestart() == 14, "Truncation is wrong.")
726 so.setRestart(None)
727 self.failUnless(so.getRestart() == None, "Truncation is wrong.")
728
729 self.failUnless(not so.isVerbose(), "initial verbosity flag is wrong.")
730 so.setVerbosityOn()
731 self.failUnless(so.isVerbose(), "verbosity (1) flag is wrong.")
732 so.setVerbosityOff()
733 self.failUnless(not so.isVerbose(), "verbosity (2) flag is wrong.")
734 so.setVerbosity(verbose=True)
735 self.failUnless(so.isVerbose(), "verbosity (3) flag is wrong.")
736 so.setVerbosity(verbose=False)
737 self.failUnless(not so.isVerbose(), "verbosity (4) flag is wrong.")
738
739 self.failUnless(not so.isSymmetric(), "initial symmetry flag is wrong.")
740 so.setSymmetryOn()
741 self.failUnless(so.isSymmetric(), "symmetry (1) flag is wrong.")
742 so.setSymmetryOff()
743 self.failUnless(not so.isSymmetric(), "symmetry (2) flag is wrong.")
744 so.setSymmetry(flag=True)
745 self.failUnless(so.isSymmetric(), "symmetry (3) flag is wrong.")
746 so.setSymmetry(flag=False)
747 self.failUnless(not so.isSymmetric(), "symmetry (4) flag is wrong.")
748
749 self.failUnless(so.adaptInnerTolerance(), "initial InnerToleranceAdaption flag is wrong.")
750 so.setInnerToleranceAdaptionOn()
751 self.failUnless(so.adaptInnerTolerance(), "InnerToleranceAdaption (1) flag is wrong.")
752 so.setInnerToleranceAdaptionOff()
753 self.failUnless(not so.adaptInnerTolerance(), "InnerToleranceAdaption (2) flag is wrong.")
754 so.setInnerToleranceAdaption(adapt=True)
755 self.failUnless(so.adaptInnerTolerance(), "InnerToleranceAdaption (3) flag is wrong.")
756 so.setInnerToleranceAdaption(adapt=False)
757 self.failUnless(not so.adaptInnerTolerance(), "InnerToleranceAdaption (4) flag is wrong.")
758
759 self.failUnless(not so.acceptConvergenceFailure(), "initial acceptConvergenceFailure flag is wrong.")
760 so.setAcceptanceConvergenceFailureOn()
761 self.failUnless(so.acceptConvergenceFailure(), "acceptConvergenceFailure (1) flag is wrong.")
762 so.setAcceptanceConvergenceFailureOff()
763 self.failUnless(not so.acceptConvergenceFailure(), "acceptConvergenceFailure (2) flag is wrong.")
764 so.setAcceptanceConvergenceFailure(accept=True)
765 self.failUnless(so.acceptConvergenceFailure(), "acceptConvergenceFailure (3) flag is wrong.")
766 so.setAcceptanceConvergenceFailure(accept=False)
767 self.failUnless(not so.acceptConvergenceFailure(), "acceptConvergenceFailure (4) flag is wrong.")
768
769 self.failUnless(so.getReordering() == 30, "initial Reordering is wrong.")
770 self.failUnlessRaises(ValueError,so.setReordering,-1)
771 so.setReordering(so.NO_REORDERING)
772 self.failUnless(so.getReordering() == 17, "NO_REORDERING is not set.")
773 so.setReordering(so.MINIMUM_FILL_IN)
774 self.failUnless(so.getReordering() == 18, "MINIMUM_FILL_IN is not set.")
775 so.setReordering(so.NESTED_DISSECTION)
776 self.failUnless(so.getReordering() == 19, "NESTED_DISSECTION is not set.")
777 so.setReordering(so.DEFAULT_REORDERING)
778 self.failUnless(so.getReordering() == 30, "DEFAULT_REORDERING is not set.")
779
780 self.failUnless(so.getPackage() == 0, "initial solver package is wrong.")
781 self.failUnlessRaises(ValueError,so.setPackage,-1)
782 so.setPackage(so.PASO)
783 self.failUnless(so.getPackage() == 21, "PASO is not set.")
784 so.setPackage(so.SUPER_LU)
785 self.failUnless(so.getPackage() == 31, "SUPER_LU is not set.")
786 so.setPackage(so.PASTIX)
787 self.failUnless(so.getPackage() == 32, "PASTIX is not set.")
788 so.setPackage(so.MKL)
789 self.failUnless(so.getPackage() == 15, "MKL is not set.")
790 so.setPackage(so.UMFPACK)
791 self.failUnless(so.getPackage() == 16, "UMFPACK is not set.")
792 so.setPackage(so.TRILINOS)
793 self.failUnless(so.getPackage() == 24, "TRILINOS is not set.")
794
795 self.failUnless(so.getSolverMethod() == 0, "initial SolverMethod is wrong.")
796 self.failUnlessRaises(ValueError,so.setSolverMethod,-1)
797 so.setSolverMethod(so.DIRECT)
798 self.failUnless(so.getSolverMethod() == 1, "DIRECT is not set.")
799 so.setSolverMethod(so.CHOLEVSKY)
800 self.failUnless(so.getSolverMethod() == 2, "CHOLEVSKY is not set.")
801 so.setSolverMethod(so.PCG)
802 self.failUnless(so.getSolverMethod() == 3, "PCG is not set.")
803 so.setSolverMethod(so.CR)
804 self.failUnless(so.getSolverMethod() == 4, "CR is not set.")
805 so.setSolverMethod(so.CGS)
806 self.failUnless(so.getSolverMethod() == 5, "CGS is not set.")
807 so.setSolverMethod(so.BICGSTAB)
808 self.failUnless(so.getSolverMethod() == 6, "BICGSTAB is not set.")
809 so.setSolverMethod(so.SSOR)
810 self.failUnless(so.getSolverMethod() == 7, "SSOR is not set.")
811 so.setSolverMethod(so.GMRES)
812 self.failUnless(so.getSolverMethod() == 11, "GMRES is not set.")
813 so.setSolverMethod(so.PRES20)
814 self.failUnless(so.getSolverMethod() == 12, "PRES20 is not set.")
815 so.setSolverMethod(so.LUMPING)
816 self.failUnless(so.getSolverMethod() == 13, "LUMPING is not set.")
817 so.setSolverMethod(so.ITERATIVE)
818 self.failUnless(so.getSolverMethod() == 20, "ITERATIVE is not set.")
819 so.setSolverMethod(so.AMG)
820 self.failUnless(so.getSolverMethod() == 22, "AMG is not set.")
821 so.setSolverMethod(so.NONLINEAR_GMRES)
822 self.failUnless(so.getSolverMethod() == 25, "NONLINEAR_GMRES is not set.")
823 so.setSolverMethod(so.TFQMR)
824 self.failUnless(so.getSolverMethod() == 26, "TFQMR is not set.")
825 so.setSolverMethod(so.MINRES)
826 self.failUnless(so.getSolverMethod() == 27, "MINRES is not set.")
827 so.setSolverMethod(so.GAUSS_SEIDEL)
828 self.failUnless(so.getSolverMethod() == 28, "GAUSS_SEIDEL is not set.")
829 so.setSolverMethod(so.DEFAULT)
830 self.failUnless(so.getSolverMethod() == 0, "DEFAULT is not set.")
831
832 self.failUnless(so.getPreconditioner() == 10, "initial Preconditioner is wrong.")
833 self.failUnlessRaises(ValueError,so.setPreconditioner,-1)
834 so.setPreconditioner(so.ILU0)
835 self.failUnless(so.getPreconditioner() == 8, "ILU0 is not set.")
836 so.setPreconditioner(so.SSOR)
837 self.failUnless(so.getPreconditioner() == 7, "SSOR is not set.")
838 so.setPreconditioner(so.ILUT)
839 self.failUnless(so.getPreconditioner() == 9, "ILUT is not set.")
840 so.setPreconditioner(so.JACOBI)
841 self.failUnless(so.getPreconditioner() == 10, "JACOBI is not set.")
842 so.setPreconditioner(so.AMG)
843 self.failUnless(so.getPreconditioner() == 22, "AMG is not set.")
844 so.setPreconditioner(so.REC_ILU)
845 self.failUnless(so.getPreconditioner() == 23, "REC_ILU is not set.")
846 so.setPreconditioner(so.GAUSS_SEIDEL)
847 self.failUnless(so.getPreconditioner() == 28, "GAUSS_SEIDEL is not set.")
848 so.setPreconditioner(so.RILU)
849 self.failUnless(so.getPreconditioner() == 29, "RILU is not set.")
850 so.setPreconditioner(so.NO_PRECONDITIONER)
851 self.failUnless(so.getPreconditioner() == 36, "NO_PRECONDITIONER is not set.")
852
853 self.failUnless(so.getCoarsening() == 0, "initial Coarseningr is wrong.")
854 self.failUnlessRaises(ValueError,so.setCoarsening,-1)
855 so.setCoarsening(so.YAIR_SHAPIRA_COARSENING)
856 self.failUnless(so.getCoarsening() == 33, "YAIR_SHAPIRA_COARSENING is not set.")
857 so.setCoarsening(so.RUGE_STUEBEN_COARSENING)
858 self.failUnless(so.getCoarsening() == 34, "RUGE_STUEBEN_COARSENING is not set.")
859 so.setCoarsening(so.AGGREGATION_COARSENING)
860 self.failUnless(so.getCoarsening() == 35, "AGREGATION_COARSENING is not set.")
861 so.setCoarsening(so.DEFAULT)
862 self.failUnless(so.getCoarsening() == 0, "DEFAULT is not set.")
863
864 self.failUnless(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")
865 self.failUnless(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")
866 self.failUnless(so.getDiagnostics("time") == None, "initial time is wrong.")
867 self.failUnless(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")
868 self.failUnless(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")
869 self.failUnless(so.getDiagnostics("converged") == None, "initial converged is wrong.")
870 self.failUnless(so.hasConverged() == None, "initial convergence flag is wrong.")
871 self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")
872 self.failUnless(so.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")
873 self.failUnless(so.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")
874 self.failUnless(so.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")
875
876 so._updateDiagnostics("num_iter",1)
877 so._updateDiagnostics("num_inner_iter",2)
878 so._updateDiagnostics("time",3)
879 so._updateDiagnostics("set_up_time",4)
880 so._updateDiagnostics("residual_norm",5)
881 so._updateDiagnostics("converged",True)
882
883 self.failUnless(so.getDiagnostics("num_iter") == 1, "num_iter is wrong.")
884 self.failUnless(so.getDiagnostics("num_inner_iter") == 2, "num_inner_iter is wrong.")
885 self.failUnless(so.getDiagnostics("time") == 3, "time is wrong.")
886 self.failUnless(so.getDiagnostics("set_up_time") == 4, "set_up_time is wrong.")
887 self.failUnless(so.getDiagnostics("residual_norm") == 5, "residual_norm is wrong.")
888 self.failUnless(so.getDiagnostics("converged"), "converged is wrong.")
889 self.failUnless(so.hasConverged(), "convergence flag is wrong.")
890 self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")
891 self.failUnless(so.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")
892 self.failUnless(so.getDiagnostics("cum_time") ==3, "cum_time is wrong.")
893 self.failUnless(so.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")
894
895 so.resetDiagnostics()
896 self.failUnless(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")
897 self.failUnless(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")
898 self.failUnless(so.getDiagnostics("time") == None, "initial time is wrong.")
899 self.failUnless(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")
900 self.failUnless(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")
901 self.failUnless(so.getDiagnostics("converged") == None, "initial converged is wrong.")
902 self.failUnless(so.hasConverged() == None, "initial convergence flag is wrong")
903 self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")
904 self.failUnless(so.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")
905 self.failUnless(so.getDiagnostics("cum_time") ==3, "cum_time is wrong.")
906 self.failUnless(so.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")
907
908 so._updateDiagnostics("num_iter",10)
909 so._updateDiagnostics("num_inner_iter",20)
910 so._updateDiagnostics("time",30)
911 so._updateDiagnostics("set_up_time",40)
912 so._updateDiagnostics("residual_norm",50)
913 so._updateDiagnostics("converged",False)
914
915 self.failUnless(so.getDiagnostics("num_iter") == 10, "num_iter is wrong.")
916 self.failUnless(so.getDiagnostics("num_inner_iter") == 20, "num_inner_iter is wrong.")
917 self.failUnless(so.getDiagnostics("time") == 30, "time is wrong.")
918 self.failUnless(so.getDiagnostics("set_up_time") == 40, "set_up_time is wrong.")
919 self.failUnless(so.getDiagnostics("residual_norm") == 50, "residual_norm is wrong.")
920 self.failUnless(not so.getDiagnostics("converged"), "converged is wrong.")
921 self.failUnless(not so.hasConverged(), "convergence flag is wrong.")
922 self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 22, "cum_num_inner_iter is wrong.")
923 self.failUnless(so.getDiagnostics("cum_num_iter") == 11, "cum_num_iter is wrong.")
924 self.failUnless(so.getDiagnostics("cum_time") ==33, "cum_time is wrong.")
925 self.failUnless(so.getDiagnostics("cum_set_up_time") == 44, "cum_set_up_time is wrong.")
926
927 so.resetDiagnostics(all=True)
928 self.failUnless(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")
929 self.failUnless(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")
930 self.failUnless(so.getDiagnostics("time") == None, "initial time is wrong.")
931 self.failUnless(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")
932 self.failUnless(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")
933 self.failUnless(so.getDiagnostics("converged") == None, "initial converged is wrong.")
934 self.failUnless(so.hasConverged() == None, "initial convergence flag is wrong.")
935 self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")
936 self.failUnless(so.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")
937 self.failUnless(so.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")
938 self.failUnless(so.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")
939
940 def test_setCoefficient_WithIllegalFunctionSpace(self):
941 mypde=LinearPDE(self.domain,debug=self.DEBUG)
942 self.failUnlessRaises(IllegalCoefficientFunctionSpace, mypde.setValue, C=Vector(0.,FunctionOnBoundary(self.domain)))
943
944 def test_setCoefficient_WithWrongName(self):
945 mypde=LinearPDE(self.domain,debug=self.DEBUG)
946 self.failUnlessRaises(IllegalCoefficient, mypde.setValue, ROMA=0.)
947
948 def test_resetCoefficient_WithWrongShape(self):
949 mypde=LinearPDE(self.domain,numEquations=2,debug=self.DEBUG)
950 self.failUnlessRaises(IllegalCoefficientValue, mypde.setValue, C=0.)
951
952 def test_reducedOn(self):
953 mypde=LinearPDE(self.domain,debug=self.DEBUG)
954 x=self.domain.getX()
955 mypde.setReducedOrderOn()
956 mypde.setValue(A=kronecker(self.domain),D=x[0],Y=x[0])
957 u=mypde.getSolution()
958 self.failUnless(self.check(u,1.),'solution is wrong.')
959
960 def test_attemptToChangeOrderAfterDefinedCoefficient(self):
961 mypde=LinearPDE(self.domain,debug=self.DEBUG)
962 mypde.setValue(D=1.)
963 self.failUnlessRaises(RuntimeError, mypde.setReducedOrderOn)
964
965 def test_reducedOnConfig(self):
966 mypde=LinearPDE(self.domain,debug=self.DEBUG)
967 mypde.setReducedOrderOn()
968 self.failUnlessEqual((mypde.getFunctionSpaceForSolution(), mypde.getFunctionSpaceForEquation()),(ReducedSolution(self.domain),ReducedSolution(self.domain)),"reduced function spaces expected.")
969 #
970 # set coefficients for scalars:
971 #
972 def test_setCoefficient_A_Scalar(self):
973 d=self.domain.getDim()
974 mypde=LinearPDE(self.domain,debug=self.DEBUG)
975 mypde.setValue(A=numpy.ones((d,d)))
976 coeff=mypde.getCoefficient("A")
977 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),Function(self.domain),1,1))
978 def test_setCoefficient_B_Scalar(self):
979 d=self.domain.getDim()
980 mypde=LinearPDE(self.domain,debug=self.DEBUG)
981 mypde.setValue(B=numpy.ones((d,)))
982 coeff=mypde.getCoefficient("B")
983 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),Function(self.domain),1,1))
984 def test_setCoefficient_C_Scalar(self):
985 d=self.domain.getDim()
986 mypde=LinearPDE(self.domain,debug=self.DEBUG)
987 mypde.setValue(C=numpy.ones((d,)))
988 coeff=mypde.getCoefficient("C")
989 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),Function(self.domain),1,1))
990 def test_setCoefficient_D_Scalar(self):
991 d=self.domain.getDim()
992 mypde=LinearPDE(self.domain,debug=self.DEBUG)
993 mypde.setValue(D=1.)
994 coeff=mypde.getCoefficient("D")
995 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),Function(self.domain),1,1))
996 def test_setCoefficient_X_Scalar(self):
997 d=self.domain.getDim()
998 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
999 mypde.setValue(X=numpy.ones((d,)))
1000 coeff=mypde.getCoefficient("X")
1001 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),Function(self.domain),1))
1002 def test_setCoefficient_Y_Scalar(self):
1003 d=self.domain.getDim()
1004 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1005 mypde.setValue(Y=1.)
1006 coeff=mypde.getCoefficient("Y")
1007 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),Function(self.domain),1))
1008 def test_setCoefficient_y_Scalar(self):
1009 d=self.domain.getDim()
1010 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1011 mypde.setValue(y=1.)
1012 coeff=mypde.getCoefficient("y")
1013 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1))
1014 def test_setCoefficient_d_Scalar(self):
1015 d=self.domain.getDim()
1016 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1017 mypde.setValue(d=1.)
1018 coeff=mypde.getCoefficient("d")
1019 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1))
1020 def test_setCoefficient_d_contact_Scalar(self):
1021 d=self.domain.getDim()
1022 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1023 mypde.setValue(d_contact=1.)
1024 coeff=mypde.getCoefficient("d_contact")
1025 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1,1))
1026 def test_setCoefficient_y_contact_Scalar(self):
1027 d=self.domain.getDim()
1028 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1029 mypde.setValue(y_contact=1.)
1030 coeff=mypde.getCoefficient("y_contact")
1031 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))
1032 def test_setCoefficient_A_reduced_Scalar(self):
1033 d=self.domain.getDim()
1034 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1035 mypde.setValue(A_reduced=numpy.ones((d,d)))
1036 coeff=mypde.getCoefficient("A_reduced")
1037 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
1038 def test_setCoefficient_B_reduced_Scalar(self):
1039 d=self.domain.getDim()
1040 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1041 mypde.setValue(B_reduced=numpy.ones((d,)))
1042 coeff=mypde.getCoefficient("B_reduced")
1043 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1044 def test_setCoefficient_C_reduced_Scalar(self):
1045 d=self.domain.getDim()
1046 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1047 mypde.setValue(C_reduced=numpy.ones((d,)))
1048 coeff=mypde.getCoefficient("C_reduced")
1049 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1050 def test_setCoefficient_D_reduced_Scalar(self):
1051 d=self.domain.getDim()
1052 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1053 mypde.setValue(D_reduced=1.)
1054 coeff=mypde.getCoefficient("D_reduced")
1055 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
1056 def test_setCoefficient_X_reduced_Scalar(self):
1057 d=self.domain.getDim()
1058 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1059 mypde.setValue(X_reduced=numpy.ones((d,)))
1060 coeff=mypde.getCoefficient("X_reduced")
1061 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
1062 def test_setCoefficient_Y_reduced_Scalar(self):
1063 d=self.domain.getDim()
1064 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1065 mypde.setValue(Y_reduced=1.)
1066 coeff=mypde.getCoefficient("Y_reduced")
1067 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
1068 def test_setCoefficient_y_reduced_Scalar(self):
1069 d=self.domain.getDim()
1070 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1071 mypde.setValue(y_reduced=1.)
1072 coeff=mypde.getCoefficient("y_reduced")
1073 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
1074 def test_setCoefficient_d_reduced_Scalar(self):
1075 d=self.domain.getDim()
1076 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1077 mypde.setValue(d_reduced=1.)
1078 coeff=mypde.getCoefficient("d_reduced")
1079 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
1080 def test_setCoefficient_d_contact_reduced_Scalar(self):
1081 d=self.domain.getDim()
1082 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1083 mypde.setValue(d_contact_reduced=1.)
1084 coeff=mypde.getCoefficient("d_contact_reduced")
1085 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
1086 def test_setCoefficient_y_contact_reduced_Scalar(self):
1087 d=self.domain.getDim()
1088 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1089 mypde.setValue(y_contact_reduced=1.)
1090 coeff=mypde.getCoefficient("y_contact_reduced")
1091 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
1092 def test_setCoefficient_r_Scalar(self):
1093 d=self.domain.getDim()
1094 mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1095 mypde.setValue(r=1.)
1096 coeff=mypde.getCoefficient("r")
1097 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),Solution(self.domain),1))
1098 def test_setCoefficient_q_Scalar(self):
1099 d=self.domain.getDim()
1100 mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1101 mypde.setValue(q=1.)
1102 coeff=mypde.getCoefficient("q")
1103 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),Solution(self.domain),1))
1104 def test_setCoefficient_r_Scalar_reducedOn(self):
1105 d=self.domain.getDim()
1106 mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1107 mypde.setReducedOrderOn()
1108 mypde.setValue(r=1.)
1109 coeff=mypde.getCoefficient("r")
1110 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
1111 def test_setCoefficient_q_Scalar_reducedOn(self):
1112 d=self.domain.getDim()
1113 mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1114 mypde.setReducedOrderOn()
1115 mypde.setValue(q=1.)
1116 coeff=mypde.getCoefficient("q")
1117 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
1118
1119 def test_setCoefficient_A_reduced_Scalar_usingA(self):
1120 d=self.domain.getDim()
1121 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1122 mypde.setValue(A=Data(numpy.ones((d,d)),ReducedFunction(self.domain)))
1123 coeff=mypde.getCoefficient("A_reduced")
1124 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
1125 def test_setCoefficient_B_reduced_Scalar_usingB(self):
1126 d=self.domain.getDim()
1127 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1128 mypde.setValue(B=Data(numpy.ones((d,)),ReducedFunction(self.domain)))
1129 coeff=mypde.getCoefficient("B_reduced")
1130 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1131 def test_setCoefficient_C_reduced_Scalar_usingC(self):
1132 d=self.domain.getDim()
1133 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1134 mypde.setValue(C=Data(numpy.ones((d,)),ReducedFunction(self.domain)))
1135 coeff=mypde.getCoefficient("C_reduced")
1136 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1137 def test_setCoefficient_D_reduced_Scalar_usingD(self):
1138 d=self.domain.getDim()
1139 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1140 mypde.setValue(D=Scalar(1.,ReducedFunction(self.domain)))
1141 coeff=mypde.getCoefficient("D_reduced")
1142 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
1143 def test_setCoefficient_X_reduced_Scalar_usingX(self):
1144 d=self.domain.getDim()
1145 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1146 mypde.setValue(X_reduced=Data(numpy.ones((d,)),ReducedFunction(self.domain)))
1147 coeff=mypde.getCoefficient("X_reduced")
1148 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
1149 def test_setCoefficient_Y_reduced_Scalar_usingY(self):
1150 d=self.domain.getDim()
1151 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1152 mypde.setValue(Y=Scalar(1.,ReducedFunction(self.domain)))
1153 coeff=mypde.getCoefficient("Y_reduced")
1154 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
1155 def test_setCoefficient_y_reduced_Scalar_using_y(self):
1156 d=self.domain.getDim()
1157 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1158 mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
1159 coeff=mypde.getCoefficient("y_reduced")
1160 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
1161 def test_setCoefficient_d_reduced_Scalar_using_d(self):
1162 d=self.domain.getDim()
1163 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1164 mypde.setValue(d=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
1165 coeff=mypde.getCoefficient("d_reduced")
1166 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
1167 def test_setCoefficient_d_contact_reduced_Scalar_using_d_contact(self):
1168 d=self.domain.getDim()
1169 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1170 mypde.setValue(d_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
1171 coeff=mypde.getCoefficient("d_contact_reduced")
1172 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
1173 def test_setCoefficient_y_contact_reduced_Scalar_using_y_contact(self):
1174 d=self.domain.getDim()
1175 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1176 mypde.setValue(y_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
1177 coeff=mypde.getCoefficient("y_contact_reduced")
1178 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
1179 #
1180 # set coefficients for systems:
1181 #
1182 def test_setCoefficient_A_System(self):
1183 d=self.domain.getDim()
1184 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1185 mypde.setValue(A=numpy.ones((self.N,d,self.N,d)))
1186 coeff=mypde.getCoefficient("A")
1187 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),Function(self.domain),self.N,self.N))
1188 def test_setCoefficient_B_System(self):
1189 d=self.domain.getDim()
1190 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1191 mypde.setValue(B=numpy.ones((self.N,d,self.N)))
1192 coeff=mypde.getCoefficient("B")
1193 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),Function(self.domain),self.N,self.N))
1194 def test_setCoefficient_C_System(self):
1195 d=self.domain.getDim()
1196 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1197 mypde.setValue(C=numpy.ones((self.N,self.N,d)))
1198 coeff=mypde.getCoefficient("C")
1199 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),Function(self.domain),self.N,self.N))
1200 def test_setCoefficient_D_System(self):
1201 d=self.domain.getDim()
1202 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1203 mypde.setValue(D=numpy.ones((self.N,self.N)))
1204 coeff=mypde.getCoefficient("D")
1205 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),Function(self.domain),self.N,self.N))
1206 def test_setCoefficient_X_System(self):
1207 d=self.domain.getDim()
1208 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1209 mypde.setValue(X=numpy.ones((self.N,d)))
1210 coeff=mypde.getCoefficient("X")
1211 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),Function(self.domain),self.N))
1212 def test_setCoefficient_Y_System(self):
1213 d=self.domain.getDim()
1214 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1215 mypde.setValue(Y=numpy.ones((self.N,)))
1216 coeff=mypde.getCoefficient("Y")
1217 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),Function(self.domain),self.N))
1218 def test_setCoefficient_y_System(self):
1219 d=self.domain.getDim()
1220 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1221 mypde.setValue(y=numpy.ones((self.N,)))
1222 coeff=mypde.getCoefficient("y")
1223 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),FunctionOnBoundary(self.domain),self.N))
1224 def test_setCoefficient_d_System(self):
1225 d=self.domain.getDim()
1226 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1227 mypde.setValue(d=numpy.ones((self.N,self.N)))
1228 coeff=mypde.getCoefficient("d")
1229 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),FunctionOnBoundary(self.domain),self.N,self.N))
1230 def test_setCoefficient_d_contact_System(self):
1231 d=self.domain.getDim()
1232 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1233 mypde.setValue(d_contact=numpy.ones((self.N,self.N)))
1234 coeff=mypde.getCoefficient("d_contact")
1235 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),FunctionOnContactZero(self.domain),self.N,self.N))
1236 def test_setCoefficient_y_contact_System(self):
1237 d=self.domain.getDim()
1238 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1239 mypde.setValue(y_contact=numpy.ones((self.N,)))
1240 coeff=mypde.getCoefficient("y_contact")
1241 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N))
1242 def test_setCoefficient_A_reduced_System(self):
1243 d=self.domain.getDim()
1244 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1245 mypde.setValue(A_reduced=numpy.ones((self.N,d,self.N,d)))
1246 coeff=mypde.getCoefficient("A_reduced")
1247 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1248 def test_setCoefficient_B_reduced_System(self):
1249 d=self.domain.getDim()
1250 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1251 mypde.setValue(B_reduced=numpy.ones((self.N,d,self.N)))
1252 coeff=mypde.getCoefficient("B_reduced")
1253 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
1254 def test_setCoefficient_C_reduced_System(self):
1255 d=self.domain.getDim()
1256 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1257 mypde.setValue(C_reduced=numpy.ones((self.N,self.N,d)))
1258 coeff=mypde.getCoefficient("C_reduced")
1259 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1260 def test_setCoefficient_D_System_reduced(self):
1261 d=self.domain.getDim()
1262 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1263 mypde.setValue(D_reduced=numpy.ones((self.N,self.N)))
1264 coeff=mypde.getCoefficient("D_reduced")
1265 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
1266 def test_setCoefficient_X_System_reduced(self):
1267 d=self.domain.getDim()
1268 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1269 mypde.setValue(X_reduced=numpy.ones((self.N,d)))
1270 coeff=mypde.getCoefficient("X_reduced")
1271 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
1272 def test_setCoefficient_Y_System_reduced(self):
1273 d=self.domain.getDim()
1274 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1275 mypde.setValue(Y_reduced=numpy.ones((self.N,)))
1276 coeff=mypde.getCoefficient("Y_reduced")
1277 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
1278 def test_setCoefficient_y_System_reduced(self):
1279 d=self.domain.getDim()
1280 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1281 mypde.setValue(y_reduced=numpy.ones((self.N,)))
1282 coeff=mypde.getCoefficient("y_reduced")
1283 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
1284 def test_setCoefficient_d_reduced_System(self):
1285 d=self.domain.getDim()
1286 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1287 mypde.setValue(d_reduced=numpy.ones((self.N,self.N)))
1288 coeff=mypde.getCoefficient("d_reduced")
1289 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
1290 def test_setCoefficient_d_contact_reduced_System(self):
1291 d=self.domain.getDim()
1292 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1293 mypde.setValue(d_contact_reduced=numpy.ones((self.N,self.N)))
1294 coeff=mypde.getCoefficient("d_contact_reduced")
1295 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
1296 def test_setCoefficient_y_contact_reduced_System(self):
1297 d=self.domain.getDim()
1298 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1299 mypde.setValue(y_contact_reduced=numpy.ones((self.N,)))
1300 coeff=mypde.getCoefficient("y_contact_reduced")
1301 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
1302 def test_setCoefficient_r_System(self):
1303 d=self.domain.getDim()
1304 mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1305 mypde.setValue(r=numpy.ones((self.N,)))
1306 coeff=mypde.getCoefficient("r")
1307 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
1308 def test_setCoefficient_q_System(self):
1309 d=self.domain.getDim()
1310 mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1311 mypde.setValue(q=numpy.ones((self.N,)))
1312 coeff=mypde.getCoefficient("q")
1313 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
1314 def test_setCoefficient_r_System_reducedOn(self):
1315 d=self.domain.getDim()
1316 mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1317 mypde.setReducedOrderOn()
1318 mypde.setValue(r=numpy.ones((self.N,)))
1319 coeff=mypde.getCoefficient("r")
1320 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
1321 def test_setCoefficient_q_System_reducedOn(self):
1322 d=self.domain.getDim()
1323 mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1324 mypde.setReducedOrderOn()
1325 mypde.setValue(q=numpy.ones((self.N,)))
1326 coeff=mypde.getCoefficient("q")
1327 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
1328
1329 def test_setCoefficient_A_reduced_System_using_A(self):
1330 d=self.domain.getDim()
1331 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1332 mypde.setValue(A=Data(numpy.ones((self.N,d,self.N,d)),ReducedFunction(self.domain)))
1333 coeff=mypde.getCoefficient("A_reduced")
1334 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1335 def test_setCoefficient_B_reduced_System_using_B(self):
1336 d=self.domain.getDim()
1337 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1338 mypde.setValue(B=Data(numpy.ones((self.N,d,self.N)),ReducedFunction(self.domain)))
1339 coeff=mypde.getCoefficient("B_reduced")
1340 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
1341 def test_setCoefficient_C_reduced_System_using_C(self):
1342 d=self.domain.getDim()
1343 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1344 mypde.setValue(C=Data(numpy.ones((self.N,self.N,d)),ReducedFunction(self.domain)))
1345 coeff=mypde.getCoefficient("C_reduced")
1346 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1347 def test_setCoefficient_D_System_reduced_using_D(self):
1348 d=self.domain.getDim()
1349 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1350 mypde.setValue(D=Data(numpy.ones((self.N,self.N)),ReducedFunction(self.domain)))
1351 coeff=mypde.getCoefficient("D_reduced")
1352 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
1353 def test_setCoefficient_X_System_reduced_using_X(self):
1354 d=self.domain.getDim()
1355 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1356 mypde.setValue(X=Data(numpy.ones((self.N,d)),ReducedFunction(self.domain)))
1357 coeff=mypde.getCoefficient("X_reduced")
1358 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
1359 def test_setCoefficient_Y_System_reduced_using_Y(self):
1360 d=self.domain.getDim()
1361 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1362 mypde.setValue(Y=Data(numpy.ones((self.N,)),ReducedFunction(self.domain)))
1363 coeff=mypde.getCoefficient("Y_reduced")
1364 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
1365 def test_setCoefficient_y_reduced_System_using_y(self):
1366 d=self.domain.getDim()
1367 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1368 mypde.setValue(y=Data(numpy.ones((self.N,)),ReducedFunctionOnBoundary(self.domain)))
1369 coeff=mypde.getCoefficient("y_reduced")
1370 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
1371 def test_setCoefficient_d_reduced_System_using_d(self):
1372 d=self.domain.getDim()
1373 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1374 mypde.setValue(d=Data(numpy.ones((self.N,self.N)),ReducedFunctionOnBoundary(self.domain)))
1375 coeff=mypde.getCoefficient("d_reduced")
1376 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
1377 def test_setCoefficient_d_contact_reduced_System_using_d_contact(self):
1378 d=self.domain.getDim()
1379 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1380 mypde.setValue(d_contact=Data(numpy.ones((self.N,self.N)),ReducedFunctionOnContactZero(self.domain)))
1381 coeff=mypde.getCoefficient("d_contact_reduced")
1382 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
1383 def test_setCoefficient_y_contact_reduced_System_using_y_contact(self):
1384 d=self.domain.getDim()
1385 mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1386 mypde.setValue(y_contact=Data(numpy.ones((self.N,)),ReducedFunctionOnContactZero(self.domain)))
1387 coeff=mypde.getCoefficient("y_contact_reduced")
1388 self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
1389 def test_resetCoefficient_HomogeneousConstraint(self):
1390 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1391 x=self.domain.getX()
1392 mypde.setValue(A=kronecker(self.domain),Y=1.,q=whereZero(x[0]))
1393 u1=mypde.getSolution()
1394 mypde.setValue(Y=2.)
1395 u2=mypde.getSolution()
1396 self.failUnless(self.check(u2,2*u1),'solution is wrong.')
1397
1398 def test_resetCoefficient_InHomogeneousConstraint(self):
1399 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1400 mypde.setSymmetryOn()
1401 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1402 x=self.domain.getX()
1403 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.,r=1,q=whereZero(x[0]))
1404 u1=mypde.getSolution()
1405 mypde.setValue(Y=2.,D=2)
1406 u2=mypde.getSolution()
1407 self.failUnless(self.check(u2,u1),'first solution is wrong.')
1408 u2=mypde.getSolution()
1409 self.failUnless(self.check(u2,u1),'first solution is wrong.')
1410 mypde.setValue(r=2,Y=4.)
1411 u2=mypde.getSolution()
1412 self.failUnless(self.check(u2,2*u1),'second solution is wrong.')
1413
1414 def test_Status(self):
1415 DIM=self.domain.getDim()
1416 x=self.domain.getX()
1417 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1418 mypde.getSolverOptions().setSymmetryOn()
1419 mypde.getSolverOptions().setTolerance(self.RES_TOL)
1420 mypde.setValue(A=kronecker(self.domain), q=whereZero(x[0])+whereZero(x[0]-1.), Y=2.)
1421 x1=self.domain.getX()
1422 u1_ref=x1[0]*(1.-x1[0])
1423 u1=mypde.getSolution()
1424 error1=Lsup(u1-u1_ref)/Lsup(u1_ref)
1425 self.failUnless(mypde.getDomainStatus() == mypde.getSystemStatus(), "status of first pde does not match domain status.")
1426
1427 self.domain.setX(x*5)
1428
1429 self.failUnless(mypde.getDomainStatus() != mypde.getSystemStatus(), "status of first pde matches updated domain status.")
1430 x2=self.domain.getX()
1431 u2_ref=x2[0]*(5.-x2[0])
1432 u2=mypde.getSolution()
1433 error2=Lsup(u2-u2_ref)/Lsup(u2_ref)
1434 self.failUnless(error2 <= max(error1,self.RES_TOL)*10., "solution of second PDE wrong.")
1435 self.failUnless(mypde.getDomainStatus() == mypde.getSystemStatus(), "status of second pde does not match domain status.")
1436
1437 def test_symmetryCheckTrue_System(self):
1438 d=self.domain.getDim()
1439 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1440 A=numpy.ones((self.N,d,self.N,d))
1441 C=2*numpy.ones((self.N,self.N,d))
1442 B=2*numpy.ones((self.N,d,self.N))
1443 D=3*numpy.ones((self.N,self.N))
1444 d=4*numpy.ones((self.N,self.N))
1445 d_contact=5*numpy.ones((self.N,self.N))
1446 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)
1447 self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
1448
1449 def test_symmetryCheckFalse_A_System(self):
1450 d=self.domain.getDim()
1451 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1452 A=numpy.ones((self.N,d,self.N,d))
1453 A[1,1,1,0]=0.
1454 mypde.setValue(A=A)
1455 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1456 def test_symmetryCheckFalse_BC_System(self):
1457 d=self.domain.getDim()
1458 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1459 C=2*numpy.ones((self.N,self.N,d))
1460 B=2*numpy.ones((self.N,d,self.N))
1461 B[0,0,1]=1.
1462 mypde.setValue(B=B,C=C)
1463 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1464
1465 def test_symmetryCheckFalse_D_System(self):
1466 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1467 D=3*numpy.ones((self.N,self.N))
1468 D[0,1]=0.
1469 mypde.setValue(D=D)
1470 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1471
1472 def test_symmetryCheckFalse_d_System(self):
1473 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1474 d=4*numpy.ones((self.N,self.N))
1475 d[0,1]=0.
1476 mypde.setValue(d=d)
1477 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1478
1479 def test_symmetryCheckFalse_d_contact_System(self):
1480 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1481 d_contact=5*numpy.ones((self.N,self.N))
1482 d_contact[0,1]=0.
1483 mypde.setValue(d_contact=d_contact)
1484 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1485
1486 def test_symmetryCheckFalse_A_reduced_System(self):
1487 d=self.domain.getDim()
1488 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1489 A=numpy.ones((self.N,d,self.N,d))
1490 A[1,1,1,0]=0.
1491 mypde.setValue(A_reduced=A)
1492 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1493 def test_symmetryCheckFalse_BC_reduced_System(self):
1494 d=self.domain.getDim()
1495 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1496 C=2*numpy.ones((self.N,self.N,d))
1497 B=2*numpy.ones((self.N,d,self.N))
1498 B[0,0,1]=1.
1499 mypde.setValue(B_reduced=B,C_reduced=C)
1500 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1501
1502 def test_symmetryCheckFalse_D_reduced_System(self):
1503 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1504 D=3*numpy.ones((self.N,self.N))
1505 D[0,1]=0.
1506 mypde.setValue(D_reduced=D)
1507 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1508
1509 def test_symmetryCheckFalse_d_reduced_System(self):
1510 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1511 d=4*numpy.ones((self.N,self.N))
1512 d[0,1]=0.
1513 mypde.setValue(d_reduced=d)
1514 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1515
1516 def test_symmetryCheckFalse_d_contact_reduced_System(self):
1517 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1518 d_contact=5*numpy.ones((self.N,self.N))
1519 d_contact[0,1]=0.
1520 mypde.setValue(d_contact_reduced=d_contact)
1521 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1522
1523 def test_symmetryCheckTrue_Scalar(self):
1524 d=self.domain.getDim()
1525 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1526 A=numpy.ones((d,d))
1527 C=2*numpy.ones((d,))
1528 B=2*numpy.ones((d,))
1529 D=3
1530 d=4
1531 d_contact=5
1532 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)
1533 self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
1534
1535 def test_symmetryCheckFalse_A_Scalar(self):
1536 d=self.domain.getDim()
1537 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1538 A=numpy.ones((d,d))
1539 A[1,0]=0.
1540 mypde.setValue(A=A)
1541 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1542 def test_symmetryCheckFalse_BC_Scalar(self):
1543 d=self.domain.getDim()
1544 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1545 C=2*numpy.ones((d,))
1546 B=2*numpy.ones((d,))
1547 B[0]=1.
1548 mypde.setValue(B=B,C=C)
1549 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1550 def test_symmetryCheckFalse_A_reduced_Scalar(self):
1551 d=self.domain.getDim()
1552 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1553 A=numpy.ones((d,d))
1554 A[1,0]=0.
1555 mypde.setValue(A_reduced=A)
1556 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1557 def test_symmetryCheckFalse_BC_reduced_Scalar(self):
1558 d=self.domain.getDim()
1559 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1560 C=2*numpy.ones((d,))
1561 B=2*numpy.ones((d,))
1562 B[0]=1.
1563 mypde.setValue(B_reduced=B,C_reduced=C)
1564 self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1565 #
1566 # solver checks (single PDE)
1567 #
1568 def test_symmetryOnIterative(self):
1569 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1570 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1571 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1572 u=mypde.getSolution()
1573 self.failUnless(self.check(u,1.),'solution is wrong.')
1574 def test_symmetryOnDirect(self):
1575 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1576 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1577 mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)
1578 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1579 u=mypde.getSolution()
1580 self.failUnless(self.check(u,1.),'solution is wrong.')
1581 def test_PCG_JACOBI(self):
1582 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1583 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1584 mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1585 mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1586 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1587 u=mypde.getSolution()
1588 self.failUnless(self.check(u,1.),'solution is wrong.')
1589 def test_PCG_ILU0(self):
1590 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1591 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1592 mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1593 mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1594 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1595 u=mypde.getSolution()
1596 self.failUnless(self.check(u,1.),'solution is wrong.')
1597 def test_PCG_RILU(self):
1598 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1599 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1600 mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1601 mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1602 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1603 u=mypde.getSolution()
1604 self.failUnless(self.check(u,1.),'solution is wrong.')
1605 def test_PCG_REC_ILU(self):
1606 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1607 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1608 mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1609 mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1610 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1611 u=mypde.getSolution()
1612 self.failUnless(self.check(u,1.),'solution is wrong.')
1613 def test_DIRECT(self):
1614 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1615 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1616 mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)
1617 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1618 u=mypde.getSolution()
1619 self.failUnless(self.check(u,1.),'solution is wrong.')
1620 def test_BICGSTAB_JACOBI(self):
1621 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1622 mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1623 mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1624 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1625 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1626 u=mypde.getSolution()
1627 self.failUnless(self.check(u,1.),'solution is wrong.')
1628 def test_BICGSTAB_ILU0(self):
1629 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1630 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1631 mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1632 mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1633 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1634 u=mypde.getSolution()
1635 self.failUnless(self.check(u,1.),'solution is wrong.')
1636 def test_BICGSTAB_RILU(self):
1637 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1638 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1639 mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1640 mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1641 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1642 u=mypde.getSolution()
1643 self.failUnless(self.check(u,1.),'solution is wrong.')
1644 def test_BICGSTAB_REC_ILU(self):
1645 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1646 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1647 mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1648 mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1649 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1650 u=mypde.getSolution()
1651 self.failUnless(self.check(u,1.),'solution is wrong.')
1652 def test_MINRES_JACOBI(self):
1653 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1654 mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1655 mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1656 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1657 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1658 u=mypde.getSolution()
1659 self.failUnless(self.check(u,1.),'solution is wrong.')
1660 def test_MINRES_ILU0(self):
1661 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1662 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1663 mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1664 mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1665 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1666 u=mypde.getSolution()
1667 self.failUnless(self.check(u,1.),'solution is wrong.')
1668 def test_MINRES_RILU(self):
1669 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1670 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1671 mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1672 mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1673 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1674 u=mypde.getSolution()
1675 self.failUnless(self.check(u,1.),'solution is wrong.')
1676 def test_MINRES_REC_ILU(self):
1677 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1678 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1679 mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1680 mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1681 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1682 u=mypde.getSolution()
1683 self.failUnless(self.check(u,1.),'solution is wrong.')
1684 def test_TFQMR_JACOBI(self):
1685 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1686 mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1687 mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1688 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1689 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1690 u=mypde.getSolution()
1691 self.failUnless(self.check(u,1.),'solution is wrong.')
1692 def test_TFQMR_ILU0(self):
1693 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1694 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1695 mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1696 mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1697 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1698 u=mypde.getSolution()
1699 self.failUnless(self.check(u,1.),'solution is wrong.')
1700 def test_TFQMR_RILU(self):
1701 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1702 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1703 mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1704 mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1705 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1706 u=mypde.getSolution()
1707 self.failUnless(self.check(u,1.),'solution is wrong.')
1708 def test_TFQMR_REC_ILU(self):
1709 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1710 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1711 mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1712 mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1713 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1714 u=mypde.getSolution()
1715 self.failUnless(self.check(u,1.),'solution is wrong.')
1716 def test_PRES20_JACOBI(self):
1717 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1718 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1719 mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1720 mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1721 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1722 u=mypde.getSolution()
1723 self.failUnless(self.check(u,1.),'solution is wrong.')
1724 def test_PRES20_ILU0(self):
1725 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1726 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1727 mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1728 mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1729 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1730 u=mypde.getSolution()
1731 self.failUnless(self.check(u,1.),'solution is wrong.')
1732 def test_PRES20_RILU(self):
1733 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1734 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1735 mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1736 mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1737 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1738 u=mypde.getSolution()
1739 self.failUnless(self.check(u,1.),'solution is wrong.')
1740 def test_PRES20_REC_ILU(self):
1741 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1742 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1743 mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1744 mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1745 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1746 u=mypde.getSolution()
1747 self.failUnless(self.check(u,1.),'solution is wrong.')
1748 def test_GMRESnoRestart_JACOBI(self):
1749 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1750 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1751 mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1752 mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1753 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1754 mypde.getSolverOptions().setTruncation(50)
1755 u=mypde.getSolution()
1756 self.failUnless(self.check(u,1.),'solution is wrong.')
1757 def test_GMRESnoRestart_ILU0(self):
1758 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1759 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1760 mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1761 mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1762 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1763 mypde.getSolverOptions().setTruncation(50)
1764 u=mypde.getSolution()
1765 self.failUnless(self.check(u,1.),'solution is wrong.')
1766 def test_GMRESnoRestart_RILU(self):
1767 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1768 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1769 mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1770 mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1771 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1772 mypde.getSolverOptions().setTruncation(50)
1773 u=mypde.getSolution()
1774 self.failUnless(self.check(u,1.),'solution is wrong.')
1775 def test_GMRESnoRestart_REC_ILU(self):
1776 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1777 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1778 mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1779 mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1780 mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1781 mypde.getSolverOptions().setTruncation(50)
1782 u=mypde.getSolution()
1783 self.failUnless(self.check(u,1.),'solution is wrong.')
1784 def test_GMRES_JACOBI(self):
1785 mypde=LinearPDE(self.domain,debug=self.DEBUG)
1786 mypde.setValue(A=kro