/[escript]/trunk/dudley/test/python/run_escriptOnDudley.py
ViewVC logotype

Diff of /trunk/dudley/test/python/run_escriptOnDudley.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.dudley import Rectangle, Brick  from esys.dudley 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 47  class Test_SharedOnDudley(Test_Shared): Line 45  class Test_SharedOnDudley(Test_Shared):
45          del self.domain          del self.domain
46          del self.tol          del self.tol
47    
48    
49  class Test_DomainOnDudley(Test_Domain):  class Test_DomainOnDudley(Test_Domain):
50     def setUp(self):     def setUp(self):
51         self.boundary_tag_list = [1, 2, 10, 20]         self.boundary_tag_list = [1, 2, 10, 20]
52         self.domain =Rectangle(NE,NE+1,2)         self.domain =Rectangle(NE,NE+1,2)
53    
54     def tearDown(self):     def tearDown(self):
55         del self.domain         del self.domain
56         del self.boundary_tag_list         del self.boundary_tag_list
57          
         
58     def test_setXError(self):     def test_setXError(self):
59         domain=Rectangle(NE,NE)         domain=Rectangle(NE,NE)
60         x=domain.getX()               x=domain.getX()
61         z=interpolate(x, Function(domain))         z=interpolate(x, Function(domain))
62         self.assertRaises(RuntimeError, domain.setX, z)         self.assertRaises(RuntimeError, domain.setX, z)
63         del x         del x
64         del z         del z
65         del domain               del domain
         
66    
67     def test_tagsContinuousFunction(self):     def test_tagsContinuousFunction(self):
68         ref_tags=[0]         ref_tags=[0]
# Line 112  class Test_DataOpsOnDudley(Test_Dump, Te Line 110  class Test_DataOpsOnDudley(Test_Dump, Te
110         del self.domain_with_different_sample_ordering         del self.domain_with_different_sample_ordering
111         del self.mainfs         del self.mainfs
112         del self.otherfs         del self.otherfs
         
113    
114    
115  class Test_TableInterpolationOnDudley(Test_TableInterpolation):  class Test_TableInterpolationOnDudley(Test_TableInterpolation):
# Line 129  class Test_TableInterpolationOnDudley(Te Line 126  class Test_TableInterpolationOnDudley(Te
126          del self.domain          del self.domain
127          del self.functionspaces          del self.functionspaces
128    
129            
                   
                   
130  class Test_CSVOnDudley(Test_saveCSV):  class Test_CSVOnDudley(Test_saveCSV):
131     def setUp(self):      def setUp(self):
132         self.domain =Rectangle(NE,NE+1)          NE0=NE
133         self.linecount1=31               #see test_save1 for the meaning of these params          NE1=NE+1
134         self.linecount2=25          self.domain=Rectangle(NE0,NE1)
135         self.line_expected=[0.25, 0., 0.25]          self.functionspaces=[ContinuousFunction, ReducedContinuousFunction]
136                  # number of total data points for each function space
137     def tearDown(self):          self.linecounts=[ (NE0+1)*(NE1+1)+1, (NE0+1)*(NE1+1)+1 ]
138         del self.domain          # number of masked points, i.e. where X[0] is non-zero
139                  self.linecounts_masked=[ NE0*(NE1+1)+1, NE0*(NE1+1)+1 ]
140     #This test checks to see that all FunctionSpaces can be saved          # expected values in first line of masked data = [ X[:], X[0] ]
141     def test_singleFS(self):          self.firstline=[ [1./NE0, 0., 1./NE0], [1./NE0, 0., 1./NE0] ]
142          fname=os.path.join(DUDLEY_WORKDIR, "test_singlefs.csv")  
143          fss=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),      def tearDown(self):
144          FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),          del self.domain
145          DiracDeltaFunctions(self.domain)]  
146          for f in fss:      def test_csv_multiFS(self):
147                  d=Data(7,f)          if getMPISizeWorld() == 1:
148                  print("Testing "+str(f)+"\n")              fname=os.path.join(DUDLEY_WORKDIR, "test_multifs.csv")
149                  saveDataCSV(fname, D=d)              sol=Data(8,Solution(self.domain))
150                ctsfn=Data(9,ContinuousFunction(self.domain))
151     def test_multiFS(self):              #test line 0
152          fname=os.path.join(DUDLEY_WORKDIR, "test_multifs.csv")              dirac=Data(-1,DiracDeltaFunctions(self.domain))
153          sol=Data(8,Solution(self.domain))              saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)
154          ctsfn=Data(9,ContinuousFunction(self.domain))              #test line 1
155          #test line 0              fun=Data(5,Function(self.domain))
156          dirac=Data(-1,DiracDeltaFunctions(self.domain))              rfun=Data(3,ReducedFunction(self.domain))
157          saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)              saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)
158          #test line 1              #test line 2
159          fun=Data(5,Function(self.domain))              bound=Data(1,FunctionOnBoundary(self.domain))
160          rfun=Data(3,ReducedFunction(self.domain))              rbound=Data(3,ReducedFunctionOnBoundary(self.domain))
161          saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)              saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)
162          #test line 2          else:
163          bound=Data(1,FunctionOnBoundary(self.domain))              print("Skipping CSV multiFS tests on dudley since MPI size > 1")
164          rbound=Data(3,ReducedFunctionOnBoundary(self.domain))  
         saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)  
165    
           
166  if __name__ == '__main__':  if __name__ == '__main__':
167     suite = unittest.TestSuite()     suite = unittest.TestSuite()
168     suite.addTest(unittest.makeSuite(Test_SharedOnDudley))     suite.addTest(unittest.makeSuite(Test_SharedOnDudley))

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

  ViewVC Help
Powered by ViewVC 1.1.26