/[escript]/branches/domexper/finley/test/python/run_escriptOnFinley.py
ViewVC logotype

Diff of /branches/domexper/finley/test/python/run_escriptOnFinley.py

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

revision 2644 by jfenwick, Wed Sep 2 04:14:03 2009 UTC revision 2646 by jfenwick, Fri Sep 4 00:13:00 2009 UTC
# Line 26  from esys.escript import * Line 26  from esys.escript import *
26  from esys.finley import Rectangle  from esys.finley import Rectangle
27  import sys  import sys
28  import os  import os
29  from test_objects import Test_Dump, Test_SetDataPointValue, Test_saveCSV  from test_objects import Test_Dump, Test_SetDataPointValue, Test_saveCSV, Test_TableInterpolation
30  from test_objects import Test_Domain  from test_objects import Test_Domain
31    
32  from test_shared import Test_Shared  from test_shared import Test_Shared
# Line 116  class Test_DataOpsOnFinley(Test_Dump, Te Line 116  class Test_DataOpsOnFinley(Test_Dump, Te
116         del self.domain_with_different_number_of_samples         del self.domain_with_different_number_of_samples
117         del self.domain_with_different_number_of_data_points_per_sample         del self.domain_with_different_number_of_data_points_per_sample
118         del self.domain_with_different_sample_ordering         del self.domain_with_different_sample_ordering
119          
120    
 #Some of this functionality could be tested in escript but we need  
 #the rectangle domain for the rest of it  
 class Test_TableInterpolation(unittest.TestCase):  
       
     RES_TOL=1.e-7 # RES_TOLerance to compare results      
       
121    
122      def test_NullFunctionSpace(self):  class Test_TableInterpolationOnFinley(Test_TableInterpolation):
123      arL=[[0, -1, -2, -3, -4], [1, 1, -2, -3, -4], [2, 2, 2, -3, -4], [3, 3, 3, 3, -4], [4, 4, 4, 4, 4]]      def setUp(self):
124      arn=numpy.array(arL)      self.domain=Rectangle(4,4)
125      ars=[arL,arn]      self.functionspaces=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
126      d0=Data(0)          FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),
127      d1=Data(1)          FunctionOnContactZero(self.domain), FunctionOnContactOne(self.domain),
128      d2=Data(2)          ReducedFunctionOnContactZero(self.domain), ReducedFunctionOnContactOne(self.domain)]
129      d35=Data(3.5)          #We aren't testing DiracDeltaFunction
130      d4=Data(4)      self.xn=3   # number of grids on x axis
131      dm05=Data(-0.5)      self.yn=3   # number of grids on y axis
132      d175=Data(1.75)  
133      d225=Data(2.25)      def tearDown(self):
134      for arr in ars:      del self.domain
135          self.failUnless(Lsup(d1.interpolateTable(arL,0, 1, 100, d2, 0, 1)+2)<self.RES_TOL)      del self.functionspaces
136          self.failUnless(Lsup(d1.interpolateTable(arL,0, 1, 100, d35, 0, 1)+3.5)<self.RES_TOL)  
         self.failUnless(Lsup(d35.interpolateTable(arL,0,1, 100, d2, 0, 1)-3.5)<self.RES_TOL)  
         self.failUnless(Lsup(d175.interpolateTable(arL,0,1,100,d225,0,1)-0)<self.RES_TOL)  
         self.failUnless(Lsup(d2.interpolateTable(arL, 1, 4, 100, d2, -1, 4)-0.25)<self.RES_TOL)  
            # Point out of bounds  
         self.failUnlessRaises(RuntimeError, d1.interpolateTable,arL,0, 1, 100, d4, 0, 1 )  
         self.failUnlessRaises(RuntimeError, d4.interpolateTable, arL,0, 1, 100, d1, 0, 1 )  
         self.failUnlessRaises(RuntimeError, dm05.interpolateTable, arL,0,1, 100, d1 , 0,1 )  
         self.failUnlessRaises(RuntimeError, d1.interpolateTable, arL,0,1, 100, dm05 , 0,1 )  
            # interpolated value too large  
         self.failUnlessRaises(RuntimeError, d2.interpolateTable, arL, 0, 1, 1, d2, 0, 1 )  
   
     def test_Rectangle(self):  
     bounds=2  
     r=Rectangle(n0=bounds, n1=bounds, l0=bounds, l1=bounds)  
     x=r.getX()  
     arr=[]  
     for j in xrange(bounds+2):  
        v=[]  
        for k in xrange(bounds+2):  
             v.append(k)  
        arr.append(v)  
     arr=numpy.array(arr)  
     x0=x[0]  
     x1=x[1]  
     d100=Data(100)  
     self.failUnlessRaises(RuntimeError, d100.interpolateTable, arr, 0, 1, 5, d100,0,1)  
     zz=x0.interpolateTable(arr,0,1,100,x1,0,1)  
137            
138                    
139                    
# Line 184  class Test_CSVOnFinley(Test_saveCSV): Line 152  class Test_CSVOnFinley(Test_saveCSV):
152      fss=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),      fss=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
153      FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),      FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),
154      FunctionOnContactZero(self.domain), FunctionOnContactOne(self.domain),      FunctionOnContactZero(self.domain), FunctionOnContactOne(self.domain),
155      ReducedFunctionOnContactZero(self.domain), ReducedFunctionOnContactOne(self.domain)]      ReducedFunctionOnContactZero(self.domain), ReducedFunctionOnContactOne(self.domain),
156        DiracDeltaFunction(self.domain)]
157      for f in fss:      for f in fss:
158          d=Data(7,f)          d=Data(7,f)
159          print "Testing "+str(f)+"\n"          print "Testing "+str(f)+"\n"
# Line 219  if __name__ == '__main__': Line 188  if __name__ == '__main__':
188     suite.addTest(unittest.makeSuite(Test_SharedOnFinley))     suite.addTest(unittest.makeSuite(Test_SharedOnFinley))
189     suite.addTest(unittest.makeSuite(Test_DataOpsOnFinley))     suite.addTest(unittest.makeSuite(Test_DataOpsOnFinley))
190     suite.addTest(unittest.makeSuite(Test_DomainOnFinley))     suite.addTest(unittest.makeSuite(Test_DomainOnFinley))
191     suite.addTest(unittest.makeSuite(Test_TableInterpolation))     suite.addTest(unittest.makeSuite(Test_TableInterpolationOnFinley))
192     suite.addTest(unittest.makeSuite(Test_CSVOnFinley))     suite.addTest(unittest.makeSuite(Test_CSVOnFinley))
193     s=unittest.TextTestRunner(verbosity=2).run(suite)     s=unittest.TextTestRunner(verbosity=2).run(suite)
194     if not s.wasSuccessful(): sys.exit(1)     if not s.wasSuccessful(): sys.exit(1)

Legend:
Removed from v.2644  
changed lines
  Added in v.2646

  ViewVC Help
Powered by ViewVC 1.1.26