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