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