/[escript]/branches/domexper/dudley/test/python/fixme_run_generators.py
ViewVC logotype

Contents of /branches/domexper/dudley/test/python/fixme_run_generators.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1312 - (show annotations)
Mon Sep 24 06:18:44 2007 UTC (12 years, 2 months ago) by ksteube
Original Path: trunk/finley/test/python/run_generators.py
File MIME type: text/x-python
File size: 8381 byte(s)
The MPI branch is hereby closed. All future work should be in trunk.

Previously in revision 1295 I merged the latest changes to trunk into trunk-mpi-branch.
In this revision I copied all files from trunk-mpi-branch over the corresponding
trunk files. I did not use 'svn merge', it was a copy.

1 #
2 # $Id$
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 checks the mesh generators against the reference meshes in test_meshes
19 """
20
21 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
22 http://www.access.edu.au
23 Primary Business: Queensland, Australia"""
24 __license__="""Licensed under the Open Software License version 3.0
25 http://www.opensource.org/licenses/osl-3.0.php"""
26
27 import sys
28 import os
29 import unittest
30 from esys.escript import *
31 from esys.finley import Rectangle,Brick,JoinFaces, ReadGmsh, ReadMesh
32
33 try:
34 FINLEY_TEST_DATA=os.environ['FINLEY_TEST_DATA']
35 except KeyError:
36 FINLEY_TEST_DATA='.'
37
38 try:
39 FINLEY_WORKDIR=os.environ['FINLEY_WORKDIR']
40 except KeyError:
41 FINLEY_WORKDIR='.'
42
43 FINLEY_TEST_MESH_PATH=FINLEY_TEST_DATA+"/data_meshes/"
44 if os.name == "nt":
45 FINLEY_TEST_MESH_PATH = FINLEY_TEST_MESH_PATH+"win32/"
46 FINLEY_WORKDIR_PATH=FINLEY_WORKDIR+"/"
47
48 TEST_FILE_EXT=".test"
49 class Test_Generators(unittest.TestCase):
50
51 def checker(self,dom,reference):
52 dom_file=FINLEY_WORKDIR_PATH+TEST_FILE_EXT
53 dom.write(dom_file)
54 # Uncomment this section to dump the files for regression testing
55 # if True:
56 # dom.write(FINLEY_TEST_MESH_PATH+reference)
57 dom_string=open(dom_file).read().splitlines()
58 ref_string=open(FINLEY_TEST_MESH_PATH+reference).read().splitlines()
59 self.failUnlessEqual(len(dom_string),len(ref_string),"number of lines in mesh files does not match reference")
60 for l in range(1,len(ref_string)):
61 self.failUnlessEqual(dom_string[l].strip(),ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),dom_string[l].strip()))
62
63 def test_hex_2D_order1(self):
64 file="hex_2D_order1.msh"
65 my_dom=Rectangle(1,1,1)
66 self.checker(my_dom,file)
67
68 def test_hex_2D_order1_onFace(self):
69 file="hex_2D_order1_onFace.msh"
70 my_dom=Rectangle(1,1,1,useElementsOnFace=1)
71 self.checker(my_dom,file)
72
73 def test_hex_2D_order2(self):
74 file="hex_2D_order2.msh"
75 my_dom=Rectangle(1,1,2)
76 self.checker(my_dom,file)
77
78 def test_hex_2D_order2_onFace(self):
79 file="hex_2D_order2_onFace.msh"
80 my_dom=Rectangle(1,1,2,useElementsOnFace=1)
81 self.checker(my_dom,file)
82
83 def test_hex_3D_order1(self):
84 file="hex_3D_order1.msh"
85 my_dom=Brick(1,1,1,1)
86 self.checker(my_dom,file)
87
88 def test_hex_3D_order1_onFace(self):
89 file="hex_3D_order1_onFace.msh"
90 my_dom=Brick(1,1,1,1,useElementsOnFace=1)
91 self.checker(my_dom,file)
92
93 def test_hex_3D_order2(self):
94 file="hex_3D_order2.msh"
95 my_dom=Brick(1,1,1,2)
96 self.checker(my_dom,file)
97
98 def test_hex_3D_order2_onFace(self):
99 file="hex_3D_order2_onFace.msh"
100 my_dom=Brick(1,1,1,2,useElementsOnFace=1)
101 self.checker(my_dom,file)
102
103 def test_hex_contact_2D_order1(self):
104 file="hex_contact_2D_order1.msh"
105 ms1=Rectangle(1,1,1,l1=0.5,useElementsOnFace=False)
106 ms2=Rectangle(1,1,1,l1=0.5,useElementsOnFace=False)
107 ms2.setX(ms2.getX()+[0,0.5])
108 my_dom=JoinFaces([ms1,ms2],optimize=False)
109 self.checker(my_dom,file)
110
111 def test_hex_contact_2D_order1_onFace(self):
112 file="hex_contact_2D_order1_onFace.msh"
113 ms1=Rectangle(1,1,1,l1=0.5,useElementsOnFace=True)
114 ms2=Rectangle(1,1,1,l1=0.5,useElementsOnFace=True)
115 ms2.setX(ms2.getX()+[0,0.5])
116 my_dom=JoinFaces([ms1,ms2],optimize=False)
117 self.checker(my_dom,file)
118
119 def test_hex_contact_2D_order2(self):
120 file="hex_contact_2D_order2.msh"
121 ms1=Rectangle(1,1,2,l1=0.5,useElementsOnFace=False)
122 ms2=Rectangle(1,1,2,l1=0.5,useElementsOnFace=False)
123 ms2.setX(ms2.getX()+[0,0.5])
124 my_dom=JoinFaces([ms1,ms2],optimize=False)
125 self.checker(my_dom,file)
126
127 def test_hex_contact_2D_order2_onFace(self):
128 file="hex_contact_2D_order2_onFace.msh"
129 ms1=Rectangle(1,1,2,l1=0.5,useElementsOnFace=True)
130 ms2=Rectangle(1,1,2,l1=0.5,useElementsOnFace=True)
131 ms2.setX(ms2.getX()+[0,0.5])
132 my_dom=JoinFaces([ms1,ms2],optimize=False)
133 self.checker(my_dom,file)
134
135 def test_hex_contact_3D_order1(self):
136 file="hex_contact_3D_order1.msh"
137 ms1=Brick(1,1,1,1,l2=0.5,useElementsOnFace=False)
138 ms2=Brick(1,1,1,1,l2=0.5,useElementsOnFace=False)
139 ms2.setX(ms2.getX()+[0,0,0.5])
140 my_dom=JoinFaces([ms1,ms2],optimize=False)
141 self.checker(my_dom,file)
142
143 def test_hex_contact_3D_order1_onFace(self):
144 file="hex_contact_3D_order1_onFace.msh"
145 ms1=Brick(1,1,1,1,l2=0.5,useElementsOnFace=True)
146 ms2=Brick(1,1,1,1,l2=0.5,useElementsOnFace=True)
147 ms2.setX(ms2.getX()+[0,0,0.5])
148 my_dom=JoinFaces([ms1,ms2],optimize=False)
149 self.checker(my_dom,file)
150
151 def test_hex_contact_3D_order2(self):
152 file="hex_contact_3D_order2.msh"
153 ms1=Brick(1,1,1,2,l2=0.5,useElementsOnFace=False)
154 ms2=Brick(1,1,1,2,l2=0.5,useElementsOnFace=False)
155 ms2.setX(ms2.getX()+[0,0,0.5])
156 my_dom=JoinFaces([ms1,ms2],optimize=False)
157 self.checker(my_dom,file)
158
159 def test_hex_contact_3D_order2_onFace(self):
160 file="hex_contact_3D_order2_onFace.msh"
161 ms1=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)
162 ms2=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)
163 ms2.setX(ms2.getX()+[0,0,0.5])
164 my_dom=JoinFaces([ms1,ms2],optimize=False)
165 self.checker(my_dom,file)
166
167 class Test_GMSHReader(unittest.TestCase):
168 def compare(self, test_file, reference_file):
169 dom_string=open(test_file).read().splitlines()
170 ref_string=open(reference_file).read().splitlines()
171 self.failUnlessEqual(len(dom_string),len(ref_string),"number of lines in mesh files does not match reference")
172 for l in range(1,len(ref_string)):
173 self.failUnlessEqual(dom_string[l].strip(),ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),dom_string[l].strip()))
174
175 def test_Tri3(self):
176 file="tri3_gmsh.msh"
177 ref ="tri3.fly"
178 test = FINLEY_WORKDIR+os.sep+"tri3_test.fly"
179 dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2,optimize=False)
180 dom.write(test)
181 self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)
182
183 def test_Tri6(self):
184 file="tri6_gmsh.msh"
185 ref="tri6.fly"
186 test = FINLEY_WORKDIR+os.sep+"tri8_test.fly"
187 dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2,optimize=False)
188 dom.write(test)
189 self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)
190
191 def test_Tet4(self):
192 file="tet4_gmsh.msh"
193 ref="tet4.fly"
194 test = FINLEY_WORKDIR+os.sep+"tet4_test.fly"
195 dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)
196 dom.write(test)
197 self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)
198
199 def test_Tet10(self):
200 file="tet10_gmsh.msh"
201 ref="tet10.fly"
202 test = FINLEY_WORKDIR+os.sep+"tet10_test.fly"
203 dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)
204 dom.write(test)
205 self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)
206
207 class Test_Reader(unittest.TestCase):
208 def test_ReadWriteTagNames(self):
209 file="hex_2D_order2.msh"
210 test = FINLEY_WORKDIR+os.sep+"test.fly"
211 dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)
212 insertTagNames(dom,A=1,B=2)
213 dom.write(test)
214 dom2 = ReadMesh(test,3,optimize=False)
215 t=getTagNames(dom)
216 self.failUnless(len(t)==6)
217 self.failUnless("A" in t)
218 self.failUnless("B" in t)
219 self.failUnless(dom2.getTag("A") == 1)
220 self.failUnless(dom2.getTag("B") == 2)
221 self.failUnless(dom2.isValidTagName("A"))
222 self.failUnless(dom2.isValidTagName("B"))
223
224
225 if __name__ == '__main__':
226 suite = unittest.TestSuite()
227 suite.addTest(unittest.makeSuite(Test_Generators))
228 suite.addTest(unittest.makeSuite(Test_GMSHReader))
229 suite.addTest(unittest.makeSuite(Test_Reader))
230 s=unittest.TextTestRunner(verbosity=2).run(suite)

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26