Coreform-Cubit-Mesh-Export 1.1.1__tar.gz → 1.3__tar.gz

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.

Files changed (14) hide show
  1. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/Coreform_Cubit_Mesh_Export.egg-info/PKG-INFO +1 -1
  2. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/PKG-INFO +1 -1
  3. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/cubit_mesh_export.py +196 -222
  4. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/pyproject.toml +1 -1
  5. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/Coreform_Cubit_Mesh_Export.egg-info/SOURCES.txt +0 -0
  6. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/Coreform_Cubit_Mesh_Export.egg-info/dependency_links.txt +0 -0
  7. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/Coreform_Cubit_Mesh_Export.egg-info/requires.txt +0 -0
  8. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/Coreform_Cubit_Mesh_Export.egg-info/top_level.txt +0 -0
  9. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/README.md +0 -0
  10. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/sample_script/cubit_mesh_export_2d_geo_lukas_format.py +0 -0
  11. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/sample_script/cubit_mesh_export_3d_cdb.py +0 -0
  12. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/sample_script/cubit_mesh_export_3d_freefem_mesh.py +0 -0
  13. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/sample_script/cubit_mesh_export_3d_gmesh_v4.py +0 -0
  14. {coreform_cubit_mesh_export-1.1.1 → coreform_cubit_mesh_export-1.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Coreform_Cubit_Mesh_Export
3
- Version: 1.1.1
3
+ Version: 1.3
4
4
  Summary: Cubit mesh export to various formats including Gmsh, Nastran, and VTK
5
5
  Author-email: Kengo Sugahara <ksugahar@gmail.com>
6
6
  Maintainer-email: Kengo Sugahara <ksugahar@gmail.com>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Coreform_Cubit_Mesh_Export
3
- Version: 1.1.1
3
+ Version: 1.3
4
4
  Summary: Cubit mesh export to various formats including Gmsh, Nastran, and VTK
5
5
  Author-email: Kengo Sugahara <ksugahar@gmail.com>
6
6
  Maintainer-email: Kengo Sugahara <ksugahar@gmail.com>
@@ -14,7 +14,9 @@ def export_Gmsh_ver2(cubit, FileName):
14
14
  fid.write(f'{cubit.get_block_count()}\n')
15
15
  for block_id in cubit.get_block_id_list():
16
16
  name = cubit.get_exodus_entity_name("block", block_id)
17
- if len(cubit.get_block_edges(block_id)) > 0:
17
+ if len(cubit.get_block_nodes(block_id)) > 0:
18
+ fid.write(f'0 {block_id} "{name}"\n')
19
+ elif len(cubit.get_block_edges(block_id)) > 0:
18
20
  fid.write(f'1 {block_id} "{name}"\n')
19
21
  elif len(cubit.get_block_tris(block_id)) + len(cubit.get_block_faces(block_id))> 0:
20
22
  fid.write(f'2 {block_id} "{name}"\n')
@@ -25,7 +27,7 @@ def export_Gmsh_ver2(cubit, FileName):
25
27
  fid.write("$Nodes\n")
26
28
  node_list = set()
27
29
  for block_id in cubit.get_block_id_list():
28
- elem_types = ["hex", "tet", "wedge", "pyramid", "tri", "face", "edge"]
30
+ elem_types = ["hex", "tet", "wedge", "pyramid", "tri", "face", "edge", "node"]
29
31
  for elem_type in elem_types:
30
32
  if elem_type == "hex":
31
33
  func = getattr(cubit, f"get_block_{elem_type}es")
@@ -48,6 +50,7 @@ def export_Gmsh_ver2(cubit, FileName):
48
50
  tri_list = set()
49
51
  quad_list = set()
50
52
  edge_list = set()
53
+ node_list = set()
51
54
 
52
55
  for block_id in cubit.get_block_id_list():
53
56
  tet_list.update(cubit.get_block_tets(block_id))
@@ -57,10 +60,11 @@ def export_Gmsh_ver2(cubit, FileName):
57
60
  tri_list.update(cubit.get_block_tris(block_id))
58
61
  quad_list.update(cubit.get_block_faces(block_id))
59
62
  edge_list.update(cubit.get_block_edges(block_id))
63
+ node_list.update(cubit.get_block_nodes(block_id))
60
64
 
61
65
  element_id = 0
62
66
  fid.write('$Elements\n')
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')
67
+ fid.write(f'{len(hex_list) + len(tet_list) + len(wedge_list) + len(pyramid_list) + len(tri_list) + len(quad_list) + len(edge_list) + len(node_list)}\n')
64
68
 
65
69
  for block_id in cubit.get_block_id_list():
66
70
 
@@ -133,140 +137,20 @@ def export_Gmsh_ver2(cubit, FileName):
133
137
  if len(node_list)==3:
134
138
  fid.write(f'{element_id} {8} {2} {block_id} {block_id} {node_list[0]} {node_list[1]} {node_list[2]}\n')
135
139
 
140
+ node_list = cubit.get_block_nodes(block_id)
141
+ for node_id in node_list:
142
+ element_id += 1
143
+ fid.write(f'{element_id} {15} {2} {block_id} {block_id} {node_id}\n')
144
+
136
145
  fid.write('$EndElements\n')
137
146
  fid.close()
138
147
  return cubit
139
148
 
140
149
  ########################################################################
141
- ### NASTRAN 2D file
142
- ########################################################################
143
-
144
- def export_2D_Nastran(cubit, FileName):
145
- import datetime
146
- formatted_date_time = datetime.datetime.now().strftime("%d-%b-%y at %H:%M:%S")
147
-
148
- fid = open(FileName,'w',encoding='UTF-8')
149
- fid.write("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n")
150
- fid.write("$\n")
151
- fid.write("$ CUBIT NX Nastran Translator\n")
152
- fid.write("$\n")
153
- fid.write(f"$ File: {FileName}\n")
154
- fid.write(f"$ Time Stamp: {formatted_date_time}\n")
155
- fid.write("$\n")
156
- fid.write("$\n")
157
- fid.write("$ PLEASE CHECK YOUR MODEL FOR UNITS CONSISTENCY.\n")
158
- fid.write("$\n")
159
- fid.write("$ It should be noted that load ID's from CUBIT may NOT correspond to Nastran SID's\n")
160
- 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")
161
- fid.write("$\n")
162
- fid.write("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n")
163
- fid.write("$\n")
164
- fid.write("$\n")
165
- fid.write("$ -------------------------\n")
166
- fid.write("$ Executive Control Section\n")
167
- fid.write("$ -------------------------\n")
168
- fid.write("$\n")
169
- fid.write("SOL 101\n")
170
- fid.write("CEND\n")
171
- fid.write("$\n")
172
- fid.write("$\n")
173
- fid.write("$ --------------------\n")
174
- fid.write("$ Case Control Section\n")
175
- fid.write("$ --------------------\n")
176
- fid.write("$\n")
177
- fid.write("ECHO = SORT\n")
178
- fid.write("$\n")
179
- fid.write("$\n")
180
- fid.write("$ Name: Initial\n")
181
- fid.write("$\n")
182
- fid.write("$\n")
183
- fid.write("$ Name: Default Set\n")
184
- fid.write("$\n")
185
- fid.write("SUBCASE = 1\n")
186
- fid.write("$\n")
187
- fid.write("LABEL = Default Set\n")
188
- fid.write("$\n")
189
- fid.write("$ -----------------\n")
190
- fid.write("$ Bulk Data Section\n")
191
- fid.write("$ -----------------\n")
192
- fid.write("$\n")
193
- fid.write("BEGIN BULK\n")
194
- fid.write("$\n")
195
- fid.write("$ Params\n")
196
- fid.write("$\n")
197
- fid.write("$\n")
198
- fid.write("$ Node cards\n")
199
- fid.write("$\n")
200
-
201
- node_list = set()
202
- for block_id in cubit.get_block_id_list():
203
- elem_types = ["tri", "face", "edge"]
204
- for elem_type in elem_types:
205
- func = getattr(cubit, f"get_block_{elem_type}s")
206
- for element_id in func(block_id):
207
- node_ids = cubit.get_connectivity(elem_type, element_id)
208
- node_list.update(node_ids)
209
- for node_id in node_list:
210
- coord = cubit.get_nodal_coordinates(node_id)
211
- fid.write(f"GRID* {node_id:>16}{0:>16}{coord[0]:>16.5f}{coord[1]:>16.5f}\n* {coord[2]:>16.5f}\n")
212
-
213
- element_id = 0
214
- fid.write("$\n")
215
- fid.write("$ Element cards\n")
216
- fid.write("$\n")
217
- for block_id in cubit.get_block_id_list():
218
- name = cubit.get_exodus_entity_name("block",block_id)
219
- fid.write("$\n")
220
- fid.write(f"$ Name: {name}\n")
221
- fid.write("$\n")
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])
227
- normal = cubit.get_surface_normal(surface_id)
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")
251
- fid.write("$\n")
252
- fid.write("$ Property cards\n")
253
- fid.write("$\n")
254
-
255
- for block_id in cubit.get_block_id_list():
256
- name = cubit.get_exodus_entity_name("block",block_id)
257
- fid.write("$\n")
258
- fid.write(f"$ Name: {name}\n")
259
- fid.write("$\n")
260
- fid.write(f"MAT1 {block_id:< 8}{1:<8}{1:<8}{1:<8}\n")
261
- fid.write("ENDDATA\n")
262
- fid.close()
263
- return cubit
264
-
265
- ########################################################################
266
- ### 3D Nastran file
150
+ ### Nastran file
267
151
  ########################################################################
268
152
 
269
- def export_3D_Nastran(cubit, FileName, PYRAM=True):
153
+ def export_Nastran(cubit, FileName, DIM="3D", PYRAM=True):
270
154
 
271
155
  import datetime
272
156
  formatted_date_time = datetime.datetime.now().strftime("%d-%b-%y at %H:%M:%S")
@@ -325,7 +209,7 @@ def export_3D_Nastran(cubit, FileName, PYRAM=True):
325
209
 
326
210
  node_list = set()
327
211
  for block_id in cubit.get_block_id_list():
328
- elem_types = ["hex", "tet", "wedge", "pyramid", "tri", "face", "edge"]
212
+ elem_types = ["hex", "tet", "wedge", "pyramid", "tri", "face", "edge", "node"]
329
213
  for elem_type in elem_types:
330
214
  if elem_type == "hex":
331
215
  func = getattr(cubit, f"get_block_{elem_type}es")
@@ -334,10 +218,12 @@ def export_3D_Nastran(cubit, FileName, PYRAM=True):
334
218
  for element_id in func(block_id):
335
219
  node_ids = cubit.get_connectivity(elem_type, element_id)
336
220
  node_list.update(node_ids)
337
- fid.write(f'{len(node_list)}\n')
338
221
  for node_id in node_list:
339
222
  coord = cubit.get_nodal_coordinates(node_id)
340
- fid.write(f"GRID* {node_id:>16}{0:>16}{coord[0]:>16.5f}{coord[1]:>16.5f}\n* {coord[2]:>16.5f}\n")
223
+ if DIM == "3D":
224
+ fid.write(f"GRID* {node_id:>16}{0:>16}{coord[0]:>16.5f}{coord[1]:>16.5f}\n* {coord[2]:>16.5f}\n")
225
+ else:
226
+ fid.write(f"GRID* {node_id:>16}{0:>16}{coord[0]:>16.5f}{coord[1]:>16.5f}\n* {0}\n")
341
227
 
342
228
  element_id = 0
343
229
  fid.write("$\n")
@@ -349,46 +235,68 @@ def export_3D_Nastran(cubit, FileName, PYRAM=True):
349
235
  fid.write(f"$ Name: {name}\n")
350
236
  fid.write("$\n")
351
237
  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:
238
+
239
+ if DIM=="3D":
240
+ for tet_id in tet_list:
241
+ node_list = cubit.get_connectivity('tet',tet_id)
370
242
  element_id += 1
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:
243
+ 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")
244
+ hex_list = cubit.get_block_hexes(block_id)
245
+ for hex_id in hex_list:
246
+ node_list = cubit.get_connectivity('hex',hex_id)
373
247
  element_id += 1
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")
248
+ 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")
249
+ wedge_list = cubit.get_block_wedges(block_id)
250
+ for wedge_id in wedge_list:
251
+ node_list = cubit.get_connectivity('wedge',wedge_id)
252
+ element_id += 1
253
+ 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")
254
+ pyramid_list = cubit.get_block_pyramids(block_id)
255
+ for pyramid_id in pyramid_list:
256
+ node_list = cubit.get_connectivity('pyramid',pyramid_id)
257
+ if PYRAM:
258
+ element_id += 1
259
+ 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")
260
+ else:
261
+ element_id += 1
262
+ 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")
263
+
375
264
  tri_list = cubit.get_block_tris(block_id)
376
265
  for tri_id in tri_list:
377
266
  node_list = cubit.get_connectivity('tri',tri_id)
378
267
  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")
268
+ if DIM=="3D":
269
+ fid.write(f"CTRIA3 {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[1]:<8}{node_list[2]:<8}\n")
270
+ else:
271
+ surface_id = int(cubit.get_geometry_owner("tri", tri_id).split()[1])
272
+ normal = cubit.get_surface_normal(surface_id)
273
+ if normal[2] > 0:
274
+ fid.write(f"CTRIA3 {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[1]:<8}{node_list[2]:<8}\n")
275
+ else:
276
+ fid.write(f"CTRIA3 {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[2]:<8}{node_list[1]:<8}\n")
380
277
  quad_list = cubit.get_block_faces(block_id)
381
278
  for quad_id in quad_list:
382
279
  node_list = cubit.get_connectivity('quad',quad_id)
383
280
  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")
281
+ if DIM=="3D":
282
+ 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")
283
+ else:
284
+ surface_id = int(cubit.get_geometry_owner("quad", quad_id).split()[1])
285
+ normal = cubit.get_surface_normal(surface_id)
286
+ node_list = cubit.get_connectivity('quad',quad_id)
287
+ if normal[2] > 0:
288
+ 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")
289
+ else:
290
+ 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")
385
291
  edge_list = cubit.get_block_edges(block_id)
386
- if len(edge_list)>0:
387
- for edge_id in edge_list:
388
- element_id += 1
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")
292
+ for edge_id in edge_list:
293
+ element_id += 1
294
+ node_list = cubit.get_connectivity('edge', edge_id)
295
+ fid.write(f"CROD {element_id:<8}{block_id:<8}{node_list[0]:<8}{node_list[1]:<8}\n")
296
+ node_list = cubit.get_block_nodes(block_id)
297
+ for node_id in node_list:
298
+ element_id += 1
299
+ fid.write(f"CMASS {element_id:<8}{block_id:<8}{node_id:<8}\n")
392
300
  fid.write("$\n")
393
301
  fid.write("$ Property cards\n")
394
302
  fid.write("$\n")
@@ -397,8 +305,16 @@ def export_3D_Nastran(cubit, FileName, PYRAM=True):
397
305
  name = cubit.get_exodus_entity_name("block",block_id)
398
306
  fid.write("$\n")
399
307
  fid.write(f"$ Name: {name}\n")
308
+ if len(cubit.get_block_nodes(block_id)) > 0:
309
+ fid.write(f"PMASS {block_id:< 8}{block_id:< 8}\n")
310
+ elif len(cubit.get_block_edges(block_id)) > 0:
311
+ fid.write(f"PROD {block_id:< 8}{block_id:< 8}\n")
312
+ elif len(cubit.get_block_tris(block_id)) + len(cubit.get_block_faces(block_id))> 0:
313
+ fid.write(f"PSHELL {block_id:< 8}{block_id:< 8}\n")
314
+ else:
315
+ fid.write(f"PSOLID {block_id:< 8}{block_id:< 8}\n")
400
316
  fid.write("$\n")
401
- fid.write(f"MAT1 {block_id:< 8}{1:<8}{1:<8}{1:<8}\n")
317
+
402
318
  fid.write("ENDDATA\n")
403
319
  fid.close()
404
320
  return cubit
@@ -441,29 +357,30 @@ def export_meg(cubit, FileName, DIM='T', MGR2=[]):
441
357
  for block_id in cubit.get_block_id_list():
442
358
  name = cubit.get_exodus_entity_name("block",block_id)
443
359
 
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")
360
+ if DIM=='T':
361
+ tet_list = cubit.get_block_tets(block_id)
362
+ for tet_id in tet_list:
363
+ node_list = cubit.get_connectivity('tet',tet_id)
364
+ element_id += 1
365
+ 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
366
 
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")
367
+ hex_list = cubit.get_block_hexes(block_id)
368
+ for hex_id in hex_list:
369
+ node_list = cubit.get_connectivity('hex',hex_id)
370
+ element_id += 1
371
+ 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
372
 
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")
373
+ wedge_list = cubit.get_block_wedges(block_id)
374
+ for wedge_id in wedge_list:
375
+ node_list = cubit.get_connectivity('wedge',wedge_id)
376
+ element_id += 1
377
+ 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
378
 
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")
379
+ pyramid_list = cubit.get_block_pyramids(block_id)
380
+ for pyramid_id in pyramid_list:
381
+ node_list = cubit.get_connectivity('pyramid',pyramid_id)
382
+ element_id += 1
383
+ 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
384
 
468
385
  tri_list = cubit.get_block_tris(block_id)
469
386
  for tri_id in tri_list:
@@ -483,6 +400,11 @@ def export_meg(cubit, FileName, DIM='T', MGR2=[]):
483
400
  element_id += 1
484
401
  fid.write(f"{name[0:4]}{DIM} {element_id} 0 {block_id} {node_list[0]} {node_list[1]}\n")
485
402
 
403
+ node_list = cubit.get_block_nodes(block_id)
404
+ for node_id in node_list:
405
+ element_id += 1
406
+ fid.write(f"{name[0:4]}{DIM} {element_id} 0 {block_id} {node_id}\n")
407
+
486
408
  fid.write("* NODE\n")
487
409
  for node_id in range(len(MGR2)):
488
410
  fid.write(f"MGR2 {node_id+1} 0 {MGR2[node_id][0]} {MGR2[node_id][1]} {MGR2[node_id][2]}\n")
@@ -494,7 +416,7 @@ def export_meg(cubit, FileName, DIM='T', MGR2=[]):
494
416
  ### vtk format
495
417
  ########################################################################
496
418
 
497
- def export_vtk(cubit, FileName):
419
+ def export_vtk(cubit, FileName, ORDER="2nd"):
498
420
 
499
421
  fid = open(FileName,'w')
500
422
  fid.write('# vtk DataFile Version 3.0\n')
@@ -515,6 +437,7 @@ def export_vtk(cubit, FileName):
515
437
  tri_list = set()
516
438
  quad_list = set()
517
439
  edge_list = set()
440
+ nodes_list = set()
518
441
 
519
442
  for block_id in cubit.get_block_id_list():
520
443
  tet_list.update(cubit.get_block_tets(block_id))
@@ -524,61 +447,112 @@ def export_vtk(cubit, FileName):
524
447
  tri_list.update(cubit.get_block_tris(block_id))
525
448
  quad_list.update(cubit.get_block_faces(block_id))
526
449
  edge_list.update(cubit.get_block_edges(block_id))
450
+ nodes_list.update(cubit.get_block_nodes(block_id))
527
451
 
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' )
529
- for tet_id in tet_list:
530
- node_list = cubit.get_connectivity("tet", tet_id)
531
- fid.write(f'4 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1}\n')
532
- for hex_id in hex_list:
533
- node_list = cubit.get_connectivity("hex", hex_id)
534
- fid.write(f'8 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} {node_list[4]-1} {node_list[5]-1} {node_list[6]-1} {node_list[7]-1}\n')
535
- for wedge_id in wedge_list:
536
- node_list = cubit.get_connectivity("wedge", wedge_id)
537
- fid.write(f'6 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} {node_list[4]-1} {node_list[5]-1} \n')
538
- for pyramid_id in pyramid_list:
539
- node_list = cubit.get_connectivity("pyramid", pyramid_id)
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')
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')
452
+ if ORDER=="2nd":
453
+ 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) + len(nodes_list)} {11*len(tet_list) + 21*len(hex_list) + 16*len(wedge_list) + 14*len(pyramid_list) + 7*len(tri_list) + 9*len(quad_list) + 4*len(edge_list) + 2*len(nodes_list)}\n' )
454
+ else:
455
+ 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) + len(nodes_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) + 2*len(nodes_list)}\n' )
550
456
 
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')
552
457
  for tet_id in tet_list:
553
- fid.write('10\n')
458
+ node_list = cubit.get_expanded_connectivity("tet", tet_id)
459
+ if len(node_list)==4:
460
+ fid.write(f'4 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1}\n')
461
+ if len(node_list)==10:
462
+ fid.write(f'10 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} {node_list[4]-1} {node_list[5]-1} {node_list[6]-1} {node_list[7]-1} {node_list[8]-1} {node_list[9]-1}\n')
554
463
  for hex_id in hex_list:
555
- fid.write('12\n')
464
+ node_list = cubit.get_expanded_connectivity("hex", hex_id)
465
+ if len(node_list)==8:
466
+ fid.write(f'8 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} {node_list[4]-1} {node_list[5]-1} {node_list[6]-1} {node_list[7]-1}\n')
467
+ if len(node_list)==20:
468
+ fid.write(f'20 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} {node_list[4]-1} {node_list[5]-1} {node_list[6]-1} {node_list[7]-1} {node_list[8]-1} {node_list[9]-1} {node_list[10]-1} {node_list[11]-1} {node_list[16]-1} {node_list[17]-1} {node_list[18]-1} {node_list[19]-1} {node_list[12]-1} {node_list[13]-1} {node_list[14]-1} {node_list[15]-1}\n')
556
469
  for wedge_id in wedge_list:
557
- fid.write('13\n')
470
+ node_list = cubit.get_expanded_connectivity("wedge", wedge_id)
471
+ if len(node_list)==6:
472
+ fid.write(f'6 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} {node_list[4]-1} {node_list[5]-1} \n')
473
+ if len(node_list)==15:
474
+ fid.write(f'15 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} {node_list[4]-1} {node_list[5]-1} {node_list[6]-1} {node_list[7]-1} {node_list[8]-1} {node_list[12]-1} {node_list[13]-1} {node_list[14]-1} {node_list[9]-1} {node_list[10]-1} {node_list[11]-1} \n')
475
+
558
476
  for pyramid_id in pyramid_list:
559
- fid.write('14\n')
477
+ node_list = cubit.get_expanded_connectivity("pyramid", pyramid_id)
478
+ if len(node_list)==5:
479
+ 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')
480
+ if len(node_list)==13:
481
+ fid.write(f'13 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} {node_list[4]-1} {node_list[5]-1} {node_list[6]-1} {node_list[7]-1} {node_list[8]-1} {node_list[9]-1} {node_list[10]-1} {node_list[11]-1} {node_list[12]-1} \n')
560
482
  for tri_id in tri_list:
561
- fid.write('5\n')
483
+ node_list = cubit.get_expanded_connectivity("tri", tri_id)
484
+ if len(node_list)==3:
485
+ fid.write(f'3 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} \n')
486
+ if len(node_list)==6:
487
+ fid.write(f'6 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} {node_list[4]-1} {node_list[5]-1} \n')
562
488
  for quad_id in quad_list:
563
- fid.write('9\n')
489
+ node_list = cubit.get_expanded_connectivity("quad", quad_id)
490
+ if len(node_list)==4:
491
+ fid.write(f'4 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} \n')
492
+ if len(node_list)==8:
493
+ fid.write(f'8 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} {node_list[3]-1} {node_list[4]-1} {node_list[5]-1} {node_list[6]-1} {node_list[7]-1}\n')
564
494
  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')
495
+ node_list = cubit.get_expanded_connectivity("edge", edge_id)
496
+ if len(node_list)==2:
497
+ fid.write(f'2 {node_list[0]-1} {node_list[1]-1} \n')
498
+ if len(node_list)==3:
499
+ fid.write(f'3 {node_list[0]-1} {node_list[1]-1} {node_list[2]-1} \n')
500
+ for node_id in nodes_list:
501
+ fid.write(f'1 {node_id-1} \n')
502
+
503
+ 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) + len(nodes_list)}\n')
504
+ if ORDER=="2nd":
505
+ for tet_id in tet_list:
506
+ fid.write('24\n')
507
+ for hex_id in hex_list:
508
+ fid.write('25\n')
509
+ for wedge_id in wedge_list:
510
+ fid.write('26\n')
511
+ for pyramid_id in pyramid_list:
512
+ fid.write('27\n')
513
+ for tri_id in tri_list:
514
+ fid.write('22\n')
515
+ for quad_id in quad_list:
516
+ fid.write('23\n')
517
+ for edge_id in edge_list:
518
+ fid.write('21\n')
519
+ for node_id in nodes_list:
520
+ fid.write('1\n')
521
+ else:
522
+ for tet_id in tet_list:
523
+ fid.write('10\n')
524
+ for hex_id in hex_list:
525
+ fid.write('12\n')
526
+ for wedge_id in wedge_list:
527
+ fid.write('13\n')
528
+ for pyramid_id in pyramid_list:
529
+ fid.write('14\n')
530
+ for tri_id in tri_list:
531
+ fid.write('5\n')
532
+ for quad_id in quad_list:
533
+ fid.write('9\n')
534
+ for edge_id in edge_list:
535
+ fid.write('3\n')
536
+ for node_id in nodes_list:
537
+ fid.write('1\n')
538
+ 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) + len(nodes_list)}\n')
567
539
  fid.write('SCALARS scalars float\n')
568
540
  fid.write('LOOKUP_TABLE default\n')
569
541
  for tet_id in tet_list:
570
- fid.write(f'{4}\n')
542
+ fid.write('1\n')
571
543
  for hex_id in hex_list:
572
- fid.write(f'{8}\n')
544
+ fid.write('2\n')
573
545
  for wedge_id in wedge_list:
574
- fid.write(f'{6}\n')
546
+ fid.write('3\n')
575
547
  for pyramid_id in pyramid_list:
576
- fid.write(f'{5}\n')
548
+ fid.write('4\n')
577
549
  for tri_id in tri_list:
578
- fid.write(f'{3}\n')
550
+ fid.write('5\n')
579
551
  for quad_id in quad_list:
580
- fid.write(f'{4}\n')
552
+ fid.write('6\n')
581
553
  for edge_id in edge_list:
582
- fid.write(f'{2}\n')
554
+ fid.write('0\n')
555
+ for node_id in nodes_list:
556
+ fid.write('-1\n')
583
557
  return cubit
584
558
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "Coreform_Cubit_Mesh_Export"
7
- version = "1.1.1"
7
+ version = "1.3"
8
8
  authors = [
9
9
  {name = "Kengo Sugahara", email = "ksugahar@gmail.com"},
10
10
  ]