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
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
########################################################################
|
|
2
|
+
### Lukas FEM 2D file
|
|
3
|
+
########################################################################
|
|
4
|
+
|
|
5
|
+
def export_2D_geo_mesh(cubit, FileName):
|
|
6
|
+
|
|
7
|
+
import numpy
|
|
8
|
+
import scipy.io
|
|
9
|
+
|
|
10
|
+
nodes = []
|
|
11
|
+
node_list = []
|
|
12
|
+
|
|
13
|
+
N = cubit.get_node_count()
|
|
14
|
+
M = cubit.get_tri_count()
|
|
15
|
+
|
|
16
|
+
node_list = set()
|
|
17
|
+
for block_id in cubit.get_block_id_list():
|
|
18
|
+
elem_types = ["hex", "tet", "wedge", "pyramid"]
|
|
19
|
+
for elem_type in elem_types:
|
|
20
|
+
if elem_type == "hex":
|
|
21
|
+
func = getattr(cubit, f"get_block_{elem_type}es")
|
|
22
|
+
else:
|
|
23
|
+
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
24
|
+
for element_id in func(block_id):
|
|
25
|
+
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
26
|
+
node_list.update(node_ids)
|
|
27
|
+
for node_id in node_list:
|
|
28
|
+
coord = cubit.get_nodal_coordinates(node_id)
|
|
29
|
+
nodes.append([coord[0],coord[1]])
|
|
30
|
+
|
|
31
|
+
for nodeset_id in cubit.get_nodeset_id_list():
|
|
32
|
+
name = cubit.get_exodus_entity_name("nodeset",nodeset_id)
|
|
33
|
+
curve_list = cubit.get_nodeset_curves(nodeset_id)
|
|
34
|
+
node_list = []
|
|
35
|
+
for curve_id in curve_list:
|
|
36
|
+
node_list += cubit.get_curve_nodes(curve_id)
|
|
37
|
+
nodeset = numpy.array([(name, node_list)], dtype=[('name', 'U20'), ('DBCnodes', 'O')])
|
|
38
|
+
try:
|
|
39
|
+
nodesets = append(nodesets,nodeset)
|
|
40
|
+
except:
|
|
41
|
+
nodesets = nodeset
|
|
42
|
+
|
|
43
|
+
conn_matrix = numpy.zeros((M,3))
|
|
44
|
+
center_x = numpy.zeros((M))
|
|
45
|
+
center_y = numpy.zeros((M))
|
|
46
|
+
block_count = cubit.get_block_count()
|
|
47
|
+
regions = numpy.rec.array([("", [], [])]*(block_count), dtype=[('name', 'U20'), ('Elements', 'O'), ('Nodes', 'O')])
|
|
48
|
+
|
|
49
|
+
for block_id in cubit.get_block_id_list():
|
|
50
|
+
Elements = []
|
|
51
|
+
name = cubit.get_exodus_entity_name("block",block_id)
|
|
52
|
+
surface_list = cubit.get_block_surfaces(block_id)
|
|
53
|
+
Nodes = []
|
|
54
|
+
Elements = []
|
|
55
|
+
for surface_id in surface_list:
|
|
56
|
+
tri_list = cubit.get_surface_tris(surface_id)
|
|
57
|
+
Elements += tri_list
|
|
58
|
+
for tri_id in tri_list:
|
|
59
|
+
x = []
|
|
60
|
+
y = []
|
|
61
|
+
node_list = cubit.get_connectivity('tri',tri_id)
|
|
62
|
+
Nodes += node_list
|
|
63
|
+
conn_matrix[tri_id-1,:] = node_list
|
|
64
|
+
for node_id in node_list:
|
|
65
|
+
coord = cubit.get_nodal_coordinates(node_id)
|
|
66
|
+
x.append(coord[0])
|
|
67
|
+
y.append(coord[1])
|
|
68
|
+
center_x[tri_id-1] = numpy.mean(x)
|
|
69
|
+
center_y[tri_id-1] = numpy.mean(y)
|
|
70
|
+
regions[block_id-1][0] = name
|
|
71
|
+
regions[block_id-1][1] = Elements
|
|
72
|
+
regions[block_id-1][2] = Nodes
|
|
73
|
+
|
|
74
|
+
geo = {'conn_matrix':conn_matrix, 'nodes':nodes, 'M':M, 'N':N, 'nodesets':nodesets , 'center_x':center_x, 'center_y':center_y, 'regions':regions }
|
|
75
|
+
scipy.io.savemat(FileName, {'geo': geo}, format='5', long_field_names=True)
|
|
76
|
+
return cubit
|
|
77
|
+
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
########################################################################
|
|
2
|
+
### 3D CDB file
|
|
3
|
+
########################################################################
|
|
4
|
+
|
|
5
|
+
def export_3D_CDB(cubit, FileName):
|
|
6
|
+
|
|
7
|
+
fid = open(FileName,'w',encoding='UTF-8')
|
|
8
|
+
fid.write(f'/COM,ANSYS RELEASE 15.0\n')
|
|
9
|
+
fid.write(f'! Exported from Coreform Cubit 2024.3\n')
|
|
10
|
+
fid.write(f'! {datetime.now().strftime("%Y/%m/%d %I:%M:%S %p")}\n')
|
|
11
|
+
fid.write(f'/PREP7\n')
|
|
12
|
+
fid.write(f'/TITLE,\n')
|
|
13
|
+
fid.write(f'*IF,_CDRDOFF,EQ,1,THEN\n')
|
|
14
|
+
fid.write(f'_CDRDOFF= \n')
|
|
15
|
+
fid.write(f'*ELSE\n')
|
|
16
|
+
fid.write(f'NUMOFF,NODE, {node_count:8d}\n')
|
|
17
|
+
fid.write(f'NUMOFF,ELEM, {elem_count:8d}\n')
|
|
18
|
+
fid.write(f'NUMOFF,TYPE, 1\n')
|
|
19
|
+
fid.write(f'*ENDIF\n')
|
|
20
|
+
fid.write(f'DOF,DELETE\n')
|
|
21
|
+
fid.write(f'ET, 1,185\n')
|
|
22
|
+
fid.write(f'NBLOCK,6,SOLID, {node_count:8d}, {node_count:8d}\n')
|
|
23
|
+
fid.write(f'(3i9,6e20.13)\n')
|
|
24
|
+
|
|
25
|
+
node_list = set()
|
|
26
|
+
for block_id in cubit.get_block_id_list():
|
|
27
|
+
elem_types = ["hex", "tet", "wedge", "pyramid"]
|
|
28
|
+
for elem_type in elem_types:
|
|
29
|
+
if elem_type == "hex":
|
|
30
|
+
func = getattr(cubit, f"get_block_{elem_type}es")
|
|
31
|
+
else:
|
|
32
|
+
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
33
|
+
for element_id in func(block_id):
|
|
34
|
+
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
35
|
+
node_list.update(node_ids)
|
|
36
|
+
fid.write(f'{len(node_list)}\n')
|
|
37
|
+
for node_id in node_list:
|
|
38
|
+
coord = cubit.get_nodal_coordinates(node_id)
|
|
39
|
+
fid.write(f'{node_id:9d}{0:9d}{0:9d}{coord[0]:20.13e}{coord[1]:20.13e}{coord[2]:20.13e}\n')
|
|
40
|
+
|
|
41
|
+
fid.write(f'N,R5.3,LOC, -1\n')
|
|
42
|
+
elem_count = 0
|
|
43
|
+
for block_id in cubit.get_block_id_list():
|
|
44
|
+
fid.write(f'EBLOCK, 19, SOLID\n')
|
|
45
|
+
fid.write(f'(19i9)\n')
|
|
46
|
+
for volume_id in cubit.get_block_volumes(block_id):
|
|
47
|
+
hex_list = cubit.get_volume_hexes(volume_id)
|
|
48
|
+
if len(hex_list)>0:
|
|
49
|
+
for hex_id in hex_list:
|
|
50
|
+
elem_count += 1
|
|
51
|
+
node_list = cubit.get_connectivity("hex", hex_id)
|
|
52
|
+
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')
|
|
53
|
+
wedge_list = cubit.get_volume_wedges(volume_id)
|
|
54
|
+
if len(wedge_list)>0:
|
|
55
|
+
for wedge_id in wedge_list:
|
|
56
|
+
elem_count += 1
|
|
57
|
+
node_list = cubit.get_connectivity("wedge", wedge_id)
|
|
58
|
+
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')
|
|
59
|
+
tet_list = cubit.get_volume_tets(volume_id)
|
|
60
|
+
if len(tet_list)>0:
|
|
61
|
+
for tet_id in tet_list:
|
|
62
|
+
elem_count += 1
|
|
63
|
+
node_list = cubit.get_connectivity("tet", tet_id)
|
|
64
|
+
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')
|
|
65
|
+
pyramid_list = cubit.get_volume_pyramids(volume_id)
|
|
66
|
+
if len(pyramid_list)>0:
|
|
67
|
+
for pyramid_id in pyramid_list:
|
|
68
|
+
elem_count += 1
|
|
69
|
+
node_list = cubit.get_connectivity("pyramid", pyramid_id)
|
|
70
|
+
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')
|
|
71
|
+
fid.write(f' -1\n')
|
|
72
|
+
|
|
73
|
+
for block_id in cubit.get_block_id_list():
|
|
74
|
+
name = cubit.get_exodus_entity_name("block",block_id)
|
|
75
|
+
elem_list = []
|
|
76
|
+
volume_list = cubit.get_block_volumes(block_id)
|
|
77
|
+
for volume_id in volume_list:
|
|
78
|
+
hex_list = cubit.get_volume_hexes(volume_id)
|
|
79
|
+
elem_list.extend(hex_list)
|
|
80
|
+
wedge_list = cubit.get_volume_wedges(volume_id)
|
|
81
|
+
elem_list.extend(wedge_list)
|
|
82
|
+
tet_list = cubit.get_volume_tets(volume_id)
|
|
83
|
+
elem_list.extend(tet_list)
|
|
84
|
+
pyramid_list = cubit.get_volume_pyramids(volume_id)
|
|
85
|
+
elem_list.extend(pyramid_list)
|
|
86
|
+
fid.write(f'CMBLOCK,{name:<8},ELEM,{len(elem_list):8d}\n')
|
|
87
|
+
fid.write(f'(8i10)\n')
|
|
88
|
+
for n in range(0, len(elem_list), 8):
|
|
89
|
+
strLine = ""
|
|
90
|
+
for m in range(n, min(n+8, len(elem_list))):
|
|
91
|
+
strLine += f'{elem_list[m]:10d}'
|
|
92
|
+
fid.write(f'{strLine}\n')
|
|
93
|
+
|
|
94
|
+
for nodeset_id in cubit.get_nodeset_id_list():
|
|
95
|
+
name = cubit.get_exodus_entity_name("nodeset",nodeset_id)
|
|
96
|
+
|
|
97
|
+
node_list.clear()
|
|
98
|
+
for block_id in cubit.get_block_id_list():
|
|
99
|
+
elem_types = ["tri", "quad"]
|
|
100
|
+
for elem_type in elem_types:
|
|
101
|
+
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
102
|
+
for element_id in func(block_id):
|
|
103
|
+
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
104
|
+
node_list.update(node_ids)
|
|
105
|
+
|
|
106
|
+
fid.write(f'CMBLOCK,{name:<8},NODE,{len(node_list):8d}\n')
|
|
107
|
+
fid.write(f'(8i10)\n')
|
|
108
|
+
node_list = list(node_list)
|
|
109
|
+
for n in range(0, len(node_list), 8):
|
|
110
|
+
strLine = ""
|
|
111
|
+
for m in range(n, min(n+8, len(node_list))):
|
|
112
|
+
strLine += f'{node_list[m]:10d}'
|
|
113
|
+
fid.write(f'{strLine}\n')
|
|
114
|
+
return cubit
|
|
115
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
node_count = cubit.get_node_count()
|
|
10
|
+
|
|
11
|
+
with open(FileName, 'w') as fid:
|
|
12
|
+
fid.write("MeshVersionFormatted 2\n")
|
|
13
|
+
fid.write("\n")
|
|
14
|
+
fid.write("Dimension 3\n")
|
|
15
|
+
fid.write("\n")
|
|
16
|
+
fid.write("Vertices\n")
|
|
17
|
+
fid.write(f'{node_count}\n')
|
|
18
|
+
node_list = set()
|
|
19
|
+
for block_id in cubit.get_block_id_list():
|
|
20
|
+
elem_types = ["hex", "tet", "wedge", "pyramid", "tri", "face"]
|
|
21
|
+
for elem_type in elem_types:
|
|
22
|
+
if elem_type == "hex":
|
|
23
|
+
func = getattr(cubit, f"get_block_{elem_type}es")
|
|
24
|
+
else:
|
|
25
|
+
func = getattr(cubit, f"get_block_{elem_type}s")
|
|
26
|
+
for element_id in func(block_id):
|
|
27
|
+
node_ids = cubit.get_connectivity(elem_type, element_id)
|
|
28
|
+
node_list.update(node_ids)
|
|
29
|
+
for node_id in node_list:
|
|
30
|
+
coord = cubit.get_nodal_coordinates(node_id)
|
|
31
|
+
fid.write(f'{coord[0]} {coord[1]} {coord[2]} {0}\n')
|
|
32
|
+
fid.write("\n")
|
|
33
|
+
fid.write("Tetrahedra\n")
|
|
34
|
+
tet_list = set()
|
|
35
|
+
for block_id in cubit.get_block_id_list():
|
|
36
|
+
tet_list.update(cubit.get_block_tets(block_id))
|
|
37
|
+
fid.write(f'{len(tet_list)}\n')
|
|
38
|
+
for block_id in cubit.get_block_id_list():
|
|
39
|
+
tet_list = cubit.get_block_tets(block_id)
|
|
40
|
+
if len(tet_list)>0:
|
|
41
|
+
for tet_id in tet_list:
|
|
42
|
+
node_list = cubit.get_connectivity("tet", tet_id)
|
|
43
|
+
fid.write(f'{node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {block_id}\n')
|
|
44
|
+
|
|
45
|
+
fid.write("Triangles\n")
|
|
46
|
+
tri_list = set()
|
|
47
|
+
for block_id in cubit.get_block_id_list():
|
|
48
|
+
tri_list.update(cubit.get_block_tris(block_id))
|
|
49
|
+
fid.write(f'{len(tri_list)}\n')
|
|
50
|
+
for block_id in cubit.get_block_id_list():
|
|
51
|
+
tet_list = cubit.get_block_tets(block_id)
|
|
52
|
+
if len(tri_list)>0:
|
|
53
|
+
for tri_id in tri_list:
|
|
54
|
+
node_list = cubit.get_connectivity("tri", tri_id)
|
|
55
|
+
fid.write(f'{node_list[0]} {node_list[1]} {node_list[2]} {block_id}\n')
|
|
56
|
+
fid.write("\n")
|
|
57
|
+
fid.write("End\n")
|
|
58
|
+
fid.close()
|
|
59
|
+
return cubit
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
########################################################################
|
|
2
|
+
### Gmsh format version 4
|
|
3
|
+
########################################################################
|
|
4
|
+
|
|
5
|
+
def export_3D_gmsh_ver4(cubit, FileName):
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
with open(FileName, 'w') as fid:
|
|
9
|
+
|
|
10
|
+
fid.write('$MeshFormat\n')
|
|
11
|
+
fid.write('4.1 0 8\n')
|
|
12
|
+
fid.write('$EndMeshFormat\n')
|
|
13
|
+
|
|
14
|
+
n_block_1d = 0
|
|
15
|
+
n_block_2d = 0
|
|
16
|
+
n_block_3d = 0
|
|
17
|
+
|
|
18
|
+
fid.write('$PhysicalNames\n')
|
|
19
|
+
fid.write(f'{cubit.get_block_count()}\n')
|
|
20
|
+
for block_id in cubit.get_block_id_list():
|
|
21
|
+
if len(cubit.get_block_edgess(block_id)) > 0:
|
|
22
|
+
fid.write(f'1 {block_id} "{name}"\n')
|
|
23
|
+
n_block_1d += 1
|
|
24
|
+
elif len(cubit.get_block_tris(block_id)) + len(cubit.get_block_faces(block_id))> 0:
|
|
25
|
+
fid.write(f'2 {block_id} "{name}"\n')
|
|
26
|
+
n_block_2d += 1
|
|
27
|
+
else:
|
|
28
|
+
fid.write(f'3 {block_id} "{name}"\n')
|
|
29
|
+
n_block_3d += 1
|
|
30
|
+
fid.write('$EndPhysicalNames\n')
|
|
31
|
+
fid.write('$Entities\n')
|
|
32
|
+
fid.write(f'{0} {n_block_1d} {n_block_2d} {n_block_3d}\n')
|
|
33
|
+
|
|
34
|
+
for nodeset_id in cubit.get_nodeset_id_list():
|
|
35
|
+
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
36
|
+
for surface_id in surface_list:
|
|
37
|
+
bounding_box = cubit.get_bounding_box("surface", surface_id)
|
|
38
|
+
minx = bounding_box[0]
|
|
39
|
+
maxx = bounding_box[1]
|
|
40
|
+
miny = bounding_box[3]
|
|
41
|
+
maxy = bounding_box[4]
|
|
42
|
+
minz = bounding_box[6]
|
|
43
|
+
maxz = bounding_box[7]
|
|
44
|
+
fid.write(f'{surface_id} {minx} {miny} {minz} {maxx} {maxy} {maxz} {1} {nodeset_id} {0}\n')
|
|
45
|
+
|
|
46
|
+
for block_id in cubit.get_block_id_list():
|
|
47
|
+
for volume_id in cubit.get_block_volumes(block_id):
|
|
48
|
+
bounding_box = cubit.get_bounding_box("volume", volume_id)
|
|
49
|
+
minx = bounding_box[0]
|
|
50
|
+
maxx = bounding_box[1]
|
|
51
|
+
miny = bounding_box[3]
|
|
52
|
+
maxy = bounding_box[4]
|
|
53
|
+
minz = bounding_box[6]
|
|
54
|
+
maxz = bounding_box[7]
|
|
55
|
+
fid.write(f'{volume_id} {minx} {miny} {minz} {maxx} {maxy} {maxz} {1} {block_id} {nodeset_surface_count}')
|
|
56
|
+
for nodeset_id in cubit.get_nodeset_id_list():
|
|
57
|
+
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
58
|
+
for surface_id in surface_list:
|
|
59
|
+
fid.write(f' {surface_id}')
|
|
60
|
+
fid.write(f'\n')
|
|
61
|
+
|
|
62
|
+
fid.write('$EndEntities\n')
|
|
63
|
+
|
|
64
|
+
counts = 0
|
|
65
|
+
node_all_set = set()
|
|
66
|
+
for nodeset_id in cubit.get_nodeset_id_list():
|
|
67
|
+
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
68
|
+
for surface_id in surface_list:
|
|
69
|
+
node_list = cubit.get_surface_nodes(surface_id)
|
|
70
|
+
if len(node_list) > 0:
|
|
71
|
+
node_all_set.update(node_list)
|
|
72
|
+
counts += 1
|
|
73
|
+
|
|
74
|
+
for block_id in cubit.get_block_id_list():
|
|
75
|
+
for volume_id in cubit.get_block_volumes(block_id):
|
|
76
|
+
node_list = cubit.parse_cubit_list( "node", f"in volume {volume_id}" )
|
|
77
|
+
if len(node_list) > 0:
|
|
78
|
+
node_all_set.update(node_list)
|
|
79
|
+
counts += 1
|
|
80
|
+
|
|
81
|
+
fid.write('$Nodes\n')
|
|
82
|
+
fid.write(f'{counts} {len(node_all_set)} {min(node_all_set)} {max(node_all_set)}\n')
|
|
83
|
+
|
|
84
|
+
node_all_set.clear()
|
|
85
|
+
|
|
86
|
+
for nodeset_id in cubit.get_nodeset_id_list():
|
|
87
|
+
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
88
|
+
for surface_id in surface_list:
|
|
89
|
+
node_list = cubit.get_surface_nodes(surface_id)
|
|
90
|
+
node_list = set(node_list) - node_all_set
|
|
91
|
+
if len(node_list) > 0:
|
|
92
|
+
node_all_set.update(node_list)
|
|
93
|
+
fid.write(f'2 {surface_id} 0 {len(node_list)}\n')
|
|
94
|
+
for node_id in node_list:
|
|
95
|
+
fid.write(f'{node_id}\n')
|
|
96
|
+
for node_id in node_list:
|
|
97
|
+
coord = cubit.get_nodal_coordinates(node_id)
|
|
98
|
+
fid.write(f'{coord[0]} {coord[1]} {coord[2]}\n')
|
|
99
|
+
|
|
100
|
+
for block_id in cubit.get_block_id_list():
|
|
101
|
+
for volume_id in cubit.get_block_volumes(block_id):
|
|
102
|
+
node_list = cubit.parse_cubit_list( "node", f"in volume {volume_id}" )
|
|
103
|
+
node_list = set(node_list) - node_all_set
|
|
104
|
+
if len(node_list) > 0:
|
|
105
|
+
node_all_set.update(node_list)
|
|
106
|
+
fid.write(f'3 {volume_id} 0 {len(node_list)}\n')
|
|
107
|
+
for node_id in node_list:
|
|
108
|
+
fid.write(f'{node_id}\n')
|
|
109
|
+
for node_id in node_list:
|
|
110
|
+
coord = cubit.get_nodal_coordinates(node_id)
|
|
111
|
+
fid.write(f'{coord[0]} {coord[1]} {coord[2]}\n')
|
|
112
|
+
|
|
113
|
+
fid.write('$EndNodes\n')
|
|
114
|
+
|
|
115
|
+
tri_all_list = []
|
|
116
|
+
quad_all_list = []
|
|
117
|
+
tet_all_list = []
|
|
118
|
+
hex_all_list = []
|
|
119
|
+
wedge_all_list = []
|
|
120
|
+
|
|
121
|
+
fid.write('$Elements\n')
|
|
122
|
+
|
|
123
|
+
for nodeset_id in cubit.get_nodeset_id_list():
|
|
124
|
+
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
125
|
+
for surface_id in surface_list:
|
|
126
|
+
tri_all_list += cubit.get_surface_tris(surface_id)
|
|
127
|
+
quad_all_list += cubit.get_surface_quads(surface_id)
|
|
128
|
+
|
|
129
|
+
for block_id in cubit.get_block_id_list():
|
|
130
|
+
for volume_id in cubit.get_block_volumes(block_id):
|
|
131
|
+
tet_all_list += cubit.get_volume_tets(volume_id)
|
|
132
|
+
hex_all_list += cubit.get_volume_hexes(volume_id)
|
|
133
|
+
wedge_all_list += cubit.get_volume_wedges(volume_id)
|
|
134
|
+
|
|
135
|
+
elementTag = 1
|
|
136
|
+
|
|
137
|
+
all_list = quad_all_list + tri_all_list + hex_all_list + tet_all_list + wedge_all_list
|
|
138
|
+
if len(all_list) > 0:
|
|
139
|
+
fid.write(f'{ nodeset_surface_count + block_volume_count} {len(all_list)} {min(all_list)} {max(all_list)}\n')
|
|
140
|
+
else:
|
|
141
|
+
fid.write(f'{ nodeset_surface_count + block_volume_count} 0 0 0\n')
|
|
142
|
+
|
|
143
|
+
for nodeset_id in cubit.get_nodeset_id_list():
|
|
144
|
+
surface_list = cubit.get_nodeset_surfaces(nodeset_id)
|
|
145
|
+
for surface_id in surface_list:
|
|
146
|
+
tri_list = cubit.get_surface_tris(surface_id)
|
|
147
|
+
if len(tri_list)>0:
|
|
148
|
+
fid.write(f'2 {surface_id} 2 {len(tri_list)}\n')
|
|
149
|
+
for tri_id in tri_list:
|
|
150
|
+
node_list = cubit.get_connectivity("tri", tri_id)
|
|
151
|
+
elementTag +=1
|
|
152
|
+
fid.write(f'{elementTag} {node_list[0]} {node_list[1]} {node_list[2]}\n')
|
|
153
|
+
|
|
154
|
+
quad_list = cubit.get_surface_quads(surface_id)
|
|
155
|
+
if len(quad_list)>0:
|
|
156
|
+
fid.write(f'2 {surface_id} 3 {len(quad_list)}\n')
|
|
157
|
+
for quad_id in quad_list:
|
|
158
|
+
node_list = cubit.get_connectivity("quad", quad_id)
|
|
159
|
+
elementTag +=1
|
|
160
|
+
fid.write(f'{elementTag} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n')
|
|
161
|
+
|
|
162
|
+
for block_id in cubit.get_block_id_list():
|
|
163
|
+
for volume_id in cubit.get_block_volumes(block_id):
|
|
164
|
+
tet_list = cubit.get_volume_tets(volume_id)
|
|
165
|
+
if len(tet_list)>0:
|
|
166
|
+
fid.write(f'3 {volume_id} 4 {len(tet_list)}\n')
|
|
167
|
+
for tet_id in tet_list:
|
|
168
|
+
node_list = cubit.get_connectivity("tet", tet_id)
|
|
169
|
+
elementTag +=1
|
|
170
|
+
fid.write(f'{elementTag} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]}\n')
|
|
171
|
+
|
|
172
|
+
hex_list = cubit.get_volume_hexes(volume_id)
|
|
173
|
+
if len(hex_list)>0:
|
|
174
|
+
fid.write(f'3 {volume_id} 5 {len(hex_list)}\n')
|
|
175
|
+
for hex_id in hex_list:
|
|
176
|
+
node_list = cubit.get_connectivity("hex", hex_id)
|
|
177
|
+
elementTag +=1
|
|
178
|
+
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')
|
|
179
|
+
|
|
180
|
+
wedge_list = cubit.get_volume_wedges(volume_id)
|
|
181
|
+
if len(wedge_list)>0:
|
|
182
|
+
fid.write(f'3 {volume_id} 6 {len(wedge_list)}\n')
|
|
183
|
+
for wedge_id in wedge_list:
|
|
184
|
+
node_list = cubit.get_connectivity("wedge", wedge_id)
|
|
185
|
+
elementTag +=1
|
|
186
|
+
fid.write(f'{elementTag} {node_list[0]} {node_list[1]} {node_list[2]} {node_list[3]} {node_list[4]} {node_list[5]}\n')
|
|
187
|
+
|
|
188
|
+
fid.write('$EndElements\n')
|
|
189
|
+
fid.close()
|
|
190
|
+
return cubit
|
|
191
|
+
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
cubit_mesh_export.py,sha256=4QF7fJbT-g7w2X0ZcI-5lShA8_oWSi7S92o2lN1rqXs,53053
|
|
2
|
-
coreform_cubit_mesh_export-1.0.4.dist-info/METADATA,sha256=bYO5klM6mN10SCrosZ3a1KgYAZn9Neu3qazopVsWRjc,5408
|
|
3
|
-
coreform_cubit_mesh_export-1.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
4
|
-
coreform_cubit_mesh_export-1.0.4.dist-info/top_level.txt,sha256=-K1cfrL0sGC26lWxEpEVcVu6kQQc0YQWy-noAn3rMRk,18
|
|
5
|
-
coreform_cubit_mesh_export-1.0.4.dist-info/RECORD,,
|
{coreform_cubit_mesh_export-1.0.4.dist-info → coreform_cubit_mesh_export-1.1.1.dist-info}/WHEEL
RENAMED
|
File without changes
|