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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5706 - (show annotations)
Mon Jun 29 03:41:36 2015 UTC (4 years, 2 months ago) by sshaw
File MIME type: text/x-python
File size: 8224 byte(s)
all python files now force use of python3 prints and division syntax to stop sneaky errors appearing in py3 environs
1 #*******************************************************
2 #
3 # Copyright (c) 2003-2015 by The 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 2012-2013 by School of Earth Sciences
12 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
13 #
14 #******************************************************
15
16
17 from __future__ import print_function, division
18
19
20 #
21 # this code generates the Dudley_ReferenceElement_InfoList in ReferenceElements.c
22 #
23 GEOBASE = {
24 "Point": (1, 1, "Point", [0] ),
25 "Line": (2, 2, "Point", [0,2, 2,1]),
26 "Tri":(4, 3, "Line", [0, 3, 5, 5, 4, 2, 3, 1, 4, 4, 5, 3]),
27 "Rec" :(4, 4, "Line", [0, 4, 8, 7, 7, 8, 6, 3, 4, 1, 5, 8, 8, 5, 2, 6] ),
28 "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] ),
29 "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] )
30
31 }
32
33 RELEVANTGEO = {
34 "Point1" : [0],
35 "Line2" : [0],
36 "Line3" : [0],
37 "Line4" : [0],
38 "Tri3" : [0,1],
39 "Tri6" : [0,1,3],
40 "Tri9" : [0,1,3,4],
41 "Tri10" : [0,1,3,4],
42 "Rec4" : [0,1],
43 "Rec8" : [0,1,4],
44 "Rec9" : [0,1,4],
45 "Rec12" : [0,1,4,5],
46 "Rec16" : [0,1,4,5],
47 "Tet4" : [0,1,2],
48 "Tet10" : [0,1,2,4,5,6],
49 "Tet16" : [0,1,2,4,5,6,7,8,9],
50 "Hex8" : [0,1,2,3],
51 "Hex20" : [0,1,2,3,8,9,10,11],
52 "Hex27" : [0,1,2,3,8,9,10,11,20],
53 "Hex32" : [0,1,2,3,8,9,10,11,12,13,14,15]
54 }
55
56 FACENODES= {
57 "Line2" : [0],
58 "Line3" : [0],
59 "Line4" : [0],
60 "Tri3" : [0,1],
61 "Tri6" : [0,1,3],
62 "Tri9" : [0,1,3,4],
63 "Tri10" : [0,1,3,4],
64 "Rec4" : [0,1],
65 "Rec8" : [0,1,4],
66 "Rec9" : [0,1,4],
67 "Rec12" : [0,1,4,5],
68 "Rec16" : [0,1,4,5],
69 "Tet4" : [0,1,2,3] ,
70 "Tet10" : [0,1,2,4,5,6],
71 "Tet16" : [0,1,2,4,5,6,7,8,9],
72 "Hex8" : [0,1,2,3],
73 "Hex20" : [0,1,2,3,8,9,10,11],
74 "Hex27" : [0,1,2,3,8,9,10,11,20],
75 "Hex32" : [0,1,2,3,8,9,10,11,12,13,14,15]
76 }
77
78 SHIFTNODES= {
79 "Point1" : ( (0,),(-1,)),
80 "Line2" : ( (1,0),(-1,)),
81 "Line3" : ( (1,0,2),(-1,)),
82 "Line4" : ( (1,0,3,2),(-1,)),
83 "Tri3" : ( (1,2,0),(0,2,1)),
84 "Tri6" : ( (1,2,0,4,5,3),(0,2,1,5,4,3)),
85 "Tri9" : ( (1,2,0,5,6,7,8,3,4),(0,2,1,8,7,6,5,4,3)),
86 "Tri10" : ( (1,2,0,5,6,7,8,3,4,9),(0,2,1,8,7,6,5,4,3,9)),
87 "Rec4" : ( (1,2,3,0),(0,3,2,1)),
88 "Rec8" : ( (1,2,3,0,5,6,7,4),(0,3,2,1,7,6,5,4)),
89 "Rec9" : ( (1,2,3,0,5,6,7,4,8),(0,3,2,1,7,6,5,4,8)),
90 "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)) ,
91 "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)),
92 "Tet4" : ( (-1,),(-1,)),
93 "Tet10" : ( (-1,),(-1,)),
94 "Tet16" : ( (-1,),(-1,)),
95 "Hex8" : ( (-1,),(-1,)),
96 "Hex20" : ( (-1,),(-1,)),
97 "Hex27" : ( (-1,),(-1,)),
98 "Hex32" : ( (-1,),(-1,)),
99 "Line2Face" : ( (0,1,2),(-1,)),
100 "Line3Face" : ( (0,1,2),(-1,)),
101 "Line4Face" : ( (0,1,2),(-1,)),
102 "Tri3Face" : ( (1,0,2), (-1,)),
103 "Tri6Face" : ( (1,0,2,3,5,4),(-1,)),
104 "Tri9Face" : ( (1,0,2,4,3,7,8,6,5),(-1,)),
105 "Tri10Face" : ( (1,0,2,4,3,7,8,6,5,9),(-1,)),
106 "Rec4Face" : ( (1,0,3,2),(-1,)),
107 "Rec8Face" : ( (1,0,3,2,4,7,6,5),(-1,)),
108 "Rec9Face" : ( (1,0,3,2,4,7,6,5,8),(-1,)),
109 "Rec12Face" : ( (1,0,3,2,5,4,11,10,9,8,7,6),(-1,)),
110 "Rec16Face" : ( (1,0,3,2,5,4,11,10,9,8,7,6,13,12,15,14),(-1,)),
111 "Tet4Face" : ( (1,2,0,3),(0,2,1,3)) ,
112 "Tet10Face" : ( (1,2,0,3,5,6,4,8,9,7),(0,2,1,3,6,7,9,8)),
113 "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)),
114 "Hex8Face" : ( (1,2,3,0,5,6,7,4),(0,3,2,1,4,7,6,5)),
115 "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)),
116 "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)),
117 "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))
118 }
119 def listToArrayStr(l):
120 out="{"
121 for s in l:
122 if len(out)==1:
123 out+=" %s"%s
124 else:
125 out+=", %s"%s
126 return out+" }"
127 def LENLEN(l):
128 if len(l) == 1:
129 if l[0] == -1:
130 return -1
131 else:
132 return 1
133 else:
134 return len(l)
135
136 outall="Dudley_ReferenceElementInfo Dudley_ReferenceElement_InfoList[]={\n"
137
138 for name in ["Point1", "Line2", "Tri3", "Tet4", "Line2Face", "Tri3Face", "Tet4Face" ]:
139 isFace=False
140 isMacro=False
141 isContact=False
142 n=1
143 z="Point"
144 for z in [ "Point", "Line", "Tri", "Tet"] :
145 if name.startswith(z):
146 s=name[len(z):]
147 n=s
148 if s.find("Macro")>=0:
149 isMacro=True
150 if s.find("Macro")>0: n=s[:s.find("Macro")]
151 s=s[s.find("Macro")+5:]
152 if s.find("Face")>=0:
153 isFace=True
154 if s.find("Face")>0: n=s[:s.find("Face")]
155 s=s[s.find("Face")+4:]
156 if s.find("_Contact")>=0:
157 isContact=True
158 if s.find("_Contact")>0: n=s[:s.find("_Contact")]
159 s=s[s.find("_Contact")+8:]
160 n=int(n)
161 break
162 numLinearNodes=GEOBASE[z][1]
163 if isFace:
164 Quadrature=GEOBASE[z][2]
165 else:
166 Quadrature=z
167 Parametrization="%s%s"%(z,n)
168 if isContact:
169 offsets=[0, n, 2*n]
170 numSides=2
171 else:
172 numSides=1
173 offsets=[0, n]
174 numNodes=offsets[-1]
175 if isMacro:
176 numSubElements=GEOBASE[z][0]
177 BasisFunctions="%s%s"%(z,numLinearNodes)
178 subElementNodes=GEOBASE[z][3]
179 else:
180 numSubElements=1
181 BasisFunctions=Parametrization
182 subElementNodes=[ i for i in range(numNodes) ]
183
184 linearTypeId="%s%s"%(z,numLinearNodes)
185 linearNodes=[ i for i in range(numLinearNodes) ]
186 if isFace: linearTypeId+="Face"
187
188 if isContact:
189 linearTypeId+="_Contact"
190 linearNodes+=[ n+i for i in range(numLinearNodes) ]
191
192 if isFace:
193 relevantGeoNodes=RELEVANTGEO["%s%s"%(z,n)]
194 else:
195 relevantGeoNodes=[ i for i in range(n) ]
196
197 if isContact:
198 faceNodes =[-1]
199 shiftNodes = [-1]
200 reverseNodes = [-1]
201 else:
202 if isFace:
203 faceNodes=FACENODES["%s%s"%(z,n)]
204 shiftNodes = SHIFTNODES["%s%sFace"%(z,n)][0]
205 reverseNodes = SHIFTNODES["%s%sFace"%(z,n)][1]
206 else:
207 faceNodes=[ i for i in range(numNodes) ]
208 shiftNodes = SHIFTNODES["%s%s"%(z,n)][0]
209 reverseNodes = SHIFTNODES["%s%s"%(z,n)][1]
210
211
212 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'% \
213 (name, name, numNodes, numSubElements, numSides, listToArrayStr(offsets), linearTypeId, listToArrayStr(linearNodes),
214 Quadrature, Parametrization, BasisFunctions, listToArrayStr(subElementNodes),
215 len(relevantGeoNodes), listToArrayStr(relevantGeoNodes),
216 LENLEN(faceNodes), listToArrayStr(faceNodes), listToArrayStr(shiftNodes), listToArrayStr(reverseNodes) )
217 outall+=out
218 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'% \
219 ("NoRef", "noElement", 0, 0, 0, listToArrayStr([0]), "NoRef", listToArrayStr([0]),
220 "NoQuad", "NoShape", "NoShape", listToArrayStr([0]),
221 -1, listToArrayStr([0]), -1, listToArrayStr([0]), listToArrayStr([0]), listToArrayStr([0]) )
222 outall+=out
223 print outall+"\n};"

  ViewVC Help
Powered by ViewVC 1.1.26