/[escript]/trunk/finley/src/generateReferenceElementList.py
ViewVC logotype

Contents of /trunk/finley/src/generateReferenceElementList.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4492 - (show annotations)
Tue Jul 2 01:44:11 2013 UTC (5 years, 9 months ago) by caltinay
File MIME type: text/x-python
File size: 9116 byte(s)
Finley changes that were held back while in release mode - moved more stuff
into finley namespace.

1 #*******************************************************
2 #
3 # Copyright (c) 2003-2013 by University of Queensland
4 # http://www.uq.edu.au
5 #
6 # Primary Business: Queensland, Australia
7 # Licensed under the Open Software License version 3.0
8 # http://www.opensource.org/licenses/osl-3.0.php
9 #
10 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 # Development since 2012 by School of Earth Sciences
12 #
13 #******************************************************/
14 #
15 # this code generates the ReferenceElement_InfoList in ReferenceElements.cpp
16 #
17 GEOBASE = {
18 "Point": (1, 1, "Point", [0] ),
19 "Line": (2, 2, "Point", [0,2, 2,1]),
20 "Tri":(4, 3, "Line", [0, 3, 5, 5, 4, 2, 3, 1, 4, 4, 5, 3]),
21 "Rec" :(4, 4, "Line", [0, 4, 8, 7, 7, 8, 6, 3, 4, 1, 5, 8, 8, 5, 2, 6] ),
22 "Tet": (8, 4, "Tri", [0, 4, 6, 7, 4, 1, 5, 8, 6, 5, 2, 9, 7, 8, 9, 3, 4, 5, 6, 8, 5, 9, 8, 6, 9, 7, 6, 8, 7, 4, 6, 8] ),
23 "Hex": (8, 8, "Rec", [0, 8, 20, 11, 12, 21, 26, 24, 8, 1, 9, 20, 21, 13, 22, 26, 11, 20, 10, 3, 24, 26, 23, 15, 20, 9, 2, 10, 26, 22, 14, 23, 12, 21, 26, 24, 4, 16, 25, 19, 21, 13, 22, 26, 16, 5, 17, 25, 24, 26, 23, 15, 19, 25, 18, 7, 26, 22, 14, 23, 25, 17, 6, 18] )
24
25 }
26
27 RELEVANTGEO = {
28 "Point1" : [0],
29 "Line2" : [0],
30 "Line3" : [0],
31 "Line4" : [0],
32 "Tri3" : [0,1],
33 "Tri6" : [0,1,3],
34 "Tri9" : [0,1,3,4],
35 "Tri10" : [0,1,3,4],
36 "Rec4" : [0,1],
37 "Rec8" : [0,1,4],
38 "Rec9" : [0,1,4],
39 "Rec12" : [0,1,4,5],
40 "Rec16" : [0,1,4,5],
41 "Tet4" : [0,1,2],
42 "Tet10" : [0,1,2,4,5,6],
43 "Tet16" : [0,1,2,4,5,6,7,8,9],
44 "Hex8" : [0,1,2,3],
45 "Hex20" : [0,1,2,3,8,9,10,11],
46 "Hex27" : [0,1,2,3,8,9,10,11,20],
47 "Hex32" : [0,1,2,3,8,9,10,11,12,13,14,15]
48 }
49
50 FACENODES= {
51 "Line2" : [0],
52 "Line3" : [0],
53 "Line4" : [0],
54 "Tri3" : [0,1],
55 "Tri6" : [0,1,3],
56 "Tri9" : [0,1,3,4],
57 "Tri10" : [0,1,3,4],
58 "Rec4" : [0,1],
59 "Rec8" : [0,1,4],
60 "Rec9" : [0,1,4],
61 "Rec12" : [0,1,4,5],
62 "Rec16" : [0,1,4,5],
63 "Tet4" : [0,1,2,3] ,
64 "Tet10" : [0,1,2,4,5,6],
65 "Tet16" : [0,1,2,4,5,6,7,8,9],
66 "Hex8" : [0,1,2,3],
67 "Hex20" : [0,1,2,3,8,9,10,11],
68 "Hex27" : [0,1,2,3,8,9,10,11,20],
69 "Hex32" : [0,1,2,3,8,9,10,11,12,13,14,15]
70 }
71
72 SHIFTNODES= {
73 "Point1" : ( (0,),(-1,)),
74 "Line2" : ( (1,0),(-1,)),
75 "Line3" : ( (1,0,2),(-1,)),
76 "Line4" : ( (1,0,3,2),(-1,)),
77 "Tri3" : ( (1,2,0),(0,2,1)),
78 "Tri6" : ( (1,2,0,4,5,3),(0,2,1,5,4,3)),
79 "Tri9" : ( (1,2,0,5,6,7,8,3,4),(0,2,1,8,7,6,5,4,3)),
80 "Tri10" : ( (1,2,0,5,6,7,8,3,4,9),(0,2,1,8,7,6,5,4,3,9)),
81 "Rec4" : ( (1,2,3,0),(0,3,2,1)),
82 "Rec8" : ( (1,2,3,0,5,6,7,4),(0,3,2,1,7,6,5,4)),
83 "Rec9" : ( (1,2,3,0,5,6,7,4,8),(0,3,2,1,7,6,5,4,8)),
84 "Rec12" : ( (1,2,3,0,6,7,8,9,10,11,4,5),(0,3,2,1,11,10,9,8,7,6,5,4)) ,
85 "Rec16" : ( (1,2,3,0,6,7,8,9,10,11,4,5,13,14,15,12),(0,3,2,1,11,10,9,8,7,6,5,4,12,15,14,13)),
86 "Tet4" : ( (-1,),(-1,)),
87 "Tet10" : ( (-1,),(-1,)),
88 "Tet16" : ( (-1,),(-1,)),
89 "Hex8" : ( (-1,),(-1,)),
90 "Hex20" : ( (-1,),(-1,)),
91 "Hex27" : ( (-1,),(-1,)),
92 "Hex32" : ( (-1,),(-1,)),
93 "Line2Face" : ( (0,1,2),(-1,)),
94 "Line3Face" : ( (0,1,2),(-1,)),
95 "Line4Face" : ( (0,1,2),(-1,)),
96 "Tri3Face" : ( (1,0,2), (-1,)),
97 "Tri6Face" : ( (1,0,2,3,5,4),(-1,)),
98 "Tri9Face" : ( (1,0,2,4,3,7,8,6,5),(-1,)),
99 "Tri10Face" : ( (1,0,2,4,3,7,8,6,5,9),(-1,)),
100 "Rec4Face" : ( (1,0,3,2),(-1,)),
101 "Rec8Face" : ( (1,0,3,2,4,7,6,5),(-1,)),
102 "Rec9Face" : ( (1,0,3,2,4,7,6,5,8),(-1,)),
103 "Rec12Face" : ( (1,0,3,2,5,4,11,10,9,8,7,6),(-1,)),
104 "Rec16Face" : ( (1,0,3,2,5,4,11,10,9,8,7,6,13,12,15,14),(-1,)),
105 "Tet4Face" : ( (1,2,0,3),(0,2,1,3)) ,
106 "Tet10Face" : ( (1,2,0,3,5,6,4,8,9,7),(0,2,1,3,6,7,9,8)),
107 "Tet16Face" : ( (1,2,0,3,6,7,8,9,4,5,11,12,10,14,15,13),(0,2,1,3,9,8,7,6,5,4,9,8,7,6,10,12,11,13,15,14)),
108 "Hex8Face" : ( (1,2,3,0,5,6,7,4),(0,3,2,1,4,7,6,5)),
109 "Hex20Face" : ( (1,2,3,0,5,6,7,4,9,10,11,8,13,14,15,12,17,18,19,16),(0,3,2,1,4,7,6,5,11,10,9,8,12,15,14,13,19,18,17,16)),
110 "Hex27Face" : ( (1,2,3,0,5,6,7,4,9,10,11,8,13,14,15,12,17,18,19,16,20,22,23,24,22,25,26),(0,3,2,1,4,7,6,5,11,10,9,8,12,15,14,13,19,18,17,16,20,24,23,22,21,25,26)),
111 "Hex32Face" : ( (1,2,3,0,5,6,7,4,10,11,12,13,14,15,8,9,17,18,19,16,21,22,23,20,26,27,28,29,30,31,34,25), (0,3,2,1,4,7,6,5,15,14,13,12,11,10,9,8,16,19,18,17,20,23,22,21,31,30,29,28,27,26,25,24))
112 }
113 def listToArrayStr(l):
114 out="{"
115 for s in l:
116 if len(out)==1:
117 out+=" %s"%s
118 else:
119 out+=", %s"%s
120 return out+" }"
121 def LENLEN(l):
122 if len(l) == 1:
123 if l[0] == -1:
124 return -1
125 else:
126 return 1
127 else:
128 return len(l)
129
130 outall="ReferenceElementInfo ReferenceElement_InfoList[]={\n"
131
132 for name in ["Point1", "Line2", "Line3", "Line4", "Tri3", "Tri6", "Tri9", "Tri10", "Rec4", "Rec8", "Rec9", "Rec12", "Rec16", "Tet4", "Tet10", "Tet16", "Hex8", "Hex20", "Hex27", "Hex32", "Line2Face", "Line3Face", "Line4Face", "Tri3Face", "Tri6Face", "Tri9Face", "Tri10Face", "Rec4Face", "Rec8Face", "Rec9Face", "Rec12Face", "Rec16Face", "Tet4Face", "Tet10Face", "Tet16Face", "Hex8Face", "Hex20Face", "Hex27Face", "Hex32Face", "Point1_Contact", "Line2_Contact", "Line3_Contact", "Line4_Contact", "Tri3_Contact", "Tri6_Contact", "Tri9_Contact", "Tri10_Contact", "Rec4_Contact", "Rec8_Contact", "Rec9_Contact", "Rec12_Contact", "Rec16_Contact", "Line2Face_Contact", "Line3Face_Contact", "Line4Face_Contact", "Tri3Face_Contact", "Tri6Face_Contact", "Tri9Face_Contact", "Tri10Face_Contact", "Rec4Face_Contact", "Rec8Face_Contact", "Rec9Face_Contact", "Rec12Face_Contact", "Rec16Face_Contact", "Tet4Face_Contact", "Tet10Face_Contact", "Tet16Face_Contact", "Hex8Face_Contact", "Hex20Face_Contact", "Hex27Face_Contact", "Hex32Face_Contact", "Line3Macro", "Tri6Macro", "Rec9Macro", "Tet10Macro", "Hex27Macro" ]:
133 isFace=False
134 isMacro=False
135 isContact=False
136 n=1
137 z="Point"
138 for z in [ "Point", "Line", "Tri", "Rec", "Tet", "Hex" ] :
139 if name.startswith(z):
140 s=name[len(z):]
141 n=s
142 if s.find("Macro")>=0:
143 isMacro=True
144 if s.find("Macro")>0: n=s[:s.find("Macro")]
145 s=s[s.find("Macro")+5:]
146 if s.find("Face")>=0:
147 isFace=True
148 if s.find("Face")>0: n=s[:s.find("Face")]
149 s=s[s.find("Face")+4:]
150 if s.find("_Contact")>=0:
151 isContact=True
152 if s.find("_Contact")>0: n=s[:s.find("_Contact")]
153 s=s[s.find("_Contact")+8:]
154 n=int(n)
155 break
156 numLinearNodes=GEOBASE[z][1]
157 if isFace:
158 Quadrature=GEOBASE[z][2]
159 else:
160 Quadrature=z
161 Parametrization="%s%s"%(z,n)
162 if isContact:
163 offsets=[0, n, 2*n]
164 numSides=2
165 else:
166 numSides=1
167 offsets=[0, n]
168 numNodes=offsets[-1]
169 if isMacro:
170 numSubElements=GEOBASE[z][0]
171 BasisFunctions="%s%s"%(z,numLinearNodes)
172 subElementNodes=GEOBASE[z][3]
173 else:
174 numSubElements=1
175 BasisFunctions=Parametrization
176 subElementNodes=[ i for i in xrange(numNodes) ]
177
178 linearTypeId="%s%s"%(z,numLinearNodes)
179 linearNodes=[ i for i in xrange(numLinearNodes) ]
180 if isFace: linearTypeId+="Face"
181
182 if isContact:
183 linearTypeId+="_Contact"
184 linearNodes+=[ n+i for i in xrange(numLinearNodes) ]
185
186 if isFace:
187 relevantGeoNodes=RELEVANTGEO["%s%s"%(z,n)]
188 else:
189 relevantGeoNodes=[ i for i in xrange(n) ]
190
191 if isContact:
192 faceNodes =[-1]
193 shiftNodes = [-1]
194 reverseNodes = [-1]
195 else:
196 if isFace:
197 faceNodes=FACENODES["%s%s"%(z,n)]
198 shiftNodes = SHIFTNODES["%s%sFace"%(z,n)][0]
199 reverseNodes = SHIFTNODES["%s%sFace"%(z,n)][1]
200 else:
201 faceNodes=[ i for i in xrange(numNodes) ]
202 shiftNodes = SHIFTNODES["%s%s"%(z,n)][0]
203 reverseNodes = SHIFTNODES["%s%s"%(z,n)][1]
204
205
206 out = '{ %s, "%s", %d, %d, %d, %s, %s,\n %s, %sQuad, %sShape, %sShape,\n %s,\n %s, %s,\n %s, %s,\n %s,\n %s },\n'% \
207 (name, name, numNodes, numSubElements, numSides, listToArrayStr(offsets), linearTypeId, listToArrayStr(linearNodes),
208 Quadrature, Parametrization, BasisFunctions, listToArrayStr(subElementNodes),
209 len(relevantGeoNodes), listToArrayStr(relevantGeoNodes),
210 LENLEN(faceNodes), listToArrayStr(faceNodes), listToArrayStr(shiftNodes), listToArrayStr(reverseNodes) )
211 outall+=out
212 out = '{ %s, "%s", %d, %d, %d, %s, %s,\n %s, %s, %s, %s,\n %s,\n %s, %s,\n %s, %s,\n %s,\n %s }\n'% \
213 ("NoRef", "noElement", 0, 0, 0, listToArrayStr([0]), "NoRef", listToArrayStr([0]),
214 "NoQuad", "NoShape", "NoShape", listToArrayStr([0]),
215 -1, listToArrayStr([0]), -1, listToArrayStr([0]), listToArrayStr([0]), listToArrayStr([0]) )
216 outall+=out
217 print outall+"\n};"

  ViewVC Help
Powered by ViewVC 1.1.26