2 #To create RVE for all the three type of boundary conditions, i.e. (Linear dispacemet, traction and periodic)
6 W_wrap=0.3; H_wrap=0.1514; hgap_wrap=0.09
7 W_weft=0.3; H_weft=0.0757; hgap_weft=1.2
8 L_RVE=3.0; W_RVE=0.8; H_RVE=0.3;
11 s_weft=hgap_weft+W_weft; s_wraf=hgap_wrap+W_wrap
12 T=(H_weft/2+H_wrap/2)/2+Vgap
14 L_RVE=2*s_weft; W_RVE=2*s_wraf; H_RVE=0.3;
16 coordx=-22.5*s_weft; coordy=T; coordz=0;
17 for i in range(0, 48):
19 str1='create vertex ' + str(coordx) +' '+str(coordy)+' '+str(coordz)+' color' ; coordx=coordx+s_weft;
22 str1='create vertex ' + str(coordx) +' '+str(-coordy)+' '+str(coordz)+' color' ; coordx=coordx+s_weft;
25 coordx=-22.5*s_weft; coordy=-T; coordz=s_wraf;
26 for i in range(0, 48):
28 str1='create vertex ' + str(coordx) +' '+str(coordy)+' '+str(coordz)+' color' ; coordx=coordx+s_weft;
31 str1='create vertex ' + str(coordx) +' '+str(-coordy)+' '+str(coordz)+' color' ; coordx=coordx+s_weft;
34 coordx=-0.5*s_weft; coordy=-T; coordz=-22*s_wraf;
35 for i in range(0, 48):
37 str1='create vertex ' + str(coordx) +' '+str(coordy)+' '+str(coordz)+' color' ; coordz=coordz+s_wraf;
40 str1='create vertex ' + str(coordx) +' '+str(-coordy)+' '+str(coordz)+' color' ; coordz=coordz+s_wraf;
43 coordx=0.5*s_weft; coordy=T; coordz=-22*s_wraf;
44 for i in range(0, 48):
46 str1='create vertex ' + str(coordx) +' '+str(coordy)+' '+str(coordz)+' color' ; coordz=coordz+s_wraf;
49 str1='create vertex ' + str(coordx) +' '+str(-coordy)+' '+str(coordz)+' color' ; coordz=coordz+s_wraf;
53 vertices=range(1,Tvertices+1); count1=0;
55 str1='create curve spline vertex '
56 for j in range(0, 48):
57 str1=str1+' '+ str(count1+vertices[j])
58 cubit.cmd(str1); count1=count1+48;
60 cubit.cmd('create planar surface with plane normal to curve 1 distance 0 from vertex 1')
61 str1='create curve location vertex 1 direction curve 8 length '+ str(W_wrap/2); cubit.cmd(str1)
62 str1='create curve location vertex 1 direction curve 7 length '+str(H_wrap/2); cubit.cmd(str1)
63 cubit.cmd('create surface ellipse vertex 198 200 1')
64 cubit.cmd('sweep surface 2 along curve 1')
66 cubit.cmd('create planar surface with plane normal to curve 2 distance 0 from vertex 49')
67 str1='create curve location vertex 49 direction curve 17 length '+ str(W_wrap/2); cubit.cmd(str1)
68 str1='create curve location vertex 49 direction curve 16 length '+str(H_wrap/2); cubit.cmd(str1)
69 cubit.cmd('create surface ellipse vertex 208 210 49')
70 cubit.cmd('sweep surface 6 along curve 2')
72 cubit.cmd('create planar surface with plane normal to curve 3 distance 0 from vertex 97')
73 str1='create curve location vertex 97 direction curve 24 length '+ str(W_weft/2); cubit.cmd(str1)
74 str1='create curve location vertex 97 direction curve 23 length '+str(H_weft/2); cubit.cmd(str1)
75 cubit.cmd('create surface ellipse vertex 218 220 97')
76 cubit.cmd('sweep surface 10 along curve 3')
78 cubit.cmd('create planar surface with plane normal to curve 4 distance 0 from vertex 145')
79 str1='create curve location vertex 145 direction curve 33 length '+ str(W_weft/2); cubit.cmd(str1)
80 str1='create curve location vertex 145 direction curve 32 length '+str(H_weft/2); cubit.cmd(str1)
81 cubit.cmd('create surface ellipse vertex 228 230 145')
82 cubit.cmd('sweep surface 14 along curve 4')
84 cubit.cmd('delete vertex all')
85 cubit.cmd('delete curve all')
86 cubit.cmd('delete body 7 3 5 1')
88 str1='brick x '+str(L_RVE)+' y '+str(H_RVE)+' z '+str(W_RVE); cubit.cmd(str1)
89 str1='move Volume '+str(9)+' x '+str(0)+' y '+str(0)+' z '+str(s_wraf/2); cubit.cmd(str1)
91 cubit.cmd('intersect volume all keep')
92 cubit.cmd('delete volume 6 2 8 4')
93 cubit.cmd('subtract volume 10 11 12 13 from volume 9 keep')
94 cubit.cmd('delete volume 9')
95 cubit.cmd('imprint volume 10 11 12 13 14')
96 cubit.cmd('merge volume 10 11 12 13 14')
99 ### =============== Meshing ================
100 cubit.cmd('group 1 add surface 42 27 24')
101 cubit.cmd('group "g2" add surface 44 25 28')
102 cubit.cmd('group "g3" add surface 39 30 33')
103 cubit.cmd('group "g4" add surface 31 40 34')
104 cubit.cmd('group "g5" add surface 43')
105 cubit.cmd('group "g6" add surface 41')
108 cubit.cmd('surface 42 27 24 size auto factor 6')
109 cubit.cmd('surface 42 27 24 scheme trimesh')
110 cubit.cmd('mesh surface 42 27 24')
111 cubit.cmd('surface 28 25 44 scheme mirror source surface 27 24 42 source vertex 263 target vertex 262 nosmoothing')
112 cubit.cmd('mesh surface 28 25 44')
114 cubit.cmd('surface 39 30 33 size auto factor 5')
115 cubit.cmd('surface 39 30 33 scheme trimesh')
116 cubit.cmd('mesh surface 39 30 33')
117 cubit.cmd('surface 31 34 40 scheme mirror source surface 30 33 39 source vertex 257 target vertex 262 nosmoothing')
118 cubit.cmd('mesh surface 31 34 40')
120 cubit.cmd('surface 43 scheme trimesh')
121 cubit.cmd('mesh surface 43')
122 cubit.cmd('surface 41 scheme mirror source surface 43 source vertex 259 target vertex 260 nosmoothing')
123 cubit.cmd('mesh surface 41')
125 ##=============================================================
127 ##=============================================================
128 cubit.cmd('volume all scheme Tetmesh')
129 cubit.cmd('mesh volume all')
131 vol=['14', '10,11,12,13']
132 mat=['MAT_ELASTIC_MATRIX','MAT_ELASTIC_FIBRES']
133 Elastic=['5.0e3', '0.3', '5.0e3', '0.3'] #E in N/mm^2 for geometry dimensions in mm
135 for i in range(0, 2):
136 cubit.cmd('set duplicate block elements on')
137 str1='block ' + str(i+1) +' volume '+vol[i]; cubit.cmd(str1)
138 str1='block ' + str(i+1) +' name "'+mat[i] + '"'; cubit.cmd(str1)
139 str1='block ' + str(i+1) +' attribute count 2'; cubit.cmd(str1)
140 str1='block ' + str(i+1) +' attribute index 1 '+str(Elastic[count]); cubit.cmd(str1)
141 str1='block ' + str(i+1) +' attribute index 2 '+str(Elastic[count+1]); cubit.cmd(str1)
144 vol=['14', '10,11,12,13']
145 mat=['MAT_MOISTURE','MAT_MOISTURE_LOW_DIFF']
148 for i in range(0, 2):
149 cubit.cmd('set duplicate block elements on')
150 str1='block ' + str(block_id) +' volume '+vol[i]; cubit.cmd(str1)
151 str1='block ' + str(block_id) +' name "'+mat[i] + '"'; cubit.cmd(str1)
152 str1='block ' + str(block_id) +' attribute count 1'; cubit.cmd(str1)
153 str1='block ' + str(block_id) +' attribute index 1 '+str(Diff[i]); cubit.cmd(str1)
157 cubit.cmd('sideset 101 surface 41 31 34 40 42 27 24') # all -ve boundary surfaces for periodic boundary conditions
158 cubit.cmd('sideset 102 surface 43 30 33 39 25 44 28') # all +ve boundary surfaces for periodic boundary conditions
159 cubit.cmd('sideset 103 surface 41 31 34 40 42 27 24 43 30 33 39 25 44 28') # all boundary surfaces
161 cubit.cmd('save as "/Users/zahur/Documents/moFEM/mofem-cephas/mofem_v0.2/users_modules/homogenisation/meshes/Textile_RVE.cub" overwrite')