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

Contents of /trunk/finley/test/python/run_utilOnFinley2.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4938 - (show annotations)
Wed May 14 01:13:23 2014 UTC (5 years, 3 months ago) by jfenwick
File MIME type: text/x-python
File size: 10240 byte(s)
Modify unit tests to read their classes from
esys.escriptcore.utestselect

Change the line in that file to switch between unittest and unittest2


1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2014 by University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Open Software License version 3.0
21 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="https://launchpad.net/escript-finley"
23
24 import esys.escriptcore.utestselect as unittest
25 from test_util import Test_util as Test_util
26 from test_util import Test_Util_SpatialFunctions, Test_Util_SpatialFunctions_noGradOnBoundary, Test_Util_SpatialFunctions_noGradOnBoundary_noContact
27
28 from esys.escript import *
29 from esys.finley import Rectangle,Brick,JoinFaces,ReadMesh
30 import sys
31 import os
32
33 if HAVE_SYMBOLS:
34 from test_symfuncs import Test_symfuncs
35 else:
36 print("Skipping symbolic tests since sympy is not available")
37 class Test_symfuncs:
38 pass
39
40 try:
41 FINLEY_TEST_DATA=os.environ['FINLEY_TEST_DATA']
42 except KeyError:
43 FINLEY_TEST_DATA='.'
44
45 FINLEY_TEST_MESH_PATH=os.path.join(FINLEY_TEST_DATA,"data_meshes")
46
47
48 NE=4 # number elements, must be even
49
50 class Test_UtilOnFinley(Test_util,Test_symfuncs):
51 def setUp(self):
52 self.domain =Rectangle(NE,NE+1,2)
53 self.functionspace = FunctionOnBoundary(self.domain) # due to a bug in escript python needs to hold a reference to the domain
54 def tearDown(self):
55 del self.functionspace
56 del self.domain
57
58 class Test_Util_SpatialFunctionsOnFinleyTet2DOrder1(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
59 def setUp(self):
60 self.order=1
61 self.domain = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet_2D_order1.fly"),optimize=False)
62 def tearDown(self):
63 del self.order
64 del self.domain
65
66 class Test_Util_SpatialFunctionsOnFinleyTet2DOrder2(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
67 def setUp(self):
68 self.order=2
69 self.domain = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet_2D_order2.fly"),optimize=False)
70 def tearDown(self):
71 del self.order
72 del self.domain
73
74 class Test_Util_SpatialFunctionsOnFinleyTet2DMacro(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
75 def setUp(self):
76 self.order=1
77 self.domain = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet_2D_macro.fly"),optimize=False)
78 def tearDown(self):
79 del self.order
80 del self.domain
81
82 class Test_Util_SpatialFunctionsOnFinleyTet3DOrder1(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
83 def setUp(self):
84 self.order=1
85 self.domain = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet_3D_order1.fly"),optimize=False)
86 def tearDown(self):
87 del self.order
88 del self.domain
89
90 class Test_Util_SpatialFunctionsOnFinleyTet3DOrder2(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
91 def setUp(self):
92 self.order=2
93 self.domain = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet_3D_order2.fly"),optimize=False)
94 def tearDown(self):
95 del self.order
96 del self.domain
97
98 class Test_Util_SpatialFunctionsOnFinleyTet3DMacro(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
99 def setUp(self):
100 self.order=1
101 self.domain = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet_3D_macro.fly"),optimize=False)
102 def tearDown(self):
103 del self.order
104 del self.domain
105
106 class Test_Util_SpatialFunctionsOnFinleyHex2DOrder1(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
107 def setUp(self):
108 self.order=1
109 self.domain = Rectangle(n0=NE,n1=NE,order=1,useElementsOnFace=0)
110 def tearDown(self):
111 del self.order
112 del self.domain
113
114 class Test_Util_SpatialFunctionsOnFinleyHex2DOrder2(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
115 def setUp(self):
116 self.order=2
117 self.domain = Rectangle(n0=NE,n1=NE,order=2,useElementsOnFace=0)
118 def tearDown(self):
119 del self.order
120 del self.domain
121
122 class Test_Util_SpatialFunctionsOnFinleyHex2DMacro(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
123 def setUp(self):
124 self.order=1
125 self.domain = Rectangle(n0=NE,n1=NE,order=-1,useElementsOnFace=0)
126 def tearDown(self):
127 del self.order
128 del self.domain
129
130 class Test_Util_SpatialFunctionsOnFinleyHex3DOrder1(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
131 def setUp(self):
132 self.order=1
133 self.domain = Brick(n0=NE,n1=NE,n2=NE,order=1,useElementsOnFace=0)
134 def tearDown(self):
135 del self.order
136 del self.domain
137
138 class Test_Util_SpatialFunctionsOnFinleyHex3DOrder2(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
139 def setUp(self):
140 self.order=2
141 self.domain = Brick(n0=NE,n1=NE,n2=NE,order=2,useElementsOnFace=0)
142 def tearDown(self):
143 del self.order
144 del self.domain
145
146 class Test_Util_SpatialFunctionsOnFinleyHex3DMacro(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
147 def setUp(self):
148 self.order=1
149 self.domain = Brick(n0=NE,n1=NE,n2=NE,order=-1,useElementsOnFace=0)
150 def tearDown(self):
151 del self.order
152 del self.domain
153
154 class Test_Util_SpatialFunctionsOnFinleyHex2DOrder1withContact(Test_Util_SpatialFunctions_noGradOnBoundary):
155 def setUp(self):
156 self.order=1
157 d1 = Rectangle(n0=NE/2+1,n1=NE,l0=0.5,order=1,useElementsOnFace=0)
158 d2 = Rectangle(n0=NE/2,n1=NE,l0=0.5,order=1,useElementsOnFace=0)
159 d2.setX(d2.getX()+[0.5,0.])
160 self.domain = JoinFaces([d1,d2],optimize=False)
161 def tearDown(self):
162 del self.order
163 del self.domain
164
165 class Test_Util_SpatialFunctionsOnFinleyHex2DOrder2withContact(Test_Util_SpatialFunctions_noGradOnBoundary):
166 def setUp(self):
167 self.order=2
168 d1 = Rectangle(n0=NE/2,n1=NE,l0=0.5,order=2,useElementsOnFace=0)
169 d2 = Rectangle(n0=NE/2,n1=NE,l0=0.5,order=2,useElementsOnFace=0)
170 d2.setX(d2.getX()+[0.5,0.])
171 self.domain = JoinFaces([d1,d2],optimize=False)
172 def tearDown(self):
173 del self.order
174 del self.domain
175
176 class Test_Util_SpatialFunctionsOnFinleyHex3DOrder1withContact(Test_Util_SpatialFunctions_noGradOnBoundary):
177 def setUp(self):
178 self.order=1
179 d1 = Brick(n0=NE/2+1,n1=NE,n2=NE,l0=0.5,order=1,useElementsOnFace=0)
180 d2 = Brick(n0=NE/2,n1=NE,n2=NE,l0=0.5,order=1,useElementsOnFace=0)
181 d2.setX(d2.getX()+[0.5,0.,0.])
182 self.domain = JoinFaces([d1,d2],optimize=False)
183 def tearDown(self):
184 del self.order
185 del self.domain
186
187 class Test_Util_SpatialFunctionsOnFinleyHex3DOrder2withContact(Test_Util_SpatialFunctions_noGradOnBoundary):
188 def setUp(self):
189 self.order=2
190 d1 = Brick(n0=NE/2+1,n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=0)
191 d2 = Brick(n0=NE/2,n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=0)
192 d2.setX(d2.getX()+[0.5,0.,0.])
193 self.domain = JoinFaces([d1,d2],optimize=False)
194 def tearDown(self):
195 del self.order
196 del self.domain
197
198 class Test_Util_SpatialFunctionsOnFinleyHex2DOrder1useElementsOnFacewithContact(Test_Util_SpatialFunctions):
199 def setUp(self):
200 self.order=1
201 d1 = Rectangle(n0=NE/2+1,n1=NE,l0=0.5,order=1,useElementsOnFace=True)
202 d2 = Rectangle(n0=NE/2,n1=NE,l0=0.5,order=1,useElementsOnFace=True)
203 d2.setX(d2.getX()+[0.5,0.])
204 self.domain = JoinFaces([d1,d2],optimize=False)
205 def tearDown(self):
206 del self.order
207 del self.domain
208
209 class Test_Util_SpatialFunctionsOnFinleyHex2DOrder2useElementsOnFacewithContact(Test_Util_SpatialFunctions):
210 def setUp(self):
211 self.order=2
212 d1 = Rectangle(n0=NE/2+1,n1=NE,l0=0.5,order=2,useElementsOnFace=True)
213 d2 = Rectangle(n0=NE/2,n1=NE,l0=0.5,order=2,useElementsOnFace=True)
214 d2.setX(d2.getX()+[0.5,0.])
215 self.domain = JoinFaces([d1,d2],optimize=False)
216 def tearDown(self):
217 del self.order
218 del self.domain
219
220 class Test_Util_SpatialFunctionsOnFinleyHex3DOrder1useElementsOnFacewithContact(Test_Util_SpatialFunctions):
221 def setUp(self):
222 self.order=1
223 d1 = Brick(n0=NE/2,n1=NE,n2=NE,l0=0.5,order=1,useElementsOnFace=True)
224 d2 = Brick(n0=NE/2+1,n1=NE,n2=NE,l0=0.5,order=1,useElementsOnFace=True)
225 d2.setX(d2.getX()+[0.5,0.,0.])
226 self.domain = JoinFaces([d1,d2],optimize=False)
227 def tearDown(self):
228 del self.order
229 del self.domain
230
231 class Test_Util_SpatialFunctionsOnFinleyHex3DOrder2useElementsOnFacewithContact(Test_Util_SpatialFunctions):
232 def setUp(self):
233 self.order=2
234 d1 = Brick(n0=NE/2,n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=True)
235 d2 = Brick(n0=NE/2+1,n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=True)
236 d2.setX(d2.getX()+[0.5,0.,0.])
237 self.domain = JoinFaces([d1,d2],optimize=False)
238 def tearDown(self):
239 del self.order
240 del self.domain
241
242 if __name__ == '__main__':
243 suite = unittest.TestSuite()
244 if True:
245 suite.addTest(unittest.makeSuite(Test_Util_SpatialFunctionsOnFinleyHex2DOrder1))
246 suite.addTest(unittest.makeSuite(Test_Util_SpatialFunctionsOnFinleyHex2DOrder2))
247 suite.addTest(unittest.makeSuite(Test_Util_SpatialFunctionsOnFinleyHex2DMacro))
248 suite.addTest(unittest.makeSuite(Test_Util_SpatialFunctionsOnFinleyHex3DOrder1))
249 suite.addTest(unittest.makeSuite(Test_Util_SpatialFunctionsOnFinleyHex3DOrder2))
250 suite.addTest(unittest.makeSuite(Test_Util_SpatialFunctionsOnFinleyHex3DMacro))
251 else:
252 suite.addTest(unittest.makeSuite(Test_Util_SpatialFunctionsOnFinleyHex2DOrder1useElementsOnFacewithContact))
253 pass
254 s=unittest.TextTestRunner(verbosity=2).run(suite)
255 if not s.wasSuccessful(): sys.exit(1)
256

  ViewVC Help
Powered by ViewVC 1.1.26