2 cubit.cmd(
'set developer commands on')
3 cubit.cmd(
'set duplicate block elements on')
5 one_master_node =
False
7 cubit.cmd(
'brick x 0.5 y 0.05 z 0.02')
9 cubit.cmd(
'block 1 add volume 1')
10 cubit.cmd(
'block 1 name "BODY_FORCE"')
11 cubit.cmd(
'block 1 attribute count 3')
12 cubit.cmd(
'block 1 attribute index 1 0')
13 cubit.cmd(
'block 1 attribute index 2 -1 ')
14 cubit.cmd(
'block 1 attribute index 2 0')
16 cubit.cmd(
'block 3 add surface 4 ')
17 cubit.cmd(
'block 3 name "FIX_ALL"')
19 cubit.cmd(
'block 4 add volume 1')
20 cubit.cmd(
'block 4 name "MAT_ELASTIC"')
21 cubit.cmd(
'block 4 attribute count 2')
22 cubit.cmd(
'block 4 attribute index 1 100')
23 cubit.cmd(
'block 4 attribute index 2 0.3')
25 cubit.cmd(
'webcut volume 1 with plane xplane offset 0.05')
26 cubit.cmd(
'webcut volume 2 with plane xplane offset 0')
28 cubit.cmd(
'delete volume 2')
30 cubit.cmd(
'volume all scheme tetmesh')
31 cubit.cmd(
'surface 22 size auto factor 9')
32 cubit.cmd(
'mesh surface 22 ')
33 cubit.cmd(
'volume all size auto factor 8')
35 cubit.cmd(
'#copy mesh surface 22 onto surface 7 source curve 38 source vertex 22 target curve 15 target vertex 12 mirror ')
36 cubit.cmd(
'#mesh surface 7')
38 cubit.cmd(
'surface 7 scheme copy source surface 22 source vertex 22 target vertex 12 source curve 38 target curve 15 ')
39 cubit.cmd(
'mesh surface 7')
40 cubit.cmd(
'mesh volume all')
43 node_list1 = cubit.parse_cubit_list(
"node",
"all in surface 22")
44 node_list2 = cubit.parse_cubit_list(
"node",
"all in surface 7")
46 if len(node_list1) != len(node_list2):
47 print(
"ERROR: node list size in surface 7 and surface 22 are different")
49 if one_master_node ==
True:
50 node_list2 = node_list2[:1]
57 for id1
in node_list1:
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:
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)
76 edge_id = cubit.get_last_id(
"edge")
77 edges_ids.append(edge_id)
84 cubit.cmd(
'merge all')
86 curve_list =
' '.join(map(str, curve_ids))
88 cubit.cmd(
'curve {} interval 1'.format(curve_list))
89 cubit.cmd(
'mesh curve {}'.format(curve_list))
94 cubit.cmd(
'equivalence node all tolerance 0.001 force')
98 edge_list2 = cubit.parse_cubit_list(
"edge",
"all in curve {} ".format(curve_list))
99 edge_list =
' '.join(map(str, edges_ids))
100 edge_list =
' '.join(map(str, edge_list2))
102 cubit.cmd(
'block 4 add edge {}'.format(edge_list))
104 cubit.cmd(
'block 4 name "MPC_COUPLING_LINKS4"')
110 cubit.cmd(
'save as "/home/my_user/Desktop/beam3D_MPCs.cub" overwrite')
112 if 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')
122 cubit.cmd(
'block 5 add surface {}'.format(22))
123 cubit.cmd(
'block 5 name "MPC_COUPLING_MASTER4"')
129 cubit.cmd(
'save as "/home/my_user/Desktop/beam3D_MPCs_MASTER.cub" overwrite')