2 from Zcracks import genereCrack, Zset
3 from Zcracks import utilityFunctions as uF
11 from Zcracks import casTests
12 from Zcracks.casTests import launchCas
13 launchCas.LAUNCH(['10'])
19 #tmpdir = "/local00/home/B27118/projets/Zcracks/Zcracks/casTests/tmpdir"
20 #if not os.path.isdir(tmpdir): os.mkdir(tmpdir)
21 tmpdir=tempfile.mktemp(prefix='tmpZcracks')
22 print "tmpdir=", tmpdir
24 meshgemsdir=os.environ('MESHGEMSHOME')
25 if len(meshgemsdir) > 0:
26 meshgems=string.split(meshgemsdir,os.sep)[-1]
27 uF.removeFromSessionPath('LD_LIBRARY_PATH', meshgems)
29 def LAUNCH(listCas=[]):
30 if type(listCas)!=list: listCas=[listCas]
36 genereCube.cube3D(L, N, os.path.join(tmpdir,'cube3D.med'))
37 genereCube.cube2D(L, N, os.path.join(tmpdir,'cube2D.med'))
44 data={'minSize':[te/10.], 'maxSize':[te], 'extractLength':[2.*te], 'is2D':True, 'crack':crack,
45 'grEdge':['EDGEXP EDGEXM EDGEYP EDGEYM']}
48 crack['actif']='Ellipse'
49 crack[crack['actif']]={'Rayon':[L/2.], 'Centre':[L/2., offset, 0.], 'Normale':[0., 1., 0.]}
50 if cas in listCas or listCas==[]:
51 synthese[cas]=execute2D(data, cas)
54 crack['actif']='Ellipse'
55 crack[crack['actif']]={'Rayon':[L], 'Centre':[L/2., 0., 0.], 'Normale':[1., 1., 0.]}
56 if cas in listCas or listCas==[]:
57 synthese[cas]=execute2D(data, cas)
60 crack['actif']='Ellipse'
61 crack[crack['actif']]={'Rayon':[L*sqrt(2.)], 'Centre':[-L/2., L/2., 0.], 'Normale':[1., 1., 0.]}
62 if cas in listCas or listCas==[]:
63 synthese[cas]=execute2D(data, cas)
66 crack['actif']='Ellipse'
67 crack[crack['actif']]={'Rayon':[L/4.], 'Centre':[0., offset, 0.], 'Normale':[0., 1., 0.]}
68 if cas in listCas or listCas==[]:
69 synthese[cas]=execute2D(data, cas)
71 data['grFace']=['FACEXM FACEXP']
73 crack['actif']='Ellipse'; crack[crack['actif']]={'Rayon':[L/4.], 'Centre':[0., offset, 0.], 'Normale':[0., 1., 0.]}
74 if cas in listCas or listCas==[]:
75 synthese[cas]=execute2D(data, cas)
78 crack['actif']='Ellipse'
79 crack[crack['actif']]={'Rayon':[L/8.], 'Centre':[-L/16., offset, 0.], 'Normale':[0., 1., 0.]}
80 if cas in listCas or listCas==[]:
81 synthese[cas]=execute2D(data, cas)
86 crack['actif']='Sphere'
87 crack[crack['actif']]={'Rayon':[L/4.], 'Centre':[0., 0., 0.]}
88 if cas in listCas or listCas==[]:
89 synthese[cas]=execute2D(data, cas)
92 crack['actif']='Sphere'
93 crack[crack['actif']]={'Rayon':[L/4.], 'Centre':[L/2., 0., 0.]}
94 if cas in listCas or listCas==[]:
95 synthese[cas]=execute2D(data, cas)
97 data['grFace']=['FACEXM FACEXP']
99 crack['actif']='Sphere'
100 crack['Sphere']={'Rayon':[L/4.], 'Centre':[0., 0., 0.]}
101 if cas in listCas or listCas==[]:
102 synthese[cas]=execute2D(data, cas)
108 data['grFace']=['FACEXP FACEXM FACEYP FACEYM FACEZP FACEZM']
112 crack['actif']='Rectangle'
113 crack[crack['actif']]={'Centre':[L/2., offset, 0.], 'Normale':[0., 1., 0.], 'Direction':[1., 0., 0.], 'Longueur':[L/2.], 'Largeur':[L]}
114 if cas in listCas or listCas==[]:
115 synthese[cas]=execute3D(data, cas)
118 crack['actif']='Sphere'
119 crack[crack['actif']]={'Rayon':[L/4.], 'Centre':[0., 0., 0.]}
120 if cas in listCas or listCas==[]:
121 synthese[cas]=execute3D(data, cas)
124 crack['actif']='Ellipse'
125 crack[crack['actif']]={'Centre':[L/4., L/4., L/4.], 'Normale':[1., 1., 1.], 'Rayon':[L]}
126 if cas in listCas or listCas==[]:
127 synthese[cas]=execute3D(data, cas)
130 crack['actif']='Sphere'
131 crack[crack['actif']]={'Rayon':[L/4.], 'Centre':[L/2., 0., 0.]}
132 if cas in listCas or listCas==[]:
133 synthese[cas]=execute3D(data, cas)
136 crack['actif']='Ellipse'
137 crack[crack['actif']]={'Rayon':[L/4.], 'Centre':[L/2., offset, 0.], 'Normale':[0., 1., 0.]}
138 if cas in listCas or listCas==[]:
139 synthese[cas]=execute3D(data, cas)
142 crack['actif']='Rectangle'
143 crack[crack['actif']]={'Centre':[L/2., 0., 0.], 'Normale':[0., 1., 0.], 'Direction':[-1., 0., 0.],
144 'Longueur':[L/2.], 'Largeur':[L], 'Rayon entaille':[te*1.5]}
145 if cas in listCas or listCas==[]:
146 synthese[cas]=execute3D(data, cas)
149 crack['actif']='Rectangle'
150 crack[crack['actif']]={'Centre':[L/2., offset, 0.], 'Normale':[0., 1., 0.], 'Direction':[1., 0., 0.],
151 'Longueur':[L/2.], 'Largeur':[L/4.], 'Rayon':[2.*te]}
152 if cas in listCas or listCas==[]:
153 synthese[cas]=execute3D(data, cas)
156 crack['actif']='Rectangle'
157 crack[crack['actif']]={'Centre':[0., offset, 0.], 'Normale':[0., 1., 0.], 'Direction':[1., 0., 0.],
159 if cas in listCas or listCas==[]:
160 synthese[cas]=execute3D(data, cas)
163 crack['actif']='Rectangle'
164 crack[crack['actif']]={'Centre':[0., 0., 0.], 'Normale':[1., 1., 0.], 'Direction':[1., -1., 0.],
165 'Longueur':[L], 'Angle':[180.]}
166 if cas in listCas or listCas==[]:
167 synthese[cas]=execute3D(data, cas)
170 data['grVol']=['VOLYP VOLYM']
173 crack['actif']='Rectangle'
174 crack[crack['actif']]={'Centre':[0., 0., 0.], 'Normale':[0., 1., 0.], 'Direction':[1., 0., 0.],
175 'Longueur':[L], 'Angle':[180.]}
176 if cas in listCas or listCas==[]:
177 synthese[cas]=execute3D(data, cas)
179 data['grVol']=['VOLXP VOLXM']
182 crack['actif']='Sphere'
183 crack[crack['actif']]={'Rayon':[L/4.], 'Centre':[0., 0., 0.]}
184 if cas in listCas or listCas==[]:
185 synthese[cas]=execute3D(data, cas)
187 data['grVol']=['VOLYP VOLYM']
190 crack['actif']='Ellipse'
191 crack[crack['actif']]={'Rayon':[L/4.], 'Centre':[L/2., offset, 0.], 'Normale':[0., 1., 0.]}
192 if cas in listCas or listCas==[]:
193 synthese[cas]=execute3D(data, cas)
197 for s in synthese.keys():
214 def execute3D(data, cas):
215 names={'saneGeoName':'cube3D', 'crackGeoName':'crack'+cas, 'crackedGeoName':'cracked'+cas}
217 crackMed=os.path.join(tmpdir,'crack'+cas+'.med')
218 crackedMed=os.path.join(tmpdir,'cracked'+cas+'.med')
220 saneGeo=os.path.join(tmpdir,names['saneGeoName'],'.geo')
221 crackGeo=os.path.join(tmpdir,names['crackGeoName'],'.geo')
222 crackedGeo=os.path.join(tmpdir,names['crackedGeoName'],'.geo')
224 for f in [crackMed, crackedMed, saneGeo, crackGeo, crackedGeo]:
225 if os.path.isfile(f): os.remove(f)
227 genereCrack.main(data, crackMed)
229 Zset.medToGeo(os.path.join(tmpdir,names['saneGeoName']),names['saneGeoName'], tmpdir)
230 Zset.medToGeo(crackMed, names['crackGeoName'], tmpdir)
231 Zset.insertCrack(data, names, tmpdir)
232 shutil.copy(os.path.join(tmpdir,'_mesh_out_to_ghs3d.mesh'),os.path.join(tmpdir,'mesh'+cas+'.mesh'))
233 shutil.copy(os.path.join(tmpdir,'insert.z7p'),os.path.join(tmpdir,'insert'+cas+'.z7p'))
235 Zset.geoToMed(crackedMed, names['crackedGeoName'], tmpdir)
237 if os.path.isfile(crackedMed):
238 uF.extendElsets(crackedMed)
239 maxAR=uF.getMaxAspectRatio(tmpdir)
240 return(maxAR<30. and maxAR>=1.)
246 def execute2D(data, cas):
247 names={'saneGeoName':'cube2D', 'crackGeoName':'crack'+cas, 'crackedGeoName':'cracked'+cas}
249 crackMed=os.path.join(tmpdir,'crack'+cas+'.med')
250 crackedMed=os.path.join(tmpdir,'cracked'+cas+'.med')
252 saneGeo=os.path.join(tmpdir,names['saneGeoName'],'.geo')
253 crackGeo=os.path.join(tmpdir,names['crackGeoName'],'.geo')
254 crackedGeo=os.path.join(tmpdir,names['crackedGeoName'],'.geo')
256 for f in [crackMed, crackedMed, saneGeo, crackGeo, crackedGeo]:
257 if os.path.isfile(f): os.remove(f)
259 genereCrack.main(data, crackMed)
261 Zset.medToGeo(os.path.join(tmpdir,names['saneGeoName']),names['saneGeoName'], tmpdir, opt=[' **to_3d'])
262 Zset.medToGeo(crackMed, names['crackGeoName'], tmpdir)
263 Zset.insertCrack(data, names, tmpdir)
264 shutil.copy(os.path.join(tmpdir,'_mesh_out_.mesh'),os.path.join(tmpdir,'mesh'+cas+'.mesh'))
265 shutil.copy(os.path.join(tmpdir,'insert.z7p'),os.path.join(tmpdir,'insert'+cas+'.z7p'))
266 Zset.geoToMed(crackedMed, names['crackedGeoName'], tmpdir)
268 if os.path.isfile(crackedMed):
269 uF.extendElsets(crackedMed)
270 maxAR=uF.getMaxAspectRatio(tmpdir)
271 return(maxAR<30. and maxAR>=1.)