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

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

Parent Directory Parent Directory | Revision Log Revision Log


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