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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6939 - (show annotations)
Mon Jan 20 03:37:18 2020 UTC (4 months, 1 week ago) by uqaeller
File MIME type: text/x-python
File size: 9292 byte(s)
Updated the copyright header.


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

  ViewVC Help
Powered by ViewVC 1.1.26