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

Diff of /trunk/finley/test/python/run_escriptOnFinley.py

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

revision 3992 by jfenwick, Fri Sep 21 02:47:54 2012 UTC revision 3993 by caltinay, Wed Sep 26 07:00:55 2012 UTC
# Line 20  __license__="""Licensed under the Open S Line 20  __license__="""Licensed under the Open S
20  http://www.opensource.org/licenses/osl-3.0.php"""  http://www.opensource.org/licenses/osl-3.0.php"""
21  __url__="https://launchpad.net/escript-finley"  __url__="https://launchpad.net/escript-finley"
22    
23    import os
24    import sys
25  import unittest  import unittest
 import tempfile  
26    
27  from esys.escript import *  from esys.escript import *
28  from esys.finley import Rectangle, Brick  from esys.finley import Rectangle, Brick
29  import sys  from test_objects import Test_Dump, Test_SetDataPointValue, Test_saveCSV, \
30  import os          Test_TableInterpolation, Test_Domain, Test_GlobalMinMax, Test_Lazy
 from test_objects import Test_Dump, Test_SetDataPointValue, Test_saveCSV, Test_TableInterpolation  
 from test_objects import Test_Domain, Test_GlobalMinMax, Test_Lazy  
   
31  from test_shared import Test_Shared  from test_shared import Test_Shared
32    
33  try:  try:
# Line 53  class Test_DomainOnFinley(Test_Domain): Line 51  class Test_DomainOnFinley(Test_Domain):
51         self.domain =Rectangle(NE,NE+1,2)         self.domain =Rectangle(NE,NE+1,2)
52     def tearDown(self):     def tearDown(self):
53         del self.domain         del self.domain
54         del self.boundary_tag_list         del self.boundary_tag_list
55          
         
56     def test_setXError(self):     def test_setXError(self):
57         domain=Rectangle(NE,NE)         domain=Rectangle(NE,NE)
58         x=domain.getX()               x=domain.getX()
59         z=interpolate(x, Function(domain))         z=interpolate(x, Function(domain))
60         self.assertRaises(RuntimeError, domain.setX, z)         self.assertRaises(RuntimeError, domain.setX, z)
61         del x         del x
# Line 131  class Test_DataOpsOnFinley(Test_Dump, Te Line 128  class Test_DataOpsOnFinley(Test_Dump, Te
128         del self.domain_with_different_sample_ordering         del self.domain_with_different_sample_ordering
129         del self.mainfs         del self.mainfs
130         del self.otherfs         del self.otherfs
         
131    
132    
133  class Test_TableInterpolationOnFinley(Test_TableInterpolation):  class Test_TableInterpolationOnFinley(Test_TableInterpolation):
134      def setUp(self):      def setUp(self):
135          self.domain=Brick(4,4,4)          self.domain=Brick(4,4,4)
136          self.functionspaces=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),          self.functionspaces=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
137              FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),              FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),
138              FunctionOnContactZero(self.domain), FunctionOnContactOne(self.domain),              FunctionOnContactZero(self.domain), FunctionOnContactOne(self.domain),
139              ReducedFunctionOnContactZero(self.domain), ReducedFunctionOnContactOne(self.domain)]              ReducedFunctionOnContactZero(self.domain), ReducedFunctionOnContactOne(self.domain)]
140              #We aren't testing DiracDeltaFunctions              #We aren't testing DiracDeltaFunctions
# Line 150  class Test_TableInterpolationOnFinley(Te Line 146  class Test_TableInterpolationOnFinley(Te
146          del self.domain          del self.domain
147          del self.functionspaces          del self.functionspaces
148    
149            
                   
                   
150  class Test_CSVOnFinley(Test_saveCSV):  class Test_CSVOnFinley(Test_saveCSV):
151     def setUp(self):      def setUp(self):
152         self.domain =Rectangle(NE,NE+1,2)          NE0=NE
153         self.linecount1=80               #see test_save1 for the meaning of these params          NE1=NE+1
154         self.linecount2=69          self.domain=Rectangle(NE0, NE1, order=2)
155         self.line_expected=[0.125, 0., 0.125]          self.functionspaces=[ContinuousFunction, ReducedContinuousFunction]
156                  # number of total data points for each function space
157     def tearDown(self):          self.linecounts=[ (2*NE0+1)*(2*NE1+1)-NE0*NE1+1, 31 ]
158         del self.domain          # number of masked points, i.e. where X[0] is non-zero
159                  self.linecounts_masked=[ (2*NE0+1)*(2*NE1+1)-(2+NE0)*NE1, 25 ]
160     #This test checks to see that all FunctionSpaces can be saved          # expected values in first line of masked data = [ X[:], X[0] ]
161     def test_singleFS(self):          self.firstline=[ [1./(2*NE0), 0., 1./(2*NE0)], [.25, 0., .25] ]
162          fname=os.path.join(FINLEY_WORKDIR, "test_singlefs.csv")  
163          fss=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),      def tearDown(self):
164          FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),          del self.domain
165          FunctionOnContactZero(self.domain), FunctionOnContactOne(self.domain),  
166          ReducedFunctionOnContactZero(self.domain), ReducedFunctionOnContactOne(self.domain),      def test_csv_multiFS(self):
167          DiracDeltaFunctions(self.domain)]          if getMPISizeWorld() == 1:
168          for f in fss:              fname=os.path.join(FINLEY_WORKDIR, "test_multifs.csv")
169                  d=Data(7,f)              sol=Data(8,Solution(self.domain))
170                  print("Testing "+str(f)+"\n")              ctsfn=Data(9,ContinuousFunction(self.domain))
171                  saveDataCSV(fname, D=d)              #test line 0
172                dirac=Data(-1,DiracDeltaFunctions(self.domain))
173     def test_multiFS(self):              saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)
174          fname=os.path.join(FINLEY_WORKDIR, "test_multifs.csv")              #test line 1
175          sol=Data(8,Solution(self.domain))              fun=Data(5,Function(self.domain))
176          ctsfn=Data(9,ContinuousFunction(self.domain))              rfun=Data(3,ReducedFunction(self.domain))
177          #test line 0              saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)
178          dirac=Data(-1,DiracDeltaFunctions(self.domain))              #test line 2
179          saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)              bound=Data(1,FunctionOnBoundary(self.domain))
180          #test line 1              rbound=Data(3,ReducedFunctionOnBoundary(self.domain))
181          fun=Data(5,Function(self.domain))              saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)
182          rfun=Data(3,ReducedFunction(self.domain))              #test line 3
183          saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)              conzz=Data(7,FunctionOnContactZero(self.domain))
184          #test line 2              rconz=Data(8,ReducedFunctionOnContactZero(self.domain))
185          bound=Data(1,FunctionOnBoundary(self.domain))              saveDataCSV(fname,A=sol,B=ctsfn, C=conzz, D=rconz)
186          rbound=Data(3,ReducedFunctionOnBoundary(self.domain))              #check for cross line exceptions
187          saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)              self.assertRaises(RuntimeError, saveDataCSV, fname, A=dirac, B=rfun)
188          #test line 3              self.assertRaises(RuntimeError, saveDataCSV, fname, A=bound, B=conzz)
189          conzz=Data(7,FunctionOnContactZero(self.domain))          else:
190          rconz=Data(8,ReducedFunctionOnContactZero(self.domain))              print("Skipping CSV multiFS tests on finley since MPI size > 1")
191          saveDataCSV(fname,A=sol,B=ctsfn, C=conzz, D=rconz)  
         #check for cross line exceptions  
         self.assertRaises(RuntimeError, saveDataCSV, fname, A=dirac, B=rfun)  
         self.assertRaises(RuntimeError, saveDataCSV, fname, A=bound, B=conzz)  
192    
           
193  if __name__ == '__main__':  if __name__ == '__main__':
194     suite = unittest.TestSuite()     suite = unittest.TestSuite()
195     suite.addTest(unittest.makeSuite(Test_SharedOnFinley))     suite.addTest(unittest.makeSuite(Test_SharedOnFinley))

Legend:
Removed from v.3992  
changed lines
  Added in v.3993

  ViewVC Help
Powered by ViewVC 1.1.26