v0.14.0
Loading...
Searching...
No Matches
create_mesh_links.py
Go to the documentation of this file.
1cubit.cmd('reset')
2cubit.cmd('set developer commands on')
3cubit.cmd('set duplicate block elements on')
4
5one_master_node = False
6
7cubit.cmd('brick x 0.5 y 0.05 z 0.02')
8
9cubit.cmd('block 1 add volume 1')
10cubit.cmd('block 1 name "BODY_FORCE"')
11cubit.cmd('block 1 attribute count 3')
12cubit.cmd('block 1 attribute index 1 0')
13cubit.cmd('block 1 attribute index 2 -1 ')
14cubit.cmd('block 1 attribute index 2 0')
15
16cubit.cmd('block 3 add surface 4 ')
17cubit.cmd('block 3 name "FIX_ALL"')
18
19cubit.cmd('block 4 add volume 1')
20cubit.cmd('block 4 name "MAT_ELASTIC"')
21cubit.cmd('block 4 attribute count 2')
22cubit.cmd('block 4 attribute index 1 100')
23cubit.cmd('block 4 attribute index 2 0.3')
24
25cubit.cmd('webcut volume 1 with plane xplane offset 0.05')
26cubit.cmd('webcut volume 2 with plane xplane offset 0')
27
28cubit.cmd('delete volume 2')
29
30cubit.cmd('volume all scheme tetmesh')
31cubit.cmd('surface 22 size auto factor 9')
32cubit.cmd('mesh surface 22 ')
33cubit.cmd('volume all size auto factor 8')
34
35cubit.cmd('#copy mesh surface 22 onto surface 7 source curve 38 source vertex 22 target curve 15 target vertex 12 mirror ')
36cubit.cmd('#mesh surface 7')
37
38cubit.cmd('surface 7 scheme copy source surface 22 source vertex 22 target vertex 12 source curve 38 target curve 15 ')
39cubit.cmd('mesh surface 7')
40cubit.cmd('mesh volume all')
41
42
43node_list1 = cubit.parse_cubit_list("node", "all in surface 22")
44node_list2 = cubit.parse_cubit_list("node", "all in surface 7")
45
46if len(node_list1) != len(node_list2):
47 print("ERROR: node list size in surface 7 and surface 22 are different")
48
49if one_master_node == True:
50 node_list2 = node_list2[:1]
51 # cubit.cmd('delete volume 1')
52
53
54edges_ids = []
55curve_ids = []
56
57for id1 in node_list1:
58 shortest_edge = 1e16
59 shortest_id2 = None
60 for id2 in node_list2:
61 cubit.cmd('create edge node {} {}'.format(id1, id2))
62 edge_id = cubit.get_last_id("edge")
63 dist = cubit.get_mesh_edge_length(edge_id)
64 cubit.cmd('delete edge {}'.format(edge_id))
65 if dist < shortest_edge:
66 shortest_id2 = id2
67 shortest_edge = dist
68 if shortest_id2 is not None:
69 cubit.cmd('create curve location at node {} location at node {} '.format(id1, shortest_id2))
70 curve_id = cubit.get_last_id("curve")
71 curve_ids.append(curve_id)
72 #cubit.cmd('create edge node {} {} owner curve {}'.format(id1, shortest_id2, curve_id))
73 # cubit.cmd('create edge node {} {}'.format(id1, shortest_id2))
74 # cubit.cmd('block 4 joint node {} spider node {} element type beam'.format(id1, shortest_id2))
75
76 edge_id = cubit.get_last_id("edge")
77 edges_ids.append(edge_id)
78
79
80print(curve_ids)
81print(edges_ids)
82
83print("we are done")
84cubit.cmd('merge all')
85
86curve_list = ' '.join(map(str, curve_ids))
87
88cubit.cmd('curve {} interval 1'.format(curve_list))
89cubit.cmd('mesh curve {}'.format(curve_list))
90cubit.cmd('')
91
92#cubit.cmd('disassociate mesh from volume all ')
93#cubit.cmd('disassociate mesh from curve all ')
94cubit.cmd('equivalence node all tolerance 0.001 force')
95#cubit.cmd('delete volume all ')
96#cubit.cmd('delete curve all ')
97
98edge_list2 = cubit.parse_cubit_list("edge", "all in curve {} ".format(curve_list))
99edge_list = ' '.join(map(str, edges_ids))
100edge_list = ' '.join(map(str, edge_list2))
101
102cubit.cmd('block 4 add edge {}'.format(edge_list))
103
104cubit.cmd('block 4 name "MPC_COUPLING_LINKS4"')
105
106#renumber Edge all start_id 99999
107#renumber Edge all start_id 1
108
109
110cubit.cmd('save as "/home/my_user/Desktop/beam3D_MPCs.cub" overwrite')
111
112if one_master_node == True:
113 cubit.cmd('delete volume 1')
114 cubit.cmd('create force on vertex 26 vector 1 0 0 0 0 0')
115 cubit.cmd('block 5 add node {}'.format(22))
116 cubit.cmd('block 5 add vertex {}'.format(26))
117 cubit.cmd('block 5 name "MPC_COUPLING_MASTER4"')
118 cubit.cmd('save as "/home/my_user/Desktop/beam3D_MPCs_MASTER_SINGLE.cub" overwrite')
119
120
121#cubit.cmd('block 5 add node all in surface {}'.format(22))
122cubit.cmd('block 5 add surface {}'.format(22))
123cubit.cmd('block 5 name "MPC_COUPLING_MASTER4"')
124
125#cubit.cmd('block 6 add surface {}'.format(7))
126#cubit.cmd('block 6 name "MPC_COUPLING_SLAVE4"')
127
128
129cubit.cmd('save as "/home/my_user/Desktop/beam3D_MPCs_MASTER.cub" overwrite')