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

Diff of /branches/symbolic_from_3470/dudley/test/python/run_escriptOnDudley.py

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

revision 1827 by ksteube, Thu Oct 2 04:28:07 2008 UTC revision 2653 by jfenwick, Tue Sep 8 04:26:30 2009 UTC
# Line 1  Line 1 
1    
2  ########################################################  ########################################################
3  #  #
4  # Copyright (c) 2003-2008 by University of Queensland  # Copyright (c) 2003-2009 by University of Queensland
5  # Earth Systems Science Computational Center (ESSCC)  # Earth Systems Science Computational Center (ESSCC)
6  # http://www.uq.edu.au/esscc  # http://www.uq.edu.au/esscc
7  #  #
# Line 11  Line 11 
11  #  #
12  ########################################################  ########################################################
13    
14  __copyright__="""Copyright (c) 2003-2008 by University of Queensland  __copyright__="""Copyright (c) 2003-2009 by University of Queensland
15  Earth Systems Science Computational Center (ESSCC)  Earth Systems Science Computational Center (ESSCC)
16  http://www.uq.edu.au/esscc  http://www.uq.edu.au/esscc
17  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
18  __license__="""Licensed under the Open Software License version 3.0  __license__="""Licensed under the Open Software License version 3.0
19  http://www.opensource.org/licenses/osl-3.0.php"""  http://www.opensource.org/licenses/osl-3.0.php"""
20  __url__="http://www.uq.edu.au/esscc/escript-finley"  __url__="https://launchpad.net/escript-finley"
21    
22  import unittest  import unittest
23  import tempfile  import tempfile
# 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  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, Test_GlobalMinMax
31    
32    from test_shared import Test_Shared
33    
34  try:  try:
35       FINLEY_WORKDIR=os.environ['FINLEY_WORKDIR']       FINLEY_WORKDIR=os.environ['FINLEY_WORKDIR']
# Line 35  except KeyError: Line 37  except KeyError:
37       FINLEY_WORKDIR='.'       FINLEY_WORKDIR='.'
38    
39  NE=4 # number elements, must be even  NE=4 # number elements, must be even
40    
41    class Test_SharedOnFinley(Test_Shared):
42      def setUp(self):
43        self.domain=Rectangle(NE,NE)
44        self.tol=0.001
45      def tearDown(self):
46        del self.domain
47        del self.tol
48    
49  class Test_DomainOnFinley(Test_Domain):  class Test_DomainOnFinley(Test_Domain):
50     def setUp(self):     def setUp(self):
51           self.boundary_tag_list = [1, 2, 10, 20]
52         self.domain =Rectangle(NE,NE+1,2)         self.domain =Rectangle(NE,NE+1,2)
53     def tearDown(self):     def tearDown(self):
54         del self.domain         del self.domain
55           del self.boundary_tag_list
56    
57     def test_tagsContinuousFunction(self):     def test_tagsContinuousFunction(self):
58         ref_tags=[0]         ref_tags=[0]
# Line 58  class Test_DomainOnFinley(Test_Domain): Line 71  class Test_DomainOnFinley(Test_Domain):
71         self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")         self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")
72         for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)         for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)
73     def test_tagsFunctionOnBoundary(self):     def test_tagsFunctionOnBoundary(self):
74         # For MPI a subdomain may be missing some tags and this test is expected to fail         ref_tags=[1, 2, 10, 20]
75         if getMPISizeWorld() == 1:         tags=FunctionOnBoundary(self.domain).getListOfTags()
76           ref_tags=[1, 2, 10, 20]         # For an MPI-distributed domain some tags may be missing
77           tags=FunctionOnBoundary(self.domain).getListOfTags()         if getMPISizeWorld() == 1: self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")
78           self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")         for i in tags: self.failUnless(i in ref_tags,"tag %s is missing."%i)
          for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)  
79     def test_tagsReducedFunctionOnBoundary(self):     def test_tagsReducedFunctionOnBoundary(self):
80         # For MPI a subdomain may be missing some tags and this test is expected to fail         ref_tags=[1, 2, 10, 20]
81         if getMPISizeWorld() == 1:         tags=ReducedFunctionOnBoundary(self.domain).getListOfTags()
82           ref_tags=[1, 2, 10, 20]         # For an MPI-distributed domain some tags may be missing
83           tags=ReducedFunctionOnBoundary(self.domain).getListOfTags()         if getMPISizeWorld() == 1: self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")
84           self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")         for i in tags: self.failUnless(i in ref_tags,"tag %s is missing."%i)
          for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)  
85     def test_tagsFunctionOnContactOne(self):     def test_tagsFunctionOnContactOne(self):
86         ref_tags=[]         ref_tags=[]
87         tags=FunctionOnContactOne(self.domain).getListOfTags()         tags=FunctionOnContactOne(self.domain).getListOfTags()
# Line 92  class Test_DomainOnFinley(Test_Domain): Line 103  class Test_DomainOnFinley(Test_Domain):
103         self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")         self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")
104         for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)         for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)
105    
106  class Test_DataOpsOnFinley(Test_Dump, Test_SetDataPointValue):  class Test_DataOpsOnFinley(Test_Dump, Test_SetDataPointValue, Test_GlobalMinMax):
107     def setUp(self):     def setUp(self):
108         self.domain =Rectangle(NE,NE+1,2)         self.domain =Rectangle(NE,NE+1,2)
109         self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1,2)         self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1,2)
110         self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,2,integrationOrder=2)         self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,2,integrationOrder=2)
111         self.domain_with_different_sample_ordering =Rectangle(1,(NE+1)*NE,2)         self.domain_with_different_sample_ordering =Rectangle(NE,NE+1,2, optimize=True)
112         self.filename_base=FINLEY_WORKDIR         self.filename_base=FINLEY_WORKDIR
113    
114     def tearDown(self):     def tearDown(self):
# Line 105  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    
121    
122    class Test_TableInterpolationOnFinley(Test_TableInterpolation):
123        def setUp(self):
124        self.domain=Rectangle(4,4)
125        self.functionspaces=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
126            FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),
127            FunctionOnContactZero(self.domain), FunctionOnContactOne(self.domain),
128            ReducedFunctionOnContactZero(self.domain), ReducedFunctionOnContactOne(self.domain)]
129            #We aren't testing DiracDeltaFunction
130        self.xn=3   # number of grids on x axis
131        self.yn=3   # number of grids on y axis
132    
133        def tearDown(self):
134        del self.domain
135        del self.functionspaces
136    
137        
138            
139            
140    class Test_CSVOnFinley(Test_saveCSV):
141       def setUp(self):
142           self.domain =Rectangle(NE,NE+1,2)
143           self.linecount1=20       #see test_save1 for the meaning of these params
144           self.linecount2=69
145          
146       def tearDown(self):
147           del self.domain
148          
149       #This test checks to see that all FunctionSpaces can be saved
150       def test_singleFS(self):
151        fname="test_singlefs.csv"
152        fss=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
153        FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),
154        FunctionOnContactZero(self.domain), FunctionOnContactOne(self.domain),
155        ReducedFunctionOnContactZero(self.domain), ReducedFunctionOnContactOne(self.domain),
156        DiracDeltaFunction(self.domain)]
157        for f in fss:
158            d=Data(7,f)
159            print "Testing "+str(f)+"\n"
160            saveDataCSV(fname, D=d)
161    
162       def test_multiFS(self):
163        fname="test_multifs.csv"
164        sol=Data(8,Solution(self.domain))
165        ctsfn=Data(9,ContinuousFunction(self.domain))
166        #test line 0
167        dirac=Data(-1,DiracDeltaFunction(self.domain))
168        saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)
169        #test line 1
170        fun=Data(5,Function(self.domain))
171        rfun=Data(3,ReducedFunction(self.domain))
172        saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)
173        #test line 2
174        bound=Data(1,FunctionOnBoundary(self.domain))
175        rbound=Data(3,ReducedFunctionOnBoundary(self.domain))
176        saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)
177        #test line 3
178        conzz=Data(7,FunctionOnContactZero(self.domain))
179        rconz=Data(8,ReducedFunctionOnContactZero(self.domain))
180        saveDataCSV(fname,A=sol,B=ctsfn, C=conzz, D=rconz)
181        #check for cross line exceptions
182        self.failUnlessRaises(RuntimeError, saveDataCSV, fname, A=dirac, B=rfun)
183        self.failUnlessRaises(RuntimeError, saveDataCSV, fname, A=bound, B=conzz)
184    
185        
186  if __name__ == '__main__':  if __name__ == '__main__':
187     suite = unittest.TestSuite()     suite = unittest.TestSuite()
188       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_TableInterpolationOnFinley))
192       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)
195    

Legend:
Removed from v.1827  
changed lines
  Added in v.2653

  ViewVC Help
Powered by ViewVC 1.1.26