1 |
# |
2 |
# $Id: run_linearPDEsOnFinley.py 1382 2008-01-10 00:21:22Z gross $ |
3 |
# |
4 |
####################################################### |
5 |
# |
6 |
# Copyright 2003-2007 by ACceSS MNRF |
7 |
# Copyright 2007 by University of Queensland |
8 |
# |
9 |
# http://esscc.uq.edu.au |
10 |
# Primary Business: Queensland, Australia |
11 |
# Licensed under the Open Software License version 3.0 |
12 |
# http://www.opensource.org/licenses/osl-3.0.php |
13 |
# |
14 |
####################################################### |
15 |
# |
16 |
|
17 |
""" |
18 |
Test suite for the linearPDE and pdetools test on finley |
19 |
|
20 |
@remark: |
21 |
|
22 |
@var __author__: name of author |
23 |
@var __licence__: licence agreement |
24 |
@var __url__: url entry point on documentation |
25 |
@var __version__: version |
26 |
@var __date__: date of the version |
27 |
""" |
28 |
|
29 |
__copyright__=""" Copyright (c) 2006 by ACcESS MNRF |
30 |
http://www.access.edu.au |
31 |
Primary Business: Queensland, Australia""" |
32 |
__license__="""Licensed under the Open Software License version 3.0 |
33 |
http://www.opensource.org/licenses/osl-3.0.php""" |
34 |
__author__="Lutz Gross, l.gross@uq.edu.au" |
35 |
__url__="http://www.iservo.edu.au/esys/escript" |
36 |
__version__="$Revision: 1382 $" |
37 |
__date__="$Date: 2008-01-10 09:21:22 +0900 (Thu, 10 Jan 2008) $" |
38 |
|
39 |
|
40 |
import unittest |
41 |
from test_linearPDEs import Test_Poisson,Test_LinearPDE, Test_LinearPDE_noLumping |
42 |
from test_assemblage import Test_assemblage_2Do1, Test_assemblage_2Do2, Test_assemblage_3Do1, Test_assemblage_3Do2, \ |
43 |
Test_assemblage_2Do1_Contact,Test_assemblage_2Do2_Contact, Test_assemblage_3Do1_Contact, Test_assemblage_3Do2_Contact |
44 |
from test_pdetools import Test_pdetools, Test_pdetools_noLumping |
45 |
from esys.escript import * |
46 |
from esys.finley import Rectangle,Brick,JoinFaces, ReadMesh |
47 |
import sys |
48 |
|
49 |
|
50 |
try: |
51 |
FINLEY_TEST_DATA=os.environ['FINLEY_TEST_DATA'] |
52 |
except KeyError: |
53 |
FINLEY_TEST_DATA='.' |
54 |
|
55 |
FINLEY_TEST_MESH_PATH=FINLEY_TEST_DATA+"/data_meshes/" |
56 |
|
57 |
NE=6 # number of element in each spatial direction (must be even) |
58 |
|
59 |
class Test_LinearPDEOnFinleyHex2DOrder1(Test_LinearPDE,Test_pdetools,Test_assemblage_2Do1): |
60 |
RES_TOL=1.e-7 |
61 |
ABS_TOL=1.e-8 |
62 |
def setUp(self): |
63 |
self.domain = Rectangle(NE,NE,1) |
64 |
def tearDown(self): |
65 |
del self.domain |
66 |
|
67 |
class Test_LinearPDEOnFinleyHex2DOrder2(Test_LinearPDE,Test_pdetools,Test_assemblage_2Do2): |
68 |
RES_TOL=1.e-7 |
69 |
ABS_TOL=1.e-8 |
70 |
def setUp(self): |
71 |
self.domain = Rectangle(NE,NE,2) |
72 |
def tearDown(self): |
73 |
del self.domain |
74 |
|
75 |
class Test_LinearPDEOnFinleyHex3DOrder1(Test_LinearPDE,Test_pdetools,Test_assemblage_3Do1): |
76 |
RES_TOL=1.e-7 |
77 |
ABS_TOL=1.e-8 |
78 |
def setUp(self): |
79 |
self.domain = Brick(NE,NE,NE,1) |
80 |
|
81 |
class Test_LinearPDEOnFinleyHex3DOrder2(Test_LinearPDE,Test_pdetools,Test_assemblage_3Do2): |
82 |
RES_TOL=1.e-7 |
83 |
ABS_TOL=1.e-8 |
84 |
def setUp(self): |
85 |
self.domain = Brick(NE,NE,NE,2) |
86 |
def tearDown(self): |
87 |
del self.domain |
88 |
|
89 |
class Test_LinearPDEOnFinleyTet2DOrder1(Test_LinearPDE,Test_pdetools,Test_assemblage_2Do1): |
90 |
RES_TOL=1.e-7 |
91 |
ABS_TOL=1.e-8 |
92 |
def setUp(self): |
93 |
self.domain = ReadMesh(FINLEY_TEST_MESH_PATH+"tet_2D_order1.fly",optimize=False) |
94 |
def tearDown(self): |
95 |
del self.domain |
96 |
|
97 |
class Test_LinearPDEOnFinleyTet2DOrder2(Test_LinearPDE_noLumping,Test_pdetools_noLumping,Test_assemblage_2Do2): |
98 |
RES_TOL=1.e-7 |
99 |
ABS_TOL=1.e-8 |
100 |
def setUp(self): |
101 |
self.domain = ReadMesh(FINLEY_TEST_MESH_PATH+"tet_2D_order2.fly",optimize=False) |
102 |
def tearDown(self): |
103 |
del self.domain |
104 |
|
105 |
class Test_LinearPDEOnFinleyTet3DOrder1(Test_LinearPDE,Test_pdetools,Test_assemblage_3Do1): |
106 |
RES_TOL=1.e-7 |
107 |
ABS_TOL=1.e-8 |
108 |
def setUp(self): |
109 |
self.domain = ReadMesh(FINLEY_TEST_MESH_PATH+"tet_3D_order1.fly",optimize=False) |
110 |
|
111 |
class Test_LinearPDEOnFinleyTet3DOrder2(Test_LinearPDE,Test_pdetools,Test_assemblage_3Do2): |
112 |
RES_TOL=1.e-7 |
113 |
ABS_TOL=1.e-8 |
114 |
def setUp(self): |
115 |
self.domain = ReadMesh(FINLEY_TEST_MESH_PATH+"tet_3D_order2.fly",optimize=False) |
116 |
def tearDown(self): |
117 |
del self.domain |
118 |
|
119 |
class Test_PoissonOnFinley(Test_Poisson): |
120 |
RES_TOL=1.e-7 |
121 |
ABS_TOL=1.e-8 |
122 |
def setUp(self): |
123 |
self.domain = Rectangle(NE,NE,2) |
124 |
def tearDown(self): |
125 |
del self.domain |
126 |
|
127 |
|
128 |
class Test_AssemblePDEwithFinley_2Do1_Contact(Test_assemblage_2Do1_Contact): |
129 |
RES_TOL=1.e-7 |
130 |
ABS_TOL=1.e-8 |
131 |
def setUp(self): |
132 |
d1 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=1) |
133 |
x1 = ContinuousFunction(d1).getX() |
134 |
ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
135 |
d2 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=1) |
136 |
ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
137 |
d2.setX(d2.getX()+[0.5,0.]) |
138 |
self.domain = JoinFaces([d1,d2],optimize=False) |
139 |
def tearDown(self): |
140 |
del self.domain |
141 |
|
142 |
class Test_AssemblePDEwithFinley_2Do2_Contact(Test_assemblage_2Do2_Contact): |
143 |
RES_TOL=1.e-7 |
144 |
ABS_TOL=1.e-8 |
145 |
def setUp(self): |
146 |
d1 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=2) |
147 |
x1 = ContinuousFunction(d1).getX() |
148 |
ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
149 |
d2 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=2) |
150 |
ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
151 |
d2.setX(d2.getX()+[0.5,0.]) |
152 |
self.domain = JoinFaces([d1,d2],optimize=False) |
153 |
def tearDown(self): |
154 |
del self.domain |
155 |
|
156 |
class Test_AssemblePDEwithFinley_3Do1_Contact(Test_assemblage_3Do1_Contact): |
157 |
RES_TOL=1.e-7 |
158 |
ABS_TOL=1.e-8 |
159 |
def setUp(self): |
160 |
d1 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=1) |
161 |
x1 = ContinuousFunction(d1).getX() |
162 |
ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
163 |
d2 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=1) |
164 |
ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
165 |
d2.setX(d2.getX()+[0.5,0.,0.]) |
166 |
self.domain = JoinFaces([d1,d2],optimize=False) |
167 |
def tearDown(self): |
168 |
del self.domain |
169 |
|
170 |
class Test_AssemblePDEwithFinley_3Do2_Contact(Test_assemblage_3Do2_Contact): |
171 |
RES_TOL=1.e-7 |
172 |
ABS_TOL=1.e-8 |
173 |
def setUp(self): |
174 |
d1 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2) |
175 |
x1 = ContinuousFunction(d1).getX() |
176 |
ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
177 |
d2 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2) |
178 |
ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
179 |
d2.setX(d2.getX()+[0.5,0.,0.]) |
180 |
self.domain = JoinFaces([d1,d2],optimize=False) |
181 |
def tearDown(self): |
182 |
del self.domain |
183 |
|
184 |
|
185 |
class Test_AssemblePDEwithFinley_2Do1_Contact_withElementsOnFace(Test_assemblage_2Do1_Contact): |
186 |
RES_TOL=1.e-7 |
187 |
ABS_TOL=1.e-8 |
188 |
def setUp(self): |
189 |
d1 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=1,useElementsOnFace=True) |
190 |
x1 = ContinuousFunction(d1).getX() |
191 |
ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
192 |
d2 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=1,useElementsOnFace=True) |
193 |
ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
194 |
d2.setX(d2.getX()+[0.5,0.]) |
195 |
self.domain = JoinFaces([d1,d2],optimize=False) |
196 |
def tearDown(self): |
197 |
del self.domain |
198 |
|
199 |
class Test_AssemblePDEwithFinley_2Do2_Contact_withElementsOnFace(Test_assemblage_2Do2_Contact): |
200 |
RES_TOL=1.e-7 |
201 |
ABS_TOL=1.e-8 |
202 |
def setUp(self): |
203 |
d1 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=2,useElementsOnFace=True) |
204 |
x1 = ContinuousFunction(d1).getX() |
205 |
ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
206 |
d2 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=2,useElementsOnFace=True) |
207 |
ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
208 |
d2.setX(d2.getX()+[0.5,0.]) |
209 |
self.domain = JoinFaces([d1,d2],optimize=False) |
210 |
def tearDown(self): |
211 |
del self.domain |
212 |
|
213 |
class Test_AssemblePDEwithFinley_3Do1_Contact_withElementsOnFace(Test_assemblage_3Do1_Contact): |
214 |
RES_TOL=1.e-7 |
215 |
ABS_TOL=1.e-8 |
216 |
def setUp(self): |
217 |
d1 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=1,useElementsOnFace=True) |
218 |
x1 = ContinuousFunction(d1).getX() |
219 |
ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
220 |
d2 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=1,useElementsOnFace=True) |
221 |
ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
222 |
d2.setX(d2.getX()+[0.5,0.,0.]) |
223 |
self.domain = JoinFaces([d1,d2],optimize=False) |
224 |
def tearDown(self): |
225 |
del self.domain |
226 |
|
227 |
class Test_AssemblePDEwithFinley_3Do2_Contact_withElementsOnFace(Test_assemblage_3Do2_Contact): |
228 |
RES_TOL=1.e-7 |
229 |
ABS_TOL=1.e-8 |
230 |
def setUp(self): |
231 |
d1 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=True) |
232 |
x1 = ContinuousFunction(d1).getX() |
233 |
ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
234 |
d2 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=True) |
235 |
ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
236 |
d2.setX(d2.getX()+[0.5,0.,0.]) |
237 |
self.domain = JoinFaces([d1,d2],optimize=False) |
238 |
def tearDown(self): |
239 |
del self.domain |
240 |
|
241 |
if __name__ == '__main__': |
242 |
suite = unittest.TestSuite() |
243 |
if True: |
244 |
suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinleyHex2DOrder1)) |
245 |
suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinleyHex2DOrder2)) |
246 |
suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinleyHex3DOrder1)) |
247 |
suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinleyHex3DOrder2)) |
248 |
|
249 |
suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinleyTet2DOrder1)) |
250 |
suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinleyTet2DOrder2)) |
251 |
suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinleyTet3DOrder1)) |
252 |
suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinleyTet3DOrder2)) |
253 |
|
254 |
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_2Do1_Contact)) |
255 |
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_2Do2_Contact)) |
256 |
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_3Do1_Contact)) |
257 |
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_3Do2_Contact)) |
258 |
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_2Do1_Contact_withElementsOnFace)) |
259 |
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_2Do2_Contact_withElementsOnFace)) |
260 |
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_3Do1_Contact_withElementsOnFace)) |
261 |
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_3Do2_Contact_withElementsOnFace)) |
262 |
else: |
263 |
pass |
264 |
|
265 |
s=unittest.TextTestRunner(verbosity=2).run(suite) |
266 |
if not s.wasSuccessful(): sys.exit(1) |
267 |
|