/[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 82 - (hide annotations)
Tue Oct 26 06:53:54 2004 UTC (16 years, 4 months ago) by jgs
File MIME type: text/x-python
File size: 10730 byte(s)
Initial revision

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26