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