Coreform-Cubit-Mesh-Export 1.0.4__py3-none-any.whl → 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Coreform-Cubit-Mesh-Export might be problematic. Click here for more details.
- {coreform_cubit_mesh_export-1.0.4.dist-info → coreform_cubit_mesh_export-1.1.1.dist-info}/METADATA +3 -8
- coreform_cubit_mesh_export-1.1.1.dist-info/RECORD +9 -0
- {coreform_cubit_mesh_export-1.0.4.dist-info → coreform_cubit_mesh_export-1.1.1.dist-info}/top_level.txt +1 -0
- cubit_mesh_export.py +273 -1041
- sample_script/cubit_mesh_export_2d_geo_lukas_format.py +77 -0
- sample_script/cubit_mesh_export_3d_cdb.py +115 -0
- sample_script/cubit_mesh_export_3d_freefem_mesh.py +59 -0
- sample_script/cubit_mesh_export_3d_gmesh_v4.py +191 -0
- coreform_cubit_mesh_export-1.0.4.dist-info/RECORD +0 -5
- {coreform_cubit_mesh_export-1.0.4.dist-info → coreform_cubit_mesh_export-1.1.1.dist-info}/WHEEL +0 -0
cubit_mesh_export.py
CHANGED
|
@@ -1,194 +1,8 @@
|
|
|
1
|
-
########################################################################
|
|
2
|
-
### FreeFEM mesh format
|
|
3
|
-
########################################################################
|
|
4
|
-
|
|
5
|
-
def export_3D_mesh(cubit, FileName):
|
|
6
|
-
|
|
7
|
-
block_count = cubit.get_block_count()
|
|
8
|
-
block_list = cubit.get_block_id_list()
|
|
9
|
-
sideset_count = cubit.get_sideset_count()
|
|
10
|
-
sideset_list = cubit.get_sideset_id_list()
|
|
11
|
-
nodeset_count = cubit.get_nodeset_count()
|
|
12
|
-
nodeset_list = cubit.get_nodeset_id_list()
|
|
13
|
-
|
|
14
|
-
node_count = cubit.get_node_count()
|
|
15
|
-
volume_count = cubit.get_volume_count()
|
|
16
|
-
volume_list = cubit.get_entities("volume")
|
|
17
|
-
nodeset_surface_count = 0
|
|
18
|
-
nodeset_surface_list = []
|
|
19
|
-
sideset_surface_list = []
|
|
20
|
-
surface_sideset_id = {}
|
|
21
|
-
surface_nodeset_id = {}
|
|
22
|
-
|
|
23
|
-
with open(FileName, 'w') as fid:
|
|
24
|
-
fid.write("MeshVersionFormatted 2\n")
|
|
25
|
-
fid.write("\n")
|
|
26
|
-
fid.write("Dimension 3\n")
|
|
27
|
-
fid.write("\n")
|
|
28
|
-
fid.write("Vertices\n")
|
|
29
|
-
fid.write(f'{node_count}\n')
|
|
30
|
-
|
|
31
|
-
node_set = set()
|
|
32
|
-
for block_id in cubit.get_block_id_list():
|
|
33
|
-
elem_types = ["hex", "tet", "wedge", "pyramid"]
|
|
34
|
-
for elem_type in elem_types:
|
|
35
|
-
if elem_type == "hex":
|
|
36
|
-
func = getattr(cubit, f"get_block_{elem_type}es")
|
|
37
|
-
else:
|
|
38
|
-
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
39
|
-
for element_id in func(block_id):
|
|
40
|
-
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
41
|
-
node_set.update(node_ids)
|
|
42
|
-
for node_id in node_set:
|
|
43
|
-
coord = cubit.get_nodal_coordinates(node_id)
|
|
44
|
-
fid.write(f'{coord[0]} {coord[1]} {coord[2]} {0}\n')
|
|
45
|
-
|
|
46
|
-
fid.write("\n")
|
|
47
|
-
tet_list = []
|
|
48
|
-
fid.write("Tetrahedra\n")
|
|
49
|
-
for block_id in cubit.get_block_id_list():
|
|
50
|
-
volume_list = cubit.get_block_volumes(block_id)
|
|
51
|
-
for volume_id in volume_list:
|
|
52
|
-
tet_list += cubit.get_volume_tets(volume_id)
|
|
53
|
-
fid.write(f'{len(tet_list)}\n')
|
|
54
|
-
|
|
55
|
-
for block_id in cubit.get_block_id_list():
|
|
56
|
-
volume_list = cubit.get_block_volumes(block_id)
|
|
57
|
-
for volume_id in volume_list:
|
|
58
|
-
tet_list = cubit.get_volume_tets(volume_id)
|
|
59
|
-
if len(tet_list)>0:
|
|
60
|
-
for tet_id in tet_list:
|
|
61
|
-
node_list = cubit.get_connectivity("tet", tet_id)
|
|
62
|
-
fid.write(f'{node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {block_id}\n')
|
|
63
|
-
|
|
64
|
-
tri_list = []
|
|
65
|
-
fid.write("Triangles\n")
|
|
66
|
-
for nodeset_id in nodeset_list:
|
|
67
|
-
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
68
|
-
for surface_id in surface_list:
|
|
69
|
-
tri_list += cubit.get_surface_tris(surface_id)
|
|
70
|
-
fid.write(f'{len(tri_list)}\n')
|
|
71
|
-
for nodeset_id in nodeset_list:
|
|
72
|
-
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
73
|
-
for surface_id in surface_list:
|
|
74
|
-
nodeset_surface_list.append(surface_id)
|
|
75
|
-
tri_list = cubit.get_surface_tris(surface_id)
|
|
76
|
-
if len(tri_list)>0:
|
|
77
|
-
for tri_id in tri_list:
|
|
78
|
-
node_list = cubit.get_connectivity("tri", tri_id)
|
|
79
|
-
fid.write(f'{node_list[0]} {node_list[1]} {node_list[2]} {nodeset_id}\n')
|
|
80
|
-
|
|
81
|
-
fid.write("\n")
|
|
82
|
-
fid.write("End\n")
|
|
83
|
-
fid.close()
|
|
84
|
-
return cubit
|
|
85
|
-
|
|
86
|
-
########################################################################
|
|
87
|
-
### Gmsh format version 2
|
|
88
|
-
########################################################################
|
|
89
|
-
|
|
90
|
-
def export_2D_gmsh_ver2(cubit, FileName):
|
|
91
|
-
|
|
92
|
-
with open(FileName, 'w') as fid:
|
|
93
|
-
|
|
94
|
-
fid.write("$MeshFormat\n")
|
|
95
|
-
fid.write("2.2 0 8\n")
|
|
96
|
-
fid.write("$EndMeshFormat\n")
|
|
97
|
-
|
|
98
|
-
fid.write("$PhysicalNames\n")
|
|
99
|
-
fid.write(f'{cubit.get_nodeset_count() + cubit.get_block_count()}\n')
|
|
100
|
-
|
|
101
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
102
|
-
name = cubit.get_exodus_entity_name("nodeset",nodeset_id)
|
|
103
|
-
fid.write(f'1 {nodeset_id} "{name}"\n')
|
|
104
|
-
|
|
105
|
-
for block_id in cubit.get_block_id_list():
|
|
106
|
-
name = cubit.get_exodus_entity_name("block",block_id)
|
|
107
|
-
fid.write(f'2 {block_id} "{name}"\n')
|
|
108
|
-
fid.write('$EndPhysicalNames\n')
|
|
109
|
-
|
|
110
|
-
fid.write("$Nodes\n")
|
|
111
|
-
|
|
112
|
-
node_set = set()
|
|
113
|
-
for block_id in cubit.get_block_id_list():
|
|
114
|
-
elem_types = ["tri", "quad"]
|
|
115
|
-
for elem_type in elem_types:
|
|
116
|
-
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
117
|
-
for element_id in func(block_id):
|
|
118
|
-
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
119
|
-
node_set.update(node_ids)
|
|
120
|
-
fid.write(f'{len(node_set)}\n')
|
|
121
|
-
for node_id in node_set:
|
|
122
|
-
coord = cubit.get_nodal_coordinates(node_id)
|
|
123
|
-
fid.write(f'{node_id} {coord[0]} {coord[1]} {coord[2]}\n')
|
|
124
|
-
fid.write('$EndNodes\n')
|
|
125
|
-
|
|
126
|
-
edge_list = []
|
|
127
|
-
quad_list = []
|
|
128
|
-
tri_list = []
|
|
129
|
-
|
|
130
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
131
|
-
curve_list = cubit.get_nodeset_curves(nodeset_id)
|
|
132
|
-
for curve_id in curve_list:
|
|
133
|
-
edge_list += cubit.get_curve_edges(curve_id)
|
|
134
|
-
|
|
135
|
-
for block_id in cubit.get_block_id_list():
|
|
136
|
-
surface_list = cubit.get_block_surfaces(block_id)
|
|
137
|
-
for surface_id in surface_list:
|
|
138
|
-
quad_list += cubit.get_surface_quads(surface_id)
|
|
139
|
-
tri_list += cubit.get_surface_tris(surface_id)
|
|
140
|
-
|
|
141
|
-
Elems = 0
|
|
142
|
-
fid.write('$Elements\n')
|
|
143
|
-
fid.write(f'{len(edge_list) + len(quad_list) + len(tri_list)}\n')
|
|
144
|
-
|
|
145
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
146
|
-
curve_list = cubit.get_nodeset_curves(nodeset_id)
|
|
147
|
-
for curve_id in curve_list:
|
|
148
|
-
edge_list = cubit.get_curve_edges(curve_id)
|
|
149
|
-
if len(edge_list)>0:
|
|
150
|
-
for edge_id in edge_list:
|
|
151
|
-
Elems += 1
|
|
152
|
-
node_list = cubit.get_connectivity('edge', edge_id)
|
|
153
|
-
fid.write(f'{Elems} {1} {2} {nodeset_id} {curve_id} {node_list[0]} {node_list[1]}\n')
|
|
154
|
-
|
|
155
|
-
for block_id in cubit.get_block_id_list():
|
|
156
|
-
surface_list = cubit.get_block_surfaces(block_id)
|
|
157
|
-
for surface_id in surface_list:
|
|
158
|
-
tri_list = cubit.get_surface_tris(surface_id)
|
|
159
|
-
if len(tri_list)>0:
|
|
160
|
-
for tri_id in tri_list:
|
|
161
|
-
Elems += 1
|
|
162
|
-
node_list = cubit.get_expanded_connectivity("tri", tri_id)
|
|
163
|
-
if len(node_list)==3:
|
|
164
|
-
fid.write(f'{Elems} {2} {2} {block_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]}\n')
|
|
165
|
-
if len(node_list)==6:
|
|
166
|
-
fid.write(f'{Elems} {9} {2} {block_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]}\n')
|
|
167
|
-
if len(node_list)==7:
|
|
168
|
-
fid.write(f'{Elems} {42} {2} {block_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[5]}\n')
|
|
169
|
-
|
|
170
|
-
quad_list = cubit.get_surface_quads(surface_id)
|
|
171
|
-
if len(quad_list)>0:
|
|
172
|
-
for quad_id in quad_list:
|
|
173
|
-
Elems += 1
|
|
174
|
-
node_list = cubit.get_expanded_connectivity("quad", quad_id)
|
|
175
|
-
if len(node_list)==4:
|
|
176
|
-
fid.write(f'{Elems} {3} {2} {block_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n')
|
|
177
|
-
if len(node_list)==8:
|
|
178
|
-
fid.write(f'{Elems} {16} {2} {block_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]}\n')
|
|
179
|
-
if len(node_list)==9:
|
|
180
|
-
fid.write(f'{Elems} {10} {2} {block_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]} {node_list[8]}\n')
|
|
181
|
-
|
|
182
|
-
fid.write('$EndElements\n')
|
|
183
|
-
|
|
184
|
-
fid.close()
|
|
185
|
-
return cubit
|
|
186
|
-
|
|
187
1
|
########################################################################
|
|
188
2
|
### Gmsh format version 2
|
|
189
3
|
########################################################################
|
|
190
4
|
|
|
191
|
-
def
|
|
5
|
+
def export_Gmsh_ver2(cubit, FileName):
|
|
192
6
|
|
|
193
7
|
with open(FileName, 'w') as fid:
|
|
194
8
|
|
|
@@ -197,462 +11,130 @@ def export_3D_gmsh_ver2(cubit, FileName):
|
|
|
197
11
|
fid.write("$EndMeshFormat\n")
|
|
198
12
|
|
|
199
13
|
fid.write("$PhysicalNames\n")
|
|
200
|
-
fid.write(f'{cubit.
|
|
201
|
-
|
|
202
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
203
|
-
name = cubit.get_exodus_entity_name("nodeset",nodeset_id)
|
|
204
|
-
fid.write(f'2 {nodeset_id} "{name}"\n')
|
|
205
|
-
|
|
14
|
+
fid.write(f'{cubit.get_block_count()}\n')
|
|
206
15
|
for block_id in cubit.get_block_id_list():
|
|
207
|
-
name = cubit.get_exodus_entity_name("block",block_id)
|
|
208
|
-
|
|
16
|
+
name = cubit.get_exodus_entity_name("block", block_id)
|
|
17
|
+
if len(cubit.get_block_edges(block_id)) > 0:
|
|
18
|
+
fid.write(f'1 {block_id} "{name}"\n')
|
|
19
|
+
elif len(cubit.get_block_tris(block_id)) + len(cubit.get_block_faces(block_id))> 0:
|
|
20
|
+
fid.write(f'2 {block_id} "{name}"\n')
|
|
21
|
+
else:
|
|
22
|
+
fid.write(f'3 {block_id} "{name}"\n')
|
|
209
23
|
fid.write('$EndPhysicalNames\n')
|
|
210
24
|
|
|
211
25
|
fid.write("$Nodes\n")
|
|
212
|
-
|
|
213
|
-
node_set = set()
|
|
26
|
+
node_list = set()
|
|
214
27
|
for block_id in cubit.get_block_id_list():
|
|
215
|
-
elem_types = ["hex", "tet", "wedge", "pyramid"]
|
|
28
|
+
elem_types = ["hex", "tet", "wedge", "pyramid", "tri", "face", "edge"]
|
|
216
29
|
for elem_type in elem_types:
|
|
217
30
|
if elem_type == "hex":
|
|
218
31
|
func = getattr(cubit, f"get_block_{elem_type}es")
|
|
219
32
|
else:
|
|
220
33
|
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
221
34
|
for element_id in func(block_id):
|
|
222
|
-
node_ids = cubit.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
35
|
+
node_ids = cubit.get_expanded_connectivity(elem_type, element_id)
|
|
36
|
+
node_list.update(node_ids)
|
|
37
|
+
|
|
38
|
+
fid.write(f'{len(node_list)}\n')
|
|
39
|
+
for node_id in node_list:
|
|
226
40
|
coord = cubit.get_nodal_coordinates(node_id)
|
|
227
41
|
fid.write(f'{node_id} {coord[0]} {coord[1]} {coord[2]}\n')
|
|
228
42
|
fid.write('$EndNodes\n')
|
|
229
43
|
|
|
230
|
-
hex_list =
|
|
231
|
-
tet_list =
|
|
232
|
-
wedge_list =
|
|
233
|
-
pyramid_list =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
for block_id in cubit.get_block_id_list():
|
|
238
|
-
volume_list = cubit.get_block_volumes(block_id)
|
|
239
|
-
for volume_id in volume_list:
|
|
240
|
-
hex_list += cubit.get_volume_hexes(volume_id)
|
|
241
|
-
tet_list += cubit.get_volume_tets(volume_id)
|
|
242
|
-
wedge_list += cubit.get_volume_wedges(volume_id)
|
|
243
|
-
pyramid_list += cubit.get_volume_pyramids(volume_id)
|
|
244
|
-
|
|
245
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
246
|
-
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
247
|
-
for surface_id in surface_list:
|
|
248
|
-
quad_list += cubit.get_surface_quads(surface_id)
|
|
249
|
-
tri_list += cubit.get_surface_tris(surface_id)
|
|
250
|
-
|
|
251
|
-
Elems = 0
|
|
252
|
-
fid.write('$Elements\n')
|
|
253
|
-
fid.write(f'{len(hex_list) + len(tet_list) + len(wedge_list) + len(pyramid_list) + len(quad_list) + len(tri_list)}\n')
|
|
254
|
-
|
|
255
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
256
|
-
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
257
|
-
for surface_id in surface_list:
|
|
258
|
-
tri_list = cubit.get_surface_tris(surface_id)
|
|
259
|
-
if len(tri_list)>0:
|
|
260
|
-
for tri_id in tri_list:
|
|
261
|
-
Elems += 1
|
|
262
|
-
node_list = cubit.get_expanded_connectivity("tri", tri_id)
|
|
263
|
-
if len(node_list)==3:
|
|
264
|
-
fid.write(f'{Elems} {2} {2} {nodeset_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]}\n')
|
|
265
|
-
if len(node_list)==6:
|
|
266
|
-
fid.write(f'{Elems} {9} {2} {nodeset_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]}\n')
|
|
267
|
-
if len(node_list)==7:
|
|
268
|
-
fid.write(f'{Elems} {42} {2} {nodeset_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[5]}\n')
|
|
269
|
-
|
|
270
|
-
quad_list = cubit.get_surface_quads(surface_id)
|
|
271
|
-
if len(quad_list)>0:
|
|
272
|
-
for quad_id in quad_list:
|
|
273
|
-
Elems += 1
|
|
274
|
-
node_list = cubit.get_expanded_connectivity("quad", quad_id)
|
|
275
|
-
if len(node_list)==4:
|
|
276
|
-
fid.write(f'{Elems} {3} {2} {nodeset_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n')
|
|
277
|
-
if len(node_list)==8:
|
|
278
|
-
fid.write(f'{Elems} {16} {2} {nodeset_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]}\n')
|
|
279
|
-
if len(node_list)==9:
|
|
280
|
-
fid.write(f'{Elems} {10} {2} {nodeset_id} {surface_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]} {node_list[8]}\n')
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
for block_id in cubit.get_block_id_list():
|
|
284
|
-
volume_list = cubit.get_block_volumes(block_id)
|
|
285
|
-
for volume_id in volume_list:
|
|
286
|
-
|
|
287
|
-
tet_list = cubit.get_volume_tets(volume_id)
|
|
288
|
-
if len(tet_list)>0:
|
|
289
|
-
for tet_id in tet_list:
|
|
290
|
-
Elems += 1
|
|
291
|
-
node_list = cubit.get_expanded_connectivity("tet", tet_id)
|
|
292
|
-
if len(node_list)==4:
|
|
293
|
-
fid.write(f'{Elems} {4} {2} {block_id} {volume_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n')
|
|
294
|
-
if len(node_list)==10:
|
|
295
|
-
fid.write(f'{Elems} {11} {2} {block_id} {volume_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]} {node_list[9]} {node_list[8]}\n')
|
|
296
|
-
if len(node_list)==11:
|
|
297
|
-
fid.write(f'{Elems} {35} {2} {block_id} {volume_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]} {node_list[8]} {node_list[9]} {node_list[10]}\n')
|
|
298
|
-
|
|
299
|
-
hex_list = cubit.get_volume_hexes(volume_id)
|
|
300
|
-
if len(hex_list)>0:
|
|
301
|
-
for hex_id in hex_list:
|
|
302
|
-
Elems += 1
|
|
303
|
-
node_list = cubit.get_expanded_connectivity("hex", hex_id)
|
|
304
|
-
if len(node_list)==8:
|
|
305
|
-
fid.write(f'{Elems} {5} {2} {block_id} {volume_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]}\n')
|
|
306
|
-
if len(node_list)==20:
|
|
307
|
-
fid.write(f'{Elems} {17} {2} {block_id} {volume_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]} {node_list[8]} {node_list[9]} {node_list[10]} {node_list[11]} {node_list[12]} {node_list[13]} {node_list[14]} {node_list[15]} {node_list[16]} {node_list[17]} {node_list[18]} {node_list[19]}\n')
|
|
308
|
-
|
|
309
|
-
wedge_list = cubit.get_volume_wedges(volume_id)
|
|
310
|
-
if len(wedge_list)>0:
|
|
311
|
-
for wedge_id in wedge_list:
|
|
312
|
-
Elems += 1
|
|
313
|
-
node_list = cubit.get_connectivity("wedge", wedge_id)
|
|
314
|
-
if len(node_list)==6:
|
|
315
|
-
fid.write(f'{Elems} {6} {2} {block_id} {volume_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]}\n')
|
|
316
|
-
if len(node_list)==15:
|
|
317
|
-
fid.write(f'{Elems} {18} {2} {block_id} {volume_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]} {node_list[8]} {node_list[9]} {node_list[10]} {node_list[11]} {node_list[12]} {node_list[13]} {node_list[14]}\n')
|
|
318
|
-
|
|
319
|
-
pyramid_list = cubit.get_volume_pyramids(volume_id)
|
|
320
|
-
if len(pyramid_list)>0:
|
|
321
|
-
for pyramid_id in pyramid_list:
|
|
322
|
-
Elems += 1
|
|
323
|
-
node_list = cubit.get_connectivity("pyramid", pyramid_id)
|
|
324
|
-
if len(node_list)==6:
|
|
325
|
-
fid.write(f'{Elems} {7} {2} {block_id} {volume_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]}\n')
|
|
326
|
-
if len(node_list)==13:
|
|
327
|
-
fid.write(f'{Elems} {19} {2} {block_id} {volume_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]} {node_list[8]} {node_list[9]} {node_list[10]} {node_list[11]} {node_list[12]} {node_list[13]} {node_list[14]}\n')
|
|
328
|
-
|
|
329
|
-
fid.write('$EndElements\n')
|
|
330
|
-
|
|
331
|
-
fid.close()
|
|
332
|
-
return cubit
|
|
333
|
-
|
|
334
|
-
########################################################################
|
|
335
|
-
### Gmsh format version 4
|
|
336
|
-
########################################################################
|
|
337
|
-
|
|
338
|
-
def export_3D_gmsh_ver4(cubit, FileName):
|
|
339
|
-
|
|
340
|
-
nodeset_surface_count = 0
|
|
341
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
342
|
-
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
343
|
-
for surface_id in surface_list:
|
|
344
|
-
nodeset_surface_count += 1
|
|
345
|
-
|
|
346
|
-
block_volume_count = 0
|
|
347
|
-
for block_id in cubit.get_block_id_list():
|
|
348
|
-
volume_list = cubit.get_block_volumes(block_id)
|
|
349
|
-
for volume_id in volume_list:
|
|
350
|
-
block_volume_count += 1
|
|
351
|
-
|
|
352
|
-
with open(FileName, 'w') as fid:
|
|
353
|
-
|
|
354
|
-
fid.write('$MeshFormat\n')
|
|
355
|
-
fid.write('4.1 0 8\n')
|
|
356
|
-
fid.write('$EndMeshFormat\n')
|
|
357
|
-
|
|
358
|
-
fid.write('$PhysicalNames\n')
|
|
359
|
-
fid.write(f'{cubit.get_nodeset_count() + cubit.get_block_count()}\n')
|
|
44
|
+
hex_list = set()
|
|
45
|
+
tet_list = set()
|
|
46
|
+
wedge_list = set()
|
|
47
|
+
pyramid_list = set()
|
|
48
|
+
tri_list = set()
|
|
49
|
+
quad_list = set()
|
|
50
|
+
edge_list = set()
|
|
360
51
|
|
|
361
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
362
|
-
name = cubit.get_exodus_entity_name("nodeset",nodeset_id)
|
|
363
|
-
fid.write(f'2 {nodeset_id} "{name}"\n')
|
|
364
52
|
for block_id in cubit.get_block_id_list():
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
# for surface_id in surface_list:
|
|
375
|
-
# vertex_list = cubit.get_relatives("surface", surface_id, "vertex")
|
|
376
|
-
# for vertex_id in vertex_list:
|
|
377
|
-
# x = cubit.vertex(vertex_id).coordinates()[0]
|
|
378
|
-
# y = cubit.vertex(vertex_id).coordinates()[1]
|
|
379
|
-
# z = cubit.vertex(vertex_id).coordinates()[2]
|
|
380
|
-
# fid.write(f'{vertex_id} {x} {y} {z} {1} {nodeset_id}\n')
|
|
381
|
-
|
|
382
|
-
# for nodeset_id in cubit.get_nodeset_id_list():
|
|
383
|
-
# surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
384
|
-
# for surface_id in surface_list:
|
|
385
|
-
# curve_list = cubit.get_relatives("surface", surface_id, "curve")
|
|
386
|
-
# for curve_id in curve_list:
|
|
387
|
-
# bounding_box = cubit.get_bounding_box("curve", curve_id)
|
|
388
|
-
# minx = bounding_box[0]
|
|
389
|
-
# maxx = bounding_box[1]
|
|
390
|
-
# miny = bounding_box[3]
|
|
391
|
-
# maxy = bounding_box[4]
|
|
392
|
-
# minz = bounding_box[6]
|
|
393
|
-
# maxz = bounding_box[7]
|
|
394
|
-
# vertex_list = cubit.get_relatives("curve", curve_id, "vertex")
|
|
395
|
-
# fid.write(f'{curve_id} {minx} {miny} {minz} {maxx} {maxy} {maxz} {1} {nodeset_id} {len(vertex_list)}')
|
|
396
|
-
# for vertex_id in vertex_list:
|
|
397
|
-
# fid.write(f' {vertex_id}')
|
|
398
|
-
# fid.write(f'\n')
|
|
399
|
-
|
|
400
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
401
|
-
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
402
|
-
for surface_id in surface_list:
|
|
403
|
-
bounding_box = cubit.get_bounding_box("surface", surface_id)
|
|
404
|
-
minx = bounding_box[0]
|
|
405
|
-
maxx = bounding_box[1]
|
|
406
|
-
miny = bounding_box[3]
|
|
407
|
-
maxy = bounding_box[4]
|
|
408
|
-
minz = bounding_box[6]
|
|
409
|
-
maxz = bounding_box[7]
|
|
410
|
-
fid.write(f'{surface_id} {minx} {miny} {minz} {maxx} {maxy} {maxz} {1} {nodeset_id} {0}\n')
|
|
411
|
-
|
|
412
|
-
for block_id in cubit.get_block_id_list():
|
|
413
|
-
for volume_id in cubit.get_block_volumes(block_id):
|
|
414
|
-
bounding_box = cubit.get_bounding_box("volume", volume_id)
|
|
415
|
-
minx = bounding_box[0]
|
|
416
|
-
maxx = bounding_box[1]
|
|
417
|
-
miny = bounding_box[3]
|
|
418
|
-
maxy = bounding_box[4]
|
|
419
|
-
minz = bounding_box[6]
|
|
420
|
-
maxz = bounding_box[7]
|
|
421
|
-
fid.write(f'{volume_id} {minx} {miny} {minz} {maxx} {maxy} {maxz} {1} {block_id} {nodeset_surface_count}')
|
|
422
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
423
|
-
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
424
|
-
for surface_id in surface_list:
|
|
425
|
-
fid.write(f' {surface_id}')
|
|
426
|
-
fid.write(f'\n')
|
|
427
|
-
|
|
428
|
-
fid.write('$EndEntities\n')
|
|
429
|
-
|
|
430
|
-
counts = 0
|
|
431
|
-
node_all_set = set()
|
|
432
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
433
|
-
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
434
|
-
for surface_id in surface_list:
|
|
435
|
-
node_list = cubit.get_surface_nodes(surface_id)
|
|
436
|
-
if len(node_list) > 0:
|
|
437
|
-
node_all_set.update(node_list)
|
|
438
|
-
counts += 1
|
|
439
|
-
|
|
440
|
-
for block_id in cubit.get_block_id_list():
|
|
441
|
-
for volume_id in cubit.get_block_volumes(block_id):
|
|
442
|
-
node_list = cubit.parse_cubit_list( "node", f"in volume {volume_id}" )
|
|
443
|
-
if len(node_list) > 0:
|
|
444
|
-
node_all_set.update(node_list)
|
|
445
|
-
counts += 1
|
|
446
|
-
|
|
447
|
-
fid.write('$Nodes\n')
|
|
448
|
-
fid.write(f'{counts} {len(node_all_set)} {min(node_all_set)} {max(node_all_set)}\n')
|
|
449
|
-
|
|
450
|
-
node_all_set.clear()
|
|
451
|
-
|
|
452
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
453
|
-
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
454
|
-
for surface_id in surface_list:
|
|
455
|
-
node_list = cubit.get_surface_nodes(surface_id)
|
|
456
|
-
node_list = set(node_list) - node_all_set
|
|
457
|
-
if len(node_list) > 0:
|
|
458
|
-
node_all_set.update(node_list)
|
|
459
|
-
fid.write(f'2 {surface_id} 0 {len(node_list)}\n')
|
|
460
|
-
for node_id in node_list:
|
|
461
|
-
fid.write(f'{node_id}\n')
|
|
462
|
-
for node_id in node_list:
|
|
463
|
-
coord = cubit.get_nodal_coordinates(node_id)
|
|
464
|
-
fid.write(f'{coord[0]} {coord[1]} {coord[2]}\n')
|
|
465
|
-
|
|
466
|
-
for block_id in cubit.get_block_id_list():
|
|
467
|
-
for volume_id in cubit.get_block_volumes(block_id):
|
|
468
|
-
node_list = cubit.parse_cubit_list( "node", f"in volume {volume_id}" )
|
|
469
|
-
node_list = set(node_list) - node_all_set
|
|
470
|
-
if len(node_list) > 0:
|
|
471
|
-
node_all_set.update(node_list)
|
|
472
|
-
fid.write(f'3 {volume_id} 0 {len(node_list)}\n')
|
|
473
|
-
for node_id in node_list:
|
|
474
|
-
fid.write(f'{node_id}\n')
|
|
475
|
-
for node_id in node_list:
|
|
476
|
-
coord = cubit.get_nodal_coordinates(node_id)
|
|
477
|
-
fid.write(f'{coord[0]} {coord[1]} {coord[2]}\n')
|
|
478
|
-
|
|
479
|
-
fid.write('$EndNodes\n')
|
|
480
|
-
|
|
481
|
-
tri_all_list = []
|
|
482
|
-
quad_all_list = []
|
|
483
|
-
tet_all_list = []
|
|
484
|
-
hex_all_list = []
|
|
485
|
-
wedge_all_list = []
|
|
486
|
-
|
|
53
|
+
tet_list.update(cubit.get_block_tets(block_id))
|
|
54
|
+
hex_list.update(cubit.get_block_hexes(block_id))
|
|
55
|
+
wedge_list.update(cubit.get_block_wedges(block_id))
|
|
56
|
+
pyramid_list.update(cubit.get_block_pyramids(block_id))
|
|
57
|
+
tri_list.update(cubit.get_block_tris(block_id))
|
|
58
|
+
quad_list.update(cubit.get_block_faces(block_id))
|
|
59
|
+
edge_list.update(cubit.get_block_edges(block_id))
|
|
60
|
+
|
|
61
|
+
element_id = 0
|
|
487
62
|
fid.write('$Elements\n')
|
|
488
|
-
|
|
489
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
490
|
-
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
491
|
-
for surface_id in surface_list:
|
|
492
|
-
tri_all_list += cubit.get_surface_tris(surface_id)
|
|
493
|
-
quad_all_list += cubit.get_surface_quads(surface_id)
|
|
63
|
+
fid.write(f'{len(hex_list) + len(tet_list) + len(wedge_list) + len(pyramid_list) + len(tri_list) + len(quad_list) + len(edge_list)}\n')
|
|
494
64
|
|
|
495
65
|
for block_id in cubit.get_block_id_list():
|
|
496
|
-
for volume_id in cubit.get_block_volumes(block_id):
|
|
497
|
-
tet_all_list += cubit.get_volume_tets(volume_id)
|
|
498
|
-
hex_all_list += cubit.get_volume_hexes(volume_id)
|
|
499
|
-
wedge_all_list += cubit.get_volume_wedges(volume_id)
|
|
500
66
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
quad_list = cubit.get_surface_quads(surface_id)
|
|
521
|
-
if len(quad_list)>0:
|
|
522
|
-
fid.write(f'2 {surface_id} 3 {len(quad_list)}\n')
|
|
523
|
-
for quad_id in quad_list:
|
|
524
|
-
node_list = cubit.get_connectivity("quad", quad_id)
|
|
525
|
-
elementTag +=1
|
|
526
|
-
fid.write(f'{elementTag} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n')
|
|
527
|
-
|
|
528
|
-
for block_id in cubit.get_block_id_list():
|
|
529
|
-
for volume_id in cubit.get_block_volumes(block_id):
|
|
530
|
-
tet_list = cubit.get_volume_tets(volume_id)
|
|
531
|
-
if len(tet_list)>0:
|
|
532
|
-
fid.write(f'3 {volume_id} 4 {len(tet_list)}\n')
|
|
533
|
-
for tet_id in tet_list:
|
|
534
|
-
node_list = cubit.get_connectivity("tet", tet_id)
|
|
535
|
-
elementTag +=1
|
|
536
|
-
fid.write(f'{elementTag} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n')
|
|
537
|
-
|
|
538
|
-
hex_list = cubit.get_volume_hexes(volume_id)
|
|
539
|
-
if len(hex_list)>0:
|
|
540
|
-
fid.write(f'3 {volume_id} 5 {len(hex_list)}\n')
|
|
541
|
-
for hex_id in hex_list:
|
|
542
|
-
node_list = cubit.get_connectivity("hex", hex_id)
|
|
543
|
-
elementTag +=1
|
|
544
|
-
fid.write(f'{elementTag} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]}\n')
|
|
545
|
-
|
|
546
|
-
wedge_list = cubit.get_volume_wedges(volume_id)
|
|
547
|
-
if len(wedge_list)>0:
|
|
548
|
-
fid.write(f'3 {volume_id} 6 {len(wedge_list)}\n')
|
|
549
|
-
for wedge_id in wedge_list:
|
|
550
|
-
node_list = cubit.get_connectivity("wedge", wedge_id)
|
|
551
|
-
elementTag +=1
|
|
552
|
-
fid.write(f'{elementTag} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]}\n')
|
|
553
|
-
|
|
554
|
-
fid.write('$EndElements\n')
|
|
555
|
-
fid.close()
|
|
556
|
-
return cubit
|
|
557
|
-
|
|
558
|
-
########################################################################
|
|
559
|
-
### NASTRAN 1D file
|
|
560
|
-
########################################################################
|
|
561
|
-
|
|
562
|
-
def export_1D_Nastran(cubit, FileName):
|
|
563
|
-
import datetime
|
|
564
|
-
formatted_date_time = datetime.datetime.now().strftime("%d-%b-%y at %H:%M:%S")
|
|
67
|
+
tet_list = cubit.get_block_tets(block_id)
|
|
68
|
+
for tet_id in tet_list:
|
|
69
|
+
element_id += 1
|
|
70
|
+
node_list = cubit.get_expanded_connectivity("tet", tet_id)
|
|
71
|
+
if len(node_list)==4:
|
|
72
|
+
fid.write(f'{element_id} { 4} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n')
|
|
73
|
+
if len(node_list)==10:
|
|
74
|
+
fid.write(f'{element_id} {11} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]} {node_list[9]} {node_list[8]}\n')
|
|
75
|
+
if len(node_list)==11:
|
|
76
|
+
fid.write(f'{element_id} {35} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]} {node_list[9]} {node_list[8]} {node_list[10]}\n')
|
|
77
|
+
|
|
78
|
+
hex_list = cubit.get_block_hexes(block_id)
|
|
79
|
+
for hex_id in hex_list:
|
|
80
|
+
element_id += 1
|
|
81
|
+
node_list = cubit.get_expanded_connectivity("hex", hex_id)
|
|
82
|
+
if len(node_list)==8:
|
|
83
|
+
fid.write(f'{element_id} { 5} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]}\n')
|
|
84
|
+
if len(node_list)==20:
|
|
85
|
+
fid.write(f'{element_id} {17} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]} {node_list[8]} {node_list[11]} {node_list[12]} {node_list[9]} {node_list[13]} {node_list[10]} {node_list[14]} {node_list[15]} {node_list[16]} {node_list[19]} {node_list[17]} {node_list[18]}\n')
|
|
565
86
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
fid.write("$\n")
|
|
575
|
-
fid.write("$ PLEASE CHECK YOUR MODEL FOR UNITS CONSISTENCY.\n")
|
|
576
|
-
fid.write("$\n")
|
|
577
|
-
fid.write("$ It should be noted that load ID's from CUBIT may NOT correspond to Nastran SID's\n")
|
|
578
|
-
fid.write("$ The SID's for the load and restraint sets start at one and increment by one:i.e.,1,2,3,4...\n")
|
|
579
|
-
fid.write("$\n")
|
|
580
|
-
fid.write("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n")
|
|
581
|
-
fid.write("$\n")
|
|
582
|
-
fid.write("$\n")
|
|
583
|
-
fid.write("$ -------------------------\n")
|
|
584
|
-
fid.write("$ Executive Control Section\n")
|
|
585
|
-
fid.write("$ -------------------------\n")
|
|
586
|
-
fid.write("$\n")
|
|
587
|
-
fid.write("SOL 101\n")
|
|
588
|
-
fid.write("CEND\n")
|
|
589
|
-
fid.write("$\n")
|
|
590
|
-
fid.write("$\n")
|
|
591
|
-
fid.write("$ --------------------\n")
|
|
592
|
-
fid.write("$ Case Control Section\n")
|
|
593
|
-
fid.write("$ --------------------\n")
|
|
594
|
-
fid.write("$\n")
|
|
595
|
-
fid.write("ECHO = SORT\n")
|
|
596
|
-
fid.write("$\n")
|
|
597
|
-
fid.write("$\n")
|
|
598
|
-
fid.write("$ Name: Initial\n")
|
|
599
|
-
fid.write("$\n")
|
|
600
|
-
fid.write("$\n")
|
|
601
|
-
fid.write("$ Name: Default Set\n")
|
|
602
|
-
fid.write("$\n")
|
|
603
|
-
fid.write("SUBCASE = 1\n")
|
|
604
|
-
fid.write("$\n")
|
|
605
|
-
fid.write("LABEL = Default Set\n")
|
|
606
|
-
fid.write("$\n")
|
|
607
|
-
fid.write("$ -----------------\n")
|
|
608
|
-
fid.write("$ Bulk Data Section\n")
|
|
609
|
-
fid.write("$ -----------------\n")
|
|
610
|
-
fid.write("$\n")
|
|
611
|
-
fid.write("BEGIN BULK\n")
|
|
612
|
-
fid.write("$\n")
|
|
613
|
-
fid.write("$ Params\n")
|
|
614
|
-
fid.write("$\n")
|
|
615
|
-
fid.write("$\n")
|
|
616
|
-
fid.write("$ Node cards\n")
|
|
617
|
-
fid.write("$\n")
|
|
87
|
+
wedge_list = cubit.get_block_wedges(block_id)
|
|
88
|
+
for wedge_id in wedge_list:
|
|
89
|
+
element_id += 1
|
|
90
|
+
node_list = cubit.get_expanded_connectivity("wedge", wedge_id)
|
|
91
|
+
if len(node_list)==6:
|
|
92
|
+
fid.write(f'{element_id} { 6} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]}\n')
|
|
93
|
+
if len(node_list)==15:
|
|
94
|
+
fid.write(f'{element_id} {18} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[8]} {node_list[9]} {node_list[7]} {node_list[10]} {node_list[11]} {node_list[12]} {node_list[14]} {node_list[13]}\n')
|
|
618
95
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
for node_id in node_set:
|
|
628
|
-
coord = cubit.get_nodal_coordinates(node_id)
|
|
629
|
-
fid.write(f"GRID* {node_id:>16}{0:>16}{coord[0]:>16.5f}{coord[1]:>16.5f}\n* {coord[2]:>16.5f}\n")
|
|
96
|
+
pyramid_list = cubit.get_block_pyramids(block_id)
|
|
97
|
+
for pyramid_id in pyramid_list:
|
|
98
|
+
element_id += 1
|
|
99
|
+
node_list = cubit.get_expanded_connectivity("pyramid", pyramid_id)
|
|
100
|
+
if len(node_list)==6:
|
|
101
|
+
fid.write(f'{element_id} { 7} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]}\n')
|
|
102
|
+
if len(node_list)==13:
|
|
103
|
+
fid.write(f'{element_id} {19} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[8]} {node_list[9]} {node_list[6]} {node_list[10]} {node_list[7]} {node_list[11]} {node_list[12]} \n')
|
|
630
104
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
105
|
+
tri_list = cubit.get_block_tris(block_id)
|
|
106
|
+
for tri_id in tri_list:
|
|
107
|
+
element_id += 1
|
|
108
|
+
node_list = cubit.get_expanded_connectivity("tri", tri_id)
|
|
109
|
+
if len(node_list)==3:
|
|
110
|
+
fid.write(f'{element_id} { 2} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]}\n')
|
|
111
|
+
if len(node_list)==6:
|
|
112
|
+
fid.write(f'{element_id} { 9} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]}\n')
|
|
113
|
+
if len(node_list)==7:
|
|
114
|
+
fid.write(f'{element_id} {42} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]}\n')
|
|
115
|
+
|
|
116
|
+
quad_list = cubit.get_block_faces(block_id)
|
|
117
|
+
for quad_id in quad_list:
|
|
118
|
+
element_id += 1
|
|
119
|
+
node_list = cubit.get_expanded_connectivity("quad", quad_id)
|
|
120
|
+
if len(node_list)==4:
|
|
121
|
+
fid.write(f'{element_id} { 3} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n')
|
|
122
|
+
if len(node_list)==8:
|
|
123
|
+
fid.write(f'{element_id} {16} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]}\n')
|
|
124
|
+
if len(node_list)==9:
|
|
125
|
+
fid.write(f'{element_id} {10} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]} {node_list[8]}\n')
|
|
126
|
+
|
|
127
|
+
edge_list = cubit.get_block_edges(block_id)
|
|
640
128
|
for edge_id in edge_list:
|
|
641
|
-
node_list = cubit.get_connectivity('edge', edge_id)
|
|
642
129
|
element_id += 1
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
130
|
+
node_list = cubit.get_expanded_connectivity("edge", edge_id)
|
|
131
|
+
if len(node_list)==2:
|
|
132
|
+
fid.write(f'{element_id} {1} {2} {block_id} {block_id} {node_list[0]} {node_list[1]}\n')
|
|
133
|
+
if len(node_list)==3:
|
|
134
|
+
fid.write(f'{element_id} {8} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]}\n')
|
|
647
135
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
fid.write("$\n")
|
|
651
|
-
fid.write(f"$ Name: {name}\n")
|
|
652
|
-
fid.write("$\n")
|
|
653
|
-
fid.write(f"MAT1 {block_id:< 8}{1:<8}{1:<8}{1:<8}\n")
|
|
654
|
-
fid.write("ENDDATA\n")
|
|
655
|
-
fid.close()
|
|
136
|
+
fid.write('$EndElements\n')
|
|
137
|
+
fid.close()
|
|
656
138
|
return cubit
|
|
657
139
|
|
|
658
140
|
########################################################################
|
|
@@ -716,15 +198,15 @@ def export_2D_Nastran(cubit, FileName):
|
|
|
716
198
|
fid.write("$ Node cards\n")
|
|
717
199
|
fid.write("$\n")
|
|
718
200
|
|
|
719
|
-
|
|
201
|
+
node_list = set()
|
|
720
202
|
for block_id in cubit.get_block_id_list():
|
|
721
|
-
elem_types = ["tri", "
|
|
203
|
+
elem_types = ["tri", "face", "edge"]
|
|
722
204
|
for elem_type in elem_types:
|
|
723
205
|
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
724
206
|
for element_id in func(block_id):
|
|
725
207
|
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
726
|
-
|
|
727
|
-
for node_id in
|
|
208
|
+
node_list.update(node_ids)
|
|
209
|
+
for node_id in node_list:
|
|
728
210
|
coord = cubit.get_nodal_coordinates(node_id)
|
|
729
211
|
fid.write(f"GRID* {node_id:>16}{0:>16}{coord[0]:>16.5f}{coord[1]:>16.5f}\n* {coord[2]:>16.5f}\n")
|
|
730
212
|
|
|
@@ -737,25 +219,35 @@ def export_2D_Nastran(cubit, FileName):
|
|
|
737
219
|
fid.write("$\n")
|
|
738
220
|
fid.write(f"$ Name: {name}\n")
|
|
739
221
|
fid.write("$\n")
|
|
740
|
-
|
|
741
|
-
|
|
222
|
+
|
|
223
|
+
tri_list = cubit.get_block_tris(block_id)
|
|
224
|
+
for tri_id in tri_list:
|
|
225
|
+
element_id += 1
|
|
226
|
+
surface_id = int(cubit.get_geometry_owner("tri", tri_id).split()[1])
|
|
742
227
|
normal = cubit.get_surface_normal(surface_id)
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
228
|
+
node_list = cubit.get_connectivity('tri',tri_id)
|
|
229
|
+
if normal[2] > 0:
|
|
230
|
+
fid.write(f"CTRIA3 {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[1]:<8}{node_list[2]:<8}\n")
|
|
231
|
+
else:
|
|
232
|
+
fid.write(f"CTRIA3 {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[2]:<8}{node_list[1]:<8}\n")
|
|
233
|
+
|
|
234
|
+
quad_list = cubit.get_block_faces(block_id)
|
|
235
|
+
for quad_id in quad_list:
|
|
236
|
+
element_id += 1
|
|
237
|
+
surface_id = int(cubit.get_geometry_owner("quad", quad_id).split()[1])
|
|
238
|
+
normal = cubit.get_surface_normal(surface_id)
|
|
239
|
+
node_list = cubit.get_connectivity('quad',quad_id)
|
|
240
|
+
if normal[2] > 0:
|
|
241
|
+
fid.write(f"CQUAD4 {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[1]:<8}{node_list[2]:<8}{node_list[3]:<8}\n")
|
|
242
|
+
else:
|
|
243
|
+
fid.write(f"CQUAD4 {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[3]:<8}{node_list[2]:<8}{node_list[1]:<1}\n")
|
|
244
|
+
|
|
245
|
+
edge_list = cubit.get_block_edges(block_id)
|
|
246
|
+
for edge_id in edge_list:
|
|
247
|
+
element_id += 1
|
|
248
|
+
node_list = cubit.get_connectivity('edge', edge_id)
|
|
249
|
+
if len(node_list)==2:
|
|
250
|
+
fid.write(f"CROD {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[1]:<8}\n")
|
|
759
251
|
fid.write("$\n")
|
|
760
252
|
fid.write("$ Property cards\n")
|
|
761
253
|
fid.write("$\n")
|
|
@@ -774,7 +266,7 @@ def export_2D_Nastran(cubit, FileName):
|
|
|
774
266
|
### 3D Nastran file
|
|
775
267
|
########################################################################
|
|
776
268
|
|
|
777
|
-
def export_3D_Nastran(cubit, FileName,
|
|
269
|
+
def export_3D_Nastran(cubit, FileName, PYRAM=True):
|
|
778
270
|
|
|
779
271
|
import datetime
|
|
780
272
|
formatted_date_time = datetime.datetime.now().strftime("%d-%b-%y at %H:%M:%S")
|
|
@@ -831,9 +323,9 @@ def export_3D_Nastran(cubit, FileName, Pyram=True):
|
|
|
831
323
|
fid.write("$ Node cards\n")
|
|
832
324
|
fid.write("$\n")
|
|
833
325
|
|
|
834
|
-
|
|
326
|
+
node_list = set()
|
|
835
327
|
for block_id in cubit.get_block_id_list():
|
|
836
|
-
elem_types = ["hex", "tet", "wedge", "pyramid"]
|
|
328
|
+
elem_types = ["hex", "tet", "wedge", "pyramid", "tri", "face", "edge"]
|
|
837
329
|
for elem_type in elem_types:
|
|
838
330
|
if elem_type == "hex":
|
|
839
331
|
func = getattr(cubit, f"get_block_{elem_type}es")
|
|
@@ -841,9 +333,9 @@ def export_3D_Nastran(cubit, FileName, Pyram=True):
|
|
|
841
333
|
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
842
334
|
for element_id in func(block_id):
|
|
843
335
|
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
844
|
-
|
|
845
|
-
fid.write(f'{len(
|
|
846
|
-
for node_id in
|
|
336
|
+
node_list.update(node_ids)
|
|
337
|
+
fid.write(f'{len(node_list)}\n')
|
|
338
|
+
for node_id in node_list:
|
|
847
339
|
coord = cubit.get_nodal_coordinates(node_id)
|
|
848
340
|
fid.write(f"GRID* {node_id:>16}{0:>16}{coord[0]:>16.5f}{coord[1]:>16.5f}\n* {coord[2]:>16.5f}\n")
|
|
849
341
|
|
|
@@ -856,42 +348,51 @@ def export_3D_Nastran(cubit, FileName, Pyram=True):
|
|
|
856
348
|
fid.write("$\n")
|
|
857
349
|
fid.write(f"$ Name: {name}\n")
|
|
858
350
|
fid.write("$\n")
|
|
859
|
-
|
|
860
|
-
for
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
351
|
+
tet_list = cubit.get_block_tets(block_id)
|
|
352
|
+
for tet_id in tet_list:
|
|
353
|
+
node_list = cubit.get_connectivity('tet',tet_id)
|
|
354
|
+
element_id += 1
|
|
355
|
+
fid.write(f"CTETRA {element_id:>8}{block_id:>8}{node_list[0]:>8}{node_list[1]:>8}{node_list[2]:>8}{node_list[3]:>8}\n")
|
|
356
|
+
hex_list = cubit.get_block_hexes(block_id)
|
|
357
|
+
for hex_id in hex_list:
|
|
358
|
+
node_list = cubit.get_connectivity('hex',hex_id)
|
|
359
|
+
element_id += 1
|
|
360
|
+
fid.write(f"CHEXA {element_id:>8}{block_id:>8}{node_list[0]:>8}{node_list[1]:>8}{node_list[2]:>8}{node_list[3]:>8}{node_list[4]:>8}{node_list[5]:>8}+\n+ {node_list[6]:>8}{node_list[7]:>8}\n")
|
|
361
|
+
wedge_list = cubit.get_block_wedges(block_id)
|
|
362
|
+
for wedge_id in wedge_list:
|
|
363
|
+
node_list = cubit.get_connectivity('wedge',wedge_id)
|
|
364
|
+
element_id += 1
|
|
365
|
+
fid.write(f"CPENTA {element_id:>8}{block_id:>8}{node_list[0]:>8}{node_list[1]:>8}{node_list[2]:>8}{node_list[3]:>8}{node_list[4]:>8}{node_list[5]:>8}\n")
|
|
366
|
+
pyramid_list = cubit.get_block_pyramids(block_id)
|
|
367
|
+
for pyramid_id in pyramid_list:
|
|
368
|
+
node_list = cubit.get_connectivity('pyramid',pyramid_id)
|
|
369
|
+
if PYRAM:
|
|
864
370
|
element_id += 1
|
|
865
|
-
fid.write(f"
|
|
866
|
-
|
|
867
|
-
for hex_id in hex_list:
|
|
868
|
-
node_list = cubit.get_connectivity('hex',hex_id)
|
|
371
|
+
fid.write(f"CPYRAM {element_id:>8}{block_id:>8}{node_list[0]:>8}{node_list[1]:>8}{node_list[2]:>8}{node_list[3]:>8}{node_list[4]:>8}\n")
|
|
372
|
+
else:
|
|
869
373
|
element_id += 1
|
|
870
|
-
fid.write(f"CHEXA {element_id:>8}{block_id:>8}{node_list[0]:>8}{node_list[1]:>8}{node_list[2]:>8}{node_list[3]:>8}{node_list[4]:>8}{node_list[
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
374
|
+
fid.write(f"CHEXA {element_id:>8}{block_id:>8}{node_list[0]:>8}{node_list[1]:>8}{node_list[2]:>8}{node_list[3]:>8}{node_list[4]:>8}{node_list[4]:>8}+\n+ {node_list[4]:>8}{node_list[4]:>8}\n")
|
|
375
|
+
tri_list = cubit.get_block_tris(block_id)
|
|
376
|
+
for tri_id in tri_list:
|
|
377
|
+
node_list = cubit.get_connectivity('tri',tri_id)
|
|
378
|
+
element_id += 1
|
|
379
|
+
fid.write(f"CTRIA3 {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[1]:<8}{node_list[2]:<8}\n")
|
|
380
|
+
quad_list = cubit.get_block_faces(block_id)
|
|
381
|
+
for quad_id in quad_list:
|
|
382
|
+
node_list = cubit.get_connectivity('quad',quad_id)
|
|
383
|
+
element_id += 1
|
|
384
|
+
fid.write(f"CQUAD4 {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[1]:<8}{node_list[2]:<8}{node_list[3]:<8}\n")
|
|
385
|
+
edge_list = cubit.get_block_edges(block_id)
|
|
386
|
+
if len(edge_list)>0:
|
|
387
|
+
for edge_id in edge_list:
|
|
874
388
|
element_id += 1
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
node_list = cubit.get_connectivity('pyramid',pyramid_id)
|
|
879
|
-
if Pyram:
|
|
880
|
-
element_id += 1
|
|
881
|
-
fid.write(f"CPYRAM {element_id:>8}{block_id:>8}{node_list[0]:>8}{node_list[1]:>8}{node_list[2]:>8}{node_list[3]:>8}{node_list[4]:>8}\n")
|
|
882
|
-
else:
|
|
883
|
-
element_id += 1
|
|
884
|
-
fid.write(f"CHEXA {element_id:>8}{block_id:>8}{node_list[0]:>8}{node_list[1]:>8}{node_list[2]:>8}{node_list[3]:>8}{node_list[4]:>8}{node_list[4]:>8}+\n+ {node_list[4]:>8}{node_list[4]:>8}\n")
|
|
389
|
+
node_list = cubit.get_connectivity('edge', edge_id)
|
|
390
|
+
if len(node_list)==2:
|
|
391
|
+
fid.write(f"CROD {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[1]:<8}\n")
|
|
885
392
|
fid.write("$\n")
|
|
886
393
|
fid.write("$ Property cards\n")
|
|
887
394
|
fid.write("$\n")
|
|
888
395
|
|
|
889
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
890
|
-
name = cubit.get_exodus_entity_name("nodeset",nodeset_id)
|
|
891
|
-
fid.write("$\n")
|
|
892
|
-
fid.write(f"$ Name: {name}\n")
|
|
893
|
-
fid.write("$\n")
|
|
894
|
-
fid.write(f"PSHELL {nodeset_id:< 8}{nodeset_id:< 8}{1:<8}{1:<8}{1:<8}\n")
|
|
895
396
|
for block_id in cubit.get_block_id_list():
|
|
896
397
|
name = cubit.get_exodus_entity_name("block",block_id)
|
|
897
398
|
fid.write("$\n")
|
|
@@ -903,126 +404,10 @@ def export_3D_Nastran(cubit, FileName, Pyram=True):
|
|
|
903
404
|
return cubit
|
|
904
405
|
|
|
905
406
|
########################################################################
|
|
906
|
-
###
|
|
407
|
+
### ELF meg file
|
|
907
408
|
########################################################################
|
|
908
409
|
|
|
909
|
-
def
|
|
910
|
-
|
|
911
|
-
fid = open(FileName,'w',encoding='UTF-8')
|
|
912
|
-
fid.write(f'/COM,ANSYS RELEASE 15.0\n')
|
|
913
|
-
fid.write(f'! Exported from Coreform Cubit 2024.3\n')
|
|
914
|
-
fid.write(f'! {datetime.now().strftime("%Y/%m/%d %I:%M:%S %p")}\n')
|
|
915
|
-
fid.write(f'/PREP7\n')
|
|
916
|
-
fid.write(f'/TITLE,\n')
|
|
917
|
-
fid.write(f'*IF,_CDRDOFF,EQ,1,THEN\n')
|
|
918
|
-
fid.write(f'_CDRDOFF= \n')
|
|
919
|
-
fid.write(f'*ELSE\n')
|
|
920
|
-
fid.write(f'NUMOFF,NODE, {node_count:8d}\n')
|
|
921
|
-
fid.write(f'NUMOFF,ELEM, {elem_count:8d}\n')
|
|
922
|
-
fid.write(f'NUMOFF,TYPE, 1\n')
|
|
923
|
-
fid.write(f'*ENDIF\n')
|
|
924
|
-
fid.write(f'DOF,DELETE\n')
|
|
925
|
-
fid.write(f'ET, 1,185\n')
|
|
926
|
-
fid.write(f'NBLOCK,6,SOLID, {node_count:8d}, {node_count:8d}\n')
|
|
927
|
-
fid.write(f'(3i9,6e20.13)\n')
|
|
928
|
-
|
|
929
|
-
node_set = set()
|
|
930
|
-
for block_id in cubit.get_block_id_list():
|
|
931
|
-
elem_types = ["hex", "tet", "wedge", "pyramid"]
|
|
932
|
-
for elem_type in elem_types:
|
|
933
|
-
if elem_type == "hex":
|
|
934
|
-
func = getattr(cubit, f"get_block_{elem_type}es")
|
|
935
|
-
else:
|
|
936
|
-
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
937
|
-
for element_id in func(block_id):
|
|
938
|
-
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
939
|
-
node_set.update(node_ids)
|
|
940
|
-
fid.write(f'{len(node_set)}\n')
|
|
941
|
-
for node_id in node_set:
|
|
942
|
-
coord = cubit.get_nodal_coordinates(node_id)
|
|
943
|
-
fid.write(f'{node_id:9d}{0:9d}{0:9d}{coord[0]:20.13e}{coord[1]:20.13e}{coord[2]:20.13e}\n')
|
|
944
|
-
|
|
945
|
-
fid.write(f'N,R5.3,LOC, -1\n')
|
|
946
|
-
elem_count = 0
|
|
947
|
-
for block_id in cubit.get_block_id_list():
|
|
948
|
-
fid.write(f'EBLOCK, 19, SOLID\n')
|
|
949
|
-
fid.write(f'(19i9)\n')
|
|
950
|
-
for volume_id in cubit.get_block_volumes(block_id):
|
|
951
|
-
hex_list = cubit.get_volume_hexes(volume_id)
|
|
952
|
-
if len(hex_list)>0:
|
|
953
|
-
for hex_id in hex_list:
|
|
954
|
-
elem_count += 1
|
|
955
|
-
node_list = cubit.get_connectivity("hex", hex_id)
|
|
956
|
-
fid.write(f'{block_id:9d}{1:9d}{1:9d}{1:9d}{0:9d}{0:9d}{0:9d}{0:9d}{8:9d}{0:9d}{elem_count:9d}{node_list[0]:9d}{node_list[1]:9d}{node_list[2]:9d}{node_list[3]:9d}{node_list[4]:9d}{node_list[5]:9d}{node_list[6]:9d}{node_list[7]:9d}\n')
|
|
957
|
-
wedge_list = cubit.get_volume_wedges(volume_id)
|
|
958
|
-
if len(wedge_list)>0:
|
|
959
|
-
for wedge_id in wedge_list:
|
|
960
|
-
elem_count += 1
|
|
961
|
-
node_list = cubit.get_connectivity("wedge", wedge_id)
|
|
962
|
-
fid.write(f'{block_id:9d}{1:9d}{1:9d}{1:9d}{0:9d}{0:9d}{0:9d}{0:9d}{8:9d}{0:9d}{elem_count:9d}{node_list[0]:9d}{node_list[1]:9d}{node_list[2]:9d}{node_list[2]:9d}{node_list[3]:9d}{node_list[4]:9d}{node_list[5]:9d}{node_list[5]:9d}\n')
|
|
963
|
-
tet_list = cubit.get_volume_tets(volume_id)
|
|
964
|
-
if len(tet_list)>0:
|
|
965
|
-
for tet_id in tet_list:
|
|
966
|
-
elem_count += 1
|
|
967
|
-
node_list = cubit.get_connectivity("tet", tet_id)
|
|
968
|
-
fid.write(f'{block_id:9d}{1:9d}{1:9d}{1:9d}{0:9d}{0:9d}{0:9d}{0:9d}{8:9d}{0:9d}{elem_count:9d}{node_list[0]:9d}{node_list[1]:9d}{node_list[2]:9d}{node_list[2]:9d}{node_list[3]:9d}{node_list[3]:9d}{node_list[3]:9d}{node_list[3]:9d}\n')
|
|
969
|
-
pyramid_list = cubit.get_volume_pyramids(volume_id)
|
|
970
|
-
if len(pyramid_list)>0:
|
|
971
|
-
for pyramid_id in pyramid_list:
|
|
972
|
-
elem_count += 1
|
|
973
|
-
node_list = cubit.get_connectivity("pyramid", pyramid_id)
|
|
974
|
-
fid.write(f'{block_id:9d}{1:9d}{1:9d}{1:9d}{0:9d}{0:9d}{0:9d}{0:9d}{8:9d}{0:9d}{elem_count:9d}{node_list[0]:9d}{node_list[1]:9d}{node_list[2]:9d}{node_list[3]:9d}{node_list[4]:9d}{node_list[4]:9d}{node_list[4]:9d}{node_list[4]:9d}\n')
|
|
975
|
-
fid.write(f' -1\n')
|
|
976
|
-
|
|
977
|
-
for block_id in cubit.get_block_id_list():
|
|
978
|
-
name = cubit.get_exodus_entity_name("block",block_id)
|
|
979
|
-
elem_list = []
|
|
980
|
-
volume_list = cubit.get_block_volumes(block_id)
|
|
981
|
-
for volume_id in volume_list:
|
|
982
|
-
hex_list = cubit.get_volume_hexes(volume_id)
|
|
983
|
-
elem_list.extend(hex_list)
|
|
984
|
-
wedge_list = cubit.get_volume_wedges(volume_id)
|
|
985
|
-
elem_list.extend(wedge_list)
|
|
986
|
-
tet_list = cubit.get_volume_tets(volume_id)
|
|
987
|
-
elem_list.extend(tet_list)
|
|
988
|
-
pyramid_list = cubit.get_volume_pyramids(volume_id)
|
|
989
|
-
elem_list.extend(pyramid_list)
|
|
990
|
-
fid.write(f'CMBLOCK,{name:<8},ELEM,{len(elem_list):8d}\n')
|
|
991
|
-
fid.write(f'(8i10)\n')
|
|
992
|
-
for n in range(0, len(elem_list), 8):
|
|
993
|
-
strLine = ""
|
|
994
|
-
for m in range(n, min(n+8, len(elem_list))):
|
|
995
|
-
strLine += f'{elem_list[m]:10d}'
|
|
996
|
-
fid.write(f'{strLine}\n')
|
|
997
|
-
|
|
998
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
999
|
-
name = cubit.get_exodus_entity_name("nodeset",nodeset_id)
|
|
1000
|
-
|
|
1001
|
-
node_set.clear()
|
|
1002
|
-
for block_id in cubit.get_block_id_list():
|
|
1003
|
-
elem_types = ["tri", "quad"]
|
|
1004
|
-
for elem_type in elem_types:
|
|
1005
|
-
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
1006
|
-
for element_id in func(block_id):
|
|
1007
|
-
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
1008
|
-
node_set.update(node_ids)
|
|
1009
|
-
|
|
1010
|
-
fid.write(f'CMBLOCK,{name:<8},NODE,{len(node_set):8d}\n')
|
|
1011
|
-
fid.write(f'(8i10)\n')
|
|
1012
|
-
node_list = list(node_set)
|
|
1013
|
-
for n in range(0, len(node_list), 8):
|
|
1014
|
-
strLine = ""
|
|
1015
|
-
for m in range(n, min(n+8, len(node_list))):
|
|
1016
|
-
strLine += f'{node_list[m]:10d}'
|
|
1017
|
-
fid.write(f'{strLine}\n')
|
|
1018
|
-
return cubit
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
########################################################################
|
|
1022
|
-
### ELF 1D file
|
|
1023
|
-
########################################################################
|
|
1024
|
-
|
|
1025
|
-
def export_1D_meg(cubit, FileName, Dim='T', MGR2=[] ):
|
|
410
|
+
def export_meg(cubit, FileName, DIM='T', MGR2=[]):
|
|
1026
411
|
|
|
1027
412
|
fid = open(FileName,'w',encoding='UTF-8')
|
|
1028
413
|
fid.write("BOOK MEP 3.50\n")
|
|
@@ -1031,111 +416,9 @@ def export_1D_meg(cubit, FileName, Dim='T', MGR2=[] ):
|
|
|
1031
416
|
fid.write("MGSC 0.001\n")
|
|
1032
417
|
fid.write("* NODE\n")
|
|
1033
418
|
|
|
1034
|
-
|
|
419
|
+
node_list = set()
|
|
1035
420
|
for block_id in cubit.get_block_id_list():
|
|
1036
|
-
elem_types = ["
|
|
1037
|
-
for elem_type in elem_types:
|
|
1038
|
-
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
1039
|
-
for element_id in func(block_id):
|
|
1040
|
-
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
1041
|
-
node_set.update(node_ids)
|
|
1042
|
-
for node_id in node_set:
|
|
1043
|
-
coord = cubit.get_nodal_coordinates(node_id)
|
|
1044
|
-
if Dim=='T':
|
|
1045
|
-
fid.write(f"MGR1 {node_id} 0 {coord[0]} {coord[1]} {coord[2]}\n")
|
|
1046
|
-
elif Dim=='K':
|
|
1047
|
-
fid.write(f"MGR1 {node_id} 0 {coord[0]} {coord[1]} {0}\n")
|
|
1048
|
-
elif Dim=='R':
|
|
1049
|
-
fid.write(f"MGR1 {node_id} 0 {coord[0]} {0} {coord[2]}\n")
|
|
1050
|
-
|
|
1051
|
-
element_id = 0
|
|
1052
|
-
fid.write("* ELEMENT T\n")
|
|
1053
|
-
for block_id in cubit.get_block_id_list():
|
|
1054
|
-
name = cubit.get_exodus_entity_name("block",block_id)
|
|
1055
|
-
curve_list = cubit.get_block_curves(block_id)
|
|
1056
|
-
for curve_id in curve_list:
|
|
1057
|
-
edge_list = cubit.get_curve_edges(curve_id)
|
|
1058
|
-
for edge_id in edge_list:
|
|
1059
|
-
node_list = cubit.get_connectivity('edge', edge_id)
|
|
1060
|
-
element_id += 1
|
|
1061
|
-
fid.write(f"{name[0:3]}2{Dim} {element_id} 0 {block_id} {node_list[0]} {node_list[1]}\n")
|
|
1062
|
-
fid.write("* ELEMENT\n")
|
|
1063
|
-
fid.write("BOOK END\n")
|
|
1064
|
-
for node_id in range(len(MGR2)):
|
|
1065
|
-
fid.write(f"MGR2 {node_id+1} 0 {MGR2[node_id][0]} {MGR2[node_id][1]} {MGR2[node_id][2]}\n")
|
|
1066
|
-
fid.close()
|
|
1067
|
-
return cubit
|
|
1068
|
-
|
|
1069
|
-
########################################################################
|
|
1070
|
-
### ELF 2D file
|
|
1071
|
-
########################################################################
|
|
1072
|
-
|
|
1073
|
-
def export_2D_meg(cubit, FileName, Dim='T', MGR2=[]):
|
|
1074
|
-
|
|
1075
|
-
fid = open(FileName,'w',encoding='UTF-8')
|
|
1076
|
-
fid.write("BOOK MEP 3.50\n")
|
|
1077
|
-
fid.write("* ELF/MESH VERSION 7.3.0\n")
|
|
1078
|
-
fid.write("* SOLVER = ELF/MAGIC\n")
|
|
1079
|
-
fid.write("MGSC 0.001\n")
|
|
1080
|
-
fid.write("* NODE\n")
|
|
1081
|
-
|
|
1082
|
-
node_set.clear()
|
|
1083
|
-
for block_id in cubit.get_block_id_list():
|
|
1084
|
-
elem_types = ["tri", "quad"]
|
|
1085
|
-
for elem_type in elem_types:
|
|
1086
|
-
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
1087
|
-
for element_id in func(block_id):
|
|
1088
|
-
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
1089
|
-
node_set.update(node_ids)
|
|
1090
|
-
for node_id in node_set:
|
|
1091
|
-
coord = cubit.get_nodal_coordinates(node_id)
|
|
1092
|
-
if Dim=='T':
|
|
1093
|
-
fid.write(f"MGR1 {node_id} 0 {coord[0]} {coord[1]} {coord[2]}\n")
|
|
1094
|
-
if Dim=='K':
|
|
1095
|
-
fid.write(f"MGR1 {node_id} 0 {coord[0]} {coord[1]} {0}\n")
|
|
1096
|
-
if Dim=='R':
|
|
1097
|
-
fid.write(f"MGR1 {node_id} 0 {coord[0]} {0} {coord[2]}\n")
|
|
1098
|
-
|
|
1099
|
-
element_id = 0
|
|
1100
|
-
fid.write("* ELEMENT T\n")
|
|
1101
|
-
for block_id in cubit.get_block_id_list():
|
|
1102
|
-
name = cubit.get_exodus_entity_name("block",block_id)
|
|
1103
|
-
for surface_id in cubit.get_block_surfaces(block_id):
|
|
1104
|
-
tri_list = cubit.get_surface_tris(surface_id)
|
|
1105
|
-
for tri_id in tri_list:
|
|
1106
|
-
node_list = cubit.get_connectivity('tri',tri_id)
|
|
1107
|
-
element_id += 1
|
|
1108
|
-
fid.write(f"{name[0:3]}3{Dim} {element_d} 0 {block_id} {node_list[0]} {node_list[1]} {node_list[2]}\n")
|
|
1109
|
-
|
|
1110
|
-
quad_list = cubit.get_surface_quads(surface_id)
|
|
1111
|
-
for quad_id in quad_list:
|
|
1112
|
-
node_list = cubit.get_connectivity('quad',quad_id)
|
|
1113
|
-
element_id += 1
|
|
1114
|
-
fid.write(f"{name[0:3]}4{Dim} {element_id} 0 {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n")
|
|
1115
|
-
|
|
1116
|
-
fid.write("* NODE\n")
|
|
1117
|
-
for node_id in range(len(MGR2)):
|
|
1118
|
-
fid.write(f"MGR2 {node_id+1} 0 {MGR2[node_id][0]} {MGR2[node_id][1]} {MGR2[node_id][2]}\n")
|
|
1119
|
-
fid.write("BOOK END\n")
|
|
1120
|
-
fid.close()
|
|
1121
|
-
return cubit
|
|
1122
|
-
|
|
1123
|
-
########################################################################
|
|
1124
|
-
### ELF 3D file
|
|
1125
|
-
########################################################################
|
|
1126
|
-
|
|
1127
|
-
def export_3D_meg(cubit, FileName, Dim='T', MGR2=[], Pyram=True):
|
|
1128
|
-
|
|
1129
|
-
fid = open(FileName,'w',encoding='UTF-8')
|
|
1130
|
-
fid.write("BOOK MEP 3.50\n")
|
|
1131
|
-
fid.write("* ELF/MESH VERSION 7.3.0\n")
|
|
1132
|
-
fid.write("* SOLVER = ELF/MAGIC\n")
|
|
1133
|
-
fid.write("MGSC 0.001\n")
|
|
1134
|
-
fid.write("* NODE\n")
|
|
1135
|
-
|
|
1136
|
-
node_set = set()
|
|
1137
|
-
for block_id in cubit.get_block_id_list():
|
|
1138
|
-
elem_types = ["hex", "tet", "wedge", "pyramid"]
|
|
421
|
+
elem_types = ["hex", "tet", "wedge", "pyramid", "tri", "face", "edge"]
|
|
1139
422
|
for elem_type in elem_types:
|
|
1140
423
|
if elem_type == "hex":
|
|
1141
424
|
func = getattr(cubit, f"get_block_{elem_type}es")
|
|
@@ -1143,55 +426,62 @@ def export_3D_meg(cubit, FileName, Dim='T', MGR2=[], Pyram=True):
|
|
|
1143
426
|
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
1144
427
|
for element_id in func(block_id):
|
|
1145
428
|
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
1146
|
-
|
|
1147
|
-
for node_id in
|
|
429
|
+
node_list.update(node_ids)
|
|
430
|
+
for node_id in node_list:
|
|
1148
431
|
coord = cubit.get_nodal_coordinates(node_id)
|
|
1149
|
-
if
|
|
432
|
+
if DIM=='T':
|
|
1150
433
|
fid.write(f"MGR1 {node_id} 0 {coord[0]} {coord[1]} {coord[2]}\n")
|
|
1151
|
-
if
|
|
434
|
+
if DIM=='K':
|
|
1152
435
|
fid.write(f"MGR1 {node_id} 0 {coord[0]} {coord[1]} {0}\n")
|
|
1153
|
-
if
|
|
436
|
+
if DIM=='R':
|
|
1154
437
|
fid.write(f"MGR1 {node_id} 0 {coord[0]} {0} {coord[2]}\n")
|
|
1155
438
|
|
|
1156
439
|
element_id = 0
|
|
1157
440
|
fid.write("* ELEMENT K\n")
|
|
1158
441
|
for block_id in cubit.get_block_id_list():
|
|
1159
442
|
name = cubit.get_exodus_entity_name("block",block_id)
|
|
1160
|
-
for volume_id in cubit.get_block_volumes(block_id):
|
|
1161
|
-
tet_list = cubit.get_volume_tets(volume_id)
|
|
1162
|
-
if len(tet_list)>0:
|
|
1163
|
-
for tet_id in tet_list:
|
|
1164
|
-
node_list = cubit.get_connectivity('tet',tet_id)
|
|
1165
|
-
node_list = cubit.get_connectivity("tet", tet_id)
|
|
1166
|
-
element_id += 1
|
|
1167
|
-
fid.write(f"{name[0:3]}4{Dim} {element_id} 0 {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n")
|
|
1168
|
-
hex_list = cubit.get_volume_hexes(volume_id)
|
|
1169
|
-
if len(hex_list)>0:
|
|
1170
|
-
for hex_id in hex_list:
|
|
1171
|
-
node_list = cubit.get_connectivity("hex", hex_id)
|
|
1172
|
-
element_id += 1
|
|
1173
|
-
fid.write(f"{name[0:3]}8{Dim} {element_id} 0 {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]}\n")
|
|
1174
|
-
wedge_list = cubit.get_volume_wedges(volume_id)
|
|
1175
|
-
if len(wedge_list)>0:
|
|
1176
|
-
for wedge_id in wedge_list:
|
|
1177
|
-
node_list = cubit.get_connectivity("wedge", wedge_id)
|
|
1178
|
-
element_id += 1
|
|
1179
|
-
fid.write(f"{name[0:3]}6{Dim} {element_id} 0 {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]}\n")
|
|
1180
443
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
444
|
+
tet_list = cubit.get_block_tets(block_id)
|
|
445
|
+
for tet_id in tet_list:
|
|
446
|
+
node_list = cubit.get_connectivity('tet',tet_id)
|
|
447
|
+
element_id += 1
|
|
448
|
+
fid.write(f"{name[0:4]}{DIM} {element_id} 0 {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n")
|
|
449
|
+
|
|
450
|
+
hex_list = cubit.get_block_hexes(block_id)
|
|
451
|
+
for hex_id in hex_list:
|
|
452
|
+
node_list = cubit.get_connectivity('hex',hex_id)
|
|
453
|
+
element_id += 1
|
|
454
|
+
fid.write(f"{name[0:4]}{DIM} {element_id} 0 {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]} {node_list[6]} {node_list[7]}\n")
|
|
455
|
+
|
|
456
|
+
wedge_list = cubit.get_block_wedges(block_id)
|
|
457
|
+
for wedge_id in wedge_list:
|
|
458
|
+
node_list = cubit.get_connectivity('wedge',wedge_id)
|
|
459
|
+
element_id += 1
|
|
460
|
+
fid.write(f"{name[0:4]}{DIM} {element_id} 0 {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]}\n")
|
|
461
|
+
|
|
462
|
+
pyramid_list = cubit.get_block_pyramids(block_id)
|
|
463
|
+
for pyramid_id in pyramid_list:
|
|
464
|
+
node_list = cubit.get_connectivity('pyramid',pyramid_id)
|
|
465
|
+
element_id += 1
|
|
466
|
+
fid.write(f"{name[0:4]}{DIM} {element_id} 0 {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[4]} {node_list[4]} {node_list[4]}\n")
|
|
467
|
+
|
|
468
|
+
tri_list = cubit.get_block_tris(block_id)
|
|
469
|
+
for tri_id in tri_list:
|
|
470
|
+
node_list = cubit.get_connectivity('tri',tri_id)
|
|
471
|
+
element_id += 1
|
|
472
|
+
fid.write(f"{name[0:4]}{DIM} {element_id} 0 {block_id} {node_list[0]} {node_list[1]} {node_list[2]}\n")
|
|
473
|
+
|
|
474
|
+
quad_list = cubit.get_block_faces(block_id)
|
|
475
|
+
for quad_id in quad_list:
|
|
476
|
+
node_list = cubit.get_connectivity('quad',quad_id)
|
|
477
|
+
element_id += 1
|
|
478
|
+
fid.write(f"{name[0:4]}{DIM} {element_id} 0 {block_id} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n")
|
|
479
|
+
|
|
480
|
+
edge_list = cubit.get_block_edges(block_id)
|
|
481
|
+
for edge_id in edge_list:
|
|
482
|
+
node_list = cubit.get_connectivity('edge',edge_id)
|
|
483
|
+
element_id += 1
|
|
484
|
+
fid.write(f"{name[0:4]}{DIM} {element_id} 0 {block_id} {node_list[0]} {node_list[1]}\n")
|
|
1195
485
|
|
|
1196
486
|
fid.write("* NODE\n")
|
|
1197
487
|
for node_id in range(len(MGR2)):
|
|
@@ -1204,7 +494,7 @@ def export_3D_meg(cubit, FileName, Dim='T', MGR2=[], Pyram=True):
|
|
|
1204
494
|
### vtk format
|
|
1205
495
|
########################################################################
|
|
1206
496
|
|
|
1207
|
-
def
|
|
497
|
+
def export_vtk(cubit, FileName):
|
|
1208
498
|
|
|
1209
499
|
fid = open(FileName,'w')
|
|
1210
500
|
fid.write('# vtk DataFile Version 3.0\n')
|
|
@@ -1218,31 +508,24 @@ def export_3D_vtk(cubit, FileName):
|
|
|
1218
508
|
coord = cubit.get_nodal_coordinates(node_id)
|
|
1219
509
|
fid.write(f'{coord[0]} {coord[1]} {coord[2]}\n')
|
|
1220
510
|
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
wedge_list =
|
|
1224
|
-
pyramid_list =
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
tet_list += cubit.get_volume_tets(volume_id)
|
|
1229
|
-
volume_id_list += [volume_id]*(len(cubit.get_volume_tets(volume_id)))
|
|
1230
|
-
|
|
1231
|
-
for block_id in cubit.get_block_id_list():
|
|
1232
|
-
for volume_id in cubit.get_block_volumes(block_id):
|
|
1233
|
-
hex_list += cubit.get_volume_hexes(volume_id)
|
|
1234
|
-
volume_id_list += [volume_id]*(len(cubit.get_volume_hexes(volume_id)))
|
|
511
|
+
hex_list = set()
|
|
512
|
+
tet_list = set()
|
|
513
|
+
wedge_list = set()
|
|
514
|
+
pyramid_list = set()
|
|
515
|
+
tri_list = set()
|
|
516
|
+
quad_list = set()
|
|
517
|
+
edge_list = set()
|
|
1235
518
|
|
|
1236
519
|
for block_id in cubit.get_block_id_list():
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
fid.write(f'CELLS {len(tet_list) + len(hex_list) + len(wedge_list) + len(pyramid_list)} {5*len(tet_list) + 9*len(hex_list) + 7*len(wedge_list) + 6*len(pyramid_list)}\n' )
|
|
520
|
+
tet_list.update(cubit.get_block_tets(block_id))
|
|
521
|
+
hex_list.update(cubit.get_block_hexes(block_id))
|
|
522
|
+
wedge_list.update(cubit.get_block_wedges(block_id))
|
|
523
|
+
pyramid_list.update(cubit.get_block_pyramids(block_id))
|
|
524
|
+
tri_list.update(cubit.get_block_tris(block_id))
|
|
525
|
+
quad_list.update(cubit.get_block_faces(block_id))
|
|
526
|
+
edge_list.update(cubit.get_block_edges(block_id))
|
|
527
|
+
|
|
528
|
+
fid.write(f'CELLS {len(tet_list) + len(hex_list) + len(wedge_list) + len(pyramid_list) + len(tri_list) + len(quad_list) + len(edge_list)} {5*len(tet_list) + 9*len(hex_list) + 7*len(wedge_list) + 6*len(pyramid_list) + 4*len(tri_list) + 5*len(quad_list) + 3*len(edge_list)}\n' )
|
|
1246
529
|
for tet_id in tet_list:
|
|
1247
530
|
node_list = cubit.get_connectivity("tet", tet_id)
|
|
1248
531
|
fid.write(f'4 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1}\n')
|
|
@@ -1255,8 +538,17 @@ def export_3D_vtk(cubit, FileName):
|
|
|
1255
538
|
for pyramid_id in pyramid_list:
|
|
1256
539
|
node_list = cubit.get_connectivity("pyramid", pyramid_id)
|
|
1257
540
|
fid.write(f'5 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} {node_list[4]-1} \n')
|
|
1258
|
-
|
|
1259
|
-
|
|
541
|
+
for tri_id in tri_list:
|
|
542
|
+
node_list = cubit.get_connectivity("tri", tri_id)
|
|
543
|
+
fid.write(f'3 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} \n')
|
|
544
|
+
for quad_id in quad_list:
|
|
545
|
+
node_list = cubit.get_connectivity("quad", quad_id)
|
|
546
|
+
fid.write(f'4 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} \n')
|
|
547
|
+
for edge_id in edge_list:
|
|
548
|
+
node_list = cubit.get_connectivity("edge", edge_id)
|
|
549
|
+
fid.write(f'2 {node_list[0]-1} {node_list[1]-1} \n')
|
|
550
|
+
|
|
551
|
+
fid.write(f'CELL_TYPES {len(tet_list) + len(hex_list) + len(wedge_list) + len(pyramid_list) + len(tri_list) + len(quad_list) + len(edge_list)}\n')
|
|
1260
552
|
for tet_id in tet_list:
|
|
1261
553
|
fid.write('10\n')
|
|
1262
554
|
for hex_id in hex_list:
|
|
@@ -1265,88 +557,28 @@ def export_3D_vtk(cubit, FileName):
|
|
|
1265
557
|
fid.write('13\n')
|
|
1266
558
|
for pyramid_id in pyramid_list:
|
|
1267
559
|
fid.write('14\n')
|
|
1268
|
-
|
|
560
|
+
for tri_id in tri_list:
|
|
561
|
+
fid.write('5\n')
|
|
562
|
+
for quad_id in quad_list:
|
|
563
|
+
fid.write('9\n')
|
|
564
|
+
for edge_id in edge_list:
|
|
565
|
+
fid.write('3\n')
|
|
566
|
+
fid.write(f'CELL_DATA {len(tet_list) + len(hex_list) + len(wedge_list) + len(pyramid_list) + len(tri_list) + len(quad_list) + len(edge_list)}\n')
|
|
1269
567
|
fid.write('SCALARS scalars float\n')
|
|
1270
568
|
fid.write('LOOKUP_TABLE default\n')
|
|
1271
|
-
for
|
|
1272
|
-
fid.write(f'{
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
nodes = []
|
|
1286
|
-
node_list = []
|
|
1287
|
-
|
|
1288
|
-
N = cubit.get_node_count()
|
|
1289
|
-
M = cubit.get_tri_count()
|
|
1290
|
-
|
|
1291
|
-
node_set = set()
|
|
1292
|
-
for block_id in cubit.get_block_id_list():
|
|
1293
|
-
elem_types = ["hex", "tet", "wedge", "pyramid"]
|
|
1294
|
-
for elem_type in elem_types:
|
|
1295
|
-
if elem_type == "hex":
|
|
1296
|
-
func = getattr(cubit, f"get_block_{elem_type}es")
|
|
1297
|
-
else:
|
|
1298
|
-
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
1299
|
-
for element_id in func(block_id):
|
|
1300
|
-
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
1301
|
-
node_set.update(node_ids)
|
|
1302
|
-
for node_id in node_set:
|
|
1303
|
-
coord = cubit.get_nodal_coordinates(node_id)
|
|
1304
|
-
nodes.append([coord[0],coord[1]])
|
|
1305
|
-
|
|
1306
|
-
for nodeset_id in cubit.get_nodeset_id_list():
|
|
1307
|
-
name = cubit.get_exodus_entity_name("nodeset",nodeset_id)
|
|
1308
|
-
curve_list = cubit.get_nodeset_curves(nodeset_id)
|
|
1309
|
-
node_list = []
|
|
1310
|
-
for curve_id in curve_list:
|
|
1311
|
-
node_list += cubit.get_curve_nodes(curve_id)
|
|
1312
|
-
nodeset = numpy.array([(name, node_list)], dtype=[('name', 'U20'), ('DBCnodes', 'O')])
|
|
1313
|
-
try:
|
|
1314
|
-
nodesets = append(nodesets,nodeset)
|
|
1315
|
-
except:
|
|
1316
|
-
nodesets = nodeset
|
|
1317
|
-
|
|
1318
|
-
conn_matrix = numpy.zeros((M,3))
|
|
1319
|
-
center_x = numpy.zeros((M))
|
|
1320
|
-
center_y = numpy.zeros((M))
|
|
1321
|
-
block_count = cubit.get_block_count()
|
|
1322
|
-
regions = numpy.rec.array([("", [], [])]*(block_count), dtype=[('name', 'U20'), ('Elements', 'O'), ('Nodes', 'O')])
|
|
1323
|
-
|
|
1324
|
-
for block_id in cubit.get_block_id_list():
|
|
1325
|
-
Elements = []
|
|
1326
|
-
name = cubit.get_exodus_entity_name("block",block_id)
|
|
1327
|
-
surface_list = cubit.get_block_surfaces(block_id)
|
|
1328
|
-
Nodes = []
|
|
1329
|
-
Elements = []
|
|
1330
|
-
for surface_id in surface_list:
|
|
1331
|
-
tri_list = cubit.get_surface_tris(surface_id)
|
|
1332
|
-
Elements += tri_list
|
|
1333
|
-
for tri_id in tri_list:
|
|
1334
|
-
x = []
|
|
1335
|
-
y = []
|
|
1336
|
-
node_list = cubit.get_connectivity('tri',tri_id)
|
|
1337
|
-
Nodes += node_list
|
|
1338
|
-
conn_matrix[tri_id-1,:] = node_list
|
|
1339
|
-
for node_id in node_list:
|
|
1340
|
-
coord = cubit.get_nodal_coordinates(node_id)
|
|
1341
|
-
x.append(coord[0])
|
|
1342
|
-
y.append(coord[1])
|
|
1343
|
-
center_x[tri_id-1] = numpy.mean(x)
|
|
1344
|
-
center_y[tri_id-1] = numpy.mean(y)
|
|
1345
|
-
regions[block_id-1][0] = name
|
|
1346
|
-
regions[block_id-1][1] = Elements
|
|
1347
|
-
regions[block_id-1][2] = Nodes
|
|
1348
|
-
|
|
1349
|
-
geo = {'conn_matrix':conn_matrix, 'nodes':nodes, 'M':M, 'N':N, 'nodesets':nodesets , 'center_x':center_x, 'center_y':center_y, 'regions':regions }
|
|
1350
|
-
scipy.io.savemat(FileName, {'geo': geo}, format='5', long_field_names=True)
|
|
569
|
+
for tet_id in tet_list:
|
|
570
|
+
fid.write(f'{4}\n')
|
|
571
|
+
for hex_id in hex_list:
|
|
572
|
+
fid.write(f'{8}\n')
|
|
573
|
+
for wedge_id in wedge_list:
|
|
574
|
+
fid.write(f'{6}\n')
|
|
575
|
+
for pyramid_id in pyramid_list:
|
|
576
|
+
fid.write(f'{5}\n')
|
|
577
|
+
for tri_id in tri_list:
|
|
578
|
+
fid.write(f'{3}\n')
|
|
579
|
+
for quad_id in quad_list:
|
|
580
|
+
fid.write(f'{4}\n')
|
|
581
|
+
for edge_id in edge_list:
|
|
582
|
+
fid.write(f'{2}\n')
|
|
1351
583
|
return cubit
|
|
1352
584
|
|