/[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 1388 - (hide annotations)
Fri Jan 11 07:45:58 2008 UTC (11 years, 8 months ago) by trankine
Original Path: trunk/escript/test/python/test_linearPDEs.py
File MIME type: text/x-python
File size: 66751 byte(s)
And get the *(&(*&(* name right
1 ksteube 1312 #
2 jgs 149 # $Id$
3 ksteube 1312 #
4     #######################################################
5     #
6     # Copyright 2003-2007 by ACceSS MNRF
7     # Copyright 2007 by University of Queensland
8     #
9     # http://esscc.uq.edu.au
10     # Primary Business: Queensland, Australia
11     # Licensed under the Open Software License version 3.0
12     # http://www.opensource.org/licenses/osl-3.0.php
13     #
14     #######################################################
15     #
16 jgs 149
17     """
18     Test suite for linearPDEs class
19    
20     The tests must be linked with a Domain class object in the setUp method:
21    
22     from esys.finley import Rectangle
23     class Test_LinearPDEOnFinley(Test_LinearPDE):
24     def setUp(self):
25     self.domain = Rectangle(10,10,2)
26 gross 798 def tearDown(self):
27     del self.domain
28 jgs 149 suite = unittest.TestSuite()
29     suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley))
30     unittest.TextTestRunner(verbosity=2).run(suite)
31    
32 gross 637 @var __author__: name of author
33     @var __copyright__: copyrights
34     @var __license__: licence agreement
35     @var __url__: url entry point on documentation
36     @var __version__: version
37     @var __date__: date of the version
38 jgs 149 """
39    
40     __author__="Lutz Gross, l.gross@uq.edu.au"
41 elspeth 609 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
42     http://www.access.edu.au
43     Primary Business: Queensland, Australia"""
44 elspeth 614 __license__="""Licensed under the Open Software License version 3.0
45     http://www.opensource.org/licenses/osl-3.0.php"""
46 jgs 149 __url__="http://www.iservo.edu.au/esys/escript"
47     __version__="$Revision$"
48     __date__="$Date$"
49    
50    
51    
52 gross 304 from esys.escript.util import Lsup,kronecker,interpolate,whereZero
53 ksteube 1312 from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar, ReducedFunction,ReducedFunctionOnBoundary,ReducedFunctionOnContactZero,Data, Tensor4, Tensor
54 gross 1072 from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace
55 jgs 149 import numarray
56     import unittest
57    
58     class Test_linearPDEs(unittest.TestCase):
59     TOL=1.e-6
60 jgs 153 SOLVER_TOL=1.e-10
61 jgs 149 DEBUG=False
62     VERBOSE=False
63     def check(self,arg,ref_arg,tol=None):
64     """
65     checks if arg and ref_arg are nearly identical using the L{Lsup<esys.escript.util.Lsup>}
66     """
67     if tol==None: tol=self.TOL
68     return Lsup(arg-ref_arg)<=tol*Lsup(ref_arg)
69    
70     class Test_Poisson(Test_linearPDEs):
71    
72     def test_config(self):
73     mypde=Poisson(self.domain,debug=self.DEBUG)
74     self.failUnlessEqual((mypde.getNumEquations(),mypde.getNumSolutions(),mypde.isSymmetric()),(1,1,True),"set up incorrect")
75     def test_setCoefficient_q(self):
76     mypde=Poisson(self.domain,debug=self.DEBUG)
77     x=self.domain.getX()
78 gross 304 q_ref=interpolate(whereZero(x[0]),Solution(self.domain))
79 jgs 149 A_ref=kronecker(self.domain)
80 gross 304 mypde.setValue(q=whereZero(x[0]))
81 jgs 149 self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("A"),A_ref),"A is not kronecker")
82     self.failUnless(mypde.getCoefficientOfGeneralPDE("B").isEmpty(),"B is not empty")
83     self.failUnless(mypde.getCoefficientOfGeneralPDE("C").isEmpty(),"C is not empty")
84     self.failUnless(mypde.getCoefficientOfGeneralPDE("D").isEmpty(),"D is not empty")
85     self.failUnless(mypde.getCoefficientOfGeneralPDE("X").isEmpty(),"X is not empty")
86     self.failUnless(mypde.getCoefficientOfGeneralPDE("Y").isEmpty(),"Y is not empty")
87     self.failUnless(mypde.getCoefficientOfGeneralPDE("y").isEmpty(),"y is not empty")
88     self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")
89     self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")
90     self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")
91 gross 1072 self.failUnless(mypde.getCoefficientOfGeneralPDE("A_reduced").isEmpty(),"A_reduced is not empty")
92     self.failUnless(mypde.getCoefficientOfGeneralPDE("B_reduced").isEmpty(),"B_reduced is not empty")
93     self.failUnless(mypde.getCoefficientOfGeneralPDE("C_reduced").isEmpty(),"C_reduced is not empty")
94     self.failUnless(mypde.getCoefficientOfGeneralPDE("D_reduced").isEmpty(),"D_reduced is not empty")
95     self.failUnless(mypde.getCoefficientOfGeneralPDE("X_reduced").isEmpty(),"X_reduced is not empty")
96     self.failUnless(mypde.getCoefficientOfGeneralPDE("Y_reduced").isEmpty(),"Y_reduced is not empty")
97     self.failUnless(mypde.getCoefficientOfGeneralPDE("y_reduced").isEmpty(),"y_reduced is not empty")
98     self.failUnless(mypde.getCoefficientOfGeneralPDE("d_reduced").isEmpty(),"d_reduced is not empty")
99     self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
100     self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
101 jgs 149 self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("q"),q_ref),"q is not empty")
102     self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
103     def test_setCoefficient_f(self):
104     mypde=Poisson(self.domain,debug=self.DEBUG)
105     x=self.domain.getX()
106     Y_ref=interpolate(x[0],Function(self.domain))
107     A_ref=kronecker(self.domain)
108     mypde.setValue(f=x[0])
109     self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("A"),A_ref),"A is not kronecker")
110     self.failUnless(mypde.getCoefficientOfGeneralPDE("B").isEmpty(),"B is not empty")
111     self.failUnless(mypde.getCoefficientOfGeneralPDE("C").isEmpty(),"C is not empty")
112     self.failUnless(mypde.getCoefficientOfGeneralPDE("D").isEmpty(),"D is not empty")
113     self.failUnless(mypde.getCoefficientOfGeneralPDE("X").isEmpty(),"X is not empty")
114     self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("Y"),Y_ref),"Y is not x[0]")
115     self.failUnless(mypde.getCoefficientOfGeneralPDE("y").isEmpty(),"y is not empty")
116     self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")
117     self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")
118     self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")
119 gross 1072 self.failUnless(mypde.getCoefficientOfGeneralPDE("A_reduced").isEmpty(),"A_reduced is not empty")
120     self.failUnless(mypde.getCoefficientOfGeneralPDE("B_reduced").isEmpty(),"B_reduced is not empty")
121     self.failUnless(mypde.getCoefficientOfGeneralPDE("C_reduced").isEmpty(),"C_reduced is not empty")
122     self.failUnless(mypde.getCoefficientOfGeneralPDE("D_reduced").isEmpty(),"D_reduced is not empty")
123     self.failUnless(mypde.getCoefficientOfGeneralPDE("X_reduced").isEmpty(),"X_reduced is not empty")
124     self.failUnless(mypde.getCoefficientOfGeneralPDE("Y_reduced").isEmpty(),"Y_reduced is not empty")
125     self.failUnless(mypde.getCoefficientOfGeneralPDE("y_reduced").isEmpty(),"y_reduced is not empty")
126     self.failUnless(mypde.getCoefficientOfGeneralPDE("d_reduced").isEmpty(),"d_reduced is not empty")
127     self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
128     self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
129 jgs 149 self.failUnless(mypde.getCoefficientOfGeneralPDE("q").isEmpty(),"q is not empty")
130     self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
131 gross 1072 def test_setCoefficient_f_reduced(self):
132     mypde=Poisson(self.domain,debug=self.DEBUG)
133     x=self.domain.getX()
134     Y_ref=interpolate(x[0],ReducedFunction(self.domain))
135     A_ref=kronecker(self.domain)
136     mypde.setValue(f_reduced=x[0])
137     self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("A"),A_ref),"A is not kronecker")
138     self.failUnless(mypde.getCoefficientOfGeneralPDE("B").isEmpty(),"B is not empty")
139     self.failUnless(mypde.getCoefficientOfGeneralPDE("C").isEmpty(),"C is not empty")
140     self.failUnless(mypde.getCoefficientOfGeneralPDE("D").isEmpty(),"D is not empty")
141     self.failUnless(mypde.getCoefficientOfGeneralPDE("X").isEmpty(),"X is not empty")
142     self.failUnless(mypde.getCoefficientOfGeneralPDE("Y").isEmpty(),"Y is not empty")
143     self.failUnless(mypde.getCoefficientOfGeneralPDE("y").isEmpty(),"y is not empty")
144     self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty")
145     self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty")
146     self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty")
147     self.failUnless(mypde.getCoefficientOfGeneralPDE("A_reduced").isEmpty(),"A_reduced is not empty")
148     self.failUnless(mypde.getCoefficientOfGeneralPDE("B_reduced").isEmpty(),"B_reduced is not empty")
149     self.failUnless(mypde.getCoefficientOfGeneralPDE("C_reduced").isEmpty(),"C_reduced is not empty")
150     self.failUnless(mypde.getCoefficientOfGeneralPDE("D_reduced").isEmpty(),"D_reduced is not empty")
151     self.failUnless(mypde.getCoefficientOfGeneralPDE("X_reduced").isEmpty(),"X_reduced is not empty")
152     self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("Y_reduced"),Y_ref),"Y_reduced is not x[0]")
153     self.failUnless(mypde.getCoefficientOfGeneralPDE("y_reduced").isEmpty(),"y_reduced is not empty")
154     self.failUnless(mypde.getCoefficientOfGeneralPDE("d_reduced").isEmpty(),"d_reduced is not empty")
155     self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
156     self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
157     self.failUnless(mypde.getCoefficientOfGeneralPDE("q").isEmpty(),"q is not empty")
158     self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty")
159 jgs 149 def test_solve(self):
160     d=self.domain.getDim()
161     cf=ContinuousFunction(self.domain)
162     x=cf.getX()
163     #construct exact solution:
164     u_ex=Scalar(1.,cf)
165     for i in range(d):
166     u_ex*=x[i]*(2.-x[i])
167     #construct mask:
168     msk=Scalar(0.,cf)
169     for i in range(d):
170 gross 304 msk+=whereZero(x[i])
171 jgs 149 #construct right hand side
172     f=Scalar(0,cf)
173     for i in range(d):
174     f_p=Scalar(1,cf)
175     for j in range(d):
176     if i==j:
177     f_p*=2.
178     else:
179     f_p*=x[j]*(2-x[j])
180     f+=f_p
181     mypde=Poisson(self.domain)
182     mypde.setValue(f=f,q=msk)
183     u=mypde.getSolution()
184     self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution")
185    
186 gross 855 class Test_LinearPDE_noLumping(Test_linearPDEs):
187 jgs 149 N=4
188     def test_setCoefficient_WithIllegalFunctionSpace(self):
189     mypde=LinearPDE(self.domain,debug=self.DEBUG)
190     try:
191     success=True
192     mypde.setValue(C=Vector(0.,FunctionOnBoundary(self.domain)))
193 gross 1072 except IllegalCoefficientFunctionSpace:
194 jgs 149 success=False
195     self.failUnless(not success,'inapropraite function space accepted')
196    
197     def test_resetCoefficient_WithWrongShape(self):
198     mypde=LinearPDE(self.domain,numEquations=2,debug=self.DEBUG)
199     try:
200     success=True
201     mypde.setValue(C=0.)
202     except IllegalCoefficientValue:
203     success=False
204     self.failUnless(not success,'illegal shape accepted')
205     def test_reducedOn(self):
206     mypde=LinearPDE(self.domain,debug=self.DEBUG)
207     x=self.domain.getX()
208     mypde.setReducedOrderOn()
209     mypde.setValue(A=kronecker(self.domain),D=x[0],Y=x[0])
210     u=mypde.getSolution()
211     self.failUnless(self.check(u,1.),'solution is wrong.')
212    
213     def test_attemptToChangeOrderAfterDefinedCoefficient(self):
214     mypde=LinearPDE(self.domain,debug=self.DEBUG)
215     mypde.setValue(D=1.)
216     try:
217     success=True
218     mypde.setReducedOrderOn()
219     except RuntimeError:
220     success=False
221     self.failUnless(not success,'alterion of order after coefficient is changed not detected.')
222    
223     def test_reducedOnConfig(self):
224     mypde=LinearPDE(self.domain,debug=self.DEBUG)
225     mypde.setReducedOrderOn()
226     self.failUnlessEqual((mypde.getFunctionSpaceForSolution(),mypde.getFunctionSpaceForEquation()),(ReducedSolution(self.domain),ReducedSolution(self.domain)),"reduced function spaces expected.")
227     #
228     # set coefficients for scalars:
229     #
230     def test_setCoefficient_A_Scalar(self):
231     d=self.domain.getDim()
232     mypde=LinearPDE(self.domain,debug=self.DEBUG)
233     mypde.setValue(A=numarray.ones((d,d)))
234     coeff=mypde.getCoefficientOfGeneralPDE("A")
235     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),Function(self.domain),1,1))
236     def test_setCoefficient_B_Scalar(self):
237     d=self.domain.getDim()
238     mypde=LinearPDE(self.domain,debug=self.DEBUG)
239     mypde.setValue(B=numarray.ones((d,)))
240     coeff=mypde.getCoefficientOfGeneralPDE("B")
241     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1))
242     def test_setCoefficient_C_Scalar(self):
243     d=self.domain.getDim()
244     mypde=LinearPDE(self.domain,debug=self.DEBUG)
245     mypde.setValue(C=numarray.ones((d,)))
246     coeff=mypde.getCoefficientOfGeneralPDE("C")
247     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1))
248     def test_setCoefficient_D_Scalar(self):
249     d=self.domain.getDim()
250     mypde=LinearPDE(self.domain,debug=self.DEBUG)
251     mypde.setValue(D=1.)
252     coeff=mypde.getCoefficientOfGeneralPDE("D")
253     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),Function(self.domain),1,1))
254     def test_setCoefficient_X_Scalar(self):
255     d=self.domain.getDim()
256     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
257     mypde.setValue(X=numarray.ones((d,)))
258     coeff=mypde.getCoefficientOfGeneralPDE("X")
259     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),Function(self.domain),1))
260     def test_setCoefficient_Y_Scalar(self):
261     d=self.domain.getDim()
262     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
263     mypde.setValue(Y=1.)
264     coeff=mypde.getCoefficientOfGeneralPDE("Y")
265     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),Function(self.domain),1))
266     def test_setCoefficient_y_Scalar(self):
267     d=self.domain.getDim()
268     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
269     mypde.setValue(y=1.)
270     coeff=mypde.getCoefficientOfGeneralPDE("y")
271     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1))
272     def test_setCoefficient_d_Scalar(self):
273     d=self.domain.getDim()
274     mypde=LinearPDE(self.domain,debug=self.DEBUG)
275     mypde.setValue(d=1.)
276     coeff=mypde.getCoefficientOfGeneralPDE("d")
277     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1))
278     def test_setCoefficient_d_contact_Scalar(self):
279     d=self.domain.getDim()
280     mypde=LinearPDE(self.domain,debug=self.DEBUG)
281     mypde.setValue(d_contact=1.)
282     coeff=mypde.getCoefficientOfGeneralPDE("d_contact")
283     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1,1))
284     def test_setCoefficient_y_contact_Scalar(self):
285     d=self.domain.getDim()
286     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
287     mypde.setValue(y_contact=1.)
288     coeff=mypde.getCoefficientOfGeneralPDE("y_contact")
289     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))
290 gross 1072 def test_setCoefficient_A_reduced_Scalar(self):
291     d=self.domain.getDim()
292     mypde=LinearPDE(self.domain,debug=self.DEBUG)
293     mypde.setValue(A_reduced=numarray.ones((d,d)))
294     coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
295     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
296     def test_setCoefficient_B_reduced_Scalar(self):
297     d=self.domain.getDim()
298     mypde=LinearPDE(self.domain,debug=self.DEBUG)
299     mypde.setValue(B_reduced=numarray.ones((d,)))
300     coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
301     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
302     def test_setCoefficient_C_reduced_Scalar(self):
303     d=self.domain.getDim()
304     mypde=LinearPDE(self.domain,debug=self.DEBUG)
305     mypde.setValue(C_reduced=numarray.ones((d,)))
306     coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
307     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
308     def test_setCoefficient_D_reduced_Scalar(self):
309     d=self.domain.getDim()
310     mypde=LinearPDE(self.domain,debug=self.DEBUG)
311     mypde.setValue(D_reduced=1.)
312     coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
313     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
314     def test_setCoefficient_X_reduced_Scalar(self):
315     d=self.domain.getDim()
316     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
317     mypde.setValue(X_reduced=numarray.ones((d,)))
318     coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
319     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
320     def test_setCoefficient_Y_reduced_Scalar(self):
321     d=self.domain.getDim()
322     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
323     mypde.setValue(Y_reduced=1.)
324     coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
325     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
326     def test_setCoefficient_y_reduced_Scalar(self):
327     d=self.domain.getDim()
328     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
329     mypde.setValue(y_reduced=1.)
330     coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
331     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
332     def test_setCoefficient_d_reduced_Scalar(self):
333     d=self.domain.getDim()
334     mypde=LinearPDE(self.domain,debug=self.DEBUG)
335     mypde.setValue(d_reduced=1.)
336     coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
337     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
338     def test_setCoefficient_d_contact_reduced_Scalar(self):
339     d=self.domain.getDim()
340     mypde=LinearPDE(self.domain,debug=self.DEBUG)
341     mypde.setValue(d_contact_reduced=1.)
342     coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
343     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
344     def test_setCoefficient_y_contact_reduced_Scalar(self):
345     d=self.domain.getDim()
346     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
347     mypde.setValue(y_contact_reduced=1.)
348     coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
349     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
350 jgs 149 def test_setCoefficient_r_Scalar(self):
351     d=self.domain.getDim()
352     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
353     mypde.setValue(r=1.)
354     coeff=mypde.getCoefficientOfGeneralPDE("r")
355     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1))
356     def test_setCoefficient_q_Scalar(self):
357     d=self.domain.getDim()
358     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
359     mypde.setValue(q=1.)
360     coeff=mypde.getCoefficientOfGeneralPDE("q")
361     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1))
362     def test_setCoefficient_r_Scalar_reducedOn(self):
363     d=self.domain.getDim()
364     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
365     mypde.setReducedOrderOn()
366     mypde.setValue(r=1.)
367     coeff=mypde.getCoefficientOfGeneralPDE("r")
368     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
369     def test_setCoefficient_q_Scalar_reducedOn(self):
370     d=self.domain.getDim()
371     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
372     mypde.setReducedOrderOn()
373     mypde.setValue(q=1.)
374     coeff=mypde.getCoefficientOfGeneralPDE("q")
375     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
376    
377 gross 1072 def test_setCoefficient_A_reduced_Scalar_usingA(self):
378     d=self.domain.getDim()
379     mypde=LinearPDE(self.domain,debug=self.DEBUG)
380     mypde.setValue(A=Data(numarray.ones((d,d)),ReducedFunction(self.domain)))
381     coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
382     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
383     def test_setCoefficient_B_reduced_Scalar_usingB(self):
384     d=self.domain.getDim()
385     mypde=LinearPDE(self.domain,debug=self.DEBUG)
386     mypde.setValue(B=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
387     coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
388     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
389     def test_setCoefficient_C_reduced_Scalar_usingC(self):
390     d=self.domain.getDim()
391     mypde=LinearPDE(self.domain,debug=self.DEBUG)
392     mypde.setValue(C=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
393     coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
394     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
395     def test_setCoefficient_D_reduced_Scalar_usingD(self):
396     d=self.domain.getDim()
397     mypde=LinearPDE(self.domain,debug=self.DEBUG)
398     mypde.setValue(D=Scalar(1.,ReducedFunction(self.domain)))
399     coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
400     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
401     def test_setCoefficient_X_reduced_Scalar_usingX(self):
402     d=self.domain.getDim()
403     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
404     mypde.setValue(X_reduced=Data(numarray.ones((d,)),ReducedFunction(self.domain)))
405     coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
406     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
407     def test_setCoefficient_Y_reduced_Scalar_usingY(self):
408     d=self.domain.getDim()
409     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
410     mypde.setValue(Y=Scalar(1.,ReducedFunction(self.domain)))
411     coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
412     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
413     def test_setCoefficient_y_reduced_Scalar_using_y(self):
414     d=self.domain.getDim()
415     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
416     mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
417     coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
418     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
419     def test_setCoefficient_d_reduced_Scalar_using_d(self):
420     d=self.domain.getDim()
421     mypde=LinearPDE(self.domain,debug=self.DEBUG)
422     mypde.setValue(d=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
423     coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
424     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
425     def test_setCoefficient_d_contact_reduced_Scalar_using_d_contact(self):
426     d=self.domain.getDim()
427     mypde=LinearPDE(self.domain,debug=self.DEBUG)
428     mypde.setValue(d_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
429     coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
430     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
431     def test_setCoefficient_y_contact_reduced_Scalar_using_y_contact(self):
432     d=self.domain.getDim()
433     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
434     mypde.setValue(y_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
435     coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
436     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
437 jgs 149 #
438     # set coefficients for systems:
439     #
440     def test_setCoefficient_A_System(self):
441     d=self.domain.getDim()
442     mypde=LinearPDE(self.domain,debug=self.DEBUG)
443     mypde.setValue(A=numarray.ones((self.N,d,self.N,d)))
444     coeff=mypde.getCoefficientOfGeneralPDE("A")
445     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),Function(self.domain),self.N,self.N))
446     def test_setCoefficient_B_System(self):
447     d=self.domain.getDim()
448     mypde=LinearPDE(self.domain,debug=self.DEBUG)
449     mypde.setValue(B=numarray.ones((self.N,d,self.N)))
450     coeff=mypde.getCoefficientOfGeneralPDE("B")
451     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),Function(self.domain),self.N,self.N))
452     def test_setCoefficient_C_System(self):
453     d=self.domain.getDim()
454     mypde=LinearPDE(self.domain,debug=self.DEBUG)
455     mypde.setValue(C=numarray.ones((self.N,self.N,d)))
456     coeff=mypde.getCoefficientOfGeneralPDE("C")
457     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),Function(self.domain),self.N,self.N))
458     def test_setCoefficient_D_System(self):
459     d=self.domain.getDim()
460     mypde=LinearPDE(self.domain,debug=self.DEBUG)
461     mypde.setValue(D=numarray.ones((self.N,self.N)))
462     coeff=mypde.getCoefficientOfGeneralPDE("D")
463     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),Function(self.domain),self.N,self.N))
464     def test_setCoefficient_X_System(self):
465     d=self.domain.getDim()
466     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
467     mypde.setValue(X=numarray.ones((self.N,d)))
468     coeff=mypde.getCoefficientOfGeneralPDE("X")
469     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),Function(self.domain),self.N))
470     def test_setCoefficient_Y_System(self):
471     d=self.domain.getDim()
472     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
473     mypde.setValue(Y=numarray.ones((self.N,)))
474     coeff=mypde.getCoefficientOfGeneralPDE("Y")
475     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),Function(self.domain),self.N))
476     def test_setCoefficient_y_System(self):
477     d=self.domain.getDim()
478     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
479     mypde.setValue(y=numarray.ones((self.N,)))
480     coeff=mypde.getCoefficientOfGeneralPDE("y")
481     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnBoundary(self.domain),self.N))
482     def test_setCoefficient_d_System(self):
483     d=self.domain.getDim()
484     mypde=LinearPDE(self.domain,debug=self.DEBUG)
485     mypde.setValue(d=numarray.ones((self.N,self.N)))
486     coeff=mypde.getCoefficientOfGeneralPDE("d")
487     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnBoundary(self.domain),self.N,self.N))
488     def test_setCoefficient_d_contact_System(self):
489     d=self.domain.getDim()
490     mypde=LinearPDE(self.domain,debug=self.DEBUG)
491     mypde.setValue(d_contact=numarray.ones((self.N,self.N)))
492     coeff=mypde.getCoefficientOfGeneralPDE("d_contact")
493     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnContactZero(self.domain),self.N,self.N))
494     def test_setCoefficient_y_contact_System(self):
495     d=self.domain.getDim()
496     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
497     mypde.setValue(y_contact=numarray.ones((self.N,)))
498     coeff=mypde.getCoefficientOfGeneralPDE("y_contact")
499     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N))
500 gross 1072 def test_setCoefficient_A_reduced_System(self):
501     d=self.domain.getDim()
502     mypde=LinearPDE(self.domain,debug=self.DEBUG)
503     mypde.setValue(A_reduced=numarray.ones((self.N,d,self.N,d)))
504     coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
505     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
506     def test_setCoefficient_B_reduced_System(self):
507     d=self.domain.getDim()
508     mypde=LinearPDE(self.domain,debug=self.DEBUG)
509     mypde.setValue(B_reduced=numarray.ones((self.N,d,self.N)))
510     coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
511     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
512     def test_setCoefficient_C_reduced_System(self):
513     d=self.domain.getDim()
514     mypde=LinearPDE(self.domain,debug=self.DEBUG)
515     mypde.setValue(C_reduced=numarray.ones((self.N,self.N,d)))
516     coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
517     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
518     def test_setCoefficient_D_System_reduced(self):
519     d=self.domain.getDim()
520     mypde=LinearPDE(self.domain,debug=self.DEBUG)
521     mypde.setValue(D_reduced=numarray.ones((self.N,self.N)))
522     coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
523     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
524     def test_setCoefficient_X_System_reduced(self):
525     d=self.domain.getDim()
526     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
527     mypde.setValue(X_reduced=numarray.ones((self.N,d)))
528     coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
529     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
530     def test_setCoefficient_Y_System_reduced(self):
531     d=self.domain.getDim()
532     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
533     mypde.setValue(Y_reduced=numarray.ones((self.N,)))
534     coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
535     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
536     def test_setCoefficient_y_System_reduced(self):
537     d=self.domain.getDim()
538     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
539     mypde.setValue(y_reduced=numarray.ones((self.N,)))
540     coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
541     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
542     def test_setCoefficient_d_reduced_System(self):
543     d=self.domain.getDim()
544     mypde=LinearPDE(self.domain,debug=self.DEBUG)
545     mypde.setValue(d_reduced=numarray.ones((self.N,self.N)))
546     coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
547     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
548     def test_setCoefficient_d_contact_reduced_System(self):
549     d=self.domain.getDim()
550     mypde=LinearPDE(self.domain,debug=self.DEBUG)
551     mypde.setValue(d_contact_reduced=numarray.ones((self.N,self.N)))
552     coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
553     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
554     def test_setCoefficient_y_contact_reduced_System(self):
555     d=self.domain.getDim()
556     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
557     mypde.setValue(y_contact_reduced=numarray.ones((self.N,)))
558     coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
559     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
560 jgs 149 def test_setCoefficient_r_System(self):
561     d=self.domain.getDim()
562     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
563     mypde.setValue(r=numarray.ones((self.N,)))
564     coeff=mypde.getCoefficientOfGeneralPDE("r")
565     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
566     def test_setCoefficient_q_System(self):
567     d=self.domain.getDim()
568     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
569     mypde.setValue(q=numarray.ones((self.N,)))
570     coeff=mypde.getCoefficientOfGeneralPDE("q")
571     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
572     def test_setCoefficient_r_System_reducedOn(self):
573     d=self.domain.getDim()
574     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
575     mypde.setReducedOrderOn()
576     mypde.setValue(r=numarray.ones((self.N,)))
577     coeff=mypde.getCoefficientOfGeneralPDE("r")
578     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
579     def test_setCoefficient_q_System_reducedOn(self):
580     d=self.domain.getDim()
581     mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
582     mypde.setReducedOrderOn()
583     mypde.setValue(q=numarray.ones((self.N,)))
584     coeff=mypde.getCoefficientOfGeneralPDE("q")
585     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
586    
587 gross 1072 def test_setCoefficient_A_reduced_System_using_A(self):
588     d=self.domain.getDim()
589     mypde=LinearPDE(self.domain,debug=self.DEBUG)
590     mypde.setValue(A=Data(numarray.ones((self.N,d,self.N,d)),ReducedFunction(self.domain)))
591     coeff=mypde.getCoefficientOfGeneralPDE("A_reduced")
592     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
593     def test_setCoefficient_B_reduced_System_using_B(self):
594     d=self.domain.getDim()
595     mypde=LinearPDE(self.domain,debug=self.DEBUG)
596     mypde.setValue(B=Data(numarray.ones((self.N,d,self.N)),ReducedFunction(self.domain)))
597     coeff=mypde.getCoefficientOfGeneralPDE("B_reduced")
598     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
599     def test_setCoefficient_C_reduced_System_using_C(self):
600     d=self.domain.getDim()
601     mypde=LinearPDE(self.domain,debug=self.DEBUG)
602     mypde.setValue(C=Data(numarray.ones((self.N,self.N,d)),ReducedFunction(self.domain)))
603     coeff=mypde.getCoefficientOfGeneralPDE("C_reduced")
604     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
605     def test_setCoefficient_D_System_reduced_using_D(self):
606     d=self.domain.getDim()
607     mypde=LinearPDE(self.domain,debug=self.DEBUG)
608     mypde.setValue(D=Data(numarray.ones((self.N,self.N)),ReducedFunction(self.domain)))
609     coeff=mypde.getCoefficientOfGeneralPDE("D_reduced")
610     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
611     def test_setCoefficient_X_System_reduced_using_X(self):
612     d=self.domain.getDim()
613     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
614     mypde.setValue(X=Data(numarray.ones((self.N,d)),ReducedFunction(self.domain)))
615     coeff=mypde.getCoefficientOfGeneralPDE("X_reduced")
616     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
617     def test_setCoefficient_Y_System_reduced_using_Y(self):
618     d=self.domain.getDim()
619     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
620     mypde.setValue(Y=Data(numarray.ones((self.N,)),ReducedFunction(self.domain)))
621     coeff=mypde.getCoefficientOfGeneralPDE("Y_reduced")
622     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
623     def test_setCoefficient_y_reduced_System_using_y(self):
624     d=self.domain.getDim()
625     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
626     mypde.setValue(y=Data(numarray.ones((self.N,)),ReducedFunctionOnBoundary(self.domain)))
627     coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
628     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
629     def test_setCoefficient_d_reduced_System_using_d(self):
630     d=self.domain.getDim()
631     mypde=LinearPDE(self.domain,debug=self.DEBUG)
632     mypde.setValue(d=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnBoundary(self.domain)))
633     coeff=mypde.getCoefficientOfGeneralPDE("d_reduced")
634     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
635     def test_setCoefficient_d_contact_reduced_System_using_d_contact(self):
636     d=self.domain.getDim()
637     mypde=LinearPDE(self.domain,debug=self.DEBUG)
638     mypde.setValue(d_contact=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnContactZero(self.domain)))
639     coeff=mypde.getCoefficientOfGeneralPDE("d_contact_reduced")
640     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
641     def test_setCoefficient_y_contact_reduced_System_using_y_contact(self):
642     d=self.domain.getDim()
643     mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
644     mypde.setValue(y_contact=Data(numarray.ones((self.N,)),ReducedFunctionOnContactZero(self.domain)))
645     coeff=mypde.getCoefficientOfGeneralPDE("y_contact_reduced")
646     self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
647 jgs 149 def test_resetCoefficient_HomogeneousConstraint(self):
648     mypde=LinearPDE(self.domain,debug=self.DEBUG)
649     x=self.domain.getX()
650 gross 304 mypde.setValue(A=kronecker(self.domain),Y=1.,q=whereZero(x[0]))
651 jgs 149 u1=mypde.getSolution()
652     mypde.setValue(Y=2.)
653     u2=mypde.getSolution()
654     self.failUnless(self.check(u2,2*u1),'solution is wrong.')
655    
656     def test_resetCoefficient_InHomogeneousConstraint(self):
657     mypde=LinearPDE(self.domain,debug=self.DEBUG)
658 jgs 154 mypde.setSymmetryOn()
659 jgs 149 x=self.domain.getX()
660 gross 304 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.,r=1,q=whereZero(x[0]))
661 jgs 154 u1=mypde.getSolution(verbose=self.VERBOSE)
662 jgs 149 mypde.setValue(Y=2.,D=2)
663 jgs 154 u2=mypde.getSolution(verbose=self.VERBOSE)
664     self.failUnless(self.check(u2,u1),'first solution is wrong.')
665     u2=mypde.getSolution(verbose=self.VERBOSE)
666     self.failUnless(self.check(u2,u1),'first solution is wrong.')
667 jgs 149 mypde.setValue(r=2,Y=4.)
668 jgs 154 u2=mypde.getSolution(verbose=self.VERBOSE)
669     self.failUnless(self.check(u2,2*u1),'second solution is wrong.')
670 jgs 149
671     def test_symmetryCheckTrue_System(self):
672     d=self.domain.getDim()
673     mypde=LinearPDE(self.domain,debug=self.DEBUG)
674     A=numarray.ones((self.N,d,self.N,d))
675     C=2*numarray.ones((self.N,self.N,d))
676     B=2*numarray.ones((self.N,d,self.N))
677     D=3*numarray.ones((self.N,self.N))
678     d=4*numarray.ones((self.N,self.N))
679     d_contact=5*numarray.ones((self.N,self.N))
680 gross 1072 mypde.setValue(A=A,B=B,C=C,D=D,d=d,d_contact=d_contact,A_reduced=-A,B_reduced=-B,C_reduced=-C,D_reduced=-D,d_reduced=-d,d_contact_reduced=-d_contact)
681 jgs 149 self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
682    
683     def test_symmetryCheckFalse_A_System(self):
684     d=self.domain.getDim()
685     mypde=LinearPDE(self.domain,debug=self.DEBUG)
686     A=numarray.ones((self.N,d,self.N,d))
687     A[1,1,1,0]=0.
688     mypde.setValue(A=A)
689     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
690     def test_symmetryCheckFalse_BC_System(self):
691     d=self.domain.getDim()
692     mypde=LinearPDE(self.domain,debug=self.DEBUG)
693     C=2*numarray.ones((self.N,self.N,d))
694     B=2*numarray.ones((self.N,d,self.N))
695     B[0,0,1]=1.
696     mypde.setValue(B=B,C=C)
697     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
698    
699     def test_symmetryCheckFalse_D_System(self):
700     mypde=LinearPDE(self.domain,debug=self.DEBUG)
701     D=3*numarray.ones((self.N,self.N))
702     D[0,1]=0.
703     mypde.setValue(D=D)
704     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
705    
706     def test_symmetryCheckFalse_d_System(self):
707     mypde=LinearPDE(self.domain,debug=self.DEBUG)
708     d=4*numarray.ones((self.N,self.N))
709     d[0,1]=0.
710     mypde.setValue(d=d)
711     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
712    
713     def test_symmetryCheckFalse_d_contact_System(self):
714     mypde=LinearPDE(self.domain,debug=self.DEBUG)
715     d_contact=5*numarray.ones((self.N,self.N))
716     d_contact[0,1]=0.
717     mypde.setValue(d_contact=d_contact)
718     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
719    
720 gross 1072 def test_symmetryCheckFalse_A_reduced_System(self):
721     d=self.domain.getDim()
722     mypde=LinearPDE(self.domain,debug=self.DEBUG)
723     A=numarray.ones((self.N,d,self.N,d))
724     A[1,1,1,0]=0.
725     mypde.setValue(A_reduced=A)
726     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
727     def test_symmetryCheckFalse_BC_reduced_System(self):
728     d=self.domain.getDim()
729     mypde=LinearPDE(self.domain,debug=self.DEBUG)
730     C=2*numarray.ones((self.N,self.N,d))
731     B=2*numarray.ones((self.N,d,self.N))
732     B[0,0,1]=1.
733     mypde.setValue(B_reduced=B,C_reduced=C)
734     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
735    
736     def test_symmetryCheckFalse_D_reduced_System(self):
737     mypde=LinearPDE(self.domain,debug=self.DEBUG)
738     D=3*numarray.ones((self.N,self.N))
739     D[0,1]=0.
740     mypde.setValue(D_reduced=D)
741     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
742    
743     def test_symmetryCheckFalse_d_reduced_System(self):
744     mypde=LinearPDE(self.domain,debug=self.DEBUG)
745     d=4*numarray.ones((self.N,self.N))
746     d[0,1]=0.
747     mypde.setValue(d_reduced=d)
748     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
749    
750     def test_symmetryCheckFalse_d_contact_reduced_System(self):
751     mypde=LinearPDE(self.domain,debug=self.DEBUG)
752     d_contact=5*numarray.ones((self.N,self.N))
753     d_contact[0,1]=0.
754     mypde.setValue(d_contact_reduced=d_contact)
755     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
756    
757 jgs 149 def test_symmetryCheckTrue_Scalar(self):
758     d=self.domain.getDim()
759     mypde=LinearPDE(self.domain,debug=self.DEBUG)
760     A=numarray.ones((d,d))
761     C=2*numarray.ones((d,))
762     B=2*numarray.ones((d,))
763     D=3
764     d=4
765     d_contact=5
766 gross 1072 mypde.setValue(A=A,B=B,C=C,D=D,d=d,d_contact=d_contact,A_reduced=-A,B_reduced=-B,C_reduced=-C,D_reduced=-D,d_reduced=-d,d_contact_reduced=-d_contact)
767 jgs 149 self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")
768    
769     def test_symmetryCheckFalse_A_Scalar(self):
770     d=self.domain.getDim()
771     mypde=LinearPDE(self.domain,debug=self.DEBUG)
772     A=numarray.ones((d,d))
773     A[1,0]=0.
774     mypde.setValue(A=A)
775     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
776     def test_symmetryCheckFalse_BC_Scalar(self):
777     d=self.domain.getDim()
778     mypde=LinearPDE(self.domain,debug=self.DEBUG)
779     C=2*numarray.ones((d,))
780     B=2*numarray.ones((d,))
781     B[0]=1.
782     mypde.setValue(B=B,C=C)
783     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
784 gross 1072 def test_symmetryCheckFalse_A_reduced_Scalar(self):
785     d=self.domain.getDim()
786     mypde=LinearPDE(self.domain,debug=self.DEBUG)
787     A=numarray.ones((d,d))
788     A[1,0]=0.
789     mypde.setValue(A_reduced=A)
790     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
791     def test_symmetryCheckFalse_BC_reduced_Scalar(self):
792     d=self.domain.getDim()
793     mypde=LinearPDE(self.domain,debug=self.DEBUG)
794     C=2*numarray.ones((d,))
795     B=2*numarray.ones((d,))
796     B[0]=1.
797     mypde.setValue(B_reduced=B,C_reduced=C)
798     self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")
799 jgs 149 #
800 ksteube 1312 # solver checks (single PDE)
801 jgs 149 #
802     def test_symmetryOnIterative(self):
803     mypde=LinearPDE(self.domain,debug=self.DEBUG)
804     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
805     u=mypde.getSolution(verbose=self.VERBOSE)
806     self.failUnless(self.check(u,1.),'solution is wrong.')
807     def test_symmetryOnDirect(self):
808     mypde=LinearPDE(self.domain,debug=self.DEBUG)
809     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
810     mypde.setSolverMethod(mypde.DIRECT)
811     u=mypde.getSolution(verbose=self.VERBOSE)
812     self.failUnless(self.check(u,1.),'solution is wrong.')
813     def test_PCG_JACOBI(self):
814     mypde=LinearPDE(self.domain,debug=self.DEBUG)
815     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
816 gross 387 mypde.setSolverMethod(mypde.PCG,mypde.JACOBI)
817     u=mypde.getSolution(verbose=self.VERBOSE)
818 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
819     def test_PCG_ILU0(self):
820     mypde=LinearPDE(self.domain,debug=self.DEBUG)
821     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
822 gross 387 mypde.setSolverMethod(mypde.PCG,mypde.ILU0)
823     u=mypde.getSolution(verbose=self.VERBOSE)
824 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
825     def test_DIRECT(self):
826     mypde=LinearPDE(self.domain,debug=self.DEBUG)
827     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
828     mypde.setSolverMethod(mypde.DIRECT)
829 jgs 154 u=mypde.getSolution(verbose=self.VERBOSE)
830 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
831     def test_BICGSTAB_JACOBI(self):
832     mypde=LinearPDE(self.domain,debug=self.DEBUG)
833 gross 387 mypde.setSolverMethod(mypde.BICGSTAB,mypde.JACOBI)
834 jgs 149 mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
835 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
836 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
837     def test_BICGSTAB_ILU0(self):
838     mypde=LinearPDE(self.domain,debug=self.DEBUG)
839     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
840 gross 387 mypde.setSolverMethod(mypde.BICGSTAB,mypde.ILU0)
841     u=mypde.getSolution(verbose=self.VERBOSE)
842 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
843     def test_PRES20_JACOBI(self):
844     mypde=LinearPDE(self.domain,debug=self.DEBUG)
845     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
846 gross 387 mypde.setSolverMethod(mypde.PRES20,mypde.JACOBI)
847     u=mypde.getSolution(verbose=self.VERBOSE)
848 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
849     def test_PRES20_ILU0(self):
850     mypde=LinearPDE(self.domain,debug=self.DEBUG)
851     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
852 gross 387 mypde.setSolverMethod(mypde.PRES20,mypde.ILU0)
853     u=mypde.getSolution(verbose=self.VERBOSE)
854 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
855     def test_GMRESnoRestart_JACOBI(self):
856     mypde=LinearPDE(self.domain,debug=self.DEBUG)
857     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
858 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
859     # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
860     u=mypde.getSolution(verbose=self.VERBOSE)
861 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
862     def test_GMRESnoRestart_ILU0(self):
863     mypde=LinearPDE(self.domain,debug=self.DEBUG)
864     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
865 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
866     # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
867     u=mypde.getSolution(verbose=self.VERBOSE)
868 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
869     def test_GMRES_JACOBI(self):
870     mypde=LinearPDE(self.domain,debug=self.DEBUG)
871     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
872 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
873     u=mypde.getSolution(verbose=self.VERBOSE)
874 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
875     def test_GMRES_ILU0(self):
876     mypde=LinearPDE(self.domain,debug=self.DEBUG)
877     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
878 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
879     u=mypde.getSolution(verbose=self.VERBOSE)
880 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
881     def test_GMRES_truncation_restart_JACOBI(self):
882     mypde=LinearPDE(self.domain,debug=self.DEBUG)
883     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
884 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
885     u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
886 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
887     def test_GMRES_truncation_restart_ILU0(self):
888     mypde=LinearPDE(self.domain,debug=self.DEBUG)
889     mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
890 gross 387 mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
891     u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
892 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
893 ksteube 1312 #
894     # solver checks (PDE system)
895     #
896     def test_symmetryOnIterative_System(self):
897     A=Tensor4(0.,Function(self.domain))
898     D=Tensor(1.,Function(self.domain))
899     Y=Vector(self.domain.getDim(),Function(self.domain))
900     for i in range(self.domain.getDim()):
901     A[i,:,i,:]=kronecker(self.domain)
902     D[i,i]+=i
903     Y[i]+=i
904     mypde=LinearPDE(self.domain,debug=self.DEBUG)
905     mypde.setValue(A=A,D=D,Y=Y)
906     u=mypde.getSolution(verbose=self.VERBOSE)
907     self.failUnless(self.check(u,1.),'solution is wrong.')
908     def test_symmetryOnDirect_System(self):
909     A=Tensor4(0.,Function(self.domain))
910     D=Tensor(1.,Function(self.domain))
911     Y=Vector(self.domain.getDim(),Function(self.domain))
912     for i in range(self.domain.getDim()):
913     A[i,:,i,:]=kronecker(self.domain)
914     D[i,i]+=i
915     Y[i]+=i
916     mypde=LinearPDE(self.domain,debug=self.DEBUG)
917     mypde.setValue(A=A,D=D,Y=Y)
918     mypde.setSolverMethod(mypde.DIRECT)
919     u=mypde.getSolution(verbose=self.VERBOSE)
920     self.failUnless(self.check(u,1.),'solution is wrong.')
921     def test_PCG_JACOBI_System(self):
922     A=Tensor4(0.,Function(self.domain))
923     D=Tensor(1.,Function(self.domain))
924     Y=Vector(self.domain.getDim(),Function(self.domain))
925     for i in range(self.domain.getDim()):
926     A[i,:,i,:]=kronecker(self.domain)
927     D[i,i]+=i
928     Y[i]+=i
929     mypde=LinearPDE(self.domain,debug=self.DEBUG)
930     mypde.setValue(A=A,D=D,Y=Y)
931     mypde.setSolverMethod(mypde.PCG,mypde.JACOBI)
932     u=mypde.getSolution(verbose=self.VERBOSE)
933     self.failUnless(self.check(u,1.),'solution is wrong.')
934     def test_PCG_ILU0_System(self):
935     A=Tensor4(0.,Function(self.domain))
936     D=Tensor(1.,Function(self.domain))
937     Y=Vector(self.domain.getDim(),Function(self.domain))
938     for i in range(self.domain.getDim()):
939     A[i,:,i,:]=kronecker(self.domain)
940     D[i,i]+=i
941     Y[i]+=i
942     mypde=LinearPDE(self.domain,debug=self.DEBUG)
943     mypde.setValue(A=A,D=D,Y=Y)
944     mypde.setSolverMethod(mypde.PCG,mypde.ILU0)
945     u=mypde.getSolution(verbose=self.VERBOSE)
946     self.failUnless(self.check(u,1.),'solution is wrong.')
947     def test_DIRECT_System(self):
948     A=Tensor4(0.,Function(self.domain))
949     D=Tensor(1.,Function(self.domain))
950     Y=Vector(self.domain.getDim(),Function(self.domain))
951     for i in range(self.domain.getDim()):
952     A[i,:,i,:]=kronecker(self.domain)
953     D[i,i]+=i
954     Y[i]+=i
955     mypde=LinearPDE(self.domain,debug=self.DEBUG)
956     mypde.setValue(A=A,D=D,Y=Y)
957     mypde.setSolverMethod(mypde.DIRECT)
958     u=mypde.getSolution(verbose=self.VERBOSE)
959     self.failUnless(self.check(u,1.),'solution is wrong.')
960     def test_BICGSTAB_JACOBI_System(self):
961     A=Tensor4(0.,Function(self.domain))
962     D=Tensor(1.,Function(self.domain))
963     Y=Vector(self.domain.getDim(),Function(self.domain))
964     for i in range(self.domain.getDim()):
965     A[i,:,i,:]=kronecker(self.domain)
966     D[i,i]+=i
967     Y[i]+=i
968     mypde=LinearPDE(self.domain,debug=self.DEBUG)
969     mypde.setValue(A=A,D=D,Y=Y)
970     mypde.setSolverMethod(mypde.BICGSTAB,mypde.JACOBI)
971     u=mypde.getSolution(verbose=self.VERBOSE)
972     self.failUnless(self.check(u,1.),'solution is wrong.')
973     def test_BICGSTAB_ILU0_System(self):
974     A=Tensor4(0.,Function(self.domain))
975     D=Tensor(1.,Function(self.domain))
976     Y=Vector(self.domain.getDim(),Function(self.domain))
977     for i in range(self.domain.getDim()):
978     A[i,:,i,:]=kronecker(self.domain)
979     D[i,i]+=i
980     Y[i]+=i
981     mypde=LinearPDE(self.domain,debug=self.DEBUG)
982     mypde.setValue(A=A,D=D,Y=Y)
983     mypde.setSolverMethod(mypde.BICGSTAB,mypde.ILU0)
984     u=mypde.getSolution(verbose=self.VERBOSE)
985     self.failUnless(self.check(u,1.),'solution is wrong.')
986     def test_PRES20_JACOBI_System(self):
987     A=Tensor4(0.,Function(self.domain))
988     D=Tensor(1.,Function(self.domain))
989     Y=Vector(self.domain.getDim(),Function(self.domain))
990     for i in range(self.domain.getDim()):
991     A[i,:,i,:]=kronecker(self.domain)
992     D[i,i]+=i
993     Y[i]+=i
994     mypde=LinearPDE(self.domain,debug=self.DEBUG)
995     mypde.setValue(A=A,D=D,Y=Y)
996     mypde.setSolverMethod(mypde.PRES20,mypde.JACOBI)
997     u=mypde.getSolution(verbose=self.VERBOSE)
998     self.failUnless(self.check(u,1.),'solution is wrong.')
999     def test_PRES20_ILU0_System(self):
1000     A=Tensor4(0.,Function(self.domain))
1001     D=Tensor(1.,Function(self.domain))
1002     Y=Vector(self.domain.getDim(),Function(self.domain))
1003     for i in range(self.domain.getDim()):
1004     A[i,:,i,:]=kronecker(self.domain)
1005     D[i,i]+=i
1006     Y[i]+=i
1007     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1008     mypde.setValue(A=A,D=D,Y=Y)
1009     mypde.setSolverMethod(mypde.PRES20,mypde.ILU0)
1010     u=mypde.getSolution(verbose=self.VERBOSE)
1011     self.failUnless(self.check(u,1.),'solution is wrong.')
1012     def test_GMRESnoRestart_JACOBI_System(self):
1013     A=Tensor4(0.,Function(self.domain))
1014     D=Tensor(1.,Function(self.domain))
1015     Y=Vector(self.domain.getDim(),Function(self.domain))
1016     for i in range(self.domain.getDim()):
1017     A[i,:,i,:]=kronecker(self.domain)
1018     D[i,i]+=i
1019     Y[i]+=i
1020     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1021     mypde.setValue(A=A,D=D,Y=Y)
1022     mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
1023     # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
1024     u=mypde.getSolution(verbose=self.VERBOSE)
1025     self.failUnless(self.check(u,1.),'solution is wrong.')
1026     def test_GMRESnoRestart_ILU0_System(self):
1027     A=Tensor4(0.,Function(self.domain))
1028     D=Tensor(1.,Function(self.domain))
1029     Y=Vector(self.domain.getDim(),Function(self.domain))
1030     for i in range(self.domain.getDim()):
1031     A[i,:,i,:]=kronecker(self.domain)
1032     D[i,i]+=i
1033     Y[i]+=i
1034     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1035     mypde.setValue(A=A,D=D,Y=Y)
1036     mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
1037     # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
1038     u=mypde.getSolution(verbose=self.VERBOSE)
1039     self.failUnless(self.check(u,1.),'solution is wrong.')
1040     def test_GMRES_JACOBI_System(self):
1041     A=Tensor4(0.,Function(self.domain))
1042     D=Tensor(1.,Function(self.domain))
1043     Y=Vector(self.domain.getDim(),Function(self.domain))
1044     for i in range(self.domain.getDim()):
1045     A[i,:,i,:]=kronecker(self.domain)
1046     D[i,i]+=i
1047     Y[i]+=i
1048     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1049     mypde.setValue(A=A,D=D,Y=Y)
1050     mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
1051     u=mypde.getSolution(verbose=self.VERBOSE)
1052     self.failUnless(self.check(u,1.),'solution is wrong.')
1053     def test_GMRES_ILU0_System(self):
1054     A=Tensor4(0.,Function(self.domain))
1055     D=Tensor(1.,Function(self.domain))
1056     Y=Vector(self.domain.getDim(),Function(self.domain))
1057     for i in range(self.domain.getDim()):
1058     A[i,:,i,:]=kronecker(self.domain)
1059     D[i,i]+=i
1060     Y[i]+=i
1061     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1062     mypde.setValue(A=A,D=D,Y=Y)
1063     mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
1064     u=mypde.getSolution(verbose=self.VERBOSE)
1065     self.failUnless(self.check(u,1.),'solution is wrong.')
1066     def test_GMRES_truncation_restart_JACOBI_System(self):
1067     A=Tensor4(0.,Function(self.domain))
1068     D=Tensor(1.,Function(self.domain))
1069     Y=Vector(self.domain.getDim(),Function(self.domain))
1070     for i in range(self.domain.getDim()):
1071     A[i,:,i,:]=kronecker(self.domain)
1072     D[i,i]+=i
1073     Y[i]+=i
1074     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1075     mypde.setValue(A=A,D=D,Y=Y)
1076     mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI)
1077     u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
1078     self.failUnless(self.check(u,1.),'solution is wrong.')
1079     def test_GMRES_truncation_restart_ILU0_System(self):
1080     A=Tensor4(0.,Function(self.domain))
1081     D=Tensor(1.,Function(self.domain))
1082     Y=Vector(self.domain.getDim(),Function(self.domain))
1083     for i in range(self.domain.getDim()):
1084     A[i,:,i,:]=kronecker(self.domain)
1085     D[i,i]+=i
1086     Y[i]+=i
1087     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1088     mypde.setValue(A=A,D=D,Y=Y)
1089     mypde.setSolverMethod(mypde.GMRES,mypde.ILU0)
1090     u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20)
1091     self.failUnless(self.check(u,1.),'solution is wrong.')
1092 gross 855
1093     class Test_LinearPDE(Test_LinearPDE_noLumping):
1094 jgs 149 def test_Lumping_attemptToSetA(self):
1095     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1096     try:
1097     success=True
1098     mypde.setSolverMethod(mypde.LUMPING)
1099     mypde.setValue(A=kronecker(self.domain))
1100     u=mypde.getSolution(verbose=self.VERBOSE)
1101 gross 531 except ValueError:
1102 jgs 149 success=False
1103 gross 531 self.failUnless(not success,'error should be issued')
1104 jgs 149 def test_Lumping_attemptToSetB(self):
1105     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1106     try:
1107     success=True
1108     mypde.setSolverMethod(mypde.LUMPING)
1109     mypde.setValue(B=kronecker(self.domain)[0])
1110     u=mypde.getSolution(verbose=self.VERBOSE)
1111 gross 531 except ValueError:
1112 jgs 149 success=False
1113 gross 531 self.failUnless(not success,'error should be issued')
1114 jgs 149 def test_Lumping_attemptToSetC(self):
1115     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1116     try:
1117     success=True
1118     mypde.setSolverMethod(mypde.LUMPING)
1119     mypde.setValue(C=kronecker(self.domain)[0])
1120     u=mypde.getSolution(verbose=self.VERBOSE)
1121 gross 531 except ValueError:
1122 jgs 149 success=False
1123 gross 531 self.failUnless(not success,'error should be issued')
1124 jgs 149
1125 gross 1072 def test_Lumping_attemptToSetA_reduced(self):
1126     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1127     try:
1128     success=True
1129     mypde.setSolverMethod(mypde.LUMPING)
1130     mypde.setValue(A_reduced=kronecker(self.domain))
1131     u=mypde.getSolution(verbose=self.VERBOSE)
1132     except ValueError:
1133     success=False
1134     self.failUnless(not success,'error should be issued')
1135     def test_Lumping_attemptToSetB_reduced(self):
1136     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1137     try:
1138     success=True
1139     mypde.setSolverMethod(mypde.LUMPING)
1140     mypde.setValue(B_reduced=kronecker(self.domain)[0])
1141     u=mypde.getSolution(verbose=self.VERBOSE)
1142     except ValueError:
1143     success=False
1144     self.failUnless(not success,'error should be issued')
1145     def test_Lumping_attemptToSetC_reduced(self):
1146     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1147     try:
1148     success=True
1149     mypde.setSolverMethod(mypde.LUMPING)
1150     mypde.setValue(C_reduced=kronecker(self.domain)[0])
1151     u=mypde.getSolution(verbose=self.VERBOSE)
1152     except ValueError:
1153     success=False
1154     self.failUnless(not success,'error should be issued')
1155    
1156 jgs 149 def test_Lumping(self):
1157     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1158     mypde.setSolverMethod(mypde.LUMPING)
1159     mypde.setValue(D=1.,Y=1.)
1160 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1161 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
1162     def test_Constrained_Lumping(self):
1163     x=self.domain.getX()
1164     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1165     mypde.setSolverMethod(mypde.LUMPING)
1166 gross 304 mypde.setValue(D=1.,Y=1.,q=whereZero(x[0]),r=1.)
1167 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1168 jgs 149 self.failUnless(self.check(u,1.),'solution is wrong.')
1169 gross 531
1170     def test_Lumping_System(self):
1171     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1172     mypde.setSolverMethod(mypde.LUMPING)
1173     mypde.setValue(D=numarray.array([[1.,0.],[0.,2.]]),Y=numarray.array([1.,2.]))
1174     u=mypde.getSolution(verbose=self.VERBOSE)
1175     self.failUnless(self.check(u,numarray.ones((2,))),'solution is wrong.')
1176     def test_Constrained_Lumping_System(self):
1177     x=self.domain.getX()
1178     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1179     mypde.setSolverMethod(mypde.LUMPING)
1180     mypde.setValue(D=numarray.array([[1.,0.],[0.,2.]]),Y=numarray.array([1.,2.]), \
1181     q=whereZero(x[0])*[0.,1],r=[0.,1.])
1182     u=mypde.getSolution(verbose=self.VERBOSE)
1183     self.failUnless(self.check(u,numarray.ones((2,))),'solution is wrong.')
1184    
1185 jgs 149 def test_Lumping_updateRHS(self):
1186     x=self.domain.getX()
1187     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1188     mypde.setSolverMethod(mypde.LUMPING)
1189     mypde.setValue(D=1.,Y=1.)
1190 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1191 jgs 149 self.failUnless(self.check(u,1.),'first solution is wrong.')
1192 gross 304 mypde.setValue(Y=2.,q=whereZero(x[0]),r=2.)
1193 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1194 jgs 149 self.failUnless(self.check(u,2.),'second solution is wrong.')
1195     def test_Lumping_updateOperator(self):
1196     x=self.domain.getX()
1197     mypde=LinearPDE(self.domain,debug=self.DEBUG)
1198     mypde.setSolverMethod(mypde.LUMPING)
1199     mypde.setValue(D=1.,Y=1.)
1200 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1201 jgs 149 mypde.setValue(D=2.)
1202 gross 387 u=mypde.getSolution(verbose=self.VERBOSE)
1203 jgs 149 self.failUnless(self.check(u,0.5),'second solution is wrong.')
1204    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26