/[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 3906 - (hide annotations)
Thu Jun 7 11:00:50 2012 UTC (7 years, 3 months ago) by jfenwick
Original Path: trunk/escript/test/python/test_linearPDEs.py
File MIME type: text/x-python
File size: 197947 byte(s)
Disable AMG on MPI builds

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