/[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 6845 - (hide annotations)
Wed Jul 3 06:03:14 2019 UTC (3 months, 2 weeks ago) by aellery
File MIME type: text/x-python
File size: 196912 byte(s)
-Turned run_comm1.py back on
-Dudley can now read files using gmsh MSH4 format
-Activated a test in test_linearPDEs that was turned off.


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