1 |
phornby |
1894 |
|
2 |
|
|
######################################################## |
3 |
|
|
# |
4 |
jfenwick |
2548 |
# Copyright (c) 2003-2009 by University of Queensland |
5 |
phornby |
1894 |
# 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-2008 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 |
jfenwick |
2344 |
__url__="https://launchpad.net/escript-finley" |
21 |
phornby |
1894 |
|
22 |
|
|
""" |
23 |
|
|
Test suite for the linearPDE and pdetools test on finley |
24 |
|
|
|
25 |
|
|
@remark: |
26 |
|
|
|
27 |
|
|
@var __author__: name of author |
28 |
|
|
@var __licence__: licence agreement |
29 |
|
|
@var __url__: url entry point on documentation |
30 |
|
|
@var __version__: version |
31 |
|
|
@var __date__: date of the version |
32 |
|
|
""" |
33 |
|
|
|
34 |
|
|
__author__="Lutz Gross, l.gross@uq.edu.au" |
35 |
|
|
|
36 |
|
|
import os |
37 |
|
|
|
38 |
|
|
import unittest |
39 |
gross |
2325 |
from test_linearPDEs import Test_Poisson,Test_LinearPDE, Test_LinearPDE_noLumping, Test_TransportPDE, Test_Helmholtz, Test_LameEquation |
40 |
phornby |
1894 |
from test_assemblage import Test_assemblage_2Do1, Test_assemblage_2Do2, Test_assemblage_3Do1, Test_assemblage_3Do2, \ |
41 |
|
|
Test_assemblage_2Do1_Contact,Test_assemblage_2Do2_Contact, Test_assemblage_3Do1_Contact, Test_assemblage_3Do2_Contact |
42 |
|
|
from test_pdetools import Test_pdetools, Test_pdetools_noLumping |
43 |
|
|
from esys.escript import * |
44 |
|
|
from esys.finley import Rectangle,Brick,JoinFaces, ReadMesh |
45 |
|
|
import sys |
46 |
|
|
|
47 |
|
|
|
48 |
|
|
try: |
49 |
|
|
FINLEY_TEST_DATA=os.environ['FINLEY_TEST_DATA'] |
50 |
|
|
except KeyError: |
51 |
|
|
FINLEY_TEST_DATA='.' |
52 |
|
|
|
53 |
gross |
2315 |
FINLEY_TEST_MESH_PATH=os.path.join(FINLEY_TEST_DATA,"data_meshes") |
54 |
phornby |
1894 |
|
55 |
gross |
2315 |
NE=8 # number of element in each spatial direction (must be even) |
56 |
phornby |
1894 |
|
57 |
gross |
2325 |
class Test_LameOnFinley(Test_LameEquation): |
58 |
|
|
RES_TOL=1.e-7 |
59 |
|
|
ABS_TOL=1.e-8 |
60 |
|
|
def setUp(self): |
61 |
|
|
self.domain = Rectangle(NE,NE,2,useFullElementOrder=True) |
62 |
|
|
def tearDown(self): |
63 |
|
|
del self.domain |
64 |
phornby |
1894 |
class Test_PoissonOnFinley(Test_Poisson): |
65 |
|
|
RES_TOL=1.e-7 |
66 |
|
|
ABS_TOL=1.e-8 |
67 |
|
|
def setUp(self): |
68 |
gross |
2315 |
self.domain = Rectangle(NE,NE,2,useFullElementOrder=True) |
69 |
phornby |
1894 |
def tearDown(self): |
70 |
|
|
del self.domain |
71 |
|
|
|
72 |
gross |
2323 |
class Test_HelmholtzOnFinley(Test_Helmholtz): |
73 |
|
|
RES_TOL=1.e-7 |
74 |
|
|
ABS_TOL=1.e-8 |
75 |
|
|
def setUp(self): |
76 |
|
|
self.domain = Rectangle(NE,NE,2,useFullElementOrder=True) |
77 |
|
|
def tearDown(self): |
78 |
|
|
del self.domain |
79 |
phornby |
1894 |
|
80 |
gross |
2323 |
|
81 |
phornby |
1894 |
class Test_AssemblePDEwithFinley_2Do1_Contact(Test_assemblage_2Do1_Contact): |
82 |
|
|
RES_TOL=1.e-7 |
83 |
|
|
ABS_TOL=1.e-8 |
84 |
|
|
def setUp(self): |
85 |
gross |
2315 |
# d1 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=1) |
86 |
|
|
# x1 = ContinuousFunction(d1).getX() |
87 |
|
|
# ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
88 |
|
|
# d2 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=1) |
89 |
|
|
# ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
90 |
|
|
# d2.setX(d2.getX()+[0.5,0.]) |
91 |
|
|
# self.domain = JoinFaces([d1,d2],optimize=False) |
92 |
|
|
self.domain=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"mesh_2Do1_Contact.fly")) |
93 |
phornby |
1894 |
def tearDown(self): |
94 |
|
|
del self.domain |
95 |
|
|
|
96 |
|
|
class Test_AssemblePDEwithFinley_2Do2_Contact(Test_assemblage_2Do2_Contact): |
97 |
|
|
RES_TOL=1.e-7 |
98 |
|
|
ABS_TOL=1.e-8 |
99 |
|
|
def setUp(self): |
100 |
gross |
2315 |
# d1 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=2) |
101 |
|
|
# x1 = ContinuousFunction(d1).getX() |
102 |
|
|
# ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
103 |
|
|
# d2 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=2) |
104 |
|
|
# ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
105 |
|
|
# d2.setX(d2.getX()+[0.5,0.]) |
106 |
|
|
# self.domain = JoinFaces([d1,d2],optimize=False) |
107 |
|
|
self.domain=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"mesh_2Do2_Contact.fly")) |
108 |
phornby |
1894 |
def tearDown(self): |
109 |
|
|
del self.domain |
110 |
|
|
|
111 |
|
|
class Test_AssemblePDEwithFinley_3Do1_Contact(Test_assemblage_3Do1_Contact): |
112 |
|
|
RES_TOL=1.e-7 |
113 |
|
|
ABS_TOL=1.e-8 |
114 |
|
|
def setUp(self): |
115 |
gross |
2315 |
# d1 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=1) |
116 |
|
|
# x1 = ContinuousFunction(d1).getX() |
117 |
|
|
# ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
118 |
|
|
# d2 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=1) |
119 |
|
|
# ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
120 |
|
|
# d2.setX(d2.getX()+[0.5,0.,0.]) |
121 |
|
|
# self.domain = JoinFaces([d1,d2],optimize=False) |
122 |
|
|
self.domain=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"mesh_3Do1_Contact.fly")) |
123 |
phornby |
1894 |
def tearDown(self): |
124 |
|
|
del self.domain |
125 |
|
|
|
126 |
|
|
class Test_AssemblePDEwithFinley_3Do2_Contact(Test_assemblage_3Do2_Contact): |
127 |
|
|
RES_TOL=1.e-7 |
128 |
|
|
ABS_TOL=1.e-8 |
129 |
|
|
def setUp(self): |
130 |
gross |
2315 |
# d1 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2) |
131 |
|
|
# x1 = ContinuousFunction(d1).getX() |
132 |
|
|
# ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
133 |
|
|
# d2 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2) |
134 |
|
|
# ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
135 |
|
|
# d2.setX(d2.getX()+[0.5,0.,0.]) |
136 |
|
|
# self.domain = JoinFaces([d1,d2],optimize=False) |
137 |
|
|
self.domain=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"mesh_3Do2_Contact.fly")) |
138 |
phornby |
1894 |
def tearDown(self): |
139 |
|
|
del self.domain |
140 |
|
|
|
141 |
|
|
|
142 |
|
|
class Test_AssemblePDEwithFinley_2Do1_Contact_withElementsOnFace(Test_assemblage_2Do1_Contact): |
143 |
|
|
RES_TOL=1.e-7 |
144 |
|
|
ABS_TOL=1.e-8 |
145 |
|
|
def setUp(self): |
146 |
gross |
2315 |
# d1 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=1,useElementsOnFace=True) |
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=1,useElementsOnFace=True) |
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 |
|
|
self.domain=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"mesh_2Do1_Contact_withElementsOnFace.fly")) |
154 |
phornby |
1894 |
def tearDown(self): |
155 |
|
|
del self.domain |
156 |
|
|
|
157 |
|
|
class Test_AssemblePDEwithFinley_2Do2_Contact_withElementsOnFace(Test_assemblage_2Do2_Contact): |
158 |
|
|
RES_TOL=1.e-7 |
159 |
|
|
ABS_TOL=1.e-8 |
160 |
|
|
def setUp(self): |
161 |
gross |
2315 |
# d1 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=2,useElementsOnFace=True) |
162 |
|
|
# x1 = ContinuousFunction(d1).getX() |
163 |
|
|
# ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
164 |
|
|
# d2 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=2,useElementsOnFace=True) |
165 |
|
|
# ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
166 |
|
|
# d2.setX(d2.getX()+[0.5,0.]) |
167 |
|
|
# self.domain = JoinFaces([d1,d2],optimize=False) |
168 |
|
|
self.domain=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"mesh_2Do2_Contact_withElementsOnFace.fly")) |
169 |
phornby |
1894 |
def tearDown(self): |
170 |
|
|
del self.domain |
171 |
|
|
|
172 |
|
|
class Test_AssemblePDEwithFinley_3Do1_Contact_withElementsOnFace(Test_assemblage_3Do1_Contact): |
173 |
|
|
RES_TOL=1.e-7 |
174 |
|
|
ABS_TOL=1.e-8 |
175 |
|
|
def setUp(self): |
176 |
gross |
2315 |
# d1 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=1,useElementsOnFace=True) |
177 |
|
|
# x1 = ContinuousFunction(d1).getX() |
178 |
|
|
# ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
179 |
|
|
# d2 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=1,useElementsOnFace=True) |
180 |
|
|
# ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
181 |
|
|
# d2.setX(d2.getX()+[0.5,0.,0.]) |
182 |
|
|
# self.domain = JoinFaces([d1,d2],optimize=False) |
183 |
|
|
self.domain=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"mesh_3Do1_Contact_withElementsOnFace.fly")) |
184 |
phornby |
1894 |
def tearDown(self): |
185 |
|
|
del self.domain |
186 |
|
|
|
187 |
|
|
class Test_AssemblePDEwithFinley_3Do2_Contact_withElementsOnFace(Test_assemblage_3Do2_Contact): |
188 |
|
|
RES_TOL=1.e-7 |
189 |
|
|
ABS_TOL=1.e-8 |
190 |
|
|
def setUp(self): |
191 |
gross |
2315 |
# d1 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=True) |
192 |
|
|
# x1 = ContinuousFunction(d1).getX() |
193 |
|
|
# ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1))) |
194 |
|
|
# d2 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=True) |
195 |
|
|
# ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2))) |
196 |
|
|
# d2.setX(d2.getX()+[0.5,0.,0.]) |
197 |
|
|
# self.domain = JoinFaces([d1,d2],optimize=False) |
198 |
|
|
self.domain=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"mesh_3Do2_Contact_withElementsOnFace.fly")) |
199 |
phornby |
1894 |
def tearDown(self): |
200 |
|
|
del self.domain |
201 |
|
|
|
202 |
|
|
if __name__ == '__main__': |
203 |
|
|
suite = unittest.TestSuite() |
204 |
|
|
if True : |
205 |
gross |
2315 |
suite.addTest(unittest.makeSuite(Test_PoissonOnFinley)) |
206 |
gross |
2323 |
suite.addTest(unittest.makeSuite(Test_HelmholtzOnFinley)) |
207 |
gross |
2325 |
suite.addTest(unittest.makeSuite(Test_LameOnFinley)) |
208 |
gross |
2315 |
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_2Do1_Contact)) |
209 |
|
|
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_2Do2_Contact)) |
210 |
|
|
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_3Do1_Contact)) |
211 |
|
|
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_3Do2_Contact)) |
212 |
|
|
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_2Do1_Contact_withElementsOnFace)) |
213 |
|
|
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_2Do2_Contact_withElementsOnFace)) |
214 |
|
|
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_3Do1_Contact_withElementsOnFace)) |
215 |
|
|
suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_3Do2_Contact_withElementsOnFace)) |
216 |
phornby |
1894 |
else: |
217 |
|
|
pass |
218 |
|
|
|
219 |
|
|
s=unittest.TextTestRunner(verbosity=2).run(suite) |
220 |
|
|
if not s.wasSuccessful(): sys.exit(1) |
221 |
|
|
|