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

Contents of /trunk/dudley/test/python/run_escriptOnDudley.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3975 - (show annotations)
Thu Sep 20 01:54:06 2012 UTC (7 years, 1 month ago) by caltinay
File MIME type: text/x-python
File size: 6964 byte(s)
Merged symbolic branch into trunk. Curious what daniel and spartacus have to
say...

1
2 ########################################################
3 #
4 # Copyright (c) 2003-2012 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2012 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 import unittest
23 import tempfile
24
25 from esys.escript import *
26 from esys.dudley import Rectangle, Brick
27 import sys
28 import os
29 from test_objects import Test_Dump, Test_SetDataPointValue, Test_saveCSV, Test_TableInterpolation
30 from test_objects import Test_Domain, Test_GlobalMinMax, Test_Lazy
31
32 from test_shared import Test_Shared
33
34 try:
35 DUDLEY_WORKDIR=os.environ['DUDLEY_WORKDIR']
36 except KeyError:
37 DUDLEY_WORKDIR='.'
38
39 NE=4 # number elements, must be even
40
41 class Test_SharedOnDudley(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_DomainOnDudley(Test_Domain):
50 def setUp(self):
51 self.boundary_tag_list = [1, 2, 10, 20]
52 self.domain =Rectangle(NE,NE+1,2)
53 def tearDown(self):
54 del self.domain
55 del self.boundary_tag_list
56
57
58 def test_setXError(self):
59 domain=Rectangle(NE,NE)
60 x=domain.getX()
61 z=interpolate(x, Function(domain))
62 self.assertRaises(RuntimeError, domain.setX, z)
63 del x
64 del z
65 del domain
66
67
68 def test_tagsContinuousFunction(self):
69 ref_tags=[0]
70 tags=ContinuousFunction(self.domain).getListOfTags()
71 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
72 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
73
74 def test_tagsFunction(self):
75 ref_tags=[0]
76 tags=Function(self.domain).getListOfTags()
77 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
78 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
79 def test_tagsReducedFunction(self):
80 ref_tags=[0]
81 tags=ReducedFunction(self.domain).getListOfTags()
82 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
83 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
84 def test_tagsFunctionOnBoundary(self):
85 ref_tags=[1, 2, 10, 20]
86 tags=FunctionOnBoundary(self.domain).getListOfTags()
87 # For an MPI-distributed domain some tags may be missing
88 if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
89 for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
90 def test_tagsReducedFunctionOnBoundary(self):
91 ref_tags=[1, 2, 10, 20]
92 tags=ReducedFunctionOnBoundary(self.domain).getListOfTags()
93 # For an MPI-distributed domain some tags may be missing
94 if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
95 for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
96
97 class Test_DataOpsOnDudley(Test_Dump, Test_SetDataPointValue, Test_GlobalMinMax, Test_Lazy):
98 def setUp(self):
99 self.domain =Rectangle(NE,NE+1,2)
100 self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1,2)
101 self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,2,integrationOrder=2)
102 self.domain_with_different_sample_ordering =Rectangle(NE,NE+1,2, optimize=True)
103 self.filename_base=DUDLEY_WORKDIR
104 self.mainfs=Function(self.domain)
105 self.otherfs=Solution(self.domain)
106
107 def tearDown(self):
108 del self.domain
109 del self.domain_with_different_number_of_samples
110 del self.domain_with_different_number_of_data_points_per_sample
111 del self.domain_with_different_sample_ordering
112 del self.mainfs
113 del self.otherfs
114
115
116
117 class Test_TableInterpolationOnDudley(Test_TableInterpolation):
118 def setUp(self):
119 self.domain=Brick(4,4,4)
120 self.functionspaces=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
121 FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain)]
122 #We aren't testing DiracDeltaFunctions
123 self.xn=5 # number of grids on x axis
124 self.yn=5 # number of grids on y axis
125 self.zn=5
126
127 def tearDown(self):
128 del self.domain
129 del self.functionspaces
130
131
132
133
134 class Test_CSVOnDudley(Test_saveCSV):
135 def setUp(self):
136 self.domain =Rectangle(NE,NE+1)
137 self.linecount1=31 #see test_save1 for the meaning of these params
138 self.linecount2=25
139 self.line_expected=[0.25, 0., 0.25]
140
141 def tearDown(self):
142 del self.domain
143
144 #This test checks to see that all FunctionSpaces can be saved
145 def test_singleFS(self):
146 fname=os.path.join(DUDLEY_WORKDIR, "test_singlefs.csv")
147 fss=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
148 FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),
149 DiracDeltaFunctions(self.domain)]
150 for f in fss:
151 d=Data(7,f)
152 print("Testing "+str(f)+"\n")
153 saveDataCSV(fname, D=d)
154
155 def test_multiFS(self):
156 fname=os.path.join(DUDLEY_WORKDIR, "test_multifs.csv")
157 sol=Data(8,Solution(self.domain))
158 ctsfn=Data(9,ContinuousFunction(self.domain))
159 #test line 0
160 dirac=Data(-1,DiracDeltaFunctions(self.domain))
161 saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)
162 #test line 1
163 fun=Data(5,Function(self.domain))
164 rfun=Data(3,ReducedFunction(self.domain))
165 saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)
166 #test line 2
167 bound=Data(1,FunctionOnBoundary(self.domain))
168 rbound=Data(3,ReducedFunctionOnBoundary(self.domain))
169 saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)
170
171
172 if __name__ == '__main__':
173 suite = unittest.TestSuite()
174 suite.addTest(unittest.makeSuite(Test_SharedOnDudley))
175 # These two assume macro elements are supported
176 #suite.addTest(unittest.makeSuite(Test_DataOpsOnDudley))
177 #suite.addTest(unittest.makeSuite(Test_DomainOnDudley))
178 suite.addTest(unittest.makeSuite(Test_TableInterpolationOnDudley))
179 suite.addTest(unittest.makeSuite(Test_CSVOnDudley))
180 s=unittest.TextTestRunner(verbosity=2).run(suite)
181 if not s.wasSuccessful(): sys.exit(1)
182

Properties

Name Value
svn:mergeinfo /branches/lapack2681/finley/test/python/run_escriptOnFinley.py:2682-2741 /branches/pasowrap/dudley/test/python/run_escriptOnDudley.py:3661-3674 /branches/py3_attempt2/dudley/test/python/run_escriptOnDudley.py:3871-3891 /branches/restext/finley/test/python/run_escriptOnFinley.py:2610-2624 /branches/ripleygmg_from_3668/dudley/test/python/run_escriptOnDudley.py:3669-3791 /branches/stage3.0/finley/test/python/run_escriptOnFinley.py:2569-2590 /branches/symbolic_from_3470/dudley/test/python/run_escriptOnDudley.py:3471-3974 /branches/symbolic_from_3470/ripley/test/python/dudley/test/python/run_escriptOnDudley.py:3517-3974 /release/3.0/finley/test/python/run_escriptOnFinley.py:2591-2601 /trunk/ripley/test/python/dudley/test/python/run_escriptOnDudley.py:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26