/[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

trunk/finley/test/python/run_escriptOnFinley.py revision 2549 by jfenwick, Mon Jul 20 06:43:47 2009 UTC branches/symbolic_from_3470/dudley/test/python/run_escriptOnDudley.py revision 3815 by caltinay, Thu Feb 9 00:27:46 2012 UTC
# Line 1  Line 1 
1    
2  ########################################################  ########################################################
3  #  #
4  # Copyright (c) 2003-2009 by University of Queensland  # Copyright (c) 2003-2010 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-2009 by University of Queensland  __copyright__="""Copyright (c) 2003-2010 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"""
# Line 23  import unittest Line 23  import unittest
23  import tempfile  import tempfile
24    
25  from esys.escript import *  from esys.escript import *
26  from esys.finley import Rectangle  from esys.dudley import Rectangle, Brick
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, Test_Lazy
31    
32  from test_shared import Test_Shared  from test_shared import Test_Shared
33    
34  try:  try:
35       FINLEY_WORKDIR=os.environ['FINLEY_WORKDIR']       DUDLEY_WORKDIR=os.environ['DUDLEY_WORKDIR']
36  except KeyError:  except KeyError:
37       FINLEY_WORKDIR='.'       DUDLEY_WORKDIR='.'
38    
39  NE=4 # number elements, must be even  NE=4 # number elements, must be even
40    
41  class Test_SharedOnFinley(Test_Shared):  class Test_SharedOnDudley(Test_Shared):
42    def setUp(self):    def setUp(self):
43      self.domain=Rectangle(NE,NE)      self.domain=Rectangle(NE,NE)
44      self.tol=0.001      self.tol=0.001
# Line 46  class Test_SharedOnFinley(Test_Shared): Line 46  class Test_SharedOnFinley(Test_Shared):
46      del self.domain      del self.domain
47      del self.tol      del self.tol
48    
49  class Test_DomainOnFinley(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)
# Line 57  class Test_DomainOnFinley(Test_Domain): Line 57  class Test_DomainOnFinley(Test_Domain):
57     def test_tagsContinuousFunction(self):     def test_tagsContinuousFunction(self):
58         ref_tags=[0]         ref_tags=[0]
59         tags=ContinuousFunction(self.domain).getListOfTags()         tags=ContinuousFunction(self.domain).getListOfTags()
60         self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")         self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
61         for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)         for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
62    
63     def test_tagsFunction(self):     def test_tagsFunction(self):
64         ref_tags=[0]         ref_tags=[0]
65         tags=Function(self.domain).getListOfTags()         tags=Function(self.domain).getListOfTags()
66         self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")         self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
67         for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)         for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
68     def test_tagsReducedFunction(self):     def test_tagsReducedFunction(self):
69         ref_tags=[0]         ref_tags=[0]
70         tags=ReducedFunction(self.domain).getListOfTags()         tags=ReducedFunction(self.domain).getListOfTags()
71         self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")         self.assertTrue(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.assertTrue(i in tags,"tag %s is missing."%i)
73     def test_tagsFunctionOnBoundary(self):     def test_tagsFunctionOnBoundary(self):
74         ref_tags=[1, 2, 10, 20]         ref_tags=[1, 2, 10, 20]
75         tags=FunctionOnBoundary(self.domain).getListOfTags()         tags=FunctionOnBoundary(self.domain).getListOfTags()
76         # For an MPI-distributed domain some tags may be missing         # For an MPI-distributed domain some tags may be missing
77         if getMPISizeWorld() == 1: self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")         if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
78         for i in tags: self.failUnless(i in ref_tags,"tag %s is missing."%i)         for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
79     def test_tagsReducedFunctionOnBoundary(self):     def test_tagsReducedFunctionOnBoundary(self):
80         ref_tags=[1, 2, 10, 20]         ref_tags=[1, 2, 10, 20]
81         tags=ReducedFunctionOnBoundary(self.domain).getListOfTags()         tags=ReducedFunctionOnBoundary(self.domain).getListOfTags()
82         # For an MPI-distributed domain some tags may be missing         # For an MPI-distributed domain some tags may be missing
83         if getMPISizeWorld() == 1: self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")         if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
84         for i in tags: self.failUnless(i in ref_tags,"tag %s is missing."%i)         for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
    def test_tagsFunctionOnContactOne(self):  
        ref_tags=[]  
        tags=FunctionOnContactOne(self.domain).getListOfTags()  
        self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")  
        for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)  
    def test_tagsFunctionOnContactZero(self):  
        ref_tags=[]  
        tags=FunctionOnContactZero(self.domain).getListOfTags()  
        self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")  
        for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)  
    def test_tagsReducedFunctionOnContactOne(self):  
        ref_tags=[]  
        tags=ReducedFunctionOnContactOne(self.domain).getListOfTags()  
        self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")  
        for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)  
    def test_tagsReducedFunctionOnContactZero(self):  
        ref_tags=[]  
        tags=ReducedFunctionOnContactZero(self.domain).getListOfTags()  
        self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.")  
        for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i)  
85    
86  class Test_DataOpsOnFinley(Test_Dump, Test_SetDataPointValue):  class Test_DataOpsOnDudley(Test_Dump, Test_SetDataPointValue, Test_GlobalMinMax, Test_Lazy):
87     def setUp(self):     def setUp(self):
88         self.domain =Rectangle(NE,NE+1,2)         self.domain =Rectangle(NE,NE+1,2)
89         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)
90         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)
91         self.domain_with_different_sample_ordering =Rectangle(NE,NE+1,2, optimize=True)         self.domain_with_different_sample_ordering =Rectangle(NE,NE+1,2, optimize=True)
92         self.filename_base=FINLEY_WORKDIR         self.filename_base=DUDLEY_WORKDIR
93           self.mainfs=Function(self.domain)
94           self.otherfs=Solution(self.domain)
95    
96     def tearDown(self):     def tearDown(self):
97         del self.domain         del self.domain
98         del self.domain_with_different_number_of_samples         del self.domain_with_different_number_of_samples
99         del self.domain_with_different_number_of_data_points_per_sample         del self.domain_with_different_number_of_data_points_per_sample
100         del self.domain_with_different_sample_ordering         del self.domain_with_different_sample_ordering
101           del self.mainfs
102           del self.otherfs
103          
104    
105    
106    class Test_TableInterpolationOnDudley(Test_TableInterpolation):
107        def setUp(self):
108        self.domain=Brick(4,4,4)
109        self.functionspaces=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
110            FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain)]
111            #We aren't testing DiracDeltaFunctions
112        self.xn=5   # number of grids on x axis
113        self.yn=5   # number of grids on y axis
114        self.zn=5
115    
116        def tearDown(self):
117        del self.domain
118        del self.functionspaces
119    
120        
121            
122            
123    class Test_CSVOnDudley(Test_saveCSV):
124       def setUp(self):
125           self.domain =Rectangle(NE,NE+1)
126           self.linecount1=31       #see test_save1 for the meaning of these params
127           self.linecount2=25
128           self.line_expected=[0.25, 0., 0.25]
129          
130       def tearDown(self):
131           del self.domain
132          
133       #This test checks to see that all FunctionSpaces can be saved
134       def test_singleFS(self):
135        fname=os.path.join(DUDLEY_WORKDIR, "test_singlefs.csv")
136        fss=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
137        FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),
138        DiracDeltaFunctions(self.domain)]
139        for f in fss:
140            d=Data(7,f)
141            print("Testing "+str(f)+"\n")
142            saveDataCSV(fname, D=d)
143    
144       def test_multiFS(self):
145        fname=os.path.join(DUDLEY_WORKDIR, "test_multifs.csv")
146        sol=Data(8,Solution(self.domain))
147        ctsfn=Data(9,ContinuousFunction(self.domain))
148        #test line 0
149        dirac=Data(-1,DiracDeltaFunctions(self.domain))
150        saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)
151        #test line 1
152        fun=Data(5,Function(self.domain))
153        rfun=Data(3,ReducedFunction(self.domain))
154        saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)
155        #test line 2
156        bound=Data(1,FunctionOnBoundary(self.domain))
157        rbound=Data(3,ReducedFunctionOnBoundary(self.domain))
158        saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)
159    
160        
161  if __name__ == '__main__':  if __name__ == '__main__':
162     suite = unittest.TestSuite()     suite = unittest.TestSuite()
163     suite.addTest(unittest.makeSuite(Test_SharedOnFinley))     suite.addTest(unittest.makeSuite(Test_SharedOnDudley))
164     suite.addTest(unittest.makeSuite(Test_DataOpsOnFinley))     # These two assume macro elements are supported
165     suite.addTest(unittest.makeSuite(Test_DomainOnFinley))     #suite.addTest(unittest.makeSuite(Test_DataOpsOnDudley))
166       #suite.addTest(unittest.makeSuite(Test_DomainOnDudley))
167       suite.addTest(unittest.makeSuite(Test_TableInterpolationOnDudley))
168       suite.addTest(unittest.makeSuite(Test_CSVOnDudley))
169     s=unittest.TextTestRunner(verbosity=2).run(suite)     s=unittest.TextTestRunner(verbosity=2).run(suite)
170     if not s.wasSuccessful(): sys.exit(1)     if not s.wasSuccessful(): sys.exit(1)
171    

Legend:
Removed from v.2549  
changed lines
  Added in v.3815

  ViewVC Help
Powered by ViewVC 1.1.26