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

Annotation of /trunk/esys2/finley/test/python/RecMeshTest.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 104 - (hide annotations)
Fri Dec 17 07:43:12 2004 UTC (16 years, 2 months ago) by jgs
File MIME type: text/x-python
File size: 10546 byte(s)
*** empty log message ***

1 jgs 82 # $Id$
2     """checks the rectangular mesh generator for a single element by comparing the generated mesh file with a reference"""
3    
4     import sys
5     import os
6    
7 jgs 104 import esys.escript
8     import esys.finley
9    
10 jgs 82 TMPFILE="tmp.msh"
11    
12     ref_line1="""Rectangular mesh with 2 nodes
13     1D-Nodes 2
14     0 0 1 0.000000000000000e+00
15     1 1 2 1.000000000000000e+00
16     Line2 1
17     0 0 0 1
18     Point1 2
19     1 1 0
20     2 2 1
21     Point1_Contact 0
22     Point1 0
23     """
24    
25     ref_line2="""Rectangular mesh with 3 nodes
26     1D-Nodes 3
27     0 0 1 0.000000000000000e+00
28     1 1 0 5.000000000000000e-01
29     2 2 2 1.000000000000000e+00
30     Line3 1
31     0 0 0 2 1
32     Point1 2
33     1 1 0
34     2 2 2
35     Point1_Contact 0
36     Point1 0
37     """
38    
39     ref_rec1="""Rectangular 2 x 2 mesh
40     2D-Nodes 4
41     0 0 11 0.000000000000000e+00 0.000000000000000e+00
42     1 1 12 1.000000000000000e+00 0.000000000000000e+00
43     2 2 21 0.000000000000000e+00 1.000000000000000e+00
44     3 3 22 1.000000000000000e+00 1.000000000000000e+00
45     Rec4 1
46     0 0 0 1 3 2
47     Line2 4
48     1 10 0 1
49     3 1 2 0
50     4 2 1 3
51     2 20 3 2
52     Line2_Contact 0
53     Point1 0
54     """
55    
56     ref_rec2="""Rectangular 3 x 3 mesh
57     2D-Nodes 8
58     0 0 11 0.000000000000000e+00 0.000000000000000e+00
59     1 1 10 5.000000000000000e-01 0.000000000000000e+00
60     2 2 12 1.000000000000000e+00 0.000000000000000e+00
61     3 3 1 0.000000000000000e+00 5.000000000000000e-01
62     5 4 2 1.000000000000000e+00 5.000000000000000e-01
63     6 5 21 0.000000000000000e+00 1.000000000000000e+00
64     7 6 20 5.000000000000000e-01 1.000000000000000e+00
65     8 7 22 1.000000000000000e+00 1.000000000000000e+00
66     Rec8 1
67     0 0 0 2 8 6 1 5 7 3
68     Line3 4
69     1 10 0 2 1
70     3 1 6 0 3
71     4 2 2 8 5
72     2 20 8 6 7
73     Line3_Contact 0
74     Point1 0
75     """
76    
77     ref_brick1="""Rectangular 2 x 2 x 2 mesh
78     3D-Nodes 8
79     0 0 111 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
80     1 1 112 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
81     2 2 121 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
82     3 3 122 1.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
83     4 4 211 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
84     5 5 212 1.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
85     6 6 221 0.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
86     7 7 222 1.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
87     Hex8 1
88     0 0 0 1 3 2 4 5 7 6
89     Rec4 6
90     1 100 0 2 3 1
91     3 1 0 4 6 2
92     5 10 0 1 5 4
93     4 2 1 3 7 5
94     6 20 2 6 7 3
95     2 200 4 5 7 6
96     Rec4_Contact 0
97     Point1 0
98     """
99    
100     ref_brick2="""Rectangular 3 x 3 x 3 mesh
101     3D-Nodes 20
102     0 0 111 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
103     1 1 110 5.000000000000000e-01 0.000000000000000e+00 0.000000000000000e+00
104     2 2 112 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
105     3 3 101 0.000000000000000e+00 5.000000000000000e-01 0.000000000000000e+00
106     5 4 102 1.000000000000000e+00 5.000000000000000e-01 0.000000000000000e+00
107     6 5 121 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
108     7 6 120 5.000000000000000e-01 1.000000000000000e+00 0.000000000000000e+00
109     8 7 122 1.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
110     9 8 11 0.000000000000000e+00 0.000000000000000e+00 5.000000000000000e-01
111     11 9 12 1.000000000000000e+00 0.000000000000000e+00 5.000000000000000e-01
112     15 10 21 0.000000000000000e+00 1.000000000000000e+00 5.000000000000000e-01
113     17 11 22 1.000000000000000e+00 1.000000000000000e+00 5.000000000000000e-01
114     18 12 211 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
115     19 13 210 5.000000000000000e-01 0.000000000000000e+00 1.000000000000000e+00
116     20 14 212 1.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
117     21 15 201 0.000000000000000e+00 5.000000000000000e-01 1.000000000000000e+00
118     23 16 202 1.000000000000000e+00 5.000000000000000e-01 1.000000000000000e+00
119     24 17 221 0.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
120     25 18 220 5.000000000000000e-01 1.000000000000000e+00 1.000000000000000e+00
121     26 19 222 1.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
122     Hex20 1
123     0 0 0 2 8 6 18 20 26 24 1 5 7 3 9 11 17 15 19 23 25 21
124     Rec8 6
125     1 100 0 6 8 2 3 7 5 1
126     3 1 0 18 24 6 9 21 15 3
127     5 10 0 2 20 18 1 11 19 9
128     4 2 2 8 26 20 5 17 23 11
129     6 20 6 24 26 8 15 25 17 7
130     2 200 18 20 26 24 19 23 25 21
131     Rec8_Contact 0
132     Point1 0
133     """
134     ref_line1_onElement="""Rectangular mesh with 2 nodes
135     1D-Nodes 2
136     0 0 1 0.000000000000000e+00
137     1 1 2 1.000000000000000e+00
138     Line2 1
139     0 0 0 1
140     Line2Face 2
141     1 1 0 1
142     2 2 1 0
143     Line2Face_Contact 0
144     Point1 0
145     """
146    
147     ref_line2_onElement="""Rectangular mesh with 3 nodes
148     1D-Nodes 3
149     0 0 1 0.000000000000000e+00
150     1 1 0 5.000000000000000e-01
151     2 2 2 1.000000000000000e+00
152     Line3 1
153     0 0 0 2 1
154     Line3Face 2
155     1 1 0 2 1
156     2 2 2 0 1
157     Line3Face_Contact 0
158     Point1 0
159     """
160    
161     ref_rec1_onElement="""Rectangular 2 x 2 mesh
162     2D-Nodes 4
163     0 0 11 0.000000000000000e+00 0.000000000000000e+00
164     1 1 12 1.000000000000000e+00 0.000000000000000e+00
165     2 2 21 0.000000000000000e+00 1.000000000000000e+00
166     3 3 22 1.000000000000000e+00 1.000000000000000e+00
167     Rec4 1
168     0 0 0 1 3 2
169     Rec4Face 4
170     1 10 0 1 3 2
171     2 20 3 2 0 1
172     3 1 2 0 1 3
173     4 2 1 3 2 0
174     Rec4Face_Contact 0
175     Point1 0
176     """
177    
178     ref_rec2_onElement="""Rectangular 3 x 3 mesh
179     2D-Nodes 8
180     0 0 11 0.000000000000000e+00 0.000000000000000e+00
181     1 1 10 5.000000000000000e-01 0.000000000000000e+00
182     2 2 12 1.000000000000000e+00 0.000000000000000e+00
183     3 3 1 0.000000000000000e+00 5.000000000000000e-01
184     5 4 2 1.000000000000000e+00 5.000000000000000e-01
185     6 5 21 0.000000000000000e+00 1.000000000000000e+00
186     7 6 20 5.000000000000000e-01 1.000000000000000e+00
187     8 7 22 1.000000000000000e+00 1.000000000000000e+00
188     Rec8 1
189     0 0 0 2 8 6 1 5 7 3
190     Rec8Face 4
191     1 10 0 2 8 6 1 5 7 3
192     2 20 8 6 0 2 7 3 1 5
193     3 1 6 0 2 8 3 1 5 7
194     4 2 2 8 6 0 5 7 3 1
195     Rec8Face_Contact 0
196     Point1 0
197     """
198    
199     ref_brick1_onElement="""Rectangular 2 x 2 x 2 mesh
200     3D-Nodes 8
201     0 0 111 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
202     1 1 112 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
203     2 2 121 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
204     3 3 122 1.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
205     4 4 211 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
206     5 5 212 1.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
207     6 6 221 0.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
208     7 7 222 1.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
209     Hex8 1
210     0 0 0 1 3 2 4 5 7 6
211     Hex8Face 6
212     1 100 0 2 3 1 4 6 7 5
213     2 200 4 5 7 6 0 1 3 2
214     3 1 0 4 6 2 1 5 7 3
215     4 2 1 3 7 5 0 2 6 4
216     5 10 0 1 5 4 2 3 7 6
217     6 20 2 6 7 3 0 4 5 1
218     Hex8Face_Contact 0
219     Point1 0
220     """
221    
222     ref_brick2_onElement="""Rectangular 3 x 3 x 3 mesh
223     3D-Nodes 20
224     0 0 111 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
225     1 1 110 5.000000000000000e-01 0.000000000000000e+00 0.000000000000000e+00
226     2 2 112 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
227     3 3 101 0.000000000000000e+00 5.000000000000000e-01 0.000000000000000e+00
228     5 4 102 1.000000000000000e+00 5.000000000000000e-01 0.000000000000000e+00
229     6 5 121 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
230     7 6 120 5.000000000000000e-01 1.000000000000000e+00 0.000000000000000e+00
231     8 7 122 1.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
232     9 8 11 0.000000000000000e+00 0.000000000000000e+00 5.000000000000000e-01
233     11 9 12 1.000000000000000e+00 0.000000000000000e+00 5.000000000000000e-01
234     15 10 21 0.000000000000000e+00 1.000000000000000e+00 5.000000000000000e-01
235     17 11 22 1.000000000000000e+00 1.000000000000000e+00 5.000000000000000e-01
236     18 12 211 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
237     19 13 210 5.000000000000000e-01 0.000000000000000e+00 1.000000000000000e+00
238     20 14 212 1.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
239     21 15 201 0.000000000000000e+00 5.000000000000000e-01 1.000000000000000e+00
240     23 16 202 1.000000000000000e+00 5.000000000000000e-01 1.000000000000000e+00
241     24 17 221 0.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
242     25 18 220 5.000000000000000e-01 1.000000000000000e+00 1.000000000000000e+00
243     26 19 222 1.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
244     Hex20 1
245     0 0 0 2 8 6 18 20 26 24 1 5 7 3 9 11 17 15 19 23 25 21
246     Hex20Face 6
247     1 100 0 6 8 2 18 24 26 20 3 7 5 1 9 15 17 11 21 25 23 19
248     2 200 18 20 26 24 0 2 8 6 19 23 25 21 9 11 17 15 1 5 7 3
249     3 1 0 18 24 6 2 20 26 8 9 21 15 3 1 19 25 7 11 23 17 5
250     4 2 2 8 26 20 0 6 24 18 5 17 23 11 1 7 25 19 3 15 21 9
251     5 10 0 2 20 18 6 8 26 24 1 11 19 9 3 5 23 21 7 17 25 15
252     6 20 6 24 26 8 0 18 20 2 15 25 17 7 3 21 23 5 9 19 11 1
253     Hex20Face_Contact 0
254     Point1 0
255     """
256    
257     def checker(dom,reference):
258     dom.write(TMPFILE)
259     mshfile=open(TMPFILE).read()
260     if reference != mshfile:
261     print reference
262     print mshfile
263     return None
264     else:
265     return not None
266    
267     failed=[]
268    
269 jgs 104 my_dom=Interval(1,1)
270 jgs 82 if checker(my_dom,ref_line1):
271     print "@@@@ line, order 1 passed"
272     else:
273     failed.append("line, order 1")
274    
275 jgs 104 my_dom=Interval(1,2)
276 jgs 82 if checker(my_dom,ref_line2):
277     print "@@@@ line, order 2 passed"
278     else:
279     failed.append("line, order 2")
280    
281 jgs 104 my_dom=Rectangle(1,1,1)
282 jgs 82 if checker(my_dom,ref_rec1):
283     print "@@@@ rec, order 1 passed"
284     else:
285     failed.append("rec, order 1")
286    
287 jgs 104 my_dom=Rectangle(1,1,2)
288 jgs 82 if checker(my_dom,ref_rec2):
289     print "@@@@ rec, order 2 passed"
290     else:
291     failed.append("rec, order 2")
292    
293 jgs 104 my_dom=Brick(1,1,1,1)
294 jgs 82 if checker(my_dom,ref_brick1):
295     print "@@@@ brick, order 1 passed"
296     else:
297     failed.append("brick, order 1")
298    
299 jgs 104 my_dom=Brick(1,1,1,2)
300 jgs 82 if checker(my_dom,ref_brick2):
301     print "@@@@ brick, order 2 passed"
302     else:
303     failed.append("brick, order 2")
304    
305 jgs 104 my_dom=Interval(1,1,useElementsOnFace=1)
306 jgs 82 if checker(my_dom,ref_line1_onElement):
307     print "@@@@ line, order 1, onElement passed"
308     else:
309     failed.append("line, order 1, onElement")
310    
311 jgs 104 #my_dom=Interval(1,2,useElementsOnFace=1)
312     #if checker(my_dom,ref_line2_onElement):
313     # print "@@@@ line, order 2, onElement passed"
314     #else:
315     # failed.append("line, order 2, onElement")
316 jgs 82
317 jgs 104 my_dom=Rectangle(1,1,1,useElementsOnFace=1)
318 jgs 82 if checker(my_dom,ref_rec1_onElement):
319     print "@@@@ rec, order 1, onElement passed"
320     else:
321     failed.append("rec, order 1, onElement")
322    
323 jgs 104 my_dom=Rectangle(1,1,2,useElementsOnFace=1)
324 jgs 82 if checker(my_dom,ref_rec2_onElement):
325     print "@@@@ rec, order 2, onElement passed"
326     else:
327     failed.append("rec, order 2, onElement")
328    
329 jgs 104 my_dom=Brick(1,1,1,1,useElementsOnFace=1)
330 jgs 82 if checker(my_dom,ref_brick1_onElement):
331     print "@@@@ brick, order 1, onElement passed"
332     else:
333     failed.append("brick, order 1, onElement")
334    
335 jgs 104 my_dom=Brick(1,1,1,2,useElementsOnFace=1)
336 jgs 82 if checker(my_dom,ref_brick2_onElement):
337     print "@@@@ brick, order 2, onElement passed"
338     else:
339     failed.append("brick, order 2, onElement")
340    
341     if len(failed) == 0:
342     print "@@ mesh generation test passed"
343     else:
344     print "@@ mesh generation failed for %s"%failed
345    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26