/[escript]/trunk/escriptcore/test/python/test_linearPDEs.py
ViewVC logotype

Diff of /trunk/escriptcore/test/python/test_linearPDEs.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2548 by jfenwick, Mon Jul 20 06:20:06 2009 UTC revision 3981 by jfenwick, Fri Sep 21 02:47:54 2012 UTC
# Line 1  Line 1 
1    # -*- coding: utf-8 -*-
2    
3  ########################################################  ##############################################################################
4  #  #
5  # Copyright (c) 2003-2009 by University of Queensland  # Copyright (c) 2003-2012 by University of Queensland
6  # Earth Systems Science Computational Center (ESSCC)  # http://www.uq.edu.au
 # http://www.uq.edu.au/esscc  
7  #  #
8  # Primary Business: Queensland, Australia  # Primary Business: Queensland, Australia
9  # Licensed under the Open Software License version 3.0  # Licensed under the Open Software License version 3.0
10  # http://www.opensource.org/licenses/osl-3.0.php  # http://www.opensource.org/licenses/osl-3.0.php
11  #  #
12  ########################################################  # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
13    # Development since 2012 by School of Earth Sciences
14    #
15    ##############################################################################
16    
17  __copyright__="""Copyright (c) 2003-2008 by University of Queensland  __copyright__="""Copyright (c) 2003-2012 by University of Queensland
18  Earth Systems Science Computational Center (ESSCC)  http://www.uq.edu.au
 http://www.uq.edu.au/esscc  
19  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
20  __license__="""Licensed under the Open Software License version 3.0  __license__="""Licensed under the Open Software License version 3.0
21  http://www.opensource.org/licenses/osl-3.0.php"""  http://www.opensource.org/licenses/osl-3.0.php"""
# Line 22  __url__="https://launchpad.net/escript-f Line 24  __url__="https://launchpad.net/escript-f
24  """  """
25  Test suite for linearPDEs class  Test suite for linearPDEs class
26    
 The tests must be linked with a Domain class object in the setUp method:  
   
    from esys.finley import Rectangle  
    class Test_LinearPDEOnFinley(Test_LinearPDE):  
        def setUp(self):  
            self.domain = Rectangle(10,10,2)  
        def tearDown(self):  
            del self.domain  
    suite = unittest.TestSuite()  
    suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley))  
    unittest.TextTestRunner(verbosity=2).run(suite)  
   
 @var __author__: name of author  
 @var __copyright__: copyrights  
 @var __license__: licence agreement  
 @var __url__: url entry point on documentation  
 @var __version__: version  
 @var __date__: date of the version  
27  """  """
28    
29  __author__="Lutz Gross, l.gross@uq.edu.au"  __author__="Lutz Gross, l.gross@uq.edu.au"
30    
31  from esys.escript.util import Lsup,kronecker,interpolate,whereZero, outer, swap_axes  from esys.escript.util import Lsup,kronecker,interpolate,whereZero, outer, swap_axes
32  from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar, ReducedFunction,ReducedFunctionOnBoundary,ReducedFunctionOnContactZero,Data, Tensor4, Tensor  from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar, ReducedFunction,ReducedFunctionOnBoundary,ReducedFunctionOnContactZero,Data, Tensor4, Tensor, getEscriptParamInt
33  from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace, TransportPDE, IllegalCoefficient, Helmholtz, LameEquation, SolverOptions  from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace, TransportPDE, IllegalCoefficient, Helmholtz, LameEquation, SolverOptions
34  import numpy  import numpy
35  import unittest  import unittest
# Line 57  class Test_linearPDEs(unittest.TestCase) Line 41  class Test_linearPDEs(unittest.TestCase)
41      VERBOSE=False      VERBOSE=False
42      def check(self,arg,ref_arg,tol=None):      def check(self,arg,ref_arg,tol=None):
43          """          """
44          checks if arg and ref_arg are nearly identical using the L{Lsup<esys.escript.util.Lsup>}          checks if arg and ref_arg are nearly identical using the `Lsup`
45          """          """
46          if tol==None: tol=self.TOL          if tol==None: tol=self.TOL
47          return Lsup(arg-ref_arg)<=tol*Lsup(ref_arg)          return Lsup(arg-ref_arg)<=tol*Lsup(ref_arg)
# Line 67  class Test_LameEquation(Test_linearPDEs) Line 51  class Test_LameEquation(Test_linearPDEs)
51      def test_config(self):      def test_config(self):
52          mypde=LameEquation(self.domain,debug=self.DEBUG)          mypde=LameEquation(self.domain,debug=self.DEBUG)
53          d=self.domain.getDim()          d=self.domain.getDim()
54          self.failUnlessEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(d,d,True),"set up incorrect")          self.assertEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(d,d,True),"set up incorrect")
55    
56      def test_setCoefficient_q(self):      def test_setCoefficient_q(self):
57          mypde=LameEquation(self.domain,debug=self.DEBUG)          mypde=LameEquation(self.domain,debug=self.DEBUG)
# Line 75  class Test_LameEquation(Test_linearPDEs) Line 59  class Test_LameEquation(Test_linearPDEs)
59          mypde.setValue(q=x)          mypde.setValue(q=x)
60    
61          q_ref=interpolate(x,Solution(self.domain))          q_ref=interpolate(x,Solution(self.domain))
62          self.failUnless(self.check(mypde.getCoefficient("A"),0),"A is not 0")          self.assertTrue(self.check(mypde.getCoefficient("A"),0),"A is not 0")
63          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
64          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
65          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
66          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
67          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
68          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
69          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
70          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
71          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
72          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
73          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
74          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
75          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
76          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
77          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
78          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
79          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
80          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
81          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
82          self.failUnless(self.check(mypde.getCoefficient("q"),q_ref),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
83          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(self.check(mypde.getCoefficient("q"),q_ref),"q is not empty")
84            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
85    
86      def test_setCoefficient_r(self):      def test_setCoefficient_r(self):
87          mypde=LameEquation(self.domain,debug=self.DEBUG)          mypde=LameEquation(self.domain,debug=self.DEBUG)
# Line 104  class Test_LameEquation(Test_linearPDEs) Line 89  class Test_LameEquation(Test_linearPDEs)
89          mypde.setValue(r=x)          mypde.setValue(r=x)
90    
91          r_ref=interpolate(x,Solution(self.domain))          r_ref=interpolate(x,Solution(self.domain))
92          self.failUnless(self.check(mypde.getCoefficient("A"),0),"A is not 0")          self.assertTrue(self.check(mypde.getCoefficient("A"),0),"A is not 0")
93          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
94          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
95          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
96          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
97          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
98          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
99          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
100          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
101          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
102          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
103          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
104          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
105          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
106          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
107          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
108          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
109          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
110          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
111          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
112          self.failUnless(self.check(mypde.getCoefficient("r"),r_ref),"r is nor x")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
113          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")          self.assertTrue(self.check(mypde.getCoefficient("r"),r_ref),"r is nor x")
114            self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
115    
116    
117      def test_setCoefficient_F(self):      def test_setCoefficient_F(self):
# Line 134  class Test_LameEquation(Test_linearPDEs) Line 120  class Test_LameEquation(Test_linearPDEs)
120          mypde.setValue(F=x)          mypde.setValue(F=x)
121    
122          Y_ref=interpolate(x,Function(self.domain))          Y_ref=interpolate(x,Function(self.domain))
123          self.failUnless(self.check(mypde.getCoefficient("A"),0),"A is not 0")          self.assertTrue(self.check(mypde.getCoefficient("A"),0),"A is not 0")
124          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
125          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
126          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
127          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
128          self.failUnless(self.check(mypde.getCoefficient("Y"),Y_ref),"Y is not x")          self.assertTrue(self.check(mypde.getCoefficient("Y"),Y_ref),"Y is not x")
129          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
130          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
131          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
132          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
133          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
134          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
135          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
136          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
137          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
138          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
139          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
140          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
141          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
142          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
143          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
144          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
145            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
146    
147      def test_setCoefficient_f(self):      def test_setCoefficient_f(self):
148          mypde=LameEquation(self.domain,debug=self.DEBUG)          mypde=LameEquation(self.domain,debug=self.DEBUG)
# Line 163  class Test_LameEquation(Test_linearPDEs) Line 150  class Test_LameEquation(Test_linearPDEs)
150          mypde.setValue(f=x)          mypde.setValue(f=x)
151    
152          y_ref=interpolate(x,FunctionOnBoundary(self.domain))          y_ref=interpolate(x,FunctionOnBoundary(self.domain))
153          self.failUnless(self.check(mypde.getCoefficient("A"),0),"A is not 0")          self.assertTrue(self.check(mypde.getCoefficient("A"),0),"A is not 0")
154          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
155          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
156          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
157          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
158          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
159          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
160          self.failUnless(self.check(mypde.getCoefficient("y"),y_ref),"d is not x[0]")          self.assertTrue(self.check(mypde.getCoefficient("y"),y_ref),"d is not x[0]")
161          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
162          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
163          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
164          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
165          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
166          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"X_reduced is not empty")
167          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
168          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
169          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
170          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
171          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
172          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
173          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")      
174          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
175            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
176    
177      def test_setCoefficient_sigma(self):      def test_setCoefficient_sigma(self):
178          mypde=LameEquation(self.domain,debug=self.DEBUG)          mypde=LameEquation(self.domain,debug=self.DEBUG)
# Line 192  class Test_LameEquation(Test_linearPDEs) Line 180  class Test_LameEquation(Test_linearPDEs)
180          mypde.setValue(sigma=outer(x,x))          mypde.setValue(sigma=outer(x,x))
181    
182          X_ref=interpolate(outer(x,x),Function(self.domain))          X_ref=interpolate(outer(x,x),Function(self.domain))
183          self.failUnless(self.check(mypde.getCoefficient("A"),0),"A is not 0")          self.assertTrue(self.check(mypde.getCoefficient("A"),0),"A is not 0")
184          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
185          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
186          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
187          self.failUnless(self.check(mypde.getCoefficient("X"),X_ref),"X is not x X x")          self.assertTrue(self.check(mypde.getCoefficient("X"),X_ref),"X is not x X x")
188          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
189          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
190          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
191          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
192          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
193          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
194          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
195          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
196          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"X_reduced is not empty")
197          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
198          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
199          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
200          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
201          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
202          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
203          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
204          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
205            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
206    
207      def test_setCoefficient_lambda(self):      def test_setCoefficient_lambda(self):
208          mypde=LameEquation(self.domain,debug=self.DEBUG)          mypde=LameEquation(self.domain,debug=self.DEBUG)
# Line 225  class Test_LameEquation(Test_linearPDEs) Line 214  class Test_LameEquation(Test_linearPDEs)
214          k3Xk3=outer(k3,k3)          k3Xk3=outer(k3,k3)
215          A_ref=x[0]*k3Xk3          A_ref=x[0]*k3Xk3
216    
217          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
218          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
219          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
220          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
221          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
222          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
223          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
224          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
225          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
226          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
227          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
228          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
229          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
230          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
231          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
232          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
233          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
234          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
235          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
236          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
237          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")      
238          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
239            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
240    
241      def test_setCoefficient_mu(self):      def test_setCoefficient_mu(self):
242          mypde=LameEquation(self.domain,debug=self.DEBUG)          mypde=LameEquation(self.domain,debug=self.DEBUG)
# Line 258  class Test_LameEquation(Test_linearPDEs) Line 248  class Test_LameEquation(Test_linearPDEs)
248          k3Xk3=outer(k3,k3)          k3Xk3=outer(k3,k3)
249          A_ref=x[0]*(swap_axes(k3Xk3,0,3)+swap_axes(k3Xk3,1,3))          A_ref=x[0]*(swap_axes(k3Xk3,0,3)+swap_axes(k3Xk3,1,3))
250    
251          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
252          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
253          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
254          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
255          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
256          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
257          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
258          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
259          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
260          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
261          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
262          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
263          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
264          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
265          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
266          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
267          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
268          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
269          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
270          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
271          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")        
272          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
273            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
274    
275      def test_setCoefficient_lambdamu(self):      def test_setCoefficient_lambdamu(self):
276          mypde=LameEquation(self.domain,debug=self.DEBUG)          mypde=LameEquation(self.domain,debug=self.DEBUG)
# Line 290  class Test_LameEquation(Test_linearPDEs) Line 281  class Test_LameEquation(Test_linearPDEs)
281          k3Xk3=outer(k3,k3)          k3Xk3=outer(k3,k3)
282          A_ref=x[0]*k3Xk3+x[1]*(swap_axes(k3Xk3,0,3)+swap_axes(k3Xk3,1,3))          A_ref=x[0]*k3Xk3+x[1]*(swap_axes(k3Xk3,0,3)+swap_axes(k3Xk3,1,3))
283    
284          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
285          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
286          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
287          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
288          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
289          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
290          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
291          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
292          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
293          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
294          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
295          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
296          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
297          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
298          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
299          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
300          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
301          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
302          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
303          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
304          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
305          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
306            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
307    
308      def test_solve(self):      def test_solve(self):
309         d=self.domain.getDim()         d=self.domain.getDim()
# Line 324  class Test_LameEquation(Test_linearPDEs) Line 316  class Test_LameEquation(Test_linearPDEs)
316         mypde.setValue(q=msk,r=u_ex,lame_mu=3,lame_lambda=50,f=(2*3+50*d)*FunctionOnBoundary(self.domain).getNormal())         mypde.setValue(q=msk,r=u_ex,lame_mu=3,lame_lambda=50,f=(2*3+50*d)*FunctionOnBoundary(self.domain).getNormal())
317    
318         u=mypde.getSolution()         u=mypde.getSolution()
319         self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution")         self.assertTrue(self.check(u,u_ex,10*self.TOL),"incorrect solution")
320    
321  class Test_Helmholtz(Test_linearPDEs):  class Test_Helmholtz(Test_linearPDEs):
322    
323      def test_config(self):      def test_config(self):
324          mypde=Helmholtz(self.domain,debug=self.DEBUG)          mypde=Helmholtz(self.domain,debug=self.DEBUG)
325          self.failUnlessEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(1,1,True),"set up incorrect")          self.assertEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(1,1,True),"set up incorrect")
326      def test_setCoefficient_q(self):      def test_setCoefficient_q(self):
327          mypde=Helmholtz(self.domain,debug=self.DEBUG)          mypde=Helmholtz(self.domain,debug=self.DEBUG)
328          x=self.domain.getX()          x=self.domain.getX()
# Line 339  class Test_Helmholtz(Test_linearPDEs): Line 331  class Test_Helmholtz(Test_linearPDEs):
331          q_ref=interpolate(whereZero(x[0]),Solution(self.domain))          q_ref=interpolate(whereZero(x[0]),Solution(self.domain))
332          A_ref=kronecker(self.domain)          A_ref=kronecker(self.domain)
333    
334          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
335          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
336          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
337          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
338          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
339          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
340          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
341          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
342          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
343          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
344          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
345          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
346          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
347          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
348          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
349          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
350          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
351          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
352          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
353          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
354          self.failUnless(self.check(mypde.getCoefficient("q"),q_ref),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")      
355          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(self.check(mypde.getCoefficient("q"),q_ref),"q is not empty")
356            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
357    
358      def test_setCoefficient_r(self):      def test_setCoefficient_r(self):
359          mypde=Helmholtz(self.domain,debug=self.DEBUG)          mypde=Helmholtz(self.domain,debug=self.DEBUG)
# Line 369  class Test_Helmholtz(Test_linearPDEs): Line 362  class Test_Helmholtz(Test_linearPDEs):
362    
363          r_ref=interpolate(x[0],Solution(self.domain))          r_ref=interpolate(x[0],Solution(self.domain))
364          A_ref=kronecker(self.domain)          A_ref=kronecker(self.domain)
365          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
366          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
367          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
368          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
369          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
370          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
371          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
372          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
373          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
374          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
375          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
376          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
377          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
378          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
379          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
380          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
381          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
382          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
383          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
384          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
385          self.failUnless(self.check(mypde.getCoefficient("r"),r_ref),"r is nor x[0]")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
386          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")          self.assertTrue(self.check(mypde.getCoefficient("r"),r_ref),"r is nor x[0]")
387            self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
388    
389    
390      def test_setCoefficient_f(self):      def test_setCoefficient_f(self):
# Line 400  class Test_Helmholtz(Test_linearPDEs): Line 394  class Test_Helmholtz(Test_linearPDEs):
394    
395          Y_ref=interpolate(x[0],Function(self.domain))          Y_ref=interpolate(x[0],Function(self.domain))
396          A_ref=kronecker(self.domain)          A_ref=kronecker(self.domain)
397          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
398          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
399          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
400          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
401          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
402          self.failUnless(self.check(mypde.getCoefficient("Y"),Y_ref),"Y is not x[0]")          self.assertTrue(self.check(mypde.getCoefficient("Y"),Y_ref),"Y is not x[0]")
403          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
404          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
405          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
406          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
407          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
408          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
409          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
410          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
411          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
412          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
413          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
414          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
415          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
416          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
417          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")      
418          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
419            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
420    
421      def test_setCoefficient_alpha(self):      def test_setCoefficient_alpha(self):
422          mypde=Helmholtz(self.domain,debug=self.DEBUG)          mypde=Helmholtz(self.domain,debug=self.DEBUG)
# Line 430  class Test_Helmholtz(Test_linearPDEs): Line 425  class Test_Helmholtz(Test_linearPDEs):
425    
426          d_ref=interpolate(x[0],FunctionOnBoundary(self.domain))          d_ref=interpolate(x[0],FunctionOnBoundary(self.domain))
427          A_ref=kronecker(self.domain)          A_ref=kronecker(self.domain)
428          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
429          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
430          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
431          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
432          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
433          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
434          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
435          self.failUnless(self.check(mypde.getCoefficient("d"),d_ref),"d is not x[0]")          self.assertTrue(self.check(mypde.getCoefficient("d"),d_ref),"d is not x[0]")
436          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
437          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
438          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
439          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
440          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
441          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"X_reduced is not empty")
442          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
443          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
444          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
445          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
446          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
447          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
448          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")      
449          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
450            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
451    
452      def test_setCoefficient_g(self):      def test_setCoefficient_g(self):
453          mypde=Helmholtz(self.domain,debug=self.DEBUG)          mypde=Helmholtz(self.domain,debug=self.DEBUG)
# Line 460  class Test_Helmholtz(Test_linearPDEs): Line 456  class Test_Helmholtz(Test_linearPDEs):
456    
457          y_ref=interpolate(x[0],FunctionOnBoundary(self.domain))          y_ref=interpolate(x[0],FunctionOnBoundary(self.domain))
458          A_ref=kronecker(self.domain)          A_ref=kronecker(self.domain)
459          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
460          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
461          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
462          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
463          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
464          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
465          self.failUnless(self.check(mypde.getCoefficient("y"),y_ref),"y is not x[0]")          self.assertTrue(self.check(mypde.getCoefficient("y"),y_ref),"y is not x[0]")
466          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
467          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
468          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
469          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
470          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
471          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
472          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
473          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
474          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
475          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
476          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
477          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
478          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
479          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")      
480          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
481            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
482    
483      def test_setCoefficient_omega(self):      def test_setCoefficient_omega(self):
484          mypde=Helmholtz(self.domain,debug=self.DEBUG)          mypde=Helmholtz(self.domain,debug=self.DEBUG)
# Line 490  class Test_Helmholtz(Test_linearPDEs): Line 487  class Test_Helmholtz(Test_linearPDEs):
487    
488          D_ref=interpolate(x[0],Function(self.domain))          D_ref=interpolate(x[0],Function(self.domain))
489          A_ref=kronecker(self.domain)          A_ref=kronecker(self.domain)
490          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
491          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
492          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
493          self.failUnless(self.check(mypde.getCoefficient("D"),D_ref),"D is not x[0]")          self.assertTrue(self.check(mypde.getCoefficient("D"),D_ref),"D is not x[0]")
494          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
495          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
496          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
497          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
498          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
499          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
500          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
501          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
502          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
503          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
504          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
505          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
506          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
507          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
508          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
509          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
510          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")        
511          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
512            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
513    
514      def test_solve(self):      def test_solve(self):
515         d=self.domain.getDim()         d=self.domain.getDim()
# Line 520  class Test_Helmholtz(Test_linearPDEs): Line 518  class Test_Helmholtz(Test_linearPDEs):
518         mypde=Helmholtz(self.domain)         mypde=Helmholtz(self.domain)
519         mypde.setValue(f=3,omega=3,alpha=2,g=2)         mypde.setValue(f=3,omega=3,alpha=2,g=2)
520         u=mypde.getSolution()         u=mypde.getSolution()
521         self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution")         self.assertTrue(self.check(u,u_ex,10*self.TOL),"incorrect solution")
522    
523  class Test_Poisson(Test_linearPDEs):  class Test_Poisson(Test_linearPDEs):
524    
525      def test_config(self):      def test_config(self):
526          mypde=Poisson(self.domain,debug=self.DEBUG)          mypde=Poisson(self.domain,debug=self.DEBUG)
527          self.failUnlessEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(1,1,True),"set up incorrect")          self.assertEqual((mypde.getNumEquations(), mypde.getNumSolutions(), mypde.getSolverOptions().isSymmetric()),(1,1,True),"set up incorrect")
528      def test_setCoefficient_q(self):      def test_setCoefficient_q(self):
529          mypde=Poisson(self.domain,debug=self.DEBUG)          mypde=Poisson(self.domain,debug=self.DEBUG)
530          x=self.domain.getX()          x=self.domain.getX()
531          q_ref=interpolate(whereZero(x[0]),Solution(self.domain))          q_ref=interpolate(whereZero(x[0]),Solution(self.domain))
532          A_ref=kronecker(self.domain)          A_ref=kronecker(self.domain)
533          mypde.setValue(q=whereZero(x[0]))          mypde.setValue(q=whereZero(x[0]))
534          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
535          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
536          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
537          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
538          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
539          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
540          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
541          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
542          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
543          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
544          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
545          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
546          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
547          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
548          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
549          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
550          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
551          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
552          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
553          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
554          self.failUnless(self.check(mypde.getCoefficient("q"),q_ref),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
555          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(self.check(mypde.getCoefficient("q"),q_ref),"q is not empty")
556            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
557      def test_setCoefficient_f(self):      def test_setCoefficient_f(self):
558          mypde=Poisson(self.domain,debug=self.DEBUG)          mypde=Poisson(self.domain,debug=self.DEBUG)
559          x=self.domain.getX()          x=self.domain.getX()
560          Y_ref=interpolate(x[0],Function(self.domain))          Y_ref=interpolate(x[0],Function(self.domain))
561          A_ref=kronecker(self.domain)          A_ref=kronecker(self.domain)
562          mypde.setValue(f=x[0])          mypde.setValue(f=x[0])
563          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
564          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
565          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
566          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
567          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
568          self.failUnless(self.check(mypde.getCoefficient("Y"),Y_ref),"Y is not x[0]")          self.assertTrue(self.check(mypde.getCoefficient("Y"),Y_ref),"Y is not x[0]")
569          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
570          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
571          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
572          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
573          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
574          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
575          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
576          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")
577          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
578          self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
579          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
580          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
581          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
582          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
583          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")
584          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
585            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
586      def test_setCoefficient_f_reduced(self):      def test_setCoefficient_f_reduced(self):
587          mypde=Poisson(self.domain,debug=self.DEBUG)          mypde=Poisson(self.domain,debug=self.DEBUG)
588          x=self.domain.getX()          x=self.domain.getX()
589          Y_ref=interpolate(x[0],ReducedFunction(self.domain))          Y_ref=interpolate(x[0],ReducedFunction(self.domain))
590          A_ref=kronecker(self.domain)          A_ref=kronecker(self.domain)
591          mypde.setValue(f_reduced=x[0])          mypde.setValue(f_reduced=x[0])
592          self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")          self.assertTrue(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker")
593          self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty")          self.assertTrue(mypde.getCoefficient("B").isEmpty(),"B is not empty")
594          self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty")          self.assertTrue(mypde.getCoefficient("C").isEmpty(),"C is not empty")
595          self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty")          self.assertTrue(mypde.getCoefficient("D").isEmpty(),"D is not empty")
596          self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty")          self.assertTrue(mypde.getCoefficient("X").isEmpty(),"X is not empty")
597          self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")          self.assertTrue(mypde.getCoefficient("Y").isEmpty(),"Y is not empty")
598          self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty")          self.assertTrue(mypde.getCoefficient("y").isEmpty(),"y is not empty")
599          self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty")          self.assertTrue(mypde.getCoefficient("d").isEmpty(),"d is not empty")
600          self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")          self.assertTrue(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")
601          self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")          self.assertTrue(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")
602          self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty")          self.assertTrue(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")
603          self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty")          self.assertTrue(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")
604          self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty")          self.assertTrue(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")
605          self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty")          self.assertTrue(self.check(mypde.getCoefficient("Y_reduced"),Y_ref),"Y_reduced is not x[0]")
606          self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty")          self.assertTrue(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")
607          self.failUnless(self.check(mypde.getCoefficient("Y_reduced"),Y_ref),"Y_reduced is not x[0]")          self.assertTrue(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")
608          self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty")          if self.domain.supportsContactElements():
609          self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")
610          self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")
611          self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty")              self.assertTrue(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty")
612          self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty")              self.assertTrue(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty")        
613          self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty")          self.assertTrue(mypde.getCoefficient("q").isEmpty(),"q is not empty")
614            self.assertTrue(mypde.getCoefficient("r").isEmpty(),"r is not empty")
615      def test_solve(self):      def test_solve(self):
616         d=self.domain.getDim()         d=self.domain.getDim()
617         cf=ContinuousFunction(self.domain)         cf=ContinuousFunction(self.domain)
# Line 636  class Test_Poisson(Test_linearPDEs): Line 637  class Test_Poisson(Test_linearPDEs):
637         mypde=Poisson(self.domain)         mypde=Poisson(self.domain)
638         mypde.setValue(f=f,q=msk)         mypde.setValue(f=f,q=msk)
639         u=mypde.getSolution()         u=mypde.getSolution()
640         self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution")         self.assertTrue(self.check(u,u_ex,10*self.TOL),"incorrect solution")
641    
642  class Test_LinearPDE_noLumping(Test_linearPDEs):  class Test_LinearPDE_noLumping(Test_linearPDEs):
643      N=4      N=4
644      def test_SolverOptions(self):      def test_SolverOptions(self):
645          so=SolverOptions()          so=SolverOptions()
646            
647            self.assertTrue(so.getSmoother() == 28, "initial Smoother is wrong.")
648            self.assertRaises(ValueError,so.setSmoother,-1)
649            so.setSmoother(so.GAUSS_SEIDEL)
650            self.assertTrue(so.getSmoother() == 28, "Gauss-Seidel smoother is not set.")
651            so.setSmoother(so.JACOBI)
652            self.assertTrue(so.getSmoother() == 10, "Jacobi smoother is not set.")
653    
654            self.assertTrue(so.getLevelMax() == 100, "initial  LevelMax is wrong.")
655            self.assertRaises(ValueError,so.setLevelMax,-1)
656            so.setLevelMax(20)
657            self.assertTrue(so.getLevelMax() == 20, "LevelMax is wrong.")
658    
659          self.failUnless(so.getLevelMax() == 10, "initial  LevelMax is wrong.")          self.assertTrue(so.getCoarseningThreshold() == 0.25, "initial  CoarseningThreshold is wrong.")
660          self.failUnlessRaises(ValueError,so.setLevelMax,-1)          self.assertRaises(ValueError,so.setCoarseningThreshold,-1)
         so.setLevelMax(3)  
         self.failUnless(so.getLevelMax() == 3, "LevelMax is wrong.")  
   
         self.failUnless(so.getCoarseningThreshold() == 0.05, "initial  CoarseningThreshold is wrong.")  
         self.failUnlessRaises(ValueError,so.setCoarseningThreshold,-1)  
661          so.setCoarseningThreshold(0.1)          so.setCoarseningThreshold(0.1)
662          self.failUnless(so.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")          self.assertTrue(so.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")
663                    
664          self.failUnless(so.getMinCoarseMatrixSize() == 500, "initial  Minimum Coarse Matrix Size is wrong.")          self.assertTrue(so.getMinCoarseMatrixSize() == 500, "initial  Minimum Coarse Matrix Size is wrong.")
665          self.failUnlessRaises(ValueError,so.setMinCoarseMatrixSize,-1)          self.assertRaises(ValueError,so.setMinCoarseMatrixSize,-1)
666          so.setMinCoarseMatrixSize(1000)          so.setMinCoarseMatrixSize(1000)
667          self.failUnless(so.getMinCoarseMatrixSize() == 1000, "Minimum Coarse Matrix Size is wrong.")          self.assertTrue(so.getMinCoarseMatrixSize() == 1000, "Minimum Coarse Matrix Size is wrong.")
668    
669          self.failUnless(so.getNumSweeps() == 2, "initial  Sweeps is wrong.")          self.assertTrue(so.getNumSweeps() == 1, "initial  Sweeps is wrong.")
670          self.failUnlessRaises(ValueError,so.setNumSweeps,-1)          self.assertRaises(ValueError,so.setNumSweeps,-1)
671          so.setNumSweeps(3)          so.setNumSweeps(3)
672          self.failUnless(so.getNumSweeps() == 3, "Sweeps is wrong.")          self.assertTrue(so.getNumSweeps() == 3, "Sweeps is wrong.")
673    
674          self.failUnless(so.getNumPreSweeps() == 2, "initial  PreSweeps is wrong.")          self.assertTrue(so.getNumPreSweeps() == 1, "initial  PreSweeps is wrong.")
675          self.failUnlessRaises(ValueError,so.setNumPreSweeps,-1)          self.assertRaises(ValueError,so.setNumPreSweeps,-1)
676          so.setNumPreSweeps(4)          so.setNumPreSweeps(4)
677          self.failUnless(so.getNumPreSweeps() == 4, "PreSweeps is wrong.")          self.assertTrue(so.getNumPreSweeps() == 4, "PreSweeps is wrong.")
678    
679          self.failUnless(so.getNumPostSweeps() == 2, "initial  PreSweeps is wrong.")          self.assertTrue(so.getNumPostSweeps() == 1, "initial  PostSweeps is wrong.")
680          self.failUnlessRaises(ValueError,so.setNumPostSweeps,-1)          self.assertRaises(ValueError,so.setNumPostSweeps,-1)
681          so.setNumPostSweeps(5)          so.setNumPostSweeps(5)
682          self.failUnless(so.getNumPostSweeps() == 5, "PreSweeps is wrong.")          self.assertTrue(so.getNumPostSweeps() == 5, "PostSweeps is wrong.")
683    
684          self.failUnless(so.getTolerance() == 1.e-8, "initial Tolerance is wrong.")          self.assertTrue(so.getTolerance() == 1.e-8, "initial Tolerance is wrong.")
685          self.failUnlessRaises(ValueError,so.setTolerance,-1)          self.assertRaises(ValueError,so.setTolerance,-1)
686          so.setTolerance(0.2)          so.setTolerance(0.2)
687          self.failUnless(so.getTolerance() == 0.2, "Tolerance is wrong.")          self.assertTrue(so.getTolerance() == 0.2, "Tolerance is wrong.")
688    
689          self.failUnless(so.getAbsoluteTolerance() == 0., "initial  AbsoluteTolerance is wrong.")          self.assertTrue(so.getAbsoluteTolerance() == 0., "initial  AbsoluteTolerance is wrong.")
690          self.failUnlessRaises(ValueError,so.setAbsoluteTolerance,-1)          self.assertRaises(ValueError,so.setAbsoluteTolerance,-1)
691          so.setAbsoluteTolerance(0.3)          so.setAbsoluteTolerance(0.3)
692          self.failUnless(so.getAbsoluteTolerance() == 0.3, "AbsoluteTolerance is wrong.")          self.assertTrue(so.getAbsoluteTolerance() == 0.3, "AbsoluteTolerance is wrong.")
693    
694          self.failUnless(so.getInnerTolerance() == 0.9, "initial InnerTolerance is wrong.")          self.assertTrue(so.getInnerTolerance() == 0.9, "initial InnerTolerance is wrong.")
695          self.failUnlessRaises(ValueError,so.setInnerTolerance,-1)          self.assertRaises(ValueError,so.setInnerTolerance,-1)
696          so.setInnerTolerance(0.4)          so.setInnerTolerance(0.4)
697          self.failUnless(so.getInnerTolerance() == 0.4, "InnerTolerance is wrong.")          self.assertTrue(so.getInnerTolerance() == 0.4, "InnerTolerance is wrong.")
698    
699          self.failUnless(so.getDropTolerance() == 0.01, "initial DropTolerance is wrong.")          self.assertTrue(so.getDropTolerance() == 0.01, "initial DropTolerance is wrong.")
700          self.failUnlessRaises(ValueError,so.setDropTolerance,-1)          self.assertRaises(ValueError,so.setDropTolerance,-1)
701          so.setDropTolerance(0.5)          so.setDropTolerance(0.5)
702          self.failUnless(so.getDropTolerance() == 0.5, "DropDropTolerance is wrong.")          self.assertTrue(so.getDropTolerance() == 0.5, "DropDropTolerance is wrong.")
703    
704          self.failUnless(so.getDropStorage() == 2., "initial DropStorage is wrong.")          self.assertTrue(so.getDropStorage() == 2., "initial DropStorage is wrong.")
705          self.failUnlessRaises(ValueError,so.setDropStorage,-1)          self.assertRaises(ValueError,so.setDropStorage,-1)
706          so.setDropStorage(10)          so.setDropStorage(10)
707          self.failUnless(so.getDropStorage() == 10, "DropStorage is wrong.")          self.assertTrue(so.getDropStorage() == 10, "DropStorage is wrong.")
708                    
709          self.failUnless(so.getRelaxationFactor() == 0.3, "initial RelaxationFactor is wrong.")          self.assertTrue(so.getRelaxationFactor() == 0.3, "initial RelaxationFactor is wrong.")
710          self.failUnlessRaises(ValueError,so.setRelaxationFactor,-1)          self.assertRaises(ValueError,so.setRelaxationFactor,-1)
711          so.setRelaxationFactor(0.1)          so.setRelaxationFactor(0.1)
712          self.failUnless(so.getRelaxationFactor() == 0.1, "Relaxation is wrong.")          self.assertTrue(so.getRelaxationFactor() == 0.1, "Relaxation is wrong.")
713    
714    
715          self.failUnless(so.getIterMax() == 100000, "initial IterMax is wrong.")          self.assertTrue(so.getIterMax() == 100000, "initial IterMax is wrong.")
716          self.failUnlessRaises(ValueError,so.setIterMax,0)          self.assertRaises(ValueError,so.setIterMax,0)
717          so.setIterMax(11)          so.setIterMax(11)
718          self.failUnless(so.getIterMax() == 11, "IterMax is wrong.")          self.assertTrue(so.getIterMax() == 11, "IterMax is wrong.")
719    
720          self.failUnless(so.getInnerIterMax() == 10, "initial InnerIterMax is wrong.")          self.assertTrue(so.getInnerIterMax() == 10, "initial InnerIterMax is wrong.")
721          self.failUnlessRaises(ValueError,so.setInnerIterMax,0)          self.assertRaises(ValueError,so.setInnerIterMax,0)
722          so.setInnerIterMax(12)          so.setInnerIterMax(12)
723          self.failUnless(so.getInnerIterMax() == 12, "InnerIterMax is wrong.")          self.assertTrue(so.getInnerIterMax() == 12, "InnerIterMax is wrong.")
724    
725          self.failUnless(so.getTruncation() == 20, "initial Truncation is wrong.")          self.assertTrue(so.getTruncation() == 20, "initial Truncation is wrong.")
726          self.failUnlessRaises(ValueError,so.setTruncation,0)          self.assertRaises(ValueError,so.setTruncation,0)
727          so.setTruncation(13)          so.setTruncation(13)
728          self.failUnless(so.getTruncation() == 13, "Truncation is wrong.")          self.assertTrue(so.getTruncation() == 13, "Truncation is wrong.")
729    
730          self.failUnless(so.getRestart() == None, "initial Truncation is wrong.")          self.assertTrue(so.getRestart() == None, "initial Truncation is wrong.")
731          self.failUnlessRaises(ValueError,so.setTruncation,0)          self.assertRaises(ValueError,so.setTruncation,0)
732          so.setRestart(14)          so.setRestart(14)
733          self.failUnless(so.getRestart() == 14, "Truncation is wrong.")          self.assertTrue(so.getRestart() == 14, "Truncation is wrong.")
734          so.setRestart(None)          so.setRestart(None)
735          self.failUnless(so.getRestart() == None, "Truncation is wrong.")          self.assertTrue(so.getRestart() == None, "Truncation is wrong.")
736                
737          self.failUnless(not so.isVerbose(), "initial verbosity flag is wrong.")          self.assertTrue(not so.isVerbose(), "initial verbosity flag is wrong.")
738          so.setVerbosityOn()          so.setVerbosityOn()
739          self.failUnless(so.isVerbose(), "verbosity (1) flag is wrong.")          self.assertTrue(so.isVerbose(), "verbosity (1) flag is wrong.")
740          so.setVerbosityOff()          so.setVerbosityOff()
741          self.failUnless(not so.isVerbose(), "verbosity (2) flag is wrong.")          self.assertTrue(not so.isVerbose(), "verbosity (2) flag is wrong.")
742          so.setVerbosity(verbose=True)          so.setVerbosity(verbose=True)
743          self.failUnless(so.isVerbose(), "verbosity (3) flag is wrong.")          self.assertTrue(so.isVerbose(), "verbosity (3) flag is wrong.")
744          so.setVerbosity(verbose=False)          so.setVerbosity(verbose=False)
745          self.failUnless(not so.isVerbose(), "verbosity (4) flag is wrong.")          self.assertTrue(not so.isVerbose(), "verbosity (4) flag is wrong.")
746    
747          self.failUnless(not so.isSymmetric(), "initial symmetry flag is wrong.")          self.assertTrue(not so.isSymmetric(), "initial symmetry flag is wrong.")
748          so.setSymmetryOn()          so.setSymmetryOn()
749          self.failUnless(so.isSymmetric(), "symmetry (1) flag is wrong.")          self.assertTrue(so.isSymmetric(), "symmetry (1) flag is wrong.")
750          so.setSymmetryOff()          so.setSymmetryOff()
751          self.failUnless(not so.isSymmetric(), "symmetry (2) flag is wrong.")          self.assertTrue(not so.isSymmetric(), "symmetry (2) flag is wrong.")
752          so.setSymmetry(flag=True)          so.setSymmetry(flag=True)
753          self.failUnless(so.isSymmetric(), "symmetry (3) flag is wrong.")          self.assertTrue(so.isSymmetric(), "symmetry (3) flag is wrong.")
754          so.setSymmetry(flag=False)          so.setSymmetry(flag=False)
755          self.failUnless(not so.isSymmetric(), "symmetry (4) flag is wrong.")          self.assertTrue(not so.isSymmetric(), "symmetry (4) flag is wrong.")
756    
757          self.failUnless(so.adaptInnerTolerance(), "initial InnerToleranceAdaption flag is wrong.")          self.assertTrue(so.adaptInnerTolerance(), "initial InnerToleranceAdaption flag is wrong.")
758          so.setInnerToleranceAdaptionOn()          so.setInnerToleranceAdaptionOn()
759          self.failUnless(so.adaptInnerTolerance(), "InnerToleranceAdaption (1) flag is wrong.")          self.assertTrue(so.adaptInnerTolerance(), "InnerToleranceAdaption (1) flag is wrong.")
760          so.setInnerToleranceAdaptionOff()          so.setInnerToleranceAdaptionOff()
761          self.failUnless(not so.adaptInnerTolerance(), "InnerToleranceAdaption (2) flag is wrong.")          self.assertTrue(not so.adaptInnerTolerance(), "InnerToleranceAdaption (2) flag is wrong.")
762          so.setInnerToleranceAdaption(adapt=True)          so.setInnerToleranceAdaption(adapt=True)
763          self.failUnless(so.adaptInnerTolerance(), "InnerToleranceAdaption (3) flag is wrong.")          self.assertTrue(so.adaptInnerTolerance(), "InnerToleranceAdaption (3) flag is wrong.")
764          so.setInnerToleranceAdaption(adapt=False)          so.setInnerToleranceAdaption(adapt=False)
765          self.failUnless(not so.adaptInnerTolerance(), "InnerToleranceAdaption (4) flag is wrong.")          self.assertTrue(not so.adaptInnerTolerance(), "InnerToleranceAdaption (4) flag is wrong.")
766            
767          self.failUnless(not so.acceptConvergenceFailure(), "initial acceptConvergenceFailure flag is wrong.")          self.assertTrue(not so.acceptConvergenceFailure(), "initial acceptConvergenceFailure flag is wrong.")
768          so.setAcceptanceConvergenceFailureOn()          so.setAcceptanceConvergenceFailureOn()
769          self.failUnless(so.acceptConvergenceFailure(), "acceptConvergenceFailure (1) flag is wrong.")          self.assertTrue(so.acceptConvergenceFailure(), "acceptConvergenceFailure (1) flag is wrong.")
770          so.setAcceptanceConvergenceFailureOff()          so.setAcceptanceConvergenceFailureOff()
771          self.failUnless(not so.acceptConvergenceFailure(), "acceptConvergenceFailure (2) flag is wrong.")          self.assertTrue(not so.acceptConvergenceFailure(), "acceptConvergenceFailure (2) flag is wrong.")
772          so.setAcceptanceConvergenceFailure(accept=True)          so.setAcceptanceConvergenceFailure(accept=True)
773          self.failUnless(so.acceptConvergenceFailure(), "acceptConvergenceFailure (3) flag is wrong.")          self.assertTrue(so.acceptConvergenceFailure(), "acceptConvergenceFailure (3) flag is wrong.")
774          so.setAcceptanceConvergenceFailure(accept=False)          so.setAcceptanceConvergenceFailure(accept=False)
775          self.failUnless(not so.acceptConvergenceFailure(), "acceptConvergenceFailure (4) flag is wrong.")            self.assertTrue(not so.acceptConvergenceFailure(), "acceptConvergenceFailure (4) flag is wrong.")  
776                    
777          self.failUnless(so.getReordering() == 30, "initial Reordering is wrong.")          self.assertTrue(so.getReordering() == 30, "initial Reordering is wrong.")
778          self.failUnlessRaises(ValueError,so.setReordering,-1)          self.assertRaises(ValueError,so.setReordering,-1)
779          so.setReordering(so.NO_REORDERING)          so.setReordering(so.NO_REORDERING)
780          self.failUnless(so.getReordering() == 17, "NO_REORDERING is not set.")          self.assertTrue(so.getReordering() == 17, "NO_REORDERING is not set.")
781          so.setReordering(so.MINIMUM_FILL_IN)          so.setReordering(so.MINIMUM_FILL_IN)
782          self.failUnless(so.getReordering() == 18, "MINIMUM_FILL_IN is not set.")          self.assertTrue(so.getReordering() == 18, "MINIMUM_FILL_IN is not set.")
783          so.setReordering(so.NESTED_DISSECTION)          so.setReordering(so.NESTED_DISSECTION)
784          self.failUnless(so.getReordering() == 19, "NESTED_DISSECTION is not set.")          self.assertTrue(so.getReordering() == 19, "NESTED_DISSECTION is not set.")
785          so.setReordering(so.DEFAULT_REORDERING)          so.setReordering(so.DEFAULT_REORDERING)
786          self.failUnless(so.getReordering() == 30, "DEFAULT_REORDERING is not set.")          self.assertTrue(so.getReordering() == 30, "DEFAULT_REORDERING is not set.")
787                    
788          self.failUnless(so.getPackage() == 0, "initial solver package is wrong.")          self.assertTrue(so.getPackage() == 0, "initial solver package is wrong.")
789          self.failUnlessRaises(ValueError,so.setPackage,-1)          self.assertRaises(ValueError,so.setPackage,-1)
790          so.setPackage(so.PASO)          so.setPackage(so.PASO)
791          self.failUnless(so.getPackage() == 21, "PASO is not set.")          self.assertTrue(so.getPackage() == 21, "PASO is not set.")
792          so.setPackage(so.SUPER_LU)          so.setPackage(so.SUPER_LU)
793          self.failUnless(so.getPackage() == 31, "SUPER_LU is not set.")          self.assertTrue(so.getPackage() == 31, "SUPER_LU is not set.")
794          so.setPackage(so.PASTIX)          so.setPackage(so.PASTIX)
795          self.failUnless(so.getPackage() == 32, "PASTIX is not set.")          self.assertTrue(so.getPackage() == 32, "PASTIX is not set.")
796          so.setPackage(so.MKL)          so.setPackage(so.MKL)
797          self.failUnless(so.getPackage() == 15, "MKL is not set.")          self.assertTrue(so.getPackage() == 15, "MKL is not set.")
798          so.setPackage(so.UMFPACK)          so.setPackage(so.UMFPACK)
799          self.failUnless(so.getPackage() == 16, "UMFPACK is not set.")          self.assertTrue(so.getPackage() == 16, "UMFPACK is not set.")
800          so.setPackage(so.TRILINOS)          so.setPackage(so.TRILINOS)
801          self.failUnless(so.getPackage() == 24, "TRILINOS is not set.")          self.assertTrue(so.getPackage() == 24, "TRILINOS is not set.")
802    
803          self.failUnless(so.getSolverMethod() == 0, "initial SolverMethod is wrong.")          self.assertTrue(so.getSolverMethod() == 0, "initial SolverMethod is wrong.")
804          self.failUnlessRaises(ValueError,so.setSolverMethod,-1)          self.assertRaises(ValueError,so.setSolverMethod,-1)
805          so.setSolverMethod(so.DIRECT)          so.setSolverMethod(so.DIRECT)
806          self.failUnless(so.getSolverMethod() == 1, "DIRECT is not set.")          self.assertTrue(so.getSolverMethod() == 1, "DIRECT is not set.")
807          so.setSolverMethod(so.CHOLEVSKY)          so.setSolverMethod(so.CHOLEVSKY)
808          self.failUnless(so.getSolverMethod() == 2, "CHOLEVSKY is not set.")          self.assertTrue(so.getSolverMethod() == 2, "CHOLEVSKY is not set.")
809          so.setSolverMethod(so.PCG)          so.setSolverMethod(so.PCG)
810          self.failUnless(so.getSolverMethod() == 3, "PCG is not set.")          self.assertTrue(so.getSolverMethod() == 3, "PCG is not set.")
811          so.setSolverMethod(so.CR)          so.setSolverMethod(so.CR)
812          self.failUnless(so.getSolverMethod() == 4, "CR is not set.")          self.assertTrue(so.getSolverMethod() == 4, "CR is not set.")
813          so.setSolverMethod(so.CGS)          so.setSolverMethod(so.CGS)
814          self.failUnless(so.getSolverMethod() == 5, "CGS is not set.")          self.assertTrue(so.getSolverMethod() == 5, "CGS is not set.")
815          so.setSolverMethod(so.BICGSTAB)          so.setSolverMethod(so.BICGSTAB)
816          self.failUnless(so.getSolverMethod() == 6, "BICGSTAB is not set.")          self.assertTrue(so.getSolverMethod() == 6, "BICGSTAB is not set.")
         so.setSolverMethod(so.SSOR)  
         self.failUnless(so.getSolverMethod() == 7, "SSOR is not set.")  
817          so.setSolverMethod(so.GMRES)          so.setSolverMethod(so.GMRES)
818          self.failUnless(so.getSolverMethod() == 11, "GMRES is not set.")          self.assertTrue(so.getSolverMethod() == 11, "GMRES is not set.")
819          so.setSolverMethod(so.PRES20)          so.setSolverMethod(so.PRES20)
820          self.failUnless(so.getSolverMethod() == 12, "PRES20 is not set.")          self.assertTrue(so.getSolverMethod() == 12, "PRES20 is not set.")
821          so.setSolverMethod(so.LUMPING)          so.setSolverMethod(so.LUMPING)
822          self.failUnless(so.getSolverMethod() == 13, "LUMPING is not set.")          self.assertTrue(so.getSolverMethod() == 13, "LUMPING is not set.")
823          so.setSolverMethod(so.ITERATIVE)          so.setSolverMethod(so.ITERATIVE)
824          self.failUnless(so.getSolverMethod() == 20, "ITERATIVE is not set.")          self.assertTrue(so.getSolverMethod() == 20, "ITERATIVE is not set.")
         so.setSolverMethod(so.AMG)  
         self.failUnless(so.getSolverMethod() == 22, "AMG is not set.")  
825          so.setSolverMethod(so.NONLINEAR_GMRES)          so.setSolverMethod(so.NONLINEAR_GMRES)
826          self.failUnless(so.getSolverMethod() == 25, "NONLINEAR_GMRES is not set.")          self.assertTrue(so.getSolverMethod() == 25, "NONLINEAR_GMRES is not set.")
827          so.setSolverMethod(so.TFQMR)          so.setSolverMethod(so.TFQMR)
828          self.failUnless(so.getSolverMethod() == 26, "TFQMR is not set.")          self.assertTrue(so.getSolverMethod() == 26, "TFQMR is not set.")
829          so.setSolverMethod(so.MINRES)          so.setSolverMethod(so.MINRES)
830          self.failUnless(so.getSolverMethod() == 27, "MINRES is not set.")          self.assertTrue(so.getSolverMethod() == 27, "MINRES is not set.")
         so.setSolverMethod(so.GAUSS_SEIDEL)  
         self.failUnless(so.getSolverMethod() == 28, "GAUSS_SEIDEL is not set.")  
831          so.setSolverMethod(so.DEFAULT)          so.setSolverMethod(so.DEFAULT)
832          self.failUnless(so.getSolverMethod() == 0, "DEFAULT is not set.")          self.assertTrue(so.getSolverMethod() == 0, "DEFAULT is not set.")
833    
834          self.failUnless(so.getPreconditioner() == 10, "initial Preconditioner is wrong.")          self.assertTrue(so.getPreconditioner() == 10, "initial Preconditioner is wrong.")
835          self.failUnlessRaises(ValueError,so.setPreconditioner,-1)          self.assertRaises(ValueError,so.setPreconditioner,-1)
836          so.setPreconditioner(so.ILU0)          so.setPreconditioner(so.ILU0)
837          self.failUnless(so.getPreconditioner() == 8, "ILU0 is not set.")          self.assertTrue(so.getPreconditioner() == 8, "ILU0 is not set.")
         so.setPreconditioner(so.SSOR)  
         self.failUnless(so.getPreconditioner() == 7, "SSOR is not set.")  
838          so.setPreconditioner(so.ILUT)          so.setPreconditioner(so.ILUT)
839          self.failUnless(so.getPreconditioner() == 9, "ILUT is not set.")          self.assertTrue(so.getPreconditioner() == 9, "ILUT is not set.")
840          so.setPreconditioner(so.JACOBI)          so.setPreconditioner(so.JACOBI)
841          self.failUnless(so.getPreconditioner() == 10, "JACOBI is not set.")          self.assertTrue(so.getPreconditioner() == 10, "JACOBI is not set.")
842          so.setPreconditioner(so.AMG)          if getEscriptParamInt('DISABLE_AMG', 0):
843          self.failUnless(so.getPreconditioner() == 22, "AMG is not set.")          print("AMG test disabled on MPI build")
844        else:
845                so.setPreconditioner(so.AMG)
846                self.assertTrue(so.getPreconditioner() == 22, "AMG is not set.")
847          so.setPreconditioner(so.REC_ILU)          so.setPreconditioner(so.REC_ILU)
848          self.failUnless(so.getPreconditioner() == 23, "REC_ILU is not set.")          self.assertTrue(so.getPreconditioner() == 23, "REC_ILU is not set.")
849          so.setPreconditioner(so.GAUSS_SEIDEL)          so.setPreconditioner(so.GAUSS_SEIDEL)
850          self.failUnless(so.getPreconditioner() == 28, "GAUSS_SEIDEL is not set.")          self.assertTrue(so.getPreconditioner() == 28, "GAUSS_SEIDEL is not set.")
851          so.setPreconditioner(so.RILU)          so.setPreconditioner(so.RILU)
852          self.failUnless(so.getPreconditioner() == 29, "RILU is not set.")          self.assertTrue(so.getPreconditioner() == 29, "RILU is not set.")
853            so.setPreconditioner(so.AMLI)
854            self.assertTrue(so.getPreconditioner() == 38, "AMLI is not set.")
855          so.setPreconditioner(so.NO_PRECONDITIONER)          so.setPreconditioner(so.NO_PRECONDITIONER)
856          self.failUnless(so.getPreconditioner() == 36, "NO_PRECONDITIONER is not set.")                  self.assertTrue(so.getPreconditioner() == 36, "NO_PRECONDITIONER is not set.")        
857    
858          self.failUnless(so.getCoarsening() == 0, "initial Coarseningr is wrong.")          self.assertTrue(so.getCoarsening() == 0, "initial Coarseningr is wrong.")
859          self.failUnlessRaises(ValueError,so.setCoarsening,-1)          self.assertRaises(ValueError,so.setCoarsening,-1)
860          so.setCoarsening(so.YAIR_SHAPIRA_COARSENING)          so.setCoarsening(so.YAIR_SHAPIRA_COARSENING)
861          self.failUnless(so.getCoarsening() == 33, "YAIR_SHAPIRA_COARSENING is not set.")          self.assertTrue(so.getCoarsening() == 33, "YAIR_SHAPIRA_COARSENING is not set.")
862          so.setCoarsening(so.RUGE_STUEBEN_COARSENING)          so.setCoarsening(so.RUGE_STUEBEN_COARSENING)
863          self.failUnless(so.getCoarsening() == 34, "RUGE_STUEBEN_COARSENING is not set.")          self.assertTrue(so.getCoarsening() == 34, "RUGE_STUEBEN_COARSENING is not set.")
864          so.setCoarsening(so.AGGREGATION_COARSENING)          so.setCoarsening(so.AGGREGATION_COARSENING)
865          self.failUnless(so.getCoarsening() == 35, "AGREGATION_COARSENING is not set.")          self.assertTrue(so.getCoarsening() == 35, "AGREGATION_COARSENING is not set.")
866            so.setCoarsening(so.STANDARD_COARSENING)
867            self.assertTrue(so.getCoarsening() == 39, "STANDARD_COARSENING is not set.")
868          so.setCoarsening(so.DEFAULT)          so.setCoarsening(so.DEFAULT)
869          self.failUnless(so.getCoarsening() == 0, "DEFAULT is not set.")          self.assertTrue(so.getCoarsening() == 0, "DEFAULT is not set.")
870    
871          self.failUnless(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")          self.assertTrue(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")
872          self.failUnless(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")          self.assertTrue(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")
873          self.failUnless(so.getDiagnostics("time") == None, "initial time is wrong.")          self.assertTrue(so.getDiagnostics("time") == None, "initial time is wrong.")
874          self.failUnless(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")          self.assertTrue(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")
875          self.failUnless(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")          self.assertTrue(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")
876          self.failUnless(so.getDiagnostics("converged") == None, "initial converged is wrong.")          self.assertTrue(so.getDiagnostics("converged") == None, "initial converged is wrong.")
877          self.failUnless(so.hasConverged() == None, "initial convergence flag is wrong.")          self.assertTrue(so.hasConverged() == None, "initial convergence flag is wrong.")
878          self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")          self.assertTrue(so.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")
879          self.failUnless(so.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")          self.assertTrue(so.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")
880          self.failUnless(so.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")          self.assertTrue(so.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")
881          self.failUnless(so.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")          self.assertTrue(so.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")
882    
883          so._updateDiagnostics("num_iter",1)          so._updateDiagnostics("num_iter",1)
884          so._updateDiagnostics("num_inner_iter",2)          so._updateDiagnostics("num_inner_iter",2)
# Line 880  class Test_LinearPDE_noLumping(Test_line Line 887  class Test_LinearPDE_noLumping(Test_line
887          so._updateDiagnostics("residual_norm",5)          so._updateDiagnostics("residual_norm",5)
888          so._updateDiagnostics("converged",True)          so._updateDiagnostics("converged",True)
889    
890          self.failUnless(so.getDiagnostics("num_iter") == 1, "num_iter is wrong.")          self.assertTrue(so.getDiagnostics("num_iter") == 1, "num_iter is wrong.")
891          self.failUnless(so.getDiagnostics("num_inner_iter") == 2, "num_inner_iter is wrong.")          self.assertTrue(so.getDiagnostics("num_inner_iter") == 2, "num_inner_iter is wrong.")
892          self.failUnless(so.getDiagnostics("time") == 3, "time is wrong.")          self.assertTrue(so.getDiagnostics("time") == 3, "time is wrong.")
893          self.failUnless(so.getDiagnostics("set_up_time") == 4, "set_up_time is wrong.")          self.assertTrue(so.getDiagnostics("set_up_time") == 4, "set_up_time is wrong.")
894          self.failUnless(so.getDiagnostics("residual_norm") == 5, "residual_norm is wrong.")          self.assertTrue(so.getDiagnostics("residual_norm") == 5, "residual_norm is wrong.")
895          self.failUnless(so.getDiagnostics("converged"), "converged is wrong.")          self.assertTrue(so.getDiagnostics("converged"), "converged is wrong.")
896          self.failUnless(so.hasConverged(), "convergence flag is wrong.")          self.assertTrue(so.hasConverged(), "convergence flag is wrong.")
897          self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")          self.assertTrue(so.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")
898          self.failUnless(so.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")          self.assertTrue(so.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")
899          self.failUnless(so.getDiagnostics("cum_time") ==3, "cum_time is wrong.")          self.assertTrue(so.getDiagnostics("cum_time") ==3, "cum_time is wrong.")
900          self.failUnless(so.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")            self.assertTrue(so.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")  
901                    
902          so.resetDiagnostics()          so.resetDiagnostics()
903          self.failUnless(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")          self.assertTrue(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")
904          self.failUnless(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")          self.assertTrue(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")
905          self.failUnless(so.getDiagnostics("time") == None, "initial time is wrong.")          self.assertTrue(so.getDiagnostics("time") == None, "initial time is wrong.")
906          self.failUnless(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")          self.assertTrue(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")
907          self.failUnless(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")          self.assertTrue(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")
908          self.failUnless(so.getDiagnostics("converged") == None, "initial converged is wrong.")          self.assertTrue(so.getDiagnostics("converged") == None, "initial converged is wrong.")
909          self.failUnless(so.hasConverged() == None, "initial convergence flag is wrong")                self.assertTrue(so.hasConverged() == None, "initial convergence flag is wrong")      
910          self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")          self.assertTrue(so.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")
911          self.failUnless(so.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")          self.assertTrue(so.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")
912          self.failUnless(so.getDiagnostics("cum_time") ==3, "cum_time is wrong.")          self.assertTrue(so.getDiagnostics("cum_time") ==3, "cum_time is wrong.")
913          self.failUnless(so.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")          self.assertTrue(so.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")
914    
915          so._updateDiagnostics("num_iter",10)          so._updateDiagnostics("num_iter",10)
916          so._updateDiagnostics("num_inner_iter",20)          so._updateDiagnostics("num_inner_iter",20)
# Line 912  class Test_LinearPDE_noLumping(Test_line Line 919  class Test_LinearPDE_noLumping(Test_line
919          so._updateDiagnostics("residual_norm",50)          so._updateDiagnostics("residual_norm",50)
920          so._updateDiagnostics("converged",False)          so._updateDiagnostics("converged",False)
921    
922          self.failUnless(so.getDiagnostics("num_iter") == 10, "num_iter is wrong.")          self.assertTrue(so.getDiagnostics("num_iter") == 10, "num_iter is wrong.")
923          self.failUnless(so.getDiagnostics("num_inner_iter") == 20, "num_inner_iter is wrong.")          self.assertTrue(so.getDiagnostics("num_inner_iter") == 20, "num_inner_iter is wrong.")
924          self.failUnless(so.getDiagnostics("time") == 30, "time is wrong.")          self.assertTrue(so.getDiagnostics("time") == 30, "time is wrong.")
925          self.failUnless(so.getDiagnostics("set_up_time") == 40, "set_up_time is wrong.")          self.assertTrue(so.getDiagnostics("set_up_time") == 40, "set_up_time is wrong.")
926          self.failUnless(so.getDiagnostics("residual_norm") == 50, "residual_norm is wrong.")          self.assertTrue(so.getDiagnostics("residual_norm") == 50, "residual_norm is wrong.")
927          self.failUnless(not so.getDiagnostics("converged"), "converged is wrong.")          self.assertTrue(not so.getDiagnostics("converged"), "converged is wrong.")
928          self.failUnless(not so.hasConverged(), "convergence flag is wrong.")          self.assertTrue(not so.hasConverged(), "convergence flag is wrong.")
929          self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 22, "cum_num_inner_iter is wrong.")          self.assertTrue(so.getDiagnostics("cum_num_inner_iter") == 22, "cum_num_inner_iter is wrong.")
930          self.failUnless(so.getDiagnostics("cum_num_iter") == 11, "cum_num_iter is wrong.")          self.assertTrue(so.getDiagnostics("cum_num_iter") == 11, "cum_num_iter is wrong.")
931          self.failUnless(so.getDiagnostics("cum_time") ==33, "cum_time is wrong.")          self.assertTrue(so.getDiagnostics("cum_time") ==33, "cum_time is wrong.")
932          self.failUnless(so.getDiagnostics("cum_set_up_time") == 44, "cum_set_up_time is wrong.")            self.assertTrue(so.getDiagnostics("cum_set_up_time") == 44, "cum_set_up_time is wrong.")  
933    
934          so.resetDiagnostics(all=True)          so.resetDiagnostics(all=True)
935          self.failUnless(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")          self.assertTrue(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")
936          self.failUnless(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")          self.assertTrue(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")
937          self.failUnless(so.getDiagnostics("time") == None, "initial time is wrong.")          self.assertTrue(so.getDiagnostics("time") == None, "initial time is wrong.")
938          self.failUnless(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")          self.assertTrue(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")
939          self.failUnless(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")          self.assertTrue(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")
940          self.failUnless(so.getDiagnostics("converged") == None, "initial converged is wrong.")          self.assertTrue(so.getDiagnostics("converged") == None, "initial converged is wrong.")
941          self.failUnless(so.hasConverged() == None, "initial convergence flag is wrong.")          self.assertTrue(so.hasConverged() == None, "initial convergence flag is wrong.")
942          self.failUnless(so.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")          self.assertTrue(so.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")
943          self.failUnless(so.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")          self.assertTrue(so.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")
944          self.failUnless(so.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")          self.assertTrue(so.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")
945          self.failUnless(so.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")          self.assertTrue(so.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")
946                    
947      def test_setCoefficient_WithIllegalFunctionSpace(self):      def test_setCoefficient_WithIllegalFunctionSpace(self):
948          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
949          self.failUnlessRaises(IllegalCoefficientFunctionSpace, mypde.setValue, C=Vector(0.,FunctionOnBoundary(self.domain)))          self.assertRaises(IllegalCoefficientFunctionSpace, mypde.setValue, C=Vector(0.,FunctionOnBoundary(self.domain)))
950    
951      def test_setCoefficient_WithWrongName(self):      def test_setCoefficient_WithWrongName(self):
952          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
953          self.failUnlessRaises(IllegalCoefficient, mypde.setValue, ROMA=0.)          self.assertRaises(IllegalCoefficient, mypde.setValue, ROMA=0.)
954    
955      def test_resetCoefficient_WithWrongShape(self):      def test_resetCoefficient_WithWrongShape(self):
956          mypde=LinearPDE(self.domain,numEquations=2,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=2,debug=self.DEBUG)
957          self.failUnlessRaises(IllegalCoefficientValue, mypde.setValue, C=0.)          self.assertRaises(IllegalCoefficientValue, mypde.setValue, C=0.)
958    
959      def test_reducedOn(self):      def test_reducedOn(self):
960          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
# Line 955  class Test_LinearPDE_noLumping(Test_line Line 962  class Test_LinearPDE_noLumping(Test_line
962          mypde.setReducedOrderOn()          mypde.setReducedOrderOn()
963          mypde.setValue(A=kronecker(self.domain),D=x[0],Y=x[0])          mypde.setValue(A=kronecker(self.domain),D=x[0],Y=x[0])
964          u=mypde.getSolution()          u=mypde.getSolution()
965          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
966    
967      def test_attemptToChangeOrderAfterDefinedCoefficient(self):      def test_attemptToChangeOrderAfterDefinedCoefficient(self):
968          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
969          mypde.setValue(D=1.)          mypde.setValue(D=1.)
970          self.failUnlessRaises(RuntimeError, mypde.setReducedOrderOn)          self.assertRaises(RuntimeError, mypde.setReducedOrderOn)
971    
972      def test_reducedOnConfig(self):      def test_reducedOnConfig(self):
973          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
974          mypde.setReducedOrderOn()          mypde.setReducedOrderOn()
975          self.failUnlessEqual((mypde.getFunctionSpaceForSolution(), mypde.getFunctionSpaceForEquation()),(ReducedSolution(self.domain),ReducedSolution(self.domain)),"reduced function spaces expected.")          self.assertEqual((mypde.getFunctionSpaceForSolution(), mypde.getFunctionSpaceForEquation()),(ReducedSolution(self.domain),ReducedSolution(self.domain)),"reduced function spaces expected.")
976      #      #
977      #  set coefficients for scalars:      #  set coefficients for scalars:
978      #      #
# Line 974  class Test_LinearPDE_noLumping(Test_line Line 981  class Test_LinearPDE_noLumping(Test_line
981          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
982          mypde.setValue(A=numpy.ones((d,d)))          mypde.setValue(A=numpy.ones((d,d)))
983          coeff=mypde.getCoefficient("A")          coeff=mypde.getCoefficient("A")
984          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),Function(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),Function(self.domain),1,1))
985      def test_setCoefficient_B_Scalar(self):      def test_setCoefficient_B_Scalar(self):
986          d=self.domain.getDim()          d=self.domain.getDim()
987          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
988          mypde.setValue(B=numpy.ones((d,)))          mypde.setValue(B=numpy.ones((d,)))
989          coeff=mypde.getCoefficient("B")          coeff=mypde.getCoefficient("B")
990          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),Function(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),Function(self.domain),1,1))
991      def test_setCoefficient_C_Scalar(self):      def test_setCoefficient_C_Scalar(self):
992          d=self.domain.getDim()          d=self.domain.getDim()
993          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
994          mypde.setValue(C=numpy.ones((d,)))          mypde.setValue(C=numpy.ones((d,)))
995          coeff=mypde.getCoefficient("C")          coeff=mypde.getCoefficient("C")
996          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),Function(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),Function(self.domain),1,1))
997      def test_setCoefficient_D_Scalar(self):      def test_setCoefficient_D_Scalar(self):
998          d=self.domain.getDim()          d=self.domain.getDim()
999          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1000          mypde.setValue(D=1.)          mypde.setValue(D=1.)
1001          coeff=mypde.getCoefficient("D")          coeff=mypde.getCoefficient("D")
1002          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),Function(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),Function(self.domain),1,1))
1003      def test_setCoefficient_X_Scalar(self):      def test_setCoefficient_X_Scalar(self):
1004          d=self.domain.getDim()          d=self.domain.getDim()
1005          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1006          mypde.setValue(X=numpy.ones((d,)))          mypde.setValue(X=numpy.ones((d,)))
1007          coeff=mypde.getCoefficient("X")          coeff=mypde.getCoefficient("X")
1008          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),Function(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),Function(self.domain),1))
1009      def test_setCoefficient_Y_Scalar(self):      def test_setCoefficient_Y_Scalar(self):
1010          d=self.domain.getDim()          d=self.domain.getDim()
1011          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1012          mypde.setValue(Y=1.)          mypde.setValue(Y=1.)
1013          coeff=mypde.getCoefficient("Y")          coeff=mypde.getCoefficient("Y")
1014          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),Function(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),Function(self.domain),1))
1015      def test_setCoefficient_y_Scalar(self):      def test_setCoefficient_y_Scalar(self):
1016          d=self.domain.getDim()          d=self.domain.getDim()
1017          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1018          mypde.setValue(y=1.)          mypde.setValue(y=1.)
1019          coeff=mypde.getCoefficient("y")          coeff=mypde.getCoefficient("y")
1020          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1))
1021      def test_setCoefficient_d_Scalar(self):      def test_setCoefficient_d_Scalar(self):
1022          d=self.domain.getDim()          d=self.domain.getDim()
1023          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1024          mypde.setValue(d=1.)          mypde.setValue(d=1.)
1025          coeff=mypde.getCoefficient("d")          coeff=mypde.getCoefficient("d")
1026          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1))
1027      def test_setCoefficient_d_contact_Scalar(self):      def test_setCoefficient_d_contact_Scalar(self):
1028          d=self.domain.getDim()          if self.domain.supportsContactElements():
1029          mypde=LinearPDE(self.domain,debug=self.DEBUG)              d=self.domain.getDim()
1030          mypde.setValue(d_contact=1.)              mypde=LinearPDE(self.domain,debug=self.DEBUG)
1031          coeff=mypde.getCoefficient("d_contact")              mypde.setValue(d_contact=1.)
1032          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1,1))              coeff=mypde.getCoefficient("d_contact")
1033                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1,1))
1034      def test_setCoefficient_y_contact_Scalar(self):      def test_setCoefficient_y_contact_Scalar(self):
1035          d=self.domain.getDim()          d=self.domain.getDim()
1036          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          if self.domain.supportsContactElements():
1037          mypde.setValue(y_contact=1.)              mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1038          coeff=mypde.getCoefficient("y_contact")              mypde.setValue(y_contact=1.)
1039          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))              coeff=mypde.getCoefficient("y_contact")
1040                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1))
1041      def test_setCoefficient_A_reduced_Scalar(self):      def test_setCoefficient_A_reduced_Scalar(self):
1042          d=self.domain.getDim()          d=self.domain.getDim()
1043          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1044          mypde.setValue(A_reduced=numpy.ones((d,d)))          mypde.setValue(A_reduced=numpy.ones((d,d)))
1045          coeff=mypde.getCoefficient("A_reduced")          coeff=mypde.getCoefficient("A_reduced")
1046          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
1047      def test_setCoefficient_B_reduced_Scalar(self):      def test_setCoefficient_B_reduced_Scalar(self):
1048          d=self.domain.getDim()          d=self.domain.getDim()
1049          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1050          mypde.setValue(B_reduced=numpy.ones((d,)))          mypde.setValue(B_reduced=numpy.ones((d,)))
1051          coeff=mypde.getCoefficient("B_reduced")          coeff=mypde.getCoefficient("B_reduced")
1052          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1053      def test_setCoefficient_C_reduced_Scalar(self):      def test_setCoefficient_C_reduced_Scalar(self):
1054          d=self.domain.getDim()          d=self.domain.getDim()
1055          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1056          mypde.setValue(C_reduced=numpy.ones((d,)))          mypde.setValue(C_reduced=numpy.ones((d,)))
1057          coeff=mypde.getCoefficient("C_reduced")          coeff=mypde.getCoefficient("C_reduced")
1058          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1059      def test_setCoefficient_D_reduced_Scalar(self):      def test_setCoefficient_D_reduced_Scalar(self):
1060          d=self.domain.getDim()          d=self.domain.getDim()
1061          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1062          mypde.setValue(D_reduced=1.)          mypde.setValue(D_reduced=1.)
1063          coeff=mypde.getCoefficient("D_reduced")          coeff=mypde.getCoefficient("D_reduced")
1064          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
1065      def test_setCoefficient_X_reduced_Scalar(self):      def test_setCoefficient_X_reduced_Scalar(self):
1066          d=self.domain.getDim()          d=self.domain.getDim()
1067          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1068          mypde.setValue(X_reduced=numpy.ones((d,)))          mypde.setValue(X_reduced=numpy.ones((d,)))
1069          coeff=mypde.getCoefficient("X_reduced")          coeff=mypde.getCoefficient("X_reduced")
1070          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
1071      def test_setCoefficient_Y_reduced_Scalar(self):      def test_setCoefficient_Y_reduced_Scalar(self):
1072          d=self.domain.getDim()          d=self.domain.getDim()
1073          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1074          mypde.setValue(Y_reduced=1.)          mypde.setValue(Y_reduced=1.)
1075          coeff=mypde.getCoefficient("Y_reduced")          coeff=mypde.getCoefficient("Y_reduced")
1076          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
1077      def test_setCoefficient_y_reduced_Scalar(self):      def test_setCoefficient_y_reduced_Scalar(self):
1078          d=self.domain.getDim()          d=self.domain.getDim()
1079          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1080          mypde.setValue(y_reduced=1.)          mypde.setValue(y_reduced=1.)
1081          coeff=mypde.getCoefficient("y_reduced")          coeff=mypde.getCoefficient("y_reduced")
1082          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
1083      def test_setCoefficient_d_reduced_Scalar(self):      def test_setCoefficient_d_reduced_Scalar(self):
1084          d=self.domain.getDim()          d=self.domain.getDim()
1085          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1086          mypde.setValue(d_reduced=1.)          mypde.setValue(d_reduced=1.)
1087          coeff=mypde.getCoefficient("d_reduced")          coeff=mypde.getCoefficient("d_reduced")
1088          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
1089      def test_setCoefficient_d_contact_reduced_Scalar(self):      def test_setCoefficient_d_contact_reduced_Scalar(self):
1090          d=self.domain.getDim()          if self.domain.supportsContactElements():
1091          mypde=LinearPDE(self.domain,debug=self.DEBUG)              d=self.domain.getDim()
1092          mypde.setValue(d_contact_reduced=1.)              mypde=LinearPDE(self.domain,debug=self.DEBUG)
1093          coeff=mypde.getCoefficient("d_contact_reduced")              mypde.setValue(d_contact_reduced=1.)
1094          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))              coeff=mypde.getCoefficient("d_contact_reduced")
1095                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
1096      def test_setCoefficient_y_contact_reduced_Scalar(self):      def test_setCoefficient_y_contact_reduced_Scalar(self):
1097          d=self.domain.getDim()          if self.domain.supportsContactElements():
1098          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)              d=self.domain.getDim()
1099          mypde.setValue(y_contact_reduced=1.)              mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1100          coeff=mypde.getCoefficient("y_contact_reduced")              mypde.setValue(y_contact_reduced=1.)
1101          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))              coeff=mypde.getCoefficient("y_contact_reduced")
1102                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
1103      def test_setCoefficient_r_Scalar(self):      def test_setCoefficient_r_Scalar(self):
1104          d=self.domain.getDim()          d=self.domain.getDim()
1105          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1106          mypde.setValue(r=1.)          mypde.setValue(r=1.)
1107          coeff=mypde.getCoefficient("r")          coeff=mypde.getCoefficient("r")
1108          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),Solution(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),Solution(self.domain),1))
1109      def test_setCoefficient_q_Scalar(self):      def test_setCoefficient_q_Scalar(self):
1110          d=self.domain.getDim()          d=self.domain.getDim()
1111          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1112          mypde.setValue(q=1.)          mypde.setValue(q=1.)
1113          coeff=mypde.getCoefficient("q")          coeff=mypde.getCoefficient("q")
1114          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),Solution(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),Solution(self.domain),1))
1115      def test_setCoefficient_r_Scalar_reducedOn(self):      def test_setCoefficient_r_Scalar_reducedOn(self):
1116          d=self.domain.getDim()          d=self.domain.getDim()
1117          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1118          mypde.setReducedOrderOn()          mypde.setReducedOrderOn()
1119          mypde.setValue(r=1.)          mypde.setValue(r=1.)
1120          coeff=mypde.getCoefficient("r")          coeff=mypde.getCoefficient("r")
1121          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
1122      def test_setCoefficient_q_Scalar_reducedOn(self):      def test_setCoefficient_q_Scalar_reducedOn(self):
1123          d=self.domain.getDim()          d=self.domain.getDim()
1124          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1125          mypde.setReducedOrderOn()          mypde.setReducedOrderOn()
1126          mypde.setValue(q=1.)          mypde.setValue(q=1.)
1127          coeff=mypde.getCoefficient("q")          coeff=mypde.getCoefficient("q")
1128          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((),ReducedSolution(self.domain),1))
1129    
1130      def test_setCoefficient_A_reduced_Scalar_usingA(self):      def test_setCoefficient_A_reduced_Scalar_usingA(self):
1131          d=self.domain.getDim()          d=self.domain.getDim()
1132          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1133          mypde.setValue(A=Data(numpy.ones((d,d)),ReducedFunction(self.domain)))          mypde.setValue(A=Data(numpy.ones((d,d)),ReducedFunction(self.domain)))
1134          coeff=mypde.getCoefficient("A_reduced")          coeff=mypde.getCoefficient("A_reduced")
1135          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1))
1136      def test_setCoefficient_B_reduced_Scalar_usingB(self):      def test_setCoefficient_B_reduced_Scalar_usingB(self):
1137          d=self.domain.getDim()          d=self.domain.getDim()
1138          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1139          mypde.setValue(B=Data(numpy.ones((d,)),ReducedFunction(self.domain)))          mypde.setValue(B=Data(numpy.ones((d,)),ReducedFunction(self.domain)))
1140          coeff=mypde.getCoefficient("B_reduced")          coeff=mypde.getCoefficient("B_reduced")
1141          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1142      def test_setCoefficient_C_reduced_Scalar_usingC(self):      def test_setCoefficient_C_reduced_Scalar_usingC(self):
1143          d=self.domain.getDim()          d=self.domain.getDim()
1144          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1145          mypde.setValue(C=Data(numpy.ones((d,)),ReducedFunction(self.domain)))          mypde.setValue(C=Data(numpy.ones((d,)),ReducedFunction(self.domain)))
1146          coeff=mypde.getCoefficient("C_reduced")          coeff=mypde.getCoefficient("C_reduced")
1147          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1))
1148      def test_setCoefficient_D_reduced_Scalar_usingD(self):      def test_setCoefficient_D_reduced_Scalar_usingD(self):
1149          d=self.domain.getDim()          d=self.domain.getDim()
1150          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1151          mypde.setValue(D=Scalar(1.,ReducedFunction(self.domain)))          mypde.setValue(D=Scalar(1.,ReducedFunction(self.domain)))
1152          coeff=mypde.getCoefficient("D_reduced")          coeff=mypde.getCoefficient("D_reduced")
1153          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1))
1154      def test_setCoefficient_X_reduced_Scalar_usingX(self):      def test_setCoefficient_X_reduced_Scalar_usingX(self):
1155          d=self.domain.getDim()          d=self.domain.getDim()
1156          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1157          mypde.setValue(X_reduced=Data(numpy.ones((d,)),ReducedFunction(self.domain)))          mypde.setValue(X_reduced=Data(numpy.ones((d,)),ReducedFunction(self.domain)))
1158          coeff=mypde.getCoefficient("X_reduced")          coeff=mypde.getCoefficient("X_reduced")
1159          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1))
1160      def test_setCoefficient_Y_reduced_Scalar_usingY(self):      def test_setCoefficient_Y_reduced_Scalar_usingY(self):
1161          d=self.domain.getDim()          d=self.domain.getDim()
1162          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1163          mypde.setValue(Y=Scalar(1.,ReducedFunction(self.domain)))          mypde.setValue(Y=Scalar(1.,ReducedFunction(self.domain)))
1164          coeff=mypde.getCoefficient("Y_reduced")          coeff=mypde.getCoefficient("Y_reduced")
1165          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunction(self.domain),1))
1166      def test_setCoefficient_y_reduced_Scalar_using_y(self):      def test_setCoefficient_y_reduced_Scalar_using_y(self):
1167          d=self.domain.getDim()          d=self.domain.getDim()
1168          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1169          mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))          mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
1170          coeff=mypde.getCoefficient("y_reduced")          coeff=mypde.getCoefficient("y_reduced")
1171          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
1172      def test_setCoefficient_d_reduced_Scalar_using_d(self):      def test_setCoefficient_d_reduced_Scalar_using_d(self):
1173          d=self.domain.getDim()          d=self.domain.getDim()
1174          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1175          mypde.setValue(d=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))          mypde.setValue(d=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
1176          coeff=mypde.getCoefficient("d_reduced")          coeff=mypde.getCoefficient("d_reduced")
1177          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1))
1178      def test_setCoefficient_d_contact_reduced_Scalar_using_d_contact(self):      def test_setCoefficient_d_contact_reduced_Scalar_using_d_contact(self):
1179          d=self.domain.getDim()          if self.domain.supportsContactElements():
1180          mypde=LinearPDE(self.domain,debug=self.DEBUG)              d=self.domain.getDim()
1181          mypde.setValue(d_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))              mypde=LinearPDE(self.domain,debug=self.DEBUG)
1182          coeff=mypde.getCoefficient("d_contact_reduced")              mypde.setValue(d_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
1183          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))              coeff=mypde.getCoefficient("d_contact_reduced")
1184                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1))
1185      def test_setCoefficient_y_contact_reduced_Scalar_using_y_contact(self):      def test_setCoefficient_y_contact_reduced_Scalar_using_y_contact(self):
1186          d=self.domain.getDim()          if self.domain.supportsContactElements():
1187          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)              d=self.domain.getDim()
1188          mypde.setValue(y_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))              mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1189          coeff=mypde.getCoefficient("y_contact_reduced")              mypde.setValue(y_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain)))
1190          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))              coeff=mypde.getCoefficient("y_contact_reduced")
1191                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1))
1192      #      #
1193      #  set coefficients for systems:      #  set coefficients for systems:
1194      #      #
# Line 1184  class Test_LinearPDE_noLumping(Test_line Line 1197  class Test_LinearPDE_noLumping(Test_line
1197          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1198          mypde.setValue(A=numpy.ones((self.N,d,self.N,d)))          mypde.setValue(A=numpy.ones((self.N,d,self.N,d)))
1199          coeff=mypde.getCoefficient("A")          coeff=mypde.getCoefficient("A")
1200          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),Function(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),Function(self.domain),self.N,self.N))
1201      def test_setCoefficient_B_System(self):      def test_setCoefficient_B_System(self):
1202          d=self.domain.getDim()          d=self.domain.getDim()
1203          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1204          mypde.setValue(B=numpy.ones((self.N,d,self.N)))          mypde.setValue(B=numpy.ones((self.N,d,self.N)))
1205          coeff=mypde.getCoefficient("B")          coeff=mypde.getCoefficient("B")
1206          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),Function(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),Function(self.domain),self.N,self.N))
1207      def test_setCoefficient_C_System(self):      def test_setCoefficient_C_System(self):
1208          d=self.domain.getDim()          d=self.domain.getDim()
1209          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1210          mypde.setValue(C=numpy.ones((self.N,self.N,d)))          mypde.setValue(C=numpy.ones((self.N,self.N,d)))
1211          coeff=mypde.getCoefficient("C")          coeff=mypde.getCoefficient("C")
1212          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),Function(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),Function(self.domain),self.N,self.N))
1213      def test_setCoefficient_D_System(self):      def test_setCoefficient_D_System(self):
1214          d=self.domain.getDim()          d=self.domain.getDim()
1215          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1216          mypde.setValue(D=numpy.ones((self.N,self.N)))          mypde.setValue(D=numpy.ones((self.N,self.N)))
1217          coeff=mypde.getCoefficient("D")          coeff=mypde.getCoefficient("D")
1218          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),Function(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),Function(self.domain),self.N,self.N))
1219      def test_setCoefficient_X_System(self):      def test_setCoefficient_X_System(self):
1220          d=self.domain.getDim()          d=self.domain.getDim()
1221          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1222          mypde.setValue(X=numpy.ones((self.N,d)))          mypde.setValue(X=numpy.ones((self.N,d)))
1223          coeff=mypde.getCoefficient("X")          coeff=mypde.getCoefficient("X")
1224          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),Function(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),Function(self.domain),self.N))
1225      def test_setCoefficient_Y_System(self):      def test_setCoefficient_Y_System(self):
1226          d=self.domain.getDim()          d=self.domain.getDim()
1227          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1228          mypde.setValue(Y=numpy.ones((self.N,)))          mypde.setValue(Y=numpy.ones((self.N,)))
1229          coeff=mypde.getCoefficient("Y")          coeff=mypde.getCoefficient("Y")
1230          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),Function(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),Function(self.domain),self.N))
1231      def test_setCoefficient_y_System(self):      def test_setCoefficient_y_System(self):
1232          d=self.domain.getDim()          d=self.domain.getDim()
1233          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1234          mypde.setValue(y=numpy.ones((self.N,)))          mypde.setValue(y=numpy.ones((self.N,)))
1235          coeff=mypde.getCoefficient("y")          coeff=mypde.getCoefficient("y")
1236          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),FunctionOnBoundary(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),FunctionOnBoundary(self.domain),self.N))
1237      def test_setCoefficient_d_System(self):      def test_setCoefficient_d_System(self):
1238          d=self.domain.getDim()          d=self.domain.getDim()
1239          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1240          mypde.setValue(d=numpy.ones((self.N,self.N)))          mypde.setValue(d=numpy.ones((self.N,self.N)))
1241          coeff=mypde.getCoefficient("d")          coeff=mypde.getCoefficient("d")
1242          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),FunctionOnBoundary(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),FunctionOnBoundary(self.domain),self.N,self.N))
1243      def test_setCoefficient_d_contact_System(self):      def test_setCoefficient_d_contact_System(self):
1244          d=self.domain.getDim()          if self.domain.supportsContactElements():
1245          mypde=LinearPDE(self.domain,debug=self.DEBUG)              d=self.domain.getDim()
1246          mypde.setValue(d_contact=numpy.ones((self.N,self.N)))              mypde=LinearPDE(self.domain,debug=self.DEBUG)
1247          coeff=mypde.getCoefficient("d_contact")              mypde.setValue(d_contact=numpy.ones((self.N,self.N)))
1248          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),FunctionOnContactZero(self.domain),self.N,self.N))              coeff=mypde.getCoefficient("d_contact")
1249                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),FunctionOnContactZero(self.domain),self.N,self.N))
1250      def test_setCoefficient_y_contact_System(self):      def test_setCoefficient_y_contact_System(self):
1251          d=self.domain.getDim()          if self.domain.supportsContactElements():
1252          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)              d=self.domain.getDim()
1253          mypde.setValue(y_contact=numpy.ones((self.N,)))              mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1254          coeff=mypde.getCoefficient("y_contact")              mypde.setValue(y_contact=numpy.ones((self.N,)))
1255          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N))              coeff=mypde.getCoefficient("y_contact")
1256                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N))
1257      def test_setCoefficient_A_reduced_System(self):      def test_setCoefficient_A_reduced_System(self):
1258          d=self.domain.getDim()          d=self.domain.getDim()
1259          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1260          mypde.setValue(A_reduced=numpy.ones((self.N,d,self.N,d)))          mypde.setValue(A_reduced=numpy.ones((self.N,d,self.N,d)))
1261          coeff=mypde.getCoefficient("A_reduced")          coeff=mypde.getCoefficient("A_reduced")
1262          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1263      def test_setCoefficient_B_reduced_System(self):      def test_setCoefficient_B_reduced_System(self):
1264          d=self.domain.getDim()          d=self.domain.getDim()
1265          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1266          mypde.setValue(B_reduced=numpy.ones((self.N,d,self.N)))          mypde.setValue(B_reduced=numpy.ones((self.N,d,self.N)))
1267          coeff=mypde.getCoefficient("B_reduced")          coeff=mypde.getCoefficient("B_reduced")
1268          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
1269      def test_setCoefficient_C_reduced_System(self):      def test_setCoefficient_C_reduced_System(self):
1270          d=self.domain.getDim()          d=self.domain.getDim()
1271          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1272          mypde.setValue(C_reduced=numpy.ones((self.N,self.N,d)))          mypde.setValue(C_reduced=numpy.ones((self.N,self.N,d)))
1273          coeff=mypde.getCoefficient("C_reduced")          coeff=mypde.getCoefficient("C_reduced")
1274          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1275      def test_setCoefficient_D_System_reduced(self):      def test_setCoefficient_D_System_reduced(self):
1276          d=self.domain.getDim()          d=self.domain.getDim()
1277          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1278          mypde.setValue(D_reduced=numpy.ones((self.N,self.N)))          mypde.setValue(D_reduced=numpy.ones((self.N,self.N)))
1279          coeff=mypde.getCoefficient("D_reduced")          coeff=mypde.getCoefficient("D_reduced")
1280          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
1281      def test_setCoefficient_X_System_reduced(self):      def test_setCoefficient_X_System_reduced(self):
1282          d=self.domain.getDim()          d=self.domain.getDim()
1283          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1284          mypde.setValue(X_reduced=numpy.ones((self.N,d)))          mypde.setValue(X_reduced=numpy.ones((self.N,d)))
1285          coeff=mypde.getCoefficient("X_reduced")          coeff=mypde.getCoefficient("X_reduced")
1286          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
1287      def test_setCoefficient_Y_System_reduced(self):      def test_setCoefficient_Y_System_reduced(self):
1288          d=self.domain.getDim()          d=self.domain.getDim()
1289          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1290          mypde.setValue(Y_reduced=numpy.ones((self.N,)))          mypde.setValue(Y_reduced=numpy.ones((self.N,)))
1291          coeff=mypde.getCoefficient("Y_reduced")          coeff=mypde.getCoefficient("Y_reduced")
1292          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
1293      def test_setCoefficient_y_System_reduced(self):      def test_setCoefficient_y_System_reduced(self):
1294          d=self.domain.getDim()          d=self.domain.getDim()
1295          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1296          mypde.setValue(y_reduced=numpy.ones((self.N,)))          mypde.setValue(y_reduced=numpy.ones((self.N,)))
1297          coeff=mypde.getCoefficient("y_reduced")          coeff=mypde.getCoefficient("y_reduced")
1298          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
1299      def test_setCoefficient_d_reduced_System(self):      def test_setCoefficient_d_reduced_System(self):
1300          d=self.domain.getDim()          d=self.domain.getDim()
1301          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1302          mypde.setValue(d_reduced=numpy.ones((self.N,self.N)))          mypde.setValue(d_reduced=numpy.ones((self.N,self.N)))
1303          coeff=mypde.getCoefficient("d_reduced")          coeff=mypde.getCoefficient("d_reduced")
1304          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
1305      def test_setCoefficient_d_contact_reduced_System(self):      def test_setCoefficient_d_contact_reduced_System(self):
1306          d=self.domain.getDim()          if self.domain.supportsContactElements():
1307          mypde=LinearPDE(self.domain,debug=self.DEBUG)              d=self.domain.getDim()
1308          mypde.setValue(d_contact_reduced=numpy.ones((self.N,self.N)))              mypde=LinearPDE(self.domain,debug=self.DEBUG)
1309          coeff=mypde.getCoefficient("d_contact_reduced")              mypde.setValue(d_contact_reduced=numpy.ones((self.N,self.N)))
1310          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))              coeff=mypde.getCoefficient("d_contact_reduced")
1311                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
1312      def test_setCoefficient_y_contact_reduced_System(self):      def test_setCoefficient_y_contact_reduced_System(self):
1313          d=self.domain.getDim()          if self.domain.supportsContactElements():
1314          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)              d=self.domain.getDim()
1315          mypde.setValue(y_contact_reduced=numpy.ones((self.N,)))              mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1316          coeff=mypde.getCoefficient("y_contact_reduced")              mypde.setValue(y_contact_reduced=numpy.ones((self.N,)))
1317          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))              coeff=mypde.getCoefficient("y_contact_reduced")
1318                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
1319      def test_setCoefficient_r_System(self):      def test_setCoefficient_r_System(self):
1320          d=self.domain.getDim()          d=self.domain.getDim()
1321          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1322          mypde.setValue(r=numpy.ones((self.N,)))          mypde.setValue(r=numpy.ones((self.N,)))
1323          coeff=mypde.getCoefficient("r")          coeff=mypde.getCoefficient("r")
1324          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
1325      def test_setCoefficient_q_System(self):      def test_setCoefficient_q_System(self):
1326          d=self.domain.getDim()          d=self.domain.getDim()
1327          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1328          mypde.setValue(q=numpy.ones((self.N,)))          mypde.setValue(q=numpy.ones((self.N,)))
1329          coeff=mypde.getCoefficient("q")          coeff=mypde.getCoefficient("q")
1330          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N))
1331      def test_setCoefficient_r_System_reducedOn(self):      def test_setCoefficient_r_System_reducedOn(self):
1332          d=self.domain.getDim()          d=self.domain.getDim()
1333          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1334          mypde.setReducedOrderOn()          mypde.setReducedOrderOn()
1335          mypde.setValue(r=numpy.ones((self.N,)))          mypde.setValue(r=numpy.ones((self.N,)))
1336          coeff=mypde.getCoefficient("r")          coeff=mypde.getCoefficient("r")
1337          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
1338      def test_setCoefficient_q_System_reducedOn(self):      def test_setCoefficient_q_System_reducedOn(self):
1339          d=self.domain.getDim()          d=self.domain.getDim()
1340          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG)
1341          mypde.setReducedOrderOn()          mypde.setReducedOrderOn()
1342          mypde.setValue(q=numpy.ones((self.N,)))          mypde.setValue(q=numpy.ones((self.N,)))
1343          coeff=mypde.getCoefficient("q")          coeff=mypde.getCoefficient("q")
1344          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N))
1345    
1346      def test_setCoefficient_A_reduced_System_using_A(self):      def test_setCoefficient_A_reduced_System_using_A(self):
1347          d=self.domain.getDim()          d=self.domain.getDim()
1348          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1349          mypde.setValue(A=Data(numpy.ones((self.N,d,self.N,d)),ReducedFunction(self.domain)))          mypde.setValue(A=Data(numpy.ones((self.N,d,self.N,d)),ReducedFunction(self.domain)))
1350          coeff=mypde.getCoefficient("A_reduced")          coeff=mypde.getCoefficient("A_reduced")
1351          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1352      def test_setCoefficient_B_reduced_System_using_B(self):      def test_setCoefficient_B_reduced_System_using_B(self):
1353          d=self.domain.getDim()          d=self.domain.getDim()
1354          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1355          mypde.setValue(B=Data(numpy.ones((self.N,d,self.N)),ReducedFunction(self.domain)))          mypde.setValue(B=Data(numpy.ones((self.N,d,self.N)),ReducedFunction(self.domain)))
1356          coeff=mypde.getCoefficient("B_reduced")          coeff=mypde.getCoefficient("B_reduced")
1357          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N))
1358      def test_setCoefficient_C_reduced_System_using_C(self):      def test_setCoefficient_C_reduced_System_using_C(self):
1359          d=self.domain.getDim()          d=self.domain.getDim()
1360          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1361          mypde.setValue(C=Data(numpy.ones((self.N,self.N,d)),ReducedFunction(self.domain)))          mypde.setValue(C=Data(numpy.ones((self.N,self.N,d)),ReducedFunction(self.domain)))
1362          coeff=mypde.getCoefficient("C_reduced")          coeff=mypde.getCoefficient("C_reduced")
1363          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N))
1364      def test_setCoefficient_D_System_reduced_using_D(self):      def test_setCoefficient_D_System_reduced_using_D(self):
1365          d=self.domain.getDim()          d=self.domain.getDim()
1366          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1367          mypde.setValue(D=Data(numpy.ones((self.N,self.N)),ReducedFunction(self.domain)))          mypde.setValue(D=Data(numpy.ones((self.N,self.N)),ReducedFunction(self.domain)))
1368          coeff=mypde.getCoefficient("D_reduced")          coeff=mypde.getCoefficient("D_reduced")
1369          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N))
1370      def test_setCoefficient_X_System_reduced_using_X(self):      def test_setCoefficient_X_System_reduced_using_X(self):
1371          d=self.domain.getDim()          d=self.domain.getDim()
1372          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1373          mypde.setValue(X=Data(numpy.ones((self.N,d)),ReducedFunction(self.domain)))          mypde.setValue(X=Data(numpy.ones((self.N,d)),ReducedFunction(self.domain)))
1374          coeff=mypde.getCoefficient("X_reduced")          coeff=mypde.getCoefficient("X_reduced")
1375          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N))
1376      def test_setCoefficient_Y_System_reduced_using_Y(self):      def test_setCoefficient_Y_System_reduced_using_Y(self):
1377          d=self.domain.getDim()          d=self.domain.getDim()
1378          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1379          mypde.setValue(Y=Data(numpy.ones((self.N,)),ReducedFunction(self.domain)))          mypde.setValue(Y=Data(numpy.ones((self.N,)),ReducedFunction(self.domain)))
1380          coeff=mypde.getCoefficient("Y_reduced")          coeff=mypde.getCoefficient("Y_reduced")
1381          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N))
1382      def test_setCoefficient_y_reduced_System_using_y(self):      def test_setCoefficient_y_reduced_System_using_y(self):
1383          d=self.domain.getDim()          d=self.domain.getDim()
1384          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1385          mypde.setValue(y=Data(numpy.ones((self.N,)),ReducedFunctionOnBoundary(self.domain)))          mypde.setValue(y=Data(numpy.ones((self.N,)),ReducedFunctionOnBoundary(self.domain)))
1386          coeff=mypde.getCoefficient("y_reduced")          coeff=mypde.getCoefficient("y_reduced")
1387          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N))
1388      def test_setCoefficient_d_reduced_System_using_d(self):      def test_setCoefficient_d_reduced_System_using_d(self):
1389          d=self.domain.getDim()          d=self.domain.getDim()
1390          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1391          mypde.setValue(d=Data(numpy.ones((self.N,self.N)),ReducedFunctionOnBoundary(self.domain)))          mypde.setValue(d=Data(numpy.ones((self.N,self.N)),ReducedFunctionOnBoundary(self.domain)))
1392          coeff=mypde.getCoefficient("d_reduced")          coeff=mypde.getCoefficient("d_reduced")
1393          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))          self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N))
1394      def test_setCoefficient_d_contact_reduced_System_using_d_contact(self):      def test_setCoefficient_d_contact_reduced_System_using_d_contact(self):
1395          d=self.domain.getDim()          if self.domain.supportsContactElements():
1396          mypde=LinearPDE(self.domain,debug=self.DEBUG)              d=self.domain.getDim()
1397          mypde.setValue(d_contact=Data(numpy.ones((self.N,self.N)),ReducedFunctionOnContactZero(self.domain)))              mypde=LinearPDE(self.domain,debug=self.DEBUG)
1398          coeff=mypde.getCoefficient("d_contact_reduced")              mypde.setValue(d_contact=Data(numpy.ones((self.N,self.N)),ReducedFunctionOnContactZero(self.domain)))
1399          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))              coeff=mypde.getCoefficient("d_contact_reduced")
1400                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumSolutions(), mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N))
1401      def test_setCoefficient_y_contact_reduced_System_using_y_contact(self):      def test_setCoefficient_y_contact_reduced_System_using_y_contact(self):
1402          d=self.domain.getDim()          if self.domain.supportsContactElements():
1403          mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)              d=self.domain.getDim()
1404          mypde.setValue(y_contact=Data(numpy.ones((self.N,)),ReducedFunctionOnContactZero(self.domain)))              mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
1405          coeff=mypde.getCoefficient("y_contact_reduced")              mypde.setValue(y_contact=Data(numpy.ones((self.N,)),ReducedFunctionOnContactZero(self.domain)))
1406          self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))              coeff=mypde.getCoefficient("y_contact_reduced")
1407                self.assertEqual((coeff.getShape(),coeff.getFunctionSpace(), mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N))
1408      def test_resetCoefficient_HomogeneousConstraint(self):      def test_resetCoefficient_HomogeneousConstraint(self):
1409          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1410          x=self.domain.getX()          x=self.domain.getX()
# Line 1393  class Test_LinearPDE_noLumping(Test_line Line 1412  class Test_LinearPDE_noLumping(Test_line
1412          u1=mypde.getSolution()          u1=mypde.getSolution()
1413          mypde.setValue(Y=2.)          mypde.setValue(Y=2.)
1414          u2=mypde.getSolution()          u2=mypde.getSolution()
1415          self.failUnless(self.check(u2,2*u1),'solution is wrong.')          self.assertTrue(self.check(u2,2*u1),'solution is wrong.')
1416    
1417      def test_resetCoefficient_InHomogeneousConstraint(self):      def test_resetCoefficient_InHomogeneousConstraint(self):
1418          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1419          mypde.setSymmetryOn()          mypde.setSymmetryOn()
1420      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1421          x=self.domain.getX()          x=self.domain.getX()
1422          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.,r=1,q=whereZero(x[0]))          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.,r=1,q=whereZero(x[0]))
1423          u1=mypde.getSolution()          u1=mypde.getSolution()
1424          mypde.setValue(Y=2.,D=2)          mypde.setValue(Y=2.,D=2)
1425          u2=mypde.getSolution()          u2=mypde.getSolution()
1426          self.failUnless(self.check(u2,u1),'first solution is wrong.')          self.assertTrue(self.check(u2,u1),'first solution is wrong.')
1427          u2=mypde.getSolution()          u2=mypde.getSolution()
1428          self.failUnless(self.check(u2,u1),'first solution is wrong.')          self.assertTrue(self.check(u2,u1),'first solution is wrong.')
1429          mypde.setValue(r=2,Y=4.)          mypde.setValue(r=2,Y=4.)
1430          u2=mypde.getSolution()          u2=mypde.getSolution()
1431          self.failUnless(self.check(u2,2*u1),'second solution is wrong.')          self.assertTrue(self.check(u2,2*u1),'second solution is wrong.')
1432    
1433      def test_Status(self):      def test_Status(self):
1434          DIM=self.domain.getDim()          DIM=self.domain.getDim()
# Line 1422  class Test_LinearPDE_noLumping(Test_line Line 1441  class Test_LinearPDE_noLumping(Test_line
1441          u1_ref=x1[0]*(1.-x1[0])          u1_ref=x1[0]*(1.-x1[0])
1442          u1=mypde.getSolution()          u1=mypde.getSolution()
1443          error1=Lsup(u1-u1_ref)/Lsup(u1_ref)          error1=Lsup(u1-u1_ref)/Lsup(u1_ref)
1444          self.failUnless(mypde.getDomainStatus() == mypde.getSystemStatus(), "status of first pde does not match domain status.")          self.assertTrue(mypde.getDomainStatus() == mypde.getSystemStatus(), "status of first pde does not match domain status.")
1445            try:
1446          self.domain.setX(x*5)              self.domain.setX(x*5)
1447            except:
1448          self.failUnless(mypde.getDomainStatus() != mypde.getSystemStatus(), "status of first pde matches updated domain status.")              # setX not supported
1449                return
1450            self.assertTrue(mypde.getDomainStatus() != mypde.getSystemStatus(), "status of first pde matches updated domain status.")
1451          x2=self.domain.getX()          x2=self.domain.getX()
1452          u2_ref=x2[0]*(5.-x2[0])          u2_ref=x2[0]*(5.-x2[0])
1453          u2=mypde.getSolution()          u2=mypde.getSolution()
1454          error2=Lsup(u2-u2_ref)/Lsup(u2_ref)          error2=Lsup(u2-u2_ref)/Lsup(u2_ref)
1455          self.failUnless(error2 <= max(error1,self.RES_TOL)*10., "solution of second PDE wrong.")          self.assertTrue(error2 <= max(error1,self.RES_TOL)*10., "solution of second PDE wrong.")
1456          self.failUnless(mypde.getDomainStatus() == mypde.getSystemStatus(), "status of second pde does not match domain status.")          self.assertTrue(mypde.getDomainStatus() == mypde.getSystemStatus(), "status of second pde does not match domain status.")
1457    
1458      def test_symmetryCheckTrue_System(self):      def test_symmetryCheckTrue_System(self):
1459          d=self.domain.getDim()          d=self.domain.getDim()
# Line 1443  class Test_LinearPDE_noLumping(Test_line Line 1464  class Test_LinearPDE_noLumping(Test_line
1464          D=3*numpy.ones((self.N,self.N))          D=3*numpy.ones((self.N,self.N))
1465          d=4*numpy.ones((self.N,self.N))          d=4*numpy.ones((self.N,self.N))
1466          d_contact=5*numpy.ones((self.N,self.N))          d_contact=5*numpy.ones((self.N,self.N))
1467          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)          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}
1468          self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")          if self.domain.supportsContactElements():
1469                    pars["d_contact"]=d_contact
1470                    pars["d_contact_reduced"]=-d_contact
1471            mypde.setValue(**pars)
1472            self.assertTrue(mypde.checkSymmetry(verbose=False),"symmetry detected")
1473    
1474      def test_symmetryCheckFalse_A_System(self):      def test_symmetryCheckFalse_A_System(self):
1475          d=self.domain.getDim()          d=self.domain.getDim()
# Line 1452  class Test_LinearPDE_noLumping(Test_line Line 1477  class Test_LinearPDE_noLumping(Test_line
1477          A=numpy.ones((self.N,d,self.N,d))          A=numpy.ones((self.N,d,self.N,d))
1478          A[1,1,1,0]=0.          A[1,1,1,0]=0.
1479          mypde.setValue(A=A)          mypde.setValue(A=A)
1480          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1481      def test_symmetryCheckFalse_BC_System(self):      def test_symmetryCheckFalse_BC_System(self):
1482          d=self.domain.getDim()          d=self.domain.getDim()
1483          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
# Line 1460  class Test_LinearPDE_noLumping(Test_line Line 1485  class Test_LinearPDE_noLumping(Test_line
1485          B=2*numpy.ones((self.N,d,self.N))          B=2*numpy.ones((self.N,d,self.N))
1486          B[0,0,1]=1.          B[0,0,1]=1.
1487          mypde.setValue(B=B,C=C)          mypde.setValue(B=B,C=C)
1488          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1489    
1490      def test_symmetryCheckFalse_D_System(self):      def test_symmetryCheckFalse_D_System(self):
1491          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1492          D=3*numpy.ones((self.N,self.N))          D=3*numpy.ones((self.N,self.N))
1493          D[0,1]=0.          D[0,1]=0.
1494          mypde.setValue(D=D)          mypde.setValue(D=D)
1495          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1496    
1497      def test_symmetryCheckFalse_d_System(self):      def test_symmetryCheckFalse_d_System(self):
1498          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1499          d=4*numpy.ones((self.N,self.N))          d=4*numpy.ones((self.N,self.N))
1500          d[0,1]=0.          d[0,1]=0.
1501          mypde.setValue(d=d)          mypde.setValue(d=d)
1502          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1503    
1504      def test_symmetryCheckFalse_d_contact_System(self):      def test_symmetryCheckFalse_d_contact_System(self):
1505          mypde=LinearPDE(self.domain,debug=self.DEBUG)          if self.domain.supportsContactElements():
1506          d_contact=5*numpy.ones((self.N,self.N))              mypde=LinearPDE(self.domain,debug=self.DEBUG)
1507          d_contact[0,1]=0.              d_contact=5*numpy.ones((self.N,self.N))
1508          mypde.setValue(d_contact=d_contact)              d_contact[0,1]=0.
1509          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")              mypde.setValue(d_contact=d_contact)
1510                self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1511    
1512      def test_symmetryCheckFalse_A_reduced_System(self):      def test_symmetryCheckFalse_A_reduced_System(self):
1513          d=self.domain.getDim()          d=self.domain.getDim()
# Line 1489  class Test_LinearPDE_noLumping(Test_line Line 1515  class Test_LinearPDE_noLumping(Test_line
1515          A=numpy.ones((self.N,d,self.N,d))          A=numpy.ones((self.N,d,self.N,d))
1516          A[1,1,1,0]=0.          A[1,1,1,0]=0.
1517          mypde.setValue(A_reduced=A)          mypde.setValue(A_reduced=A)
1518          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1519      def test_symmetryCheckFalse_BC_reduced_System(self):      def test_symmetryCheckFalse_BC_reduced_System(self):
1520          d=self.domain.getDim()          d=self.domain.getDim()
1521          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
# Line 1497  class Test_LinearPDE_noLumping(Test_line Line 1523  class Test_LinearPDE_noLumping(Test_line
1523          B=2*numpy.ones((self.N,d,self.N))          B=2*numpy.ones((self.N,d,self.N))
1524          B[0,0,1]=1.          B[0,0,1]=1.
1525          mypde.setValue(B_reduced=B,C_reduced=C)          mypde.setValue(B_reduced=B,C_reduced=C)
1526          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1527    
1528      def test_symmetryCheckFalse_D_reduced_System(self):      def test_symmetryCheckFalse_D_reduced_System(self):
1529          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1530          D=3*numpy.ones((self.N,self.N))          D=3*numpy.ones((self.N,self.N))
1531          D[0,1]=0.          D[0,1]=0.
1532          mypde.setValue(D_reduced=D)          mypde.setValue(D_reduced=D)
1533          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1534    
1535      def test_symmetryCheckFalse_d_reduced_System(self):      def test_symmetryCheckFalse_d_reduced_System(self):
1536          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1537          d=4*numpy.ones((self.N,self.N))          d=4*numpy.ones((self.N,self.N))
1538          d[0,1]=0.          d[0,1]=0.
1539          mypde.setValue(d_reduced=d)          mypde.setValue(d_reduced=d)
1540          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1541    
1542      def test_symmetryCheckFalse_d_contact_reduced_System(self):      def test_symmetryCheckFalse_d_contact_reduced_System(self):
1543          mypde=LinearPDE(self.domain,debug=self.DEBUG)          if self.domain.supportsContactElements():
1544          d_contact=5*numpy.ones((self.N,self.N))              mypde=LinearPDE(self.domain,debug=self.DEBUG)
1545          d_contact[0,1]=0.              d_contact=5*numpy.ones((self.N,self.N))
1546          mypde.setValue(d_contact_reduced=d_contact)              d_contact[0,1]=0.
1547          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")              mypde.setValue(d_contact_reduced=d_contact)
1548                self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1549    
1550      def test_symmetryCheckTrue_Scalar(self):      def test_symmetryCheckTrue_Scalar(self):
1551          d=self.domain.getDim()          d=self.domain.getDim()
# Line 1529  class Test_LinearPDE_noLumping(Test_line Line 1556  class Test_LinearPDE_noLumping(Test_line
1556          D=3          D=3
1557          d=4          d=4
1558          d_contact=5          d_contact=5
1559          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)          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}
1560          self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected")          if self.domain.supportsContactElements():
1561                    pars["d_contact"]=d_contact
1562                    pars["d_contact_reduced"]=-d_contact
1563            mypde.setValue(**pars)
1564            self.assertTrue(mypde.checkSymmetry(verbose=False),"symmetry detected")
1565    
1566      def test_symmetryCheckFalse_A_Scalar(self):      def test_symmetryCheckFalse_A_Scalar(self):
1567          d=self.domain.getDim()          d=self.domain.getDim()
# Line 1538  class Test_LinearPDE_noLumping(Test_line Line 1569  class Test_LinearPDE_noLumping(Test_line
1569          A=numpy.ones((d,d))          A=numpy.ones((d,d))
1570          A[1,0]=0.          A[1,0]=0.
1571          mypde.setValue(A=A)          mypde.setValue(A=A)
1572          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1573      def test_symmetryCheckFalse_BC_Scalar(self):      def test_symmetryCheckFalse_BC_Scalar(self):
1574          d=self.domain.getDim()          d=self.domain.getDim()
1575          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
# Line 1546  class Test_LinearPDE_noLumping(Test_line Line 1577  class Test_LinearPDE_noLumping(Test_line
1577          B=2*numpy.ones((d,))          B=2*numpy.ones((d,))
1578          B[0]=1.          B[0]=1.
1579          mypde.setValue(B=B,C=C)          mypde.setValue(B=B,C=C)
1580          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1581      def test_symmetryCheckFalse_A_reduced_Scalar(self):      def test_symmetryCheckFalse_A_reduced_Scalar(self):
1582          d=self.domain.getDim()          d=self.domain.getDim()
1583          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1584          A=numpy.ones((d,d))          A=numpy.ones((d,d))
1585          A[1,0]=0.          A[1,0]=0.
1586          mypde.setValue(A_reduced=A)          mypde.setValue(A_reduced=A)
1587          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1588      def test_symmetryCheckFalse_BC_reduced_Scalar(self):      def test_symmetryCheckFalse_BC_reduced_Scalar(self):
1589          d=self.domain.getDim()          d=self.domain.getDim()
1590          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
# Line 1561  class Test_LinearPDE_noLumping(Test_line Line 1592  class Test_LinearPDE_noLumping(Test_line
1592          B=2*numpy.ones((d,))          B=2*numpy.ones((d,))
1593          B[0]=1.          B[0]=1.
1594          mypde.setValue(B_reduced=B,C_reduced=C)          mypde.setValue(B_reduced=B,C_reduced=C)
1595          self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected")          self.assertTrue(not mypde.checkSymmetry(verbose=False),"symmetry detected")
1596      #      #
1597      #   solver checks (single PDE)      #   solver checks (single PDE)
1598      #      #
1599      def test_symmetryOnIterative(self):      def test_symmetryOnIterative(self):
1600          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1601          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1602      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1603          u=mypde.getSolution()          u=mypde.getSolution()
1604          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1605      def test_symmetryOnDirect(self):      def test_symmetryOnDirect(self):
1606          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1607          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1608          mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)          mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)
1609      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1610          u=mypde.getSolution()          u=mypde.getSolution()
1611          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1612      def test_PCG_JACOBI(self):      def test_PCG_JACOBI(self):
1613          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1614          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1615          mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1616      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1617      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1618            u=mypde.getSolution()
1619            self.assertTrue(self.check(u,1.),'solution is wrong.')
1620        def test_PCG_GAUSS_SEIDEL(self):
1621            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1622            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1623            mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1624            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1625            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1626          u=mypde.getSolution()          u=mypde.getSolution()
1627          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1628        def test_PCG_AMG(self):
1629            if self.order!=2:
1630                if getEscriptParamInt('DISABLE_AMG', 0):
1631                    print("AMG test disabled on MPI build")
1632                    return
1633                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1634                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1635                mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1636                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1637                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1638                u=mypde.getSolution()
1639                self.assertTrue(self.check(u,1.),'solution is wrong.')
1640      def test_PCG_ILU0(self):      def test_PCG_ILU0(self):
1641          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1642          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1643      mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1644      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1645      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1646          u=mypde.getSolution()          u=mypde.getSolution()
1647          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1648      def test_PCG_RILU(self):      def test_PCG_RILU(self):
1649          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1650          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1651      mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1652      mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1653      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1654          u=mypde.getSolution()          u=mypde.getSolution()
1655          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1656      def test_PCG_REC_ILU(self):      def test_PCG_REC_ILU(self):
1657          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1658          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1659      mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
1660      mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1661      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1662          u=mypde.getSolution()          u=mypde.getSolution()
1663          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1664      def test_DIRECT(self):      def test_DIRECT(self):
1665          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1666          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1667          mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)          mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)
1668      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1669          u=mypde.getSolution()          u=mypde.getSolution()
1670          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1671      def test_BICGSTAB_JACOBI(self):      def test_BICGSTAB_JACOBI(self):
1672          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1673      mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)          mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1674      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1675          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1676          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1677          u=mypde.getSolution()          u=mypde.getSolution()
1678          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1679        def test_BICGSTAB_GAUSS_SEIDEL(self):
1680            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1681            mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1682            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1683            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1684            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1685            u=mypde.getSolution()
1686            self.assertTrue(self.check(u,1.),'solution is wrong.')
1687        def test_BICGSTAB_AMG(self):
1688            if self.order!=2:
1689                if getEscriptParamInt('DISABLE_AMG', 0):
1690                    print("AMG test disabled on MPI build")
1691                    return    
1692                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1693                mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1694                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1695                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1696                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1697                u=mypde.getSolution()
1698                self.assertTrue(self.check(u,1.),'solution is wrong.')
1699      def test_BICGSTAB_ILU0(self):      def test_BICGSTAB_ILU0(self):
1700          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1701          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1702      mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)          mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1703      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1704          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1705          u=mypde.getSolution()          u=mypde.getSolution()
1706          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1707      def test_BICGSTAB_RILU(self):      def test_BICGSTAB_RILU(self):
1708          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1709          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1710      mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)          mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1711      mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1712          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1713          u=mypde.getSolution()          u=mypde.getSolution()
1714          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1715      def test_BICGSTAB_REC_ILU(self):      def test_BICGSTAB_REC_ILU(self):
1716          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1717          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1718      mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)          mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
1719      mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1720          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1721          u=mypde.getSolution()          u=mypde.getSolution()
1722          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1723      def test_MINRES_JACOBI(self):      def test_MINRES_JACOBI(self):
1724          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1725      mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1726      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1727          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1728          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1729          u=mypde.getSolution()          u=mypde.getSolution()
1730          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1731        def test_MINRES_GAUSS_SEIDEL(self):
1732            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1733            mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1734            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1735            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1736            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1737            u=mypde.getSolution()
1738            self.assertTrue(self.check(u,1.),'solution is wrong.')
1739        def test_MINRES_AMG(self):
1740            if self.order!=2:
1741                if getEscriptParamInt('DISABLE_AMG',0):
1742                    print("AMG test disabled on MPI build")
1743                    return                
1744                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1745                mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1746                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1747                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1748                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1749                u=mypde.getSolution()
1750                self.assertTrue(self.check(u,1.),'solution is wrong.')
1751      def test_MINRES_ILU0(self):      def test_MINRES_ILU0(self):
1752          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1753          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1754      mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1755      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1756          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1757          u=mypde.getSolution()          u=mypde.getSolution()
1758          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1759      def test_MINRES_RILU(self):      def test_MINRES_RILU(self):
1760          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1761          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1762      mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1763      mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1764          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1765          u=mypde.getSolution()          u=mypde.getSolution()
1766          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1767      def test_MINRES_REC_ILU(self):      def test_MINRES_REC_ILU(self):
1768          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1769          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1770      mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.MINRES)
1771      mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1772          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1773          u=mypde.getSolution()          u=mypde.getSolution()
1774          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1775      def test_TFQMR_JACOBI(self):      def test_TFQMR_JACOBI(self):
1776          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1777      mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)          mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1778      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1779            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1780            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1781            u=mypde.getSolution()
1782            self.assertTrue(self.check(u,1.),'solution is wrong.')
1783        def test_TFQMR_GAUSS_SEIDEL(self):
1784            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1785            mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1786            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1787          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1788          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1789          u=mypde.getSolution()          u=mypde.getSolution()
1790          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1791        def test_TFQMR_AMG(self):
1792            if self.order!=2:
1793                if getEscriptParamInt('DISABLE_AMG', 0):
1794                    print("AMG test disabled on MPI build")
1795                    return
1796                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1797                mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1798                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1799                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1800                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1801                u=mypde.getSolution()
1802                self.assertTrue(self.check(u,1.),'solution is wrong.')
1803      def test_TFQMR_ILU0(self):      def test_TFQMR_ILU0(self):
1804          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1805          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1806      mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)          mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1807      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1808          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1809          u=mypde.getSolution()          u=mypde.getSolution()
1810          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1811      def test_TFQMR_RILU(self):      def test_TFQMR_RILU(self):
1812          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1813          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1814      mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)          mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1815      mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1816          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1817          u=mypde.getSolution()          u=mypde.getSolution()
1818          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1819      def test_TFQMR_REC_ILU(self):      def test_TFQMR_REC_ILU(self):
1820          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1821          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1822      mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)          mypde.getSolverOptions().setSolverMethod(SolverOptions.TFQMR)
1823      mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1824          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1825          u=mypde.getSolution()          u=mypde.getSolution()
1826          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1827      def test_PRES20_JACOBI(self):      def test_PRES20_JACOBI(self):
1828          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1829          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1830      mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1831      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1832          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1833          u=mypde.getSolution()          u=mypde.getSolution()
1834          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1835        def test_PRES20_GAUSS_SEIDEL(self):
1836            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1837            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1838            mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1839            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1840            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1841            u=mypde.getSolution()
1842            self.assertTrue(self.check(u,1.),'solution is wrong.')
1843        def test_PRES20_AMG(self):
1844            if self.order!=2:
1845                if getEscriptParamInt('DISABLE_AMG', 0):
1846                    print("AMG test disabled on MPI build")
1847                    return
1848                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1849                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1850                mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1851                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1852                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1853                u=mypde.getSolution()
1854                self.assertTrue(self.check(u,1.),'solution is wrong.')
1855      def test_PRES20_ILU0(self):      def test_PRES20_ILU0(self):
1856          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1857          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1858      mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1859      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1860          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1861          u=mypde.getSolution()          u=mypde.getSolution()
1862          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1863      def test_PRES20_RILU(self):      def test_PRES20_RILU(self):
1864          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1865          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1866      mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1867      mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1868          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1869          u=mypde.getSolution()          u=mypde.getSolution()
1870          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1871      def test_PRES20_REC_ILU(self):      def test_PRES20_REC_ILU(self):
1872          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1873          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1874      mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
1875      mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1876          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1877          u=mypde.getSolution()          u=mypde.getSolution()
1878          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1879      def test_GMRESnoRestart_JACOBI(self):      def test_GMRESnoRestart_JACOBI(self):
1880          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1881          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1882      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1883      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1884      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1885      mypde.getSolverOptions().setTruncation(50)          mypde.getSolverOptions().setTruncation(50)
1886          u=mypde.getSolution()          u=mypde.getSolution()
1887          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1888        def test_GMRESnoRestart_GAUSS_SEIDEL(self):
1889            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1890            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1891            mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1892            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1893            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1894            mypde.getSolverOptions().setTruncation(50)
1895            u=mypde.getSolution()
1896            self.assertTrue(self.check(u,1.),'solution is wrong.')
1897        def test_GMRESnoRestart_AMG(self):
1898            if self.order!=2:
1899                if getEscriptParamInt('DISABLE_AMG', 0):
1900                    print("AMG test disabled on MPI build")
1901                    return    
1902                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1903                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1904                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1905                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1906                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1907                mypde.getSolverOptions().setTruncation(50)
1908                u=mypde.getSolution()
1909                self.assertTrue(self.check(u,1.),'solution is wrong.')
1910      def test_GMRESnoRestart_ILU0(self):      def test_GMRESnoRestart_ILU0(self):
1911          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1912          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1913      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1914      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1915      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1916      mypde.getSolverOptions().setTruncation(50)                                  mypde.getSolverOptions().setTruncation(50)                        
1917          u=mypde.getSolution()          u=mypde.getSolution()
1918          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1919      def test_GMRESnoRestart_RILU(self):      def test_GMRESnoRestart_RILU(self):
1920          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1921          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1922      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1923      mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1924      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1925      mypde.getSolverOptions().setTruncation(50)          mypde.getSolverOptions().setTruncation(50)
1926          u=mypde.getSolution()          u=mypde.getSolution()
1927          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1928      def test_GMRESnoRestart_REC_ILU(self):      def test_GMRESnoRestart_REC_ILU(self):
1929          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1930          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1931      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1932      mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1933      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1934      mypde.getSolverOptions().setTruncation(50)          mypde.getSolverOptions().setTruncation(50)
1935          u=mypde.getSolution()          u=mypde.getSolution()
1936          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1937      def test_GMRES_JACOBI(self):      def test_GMRES_JACOBI(self):
1938          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1939          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1940      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1941      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1942          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1943          u=mypde.getSolution()          u=mypde.getSolution()
1944          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1945        def test_GMRES_GAUSS_SEIDEL(self):
1946            mypde=LinearPDE(self.domain,debug=self.DEBUG)
1947            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1948            mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1949            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
1950            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1951            u=mypde.getSolution()
1952            self.assertTrue(self.check(u,1.),'solution is wrong.')
1953        def test_GMRES_AMG(self):
1954            if self.order!=2:
1955                if getEscriptParamInt('DISABLE_AMG', 0):
1956                    print("AMG test disabled on MPI build")
1957                    return    
1958                mypde=LinearPDE(self.domain,debug=self.DEBUG)
1959                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1960                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1961                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
1962                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1963                u=mypde.getSolution()
1964                self.assertTrue(self.check(u,1.),'solution is wrong.')        
1965      def test_GMRES_ILU0(self):      def test_GMRES_ILU0(self):
1966          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1967          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1968      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1969      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
1970          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1971          u=mypde.getSolution()          u=mypde.getSolution()
1972          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1973      def test_GMRES_RILU(self):      def test_GMRES_RILU(self):
1974          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1975          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1976      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1977      mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
1978          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1979          u=mypde.getSolution()          u=mypde.getSolution()
1980          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1981      def test_GMRES_REC_ILU(self):      def test_GMRES_REC_ILU(self):
1982          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1983          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1984      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1985      mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
1986          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1987          u=mypde.getSolution()          u=mypde.getSolution()
1988          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1989      def test_GMRES_truncation_restart_JACOBI(self):      def test_GMRES_truncation_restart_JACOBI(self):
1990          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
1991          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
1992      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
1993      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
1994      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
1995      mypde.getSolverOptions().setTruncation(10)          mypde.getSolverOptions().setTruncation(10)
1996      mypde.getSolverOptions().setRestart(20)          mypde.getSolverOptions().setRestart(20)
1997          u=mypde.getSolution()          u=mypde.getSolution()
1998          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
1999        def test_GMRES_truncation_restart_GAUSS_SEIDEL(self):
2000            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2001            mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
2002            mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2003            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2004            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2005            mypde.getSolverOptions().setTruncation(10)
2006            mypde.getSolverOptions().setRestart(20)
2007            u=mypde.getSolution()
2008            self.assertTrue(self.check(u,1.),'solution is wrong.')
2009        def test_GMRES_truncation_restart_AMG(self):
2010            if self.order!=2:
2011                if getEscriptParamInt('DISABLE_AMG', 0):
2012                    print("AMG test disabled on MPI build")
2013                    return    
2014                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2015                mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
2016                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2017                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2018                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2019                mypde.getSolverOptions().setTruncation(10)
2020                mypde.getSolverOptions().setRestart(20)
2021                u=mypde.getSolution()
2022                self.assertTrue(self.check(u,1.),'solution is wrong.')
2023      def test_GMRES_truncation_restart_ILU0(self):      def test_GMRES_truncation_restart_ILU0(self):
2024          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2025          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
2026      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2027      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
2028      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2029      mypde.getSolverOptions().setTruncation(10)          mypde.getSolverOptions().setTruncation(10)
2030      mypde.getSolverOptions().setRestart(20)          mypde.getSolverOptions().setRestart(20)
2031          u=mypde.getSolution()          u=mypde.getSolution()
2032          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2033      def test_GMRES_truncation_restart_RILU(self):      def test_GMRES_truncation_restart_RILU(self):
2034          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2035          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
2036      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2037      mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.RILU)
2038      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2039      mypde.getSolverOptions().setTruncation(10)          mypde.getSolverOptions().setTruncation(10)
2040      mypde.getSolverOptions().setRestart(20)          mypde.getSolverOptions().setRestart(20)
2041          u=mypde.getSolution()          u=mypde.getSolution()
2042          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2043      def test_GMRES_truncation_restart_REC_ILU(self):      def test_GMRES_truncation_restart_REC_ILU(self):
2044          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2045          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)          mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.)
2046      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2047      mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)          mypde.getSolverOptions().setPreconditioner(SolverOptions.REC_ILU)
2048      mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2049      mypde.getSolverOptions().setTruncation(10)          mypde.getSolverOptions().setTruncation(10)
2050      mypde.getSolverOptions().setRestart(20)          mypde.getSolverOptions().setRestart(20)
2051          u=mypde.getSolution()          u=mypde.getSolution()
2052          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2053      #      #
2054      #   solver checks (PDE system)      #   solver checks (PDE system)
2055      #      #
# Line 1868  class Test_LinearPDE_noLumping(Test_line Line 2065  class Test_LinearPDE_noLumping(Test_line
2065          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2066          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2067          u=mypde.getSolution()          u=mypde.getSolution()
2068          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2069      def test_symmetryOnDirect_System(self):      def test_symmetryOnDirect_System(self):
2070          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2071          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1882  class Test_LinearPDE_noLumping(Test_line Line 2079  class Test_LinearPDE_noLumping(Test_line
2079          mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)          mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)
2080          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2081          u=mypde.getSolution()          u=mypde.getSolution()
2082          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2083      def test_PCG_JACOBI_System(self):      def test_PCG_JACOBI_System(self):
2084          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2085          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1894  class Test_LinearPDE_noLumping(Test_line Line 2091  class Test_LinearPDE_noLumping(Test_line
2091          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2092          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2093          mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
2094      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
2095            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2096            u=mypde.getSolution()
2097            self.assertTrue(self.check(u,1.),'solution is wrong.')
2098        def test_PCG_GAUSS_SEIDEL_System(self):
2099            A=Tensor4(0.,Function(self.domain))
2100            D=Tensor(1.,Function(self.domain))
2101            Y=Vector(self.domain.getDim(),Function(self.domain))
2102            for i in range(self.domain.getDim()):
2103                A[i,:,i,:]=kronecker(self.domain)
2104                D[i,i]+=i
2105                Y[i]+=i
2106            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2107            mypde.setValue(A=A,D=D,Y=Y)
2108            mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
2109            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2110          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2111          u=mypde.getSolution()          u=mypde.getSolution()
2112          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2113        def test_PCG_AMG_System(self):
2114            if self.order!=2:
2115                if getEscriptParamInt('DISABLE_AMG', 0):
2116                    print("AMG test disabled on MPI build")
2117                    return
2118                A=Tensor4(0.,Function(self.domain))
2119                D=Tensor(1.,Function(self.domain))
2120                Y=Vector(self.domain.getDim(),Function(self.domain))
2121                for i in range(self.domain.getDim()):
2122                    A[i,:,i,:]=kronecker(self.domain)
2123                    D[i,i]+=i
2124                    Y[i]+=i
2125                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2126                mypde.setValue(A=A,D=D,Y=Y)
2127                mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
2128                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2129                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2130                u=mypde.getSolution()
2131                self.assertTrue(self.check(u,1.),'solution is wrong.')
2132      def test_PCG_ILU0_System(self):      def test_PCG_ILU0_System(self):
2133          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2134          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1909  class Test_LinearPDE_noLumping(Test_line Line 2140  class Test_LinearPDE_noLumping(Test_line
2140          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2141          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2142          mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
2143      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
2144          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2145          u=mypde.getSolution()          u=mypde.getSolution()
2146          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2147      def test_DIRECT_System(self):      def test_DIRECT_System(self):
2148          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2149          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1926  class Test_LinearPDE_noLumping(Test_line Line 2157  class Test_LinearPDE_noLumping(Test_line
2157          mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)          mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)
2158          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2159          u=mypde.getSolution()          u=mypde.getSolution()
2160          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2161      def test_BICGSTAB_JACOBI_System(self):      def test_BICGSTAB_JACOBI_System(self):
2162          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2163          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1937  class Test_LinearPDE_noLumping(Test_line Line 2168  class Test_LinearPDE_noLumping(Test_line
2168              Y[i]+=i              Y[i]+=i
2169          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2170          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2171      mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)          mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
2172      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
2173          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2174          u=mypde.getSolution()          u=mypde.getSolution()
2175          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2176        def test_BICGSTAB_GAUSS_SEIDEL_System(self):
2177            A=Tensor4(0.,Function(self.domain))
2178            D=Tensor(1.,Function(self.domain))
2179            Y=Vector(self.domain.getDim(),Function(self.domain))
2180            for i in range(self.domain.getDim()):
2181                A[i,:,i,:]=kronecker(self.domain)
2182                D[i,i]+=i
2183                Y[i]+=i
2184            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2185            mypde.setValue(A=A,D=D,Y=Y)
2186            mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
2187            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2188            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2189            u=mypde.getSolution()
2190            self.assertTrue(self.check(u,1.),'solution is wrong.')
2191        def test_BICGSTAB_AMG_System(self):
2192            if self.order!=2:
2193                if getEscriptParamInt('DISABLE_AMG', 0):
2194                    print("AMG test disabled on MPI build")
2195                    return    
2196                A=Tensor4(0.,Function(self.domain))
2197                D=Tensor(1.,Function(self.domain))
2198                Y=Vector(self.domain.getDim(),Function(self.domain))
2199                for i in range(self.domain.getDim()):
2200                    A[i,:,i,:]=kronecker(self.domain)
2201                    D[i,i]+=i
2202                    Y[i]+=i
2203                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2204                mypde.setValue(A=A,D=D,Y=Y)
2205                mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
2206                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2207                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2208                u=mypde.getSolution()
2209                self.assertTrue(self.check(u,1.),'solution is wrong.')
2210      def test_BICGSTAB_ILU0_System(self):      def test_BICGSTAB_ILU0_System(self):
2211          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2212          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1952  class Test_LinearPDE_noLumping(Test_line Line 2217  class Test_LinearPDE_noLumping(Test_line
2217              Y[i]+=i              Y[i]+=i
2218          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2219          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2220      mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)          mypde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
2221      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
2222          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2223          u=mypde.getSolution()          u=mypde.getSolution()
2224          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2225      def test_PRES20_JACOBI_System(self):      def test_PRES20_JACOBI_System(self):
2226          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2227          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1967  class Test_LinearPDE_noLumping(Test_line Line 2232  class Test_LinearPDE_noLumping(Test_line
2232              Y[i]+=i              Y[i]+=i
2233          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2234          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2235      mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
2236      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
2237          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2238          u=mypde.getSolution()          u=mypde.getSolution()
2239          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2240        def test_PRES20_GAUSS_SEIDEL_System(self):
2241            A=Tensor4(0.,Function(self.domain))
2242            D=Tensor(1.,Function(self.domain))
2243            Y=Vector(self.domain.getDim(),Function(self.domain))
2244            for i in range(self.domain.getDim()):
2245                A[i,:,i,:]=kronecker(self.domain)
2246                D[i,i]+=i
2247                Y[i]+=i
2248            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2249            mypde.setValue(A=A,D=D,Y=Y)
2250            mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
2251            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2252            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2253            u=mypde.getSolution()
2254            self.assertTrue(self.check(u,1.),'solution is wrong.')
2255        def test_PRES20_AMG_System(self):
2256            if self.order!=2:
2257                if getEscriptParamInt('DISABLE_AMG', 0):
2258                    print("AMG test disabled on MPI build")
2259                    return
2260                A=Tensor4(0.,Function(self.domain))
2261                D=Tensor(1.,Function(self.domain))
2262                Y=Vector(self.domain.getDim(),Function(self.domain))
2263                for i in range(self.domain.getDim()):
2264                    A[i,:,i,:]=kronecker(self.domain)
2265                    D[i,i]+=i
2266                    Y[i]+=i
2267                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2268                mypde.setValue(A=A,D=D,Y=Y)
2269                mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
2270                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2271                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2272                u=mypde.getSolution()
2273                self.assertTrue(self.check(u,1.),'solution is wrong.')
2274      def test_PRES20_ILU0_System(self):      def test_PRES20_ILU0_System(self):
2275          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2276          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1982  class Test_LinearPDE_noLumping(Test_line Line 2281  class Test_LinearPDE_noLumping(Test_line
2281              Y[i]+=i              Y[i]+=i
2282          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2283          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2284      mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)          mypde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
2285      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
2286          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2287          u=mypde.getSolution()          u=mypde.getSolution()
2288          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2289      def test_GMRESnoRestart_JACOBI_System(self):      def test_GMRESnoRestart_JACOBI_System(self):
2290          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2291          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 1997  class Test_LinearPDE_noLumping(Test_line Line 2296  class Test_LinearPDE_noLumping(Test_line
2296              Y[i]+=i              Y[i]+=i
2297          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2298          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2299      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2300      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
2301            # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
2302            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2303            u=mypde.getSolution()
2304            self.assertTrue(self.check(u,1.),'solution is wrong.')
2305        def test_GMRESnoRestart_GAUSS_SEIDEL_System(self):
2306            A=Tensor4(0.,Function(self.domain))
2307            D=Tensor(1.,Function(self.domain))
2308            Y=Vector(self.domain.getDim(),Function(self.domain))
2309            for i in range(self.domain.getDim()):
2310                A[i,:,i,:]=kronecker(self.domain)
2311                D[i,i]+=i
2312                Y[i]+=i
2313            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2314            mypde.setValue(A=A,D=D,Y=Y)
2315            mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2316            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2317          # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)          # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
2318          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2319          u=mypde.getSolution()          u=mypde.getSolution()
2320          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2321        def test_GMRESnoRestart_AMG_System(self):
2322            if self.order!=2:
2323                if getEscriptParamInt('DISABLE_AMG',0):
2324                    print("AMG test disabled on MPI build")
2325                    return        
2326                A=Tensor4(0.,Function(self.domain))
2327                D=Tensor(1.,Function(self.domain))
2328                Y=Vector(self.domain.getDim(),Function(self.domain))
2329                for i in range(self.domain.getDim()):
2330                    A[i,:,i,:]=kronecker(self.domain)
2331                    D[i,i]+=i
2332                    Y[i]+=i
2333                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2334                mypde.setValue(A=A,D=D,Y=Y)
2335                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2336                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2337                # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
2338                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2339                u=mypde.getSolution()
2340                self.assertTrue(self.check(u,1.),'solution is wrong.')
2341      def test_GMRESnoRestart_ILU0_System(self):      def test_GMRESnoRestart_ILU0_System(self):
2342          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2343          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2013  class Test_LinearPDE_noLumping(Test_line Line 2348  class Test_LinearPDE_noLumping(Test_line
2348              Y[i]+=i              Y[i]+=i
2349          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2350          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2351      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2352      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
2353          # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)          # u=mypde.getSolution(verbose=self.VERBOSE,truncation=5)
2354          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2355          u=mypde.getSolution()          u=mypde.getSolution()
2356          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2357      def test_GMRES_JACOBI_System(self):      def test_GMRES_JACOBI_System(self):
2358          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2359          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2029  class Test_LinearPDE_noLumping(Test_line Line 2364  class Test_LinearPDE_noLumping(Test_line
2364              Y[i]+=i              Y[i]+=i
2365          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2366          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2367      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2368      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
2369            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2370            u=mypde.getSolution()
2371            self.assertTrue(self.check(u,1.),'solution is wrong.')
2372        def test_GMRES_GAUSS_SEIDEL_System(self):
2373            A=Tensor4(0.,Function(self.domain))
2374            D=Tensor(1.,Function(self.domain))
2375            Y=Vector(self.domain.getDim(),Function(self.domain))
2376            for i in range(self.domain.getDim()):
2377                A[i,:,i,:]=kronecker(self.domain)
2378                D[i,i]+=i
2379                Y[i]+=i
2380            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2381            mypde.setValue(A=A,D=D,Y=Y)
2382            mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2383            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2384          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2385          u=mypde.getSolution()          u=mypde.getSolution()
2386          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2387        def test_GMRES_AMG_System(self):
2388            if self.order!=2:
2389                if getEscriptParamInt('DISABLE_AMG', 0):
2390                    print("AMG test disabled on MPI build")
2391                    return    
2392                A=Tensor4(0.,Function(self.domain))
2393                D=Tensor(1.,Function(self.domain))
2394                Y=Vector(self.domain.getDim(),Function(self.domain))
2395                for i in range(self.domain.getDim()):
2396                    A[i,:,i,:]=kronecker(self.domain)
2397                    D[i,i]+=i
2398                    Y[i]+=i
2399                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2400                mypde.setValue(A=A,D=D,Y=Y)
2401                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2402                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2403                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2404                u=mypde.getSolution()
2405                self.assertTrue(self.check(u,1.),'solution is wrong.')
2406      def test_GMRES_ILU0_System(self):      def test_GMRES_ILU0_System(self):
2407          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2408          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2044  class Test_LinearPDE_noLumping(Test_line Line 2413  class Test_LinearPDE_noLumping(Test_line
2413              Y[i]+=i              Y[i]+=i
2414          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2415          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2416      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2417      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
2418          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2419          u=mypde.getSolution()          u=mypde.getSolution()
2420          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2421      def test_GMRES_truncation_restart_JACOBI_System(self):      def test_GMRES_truncation_restart_JACOBI_System(self):
2422          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2423          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2059  class Test_LinearPDE_noLumping(Test_line Line 2428  class Test_LinearPDE_noLumping(Test_line
2428              Y[i]+=i              Y[i]+=i
2429          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2430          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2431      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2432      mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)          mypde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
2433          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2434      mypde.getSolverOptions().setTruncation(10)          mypde.getSolverOptions().setTruncation(10)
2435      mypde.getSolverOptions().setRestart(20)          mypde.getSolverOptions().setRestart(20)
2436          u=mypde.getSolution()          u=mypde.getSolution()
2437          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2438        def test_GMRES_truncation_restart_GAUSS_SEIDEL_System(self):
2439            A=Tensor4(0.,Function(self.domain))
2440            D=Tensor(1.,Function(self.domain))
2441            Y=Vector(self.domain.getDim(),Function(self.domain))
2442            for i in range(self.domain.getDim()):
2443                A[i,:,i,:]=kronecker(self.domain)
2444                D[i,i]+=i
2445                Y[i]+=i
2446            mypde=LinearPDE(self.domain,debug=self.DEBUG)
2447            mypde.setValue(A=A,D=D,Y=Y)
2448            mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2449            mypde.getSolverOptions().setPreconditioner(SolverOptions.GAUSS_SEIDEL)
2450            mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2451            mypde.getSolverOptions().setTruncation(10)
2452            mypde.getSolverOptions().setRestart(20)
2453            u=mypde.getSolution()
2454            self.assertTrue(self.check(u,1.),'solution is wrong.')
2455        def test_GMRES_truncation_restart_AMG_System(self):
2456            if self.order!=2:
2457                if getEscriptParamInt('DISABLE_AMG', 0):
2458                    print("AMG test disabled on MPI build")
2459                    return    
2460                A=Tensor4(0.,Function(self.domain))
2461                D=Tensor(1.,Function(self.domain))
2462                Y=Vector(self.domain.getDim(),Function(self.domain))
2463                for i in range(self.domain.getDim()):
2464                    A[i,:,i,:]=kronecker(self.domain)
2465                    D[i,i]+=i
2466                    Y[i]+=i
2467                mypde=LinearPDE(self.domain,debug=self.DEBUG)
2468                mypde.setValue(A=A,D=D,Y=Y)
2469                mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2470                mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
2471                mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2472                mypde.getSolverOptions().setTruncation(10)
2473                mypde.getSolverOptions().setRestart(20)
2474                u=mypde.getSolution()
2475                self.assertTrue(self.check(u,1.),'solution is wrong.')
2476      def test_GMRES_truncation_restart_ILU0_System(self):      def test_GMRES_truncation_restart_ILU0_System(self):
2477          A=Tensor4(0.,Function(self.domain))          A=Tensor4(0.,Function(self.domain))
2478          D=Tensor(1.,Function(self.domain))          D=Tensor(1.,Function(self.domain))
# Line 2076  class Test_LinearPDE_noLumping(Test_line Line 2483  class Test_LinearPDE_noLumping(Test_line
2483              Y[i]+=i              Y[i]+=i
2484          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)
2485          mypde.setValue(A=A,D=D,Y=Y)          mypde.setValue(A=A,D=D,Y=Y)
2486      mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)          mypde.getSolverOptions().setSolverMethod(SolverOptions.GMRES)
2487      mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)          mypde.getSolverOptions().setPreconditioner(SolverOptions.ILU0)
2488          mypde.getSolverOptions().setVerbosity(self.VERBOSE)          mypde.getSolverOptions().setVerbosity(self.VERBOSE)
2489      mypde.getSolverOptions().setTruncation(10)          mypde.getSolverOptions().setTruncation(10)
2490      mypde.getSolverOptions().setRestart(20)          mypde.getSolverOptions().setRestart(20)
2491          u=mypde.getSolution()          u=mypde.getSolution()
2492          self.failUnless(self.check(u,1.),'solution is wrong.')          self.assertTrue(self.check(u,1.),'solution is wrong.')
2493    
2494    
2495        def test_FluxScalar0(self):
2496            pde= LinearPDE(self.domain, numEquations=1, numSolutions=1)
2497            u=self.domain.getX()[0]
2498            f = pde.getFlux(u)
2499            self.assertEqual(f.getShape(),(self.domain.getDim(),),"wrong shape of result.")
2500            self.assertEqual(f.getFunctionSpace(),Function(self.domain),"wrong function space")
2501            self.assertEqual(Lsup(f),0.,"wrong result")
2502    
2503        def test_FluxScalar(self):
2504            pde= LinearPDE(self.domain, numEquations=1, numSolutions=1)
2505            pde.setValue(X=kronecker(self.domain)[0]*1., B=kronecker(self.domain)[1]*2, A=5*kronecker(self.domain))
2506            x=self.domain.getX()[0]
2507            f = pde.getFlux(x)
2508            self.assertEqual(f.getShape(),(self.domain.getDim(),),"wrong shape of result.")
2509            self.assertEqual(f.getFunctionSpace(),Function(self.domain),"wrong function space")
2510            f_ref=x*kronecker(self.domain)[1]*2+(5-1)*kronecker(self.domain)[0]
2511            self.assertTrue(self.check(f, f_ref),"wrong result")
2512    
2513        def test_FluxScalarReduced(self):
2514            pde= LinearPDE(self.domain, numEquations=1, numSolutions=1)
2515            pde.setValue(X_reduced=kronecker(self.domain)[0]*1., B_reduced=kronecker(self.domain)[1]*2, A_reduced=5*kronecker(self.domain))
2516            x=self.domain.getX()[0]
2517            f = pde.getFlux(x)
2518            self.assertEqual(f.getShape(),(self.domain.getDim(),),"wrong shape of result.")
2519            self.assertEqual(f.getFunctionSpace(),ReducedFunction(self.domain),"wrong function space")
2520            f_ref=x*kronecker(self.domain)[1]*2+(5-1)*kronecker(self.domain)[0]
2521            self.assertTrue(self.check(f, f_ref),"wrong result")
2522    
2523        def test_FluxSystem0(self):
2524            pde= LinearPDE(self.domain, numEquations=2, numSolutions=2)
2525            u=self.domain.getX()
2526            f = pde.getFlux(u)
2527            self.assertEqual(f.getShape(),(2, self.domain.getDim()),"wrong shape of result.")
2528            self.assertEqual(f.getFunctionSpace(),Function(self.domain),"wrong function space")
2529            self.assertEqual(Lsup(f),0.,"wrong result")
2530    
2531        def test_FluxSystem(self):
2532            pde= LinearPDE(self.domain, numEquations=2, numSolutions=2)
2533            X=Data(0., (2, self.domain.getDim()), Function(self.domain))
2534            X[0,0]=1
2535            B=Data(0., (2, self.domain.getDim(),2), Function(self.domain))
2536            B[0,0,0]=5
2537            A=Data(0., (2, self.domain.getDim(),2, self.domain.getDim()), Function(self.domain))
2538            A[0,0,0,0]=10
2539            pde.setValue(X=X, B=B, A=A)
2540            x=self.domain.getX()
2541            f = pde.getFlux(x[:2])
2542            self.assertEqual(f.getShape(),(2, self.domain.getDim()),"wrong shape of result.")
2543            self.assertEqual(f.getFunctionSpace(),Function(self.domain),"wrong function space")
2544            f_ref=X*(5*x[0]-1+10)
2545            self.assertTrue(self.check(f, f_ref),"wrong result")
2546        def test_FluxSystemReduced(self):
2547            pde= LinearPDE(self.domain, numEquations=2, numSolutions=2)
2548            X=Data(0., (2, self.domain.getDim()), ReducedFunction(self.domain))
2549            X[0,0]=1
2550            B=Data(0., (2, self.domain.getDim(),2), ReducedFunction(self.domain))
2551            B[0,0,0]=5
2552            A=Data(0., (2, self.domain.getDim(),2, self.domain.getDim()), ReducedFunction(self.domain))
2553            A[0,0,0,0]=10
2554            pde.setValue(X=X, B=B, A=A)
2555            x=self.domain.getX()
2556            f = pde.getFlux(x[:2])
2557            self.assertEqual(f.getShape(),(2, self.domain.getDim()),"wrong shape of result.")
2558            self.assertEqual(f.getFunctionSpace(),ReducedFunction(self.domain),"wrong function space")
2559            f_ref=X*(5*x[0]-1+10)
2560            self.assertTrue(self.check(f, f_ref),"wrong result")
2561