1 # -*- coding: utf-8 -*-
5 from .geomsmesh import geompy
6 from .geomsmesh import geomPublish
7 from .geomsmesh import geomPublishInFather
9 from .geomsmesh import smesh
10 from salome.smesh import smeshBuilder
14 from .extractionOrientee import extractionOrientee
15 from .sortFaces import sortFaces
16 from .sortEdges import sortEdges
17 from .eliminateDoubles import eliminateDoubles
18 from .substractSubShapes import substractSubShapes
19 from .produitMixte import produitMixte
20 from .findWireEndVertices import findWireEndVertices
21 from .getSubshapeIds import getSubshapeIds
22 from .putName import putName
23 from .distance2 import distance2
24 from .enleveDefaut import enleveDefaut
25 from .shapeSurFissure import shapeSurFissure
26 from .regroupeSainEtDefaut import RegroupeSainEtDefaut
27 from .triedreBase import triedreBase
29 # -----------------------------------------------------------------------------
30 # --- procedure complete fissure longue
32 def insereFissureLongue(geometriesSaines, maillagesSains,
33 shapesFissure, shapeFissureParams,
34 maillageFissureParams, elementsDefaut, step=-1):
40 #geometrieSaine = geometriesSaines[0]
41 #maillageSain = maillagesSains[0]
42 #isHexa = maillagesSains[1]
43 shapeDefaut = shapesFissure[0] # face de fissure, debordant
44 #tailleDefaut = shapesFissure[2]
45 wiretube = shapesFissure[4] # wire fond de fissure, debordant
46 planfiss = shapesFissure[7] # plan de fissure
47 pipefiss = shapesFissure[8] # pipe, debordant
49 profondeur = shapeFissureParams['profondeur']
50 rayonPipe = profondeur/4.0
52 nomRep = maillageFissureParams['nomRep']
53 nomFicSain = maillageFissureParams['nomFicSain']
54 nomFicFissure = maillageFissureParams['nomFicFissure']
56 #nbsegExt = maillageFissureParams['nbsegExt'] # 5
57 #nbsegGen = maillageFissureParams['nbsegGen'] # 25
58 #nbsegRad = maillageFissureParams['nbsegRad'] # 5
59 #scaleRad = maillageFissureParams['scaleRad'] # 4
60 #nbsegCercle = maillageFissureParams['nbsegCercle'] # 6
61 #nbsegFis = maillageFissureParams['nbsegFis'] # 20
62 #lensegEllipsoide = maillageFissureParams['lensegEllipso'] # 1.0
64 #fichierMaillageSain = nomRep + '/' + nomFicSain + '.med'
65 fichierMaillageFissure = nomRep + '/' + nomFicFissure + '.med'
67 facesDefaut = elementsDefaut[0]
68 #centreDefaut = elementsDefaut[1]
69 #normalDefaut = elementsDefaut[2]
70 #extrusionDefaut = elementsDefaut[3]
71 #dmoyen = elementsDefaut[4]
72 #bordsPartages = elementsDefaut[5]
73 #fillconts = elementsDefaut[6]
74 #idFilToCont = elementsDefaut[7]
75 maillageSain = elementsDefaut[8]
76 internalBoundary = elementsDefaut[9]
77 zoneDefaut = elementsDefaut[10]
78 zoneDefaut_skin = elementsDefaut[11]
79 zoneDefaut_internalFaces = elementsDefaut[12]
80 zoneDefaut_internalEdges = elementsDefaut[13]
82 facePorteFissure = shapeDefaut
83 WirePorteFondFissure = wiretube
84 fillingFaceExterne = facesDefaut[0]
85 logging.debug("fillingFaceExterne %s", fillingFaceExterne)
86 geomPublish(initLog.debug, fillingFaceExterne, "fillingFaceExterne")
87 edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False)
89 O, OX, OY, OZ = triedreBase()
91 # -----------------------------------------------------------------------------
92 # --- peau et face de fissure
94 # --- partition peau defaut - face de fissure prolongee - wire de fond de fissure prolongée
95 partitionPeauFissFond = geompy.MakePartition([facePorteFissure, WirePorteFondFissure, fillingFaceExterne], [], [], [], geompy.ShapeType["FACE"], 0, [], 0)
96 geomPublish(initLog.debug, partitionPeauFissFond, 'partitionPeauFissFond' )
98 edges = geompy.ExtractShapes(WirePorteFondFissure, geompy.ShapeType["EDGE"], False)
102 for i, edge in enumerate(edges):
103 props = geompy.BasicProperties(edge)
108 edgemax = edges[imax]
109 geomPublish(initLog.debug, edgemax, 'edgemax')
110 centreFondFiss = geompy.MakeVertexOnCurve(edgemax, 0.5)
111 geomPublish(initLog.debug, centreFondFiss, 'centreFondFiss')
112 tangentFondFiss = geompy.MakeTangentOnCurve(edgemax, 0.5)
113 geomPublish(initLog.debug, tangentFondFiss, 'tangentFondFiss')
115 bord1FondFiss = geompy.MakeVertexOnCurve(edgemax, 0.0)
116 geomPublish(initLog.debug, bord1FondFiss, 'bord1FondFiss')
117 tangentBord1FondFiss = geompy.MakeTangentOnCurve(edgemax, 0.0)
118 geomPublish(initLog.debug, tangentBord1FondFiss, 'tangentBord1FondFiss')
120 bord2FondFiss = geompy.MakeVertexOnCurve(edgemax, 1.0)
121 geomPublish(initLog.debug, bord2FondFiss, 'bord2FondFiss')
122 tangentBord2FondFiss = geompy.MakeTangentOnCurve(edgemax, 1.0)
123 geomPublish(initLog.debug, tangentBord2FondFiss, 'tangentBord2FondFiss')
125 planBord1 = geompy.MakePlane(bord1FondFiss, tangentBord1FondFiss, 3*rayonPipe)
126 planBord2 = geompy.MakePlane(bord2FondFiss, tangentBord2FondFiss, 3*rayonPipe)
127 geomPublish(initLog.debug, planBord1, 'planBord1')
128 geomPublish(initLog.debug, planBord2, 'planBord2')
130 [edgesInside, edgesOutside, edgesOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "EDGE", 1.e-3)
131 [facesInside, facesOutside, facesOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "FACE", 1.e-3)
133 # --- partition peau -face fissure - pipe fond de fissure prolongé
134 partitionPeauFissByPipe = geompy.MakePartition([facesInside[0], facesOnside[0]], [pipefiss], [], [], geompy.ShapeType["FACE"], 0, [], 0)
135 geomPublish(initLog.debug, partitionPeauFissByPipe, 'partitionPeauFissByPipe' )
137 # --- identification face de peau
138 [facesPeauFissInside, facesPeauFissOutside, facesPeauFissOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissByPipe, centreFondFiss, "FACE", 0.1, "peauFiss_bord_")
139 facesPeauSorted, minsur, maxsurf = sortFaces(facesPeauFissOnside) # 4 demi disques, une grande face
140 facePeau = facesPeauSorted[-1] # la plus grande face
141 geomPublishInFather(initLog.debug,partitionPeauFissByPipe, facePeau, "facePeau")
143 # --- identification edges de bord face peau
145 for i, edge in enumerate(edgesFilling):
146 edgepeau = geompy.GetInPlace(facePeau, edge)
147 edgesBords.append(edgepeau)
148 groupEdgesBordPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
149 geompy.UnionList(groupEdgesBordPeau, edgesBords)
150 geomPublishInFather(initLog.debug,facePeau, groupEdgesBordPeau , "EdgesBords")
152 # --- identification face fissure externe au pipe et edge commune peau fissure
153 for face in facesPeauFissInside:
155 sharedEdges = geompy.GetSharedShapesMulti([facePeau, face], geompy.ShapeType["EDGE"])
156 if sharedEdges is not None:
158 edgePeauFiss = sharedEdges[0]
159 geomPublishInFather(initLog.debug,partitionPeauFissByPipe, faceFiss, "faceFiss")
160 geomPublishInFather(initLog.debug,faceFiss, edgePeauFiss, "edgePeauFiss")
161 geomPublishInFather(initLog.debug,facePeau, edgePeauFiss, "edgePeauFiss")
165 verticesEdgePeauFiss = geompy.ExtractShapes(edgePeauFiss, geompy.ShapeType["VERTEX"], False)
167 # --- identification edges demi cercle dans face de peau
168 edgesFacePeau = geompy.ExtractShapes(facePeau, geompy.ShapeType["EDGE"], False)
169 edgesFacePeauSorted, minlg, maxlg = sortEdges(edgesFacePeau)
170 demiCerclesPeau = edgesFacePeauSorted[0:4]
171 verticesDemiCerclesPeau = []
172 for i, edge in enumerate(demiCerclesPeau):
173 name = "demiCerclePeau_%d"%i
174 geomPublishInFather(initLog.debug,facePeau, edge, name)
175 verticesDemiCerclesPeau += geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
176 verticesDemiCerclesPeau = eliminateDoubles(facePeau, verticesDemiCerclesPeau)
177 for i, vertex in enumerate(verticesDemiCerclesPeau):
178 name = "verticesDemiCerclesPeau_%d"%i
179 geomPublishInFather(initLog.debug,facePeau, vertex, name)
180 verticesOutCercles = substractSubShapes(facePeau, verticesDemiCerclesPeau, verticesEdgePeauFiss)
181 for i, vertex in enumerate(verticesOutCercles):
182 name = "verticesOutCercles_%d"%i
183 geomPublishInFather(initLog.debug,facePeau, vertex, name)
185 # --- demi cercles regroupés
186 groupsDemiCerclesPeau = []
187 for i, vertex in enumerate(verticesEdgePeauFiss):
189 for edge in demiCerclesPeau:
190 if geompy.MinDistance(vertex, edge) < 1.e-5:
192 group = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
193 geompy.UnionList(group, demis)
195 geomPublishInFather(initLog.debug,facePeau, group , name)
196 groupsDemiCerclesPeau.append(group)
198 # --- identification edges commune pipe face fissure externe au pipe
199 edgePeauFissId = geompy.GetSubShapeID(partitionPeauFissByPipe, edgePeauFiss)
200 edgesFaceFiss = geompy.ExtractShapes(faceFiss, geompy.ShapeType["EDGE"], False)
201 edgesFaceFissPipe = []
202 for edge in edgesFaceFiss:
203 if geompy.GetSubShapeID(partitionPeauFissByPipe, edge) != edgePeauFissId:
204 edgesFaceFissPipe.append(edge)
205 name = "edgeFaceFissPipe_%d"%len(edgesFaceFissPipe)
206 geomPublishInFather(initLog.debug,faceFiss, edge, name)
207 groupEdgesFaceFissPipe = geompy.CreateGroup(faceFiss, geompy.ShapeType["EDGE"])
208 geompy.UnionList(groupEdgesFaceFissPipe, edgesFaceFissPipe)
209 geomPublishInFather(initLog.debug,faceFiss, groupEdgesFaceFissPipe, "edgesFaceFissPipe")
211 # -----------------------------------------------------------------------------
212 # --- pipe de fond de fissure
214 wireFondFiss = geompy.MakeWire(edgesInside, 1e-07)
216 disque = geompy.MakeDiskPntVecR(centreFondFiss, tangentFondFiss, rayonPipe)
217 [vertex] = geompy.ExtractShapes(disque, geompy.ShapeType["VERTEX"], False)
218 vertproj = geompy.MakeProjection(vertex, planfiss)
219 vec1 = geompy.MakeVector(centreFondFiss, vertex)
221 # si centreFondFiss et vertproj sont proches: exception. Angle = +- 90°
222 vec2 = geompy.MakeVector(centreFondFiss, vertproj)
223 angle = geompy.GetAngleRadians(vec1, vec2)
225 # on utilise la projection du centre sur la peau pour avoir un vecteur non nul
226 vertproj = geompy.MakeProjection(centreFondFiss, facePeau)
227 vec2 = geompy.MakeVector(centreFondFiss, vertproj)
228 angle = geompy.GetAngleRadians(vec1, vec2)
229 sommetAxe = geompy.MakeTranslationVector(centreFondFiss, tangentFondFiss)
230 pm = produitMixte(centreFondFiss, vertex, vertproj, sommetAxe)
232 disque = geompy.MakeRotation(disque, tangentFondFiss, angle)
234 disque = geompy.MakeRotation(disque, tangentFondFiss, -angle)
235 [vertexReference] = geompy.ExtractShapes(disque, geompy.ShapeType["VERTEX"], False)
237 pipeFondFiss = geompy.MakePipe(disque, wireFondFiss)
238 pipeFondFiss = geompy.MakePartition([pipeFondFiss], [planfiss, wireFondFiss, planBord1, planBord2], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
239 #pipe = geompy.MakePipe(disque, WirePorteFondFissure)
240 #pipe = geompy.MakePartition([pipe],[fillingFaceExterne], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
241 #pipes = geompy.ExtractShapes(pipe, geompy.ShapeType["SOLID"], False)
242 #pipesSorted, volmin, volmax = sortSolids(pipes)
243 #pipeFondFiss = pipesSorted[-1]
244 #pipeFondFiss = geompy.MakePartition([pipeFondFiss], [planfiss, wireFondFiss, planBord1, planBord2], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
246 geomPublish(initLog.debug, disque, 'disque')
247 geomPublish(initLog.debug, wireFondFiss, 'wireFondFiss')
248 geomPublish(initLog.debug, pipeFondFiss, 'pipeFondFiss')
250 VerticesEndFondFiss = findWireEndVertices(wireFondFiss)
251 for i, v in enumerate(VerticesEndFondFiss):
252 name = "vertexEndFondFiss_%d"%i
253 geomPublishInFather(initLog.debug,wireFondFiss, v, name)
254 VerticesEndPipeFiss = []
255 for v in VerticesEndFondFiss:
256 VerticesEndPipeFiss.append(geompy.GetInPlace(pipeFondFiss, v))
257 for i, v in enumerate(VerticesEndPipeFiss):
258 name = "vertexEndPipeFiss_%d"%i
259 geomPublishInFather(initLog.debug,pipeFondFiss, v, name)
261 geomPublishInFather(initLog.debug,pipeFondFiss, VerticesEndPipeFiss[0], "PFOR")
262 geomPublishInFather(initLog.debug,pipeFondFiss, VerticesEndPipeFiss[1], "PFEX")
263 if geompy.MinDistance(VerticesEndPipeFiss[0], verticesOutCercles[0]) > geompy.MinDistance(VerticesEndPipeFiss[0], verticesOutCercles[1]):
264 a = verticesOutCercles[0]
265 verticesOutCercles[0] = verticesOutCercles[1]
266 verticesOutCercles[1] = a
267 geomPublishInFather(initLog.debug,facePeau, verticesOutCercles[0], "THOR")
268 geomPublishInFather(initLog.debug,facePeau, verticesOutCercles[1], "THEX")
270 [facesPipeInside, facesPipeOutside, facesPipeOnside] = extractionOrientee(fillingFaceExterne, pipeFondFiss, centreFondFiss, "FACE", 0.1, "pipe_bord_")
271 [edgesPipeInside, edgesPipeOutside, edgesPipeOnside] = extractionOrientee(fillingFaceExterne, pipeFondFiss, centreFondFiss, "EDGE", 0.1, "pipe_bord_")
272 disqueInt1 = geompy.GetInPlaceByHistory(pipeFondFiss, planBord1)
273 disqueInt2 = geompy.GetInPlaceByHistory(pipeFondFiss, planBord2)
274 disques = facesPipeOnside + [disqueInt1, disqueInt2]
275 edgesDiskInt = geompy.ExtractShapes(disqueInt1, geompy.ShapeType["EDGE"], False)
276 edgesDiskInt = edgesDiskInt +geompy.ExtractShapes(disqueInt2, geompy.ShapeType["EDGE"], False)
277 edgesSorted, minlg, maxlg = sortEdges(edgesDiskInt) # 4 rayons, 2 demi cercles
279 centre = geompy.MakeVertexOnSurface(planfiss, 0.5, 0.5)
280 refpoint = geompy.MakeTranslationVector(centre, geompy.GetNormal(planfiss,centre))
281 geomPublish(initLog.debug, refpoint, 'refpoint')
282 [facesPipeInplan, facesPipeOutplan, facesPipeOnplan] = extractionOrientee(planfiss, pipeFondFiss, refpoint, "FACE", 0.1, "pipe_plan_")
283 [edgesPipeInplan, edgesPipeOutplan, edgesPipeOnplan] = extractionOrientee(planfiss, pipeFondFiss, refpoint, "EDGE", 0.1, "pipe_plan_")
285 # --- rayon disques = (edgesPipeOnside inter edgesPipeOnplan) + rayons disque internes
286 # demi cercles = edgesPipeOnside moins edgesPipeOnplan + demi cercles disque internes
287 # generatrices = edgesPipeOnplan moins rayon disques (3 grandes et 6 petites)
288 edgesIdPipeOnside = getSubshapeIds(pipeFondFiss, edgesPipeOnside)
289 edgesIdPipeOnplan = getSubshapeIds(pipeFondFiss, edgesPipeOnplan)
292 for i, edgeId in enumerate(edgesIdPipeOnside):
293 if edgeId in edgesIdPipeOnplan:
294 rayons.append(edgesPipeOnside[i])
296 demiCercles.append(edgesPipeOnside[i])
297 demiCerclesExternes = demiCercles
298 rayons = rayons + edgesSorted[:4] # les 4 plus petits sont les rayons
299 demiCercles = demiCercles + edgesSorted[4:] # les suivants sont les arcs de cercle
300 rayonsId = getSubshapeIds(pipeFondFiss, rayons)
302 for i, edgeId in enumerate(edgesIdPipeOnplan):
303 if edgeId not in rayonsId:
304 generatrices.append(edgesPipeOnplan[i])
306 # --- generatrices en contact avec la face fissure externe au pipe
308 for edge in generatrices:
309 distance = geompy.MinDistance(vertexReference, edge)
310 logging.debug("distance %s", distance)
312 generFiss.append(edge)
314 for edge in generatrices:
315 distance = geompy.MinDistance(generFiss[0], edge)
316 logging.debug("distance %s", distance)
318 generFiss.append(edge)
319 groupGenerFiss = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["EDGE"])
320 geompy.UnionList(groupGenerFiss, generFiss)
321 geomPublishInFather(initLog.debug,pipeFondFiss, groupGenerFiss, "GenFiss")
323 # --- demi cercles externes regroupés
324 groupsDemiCerclesPipe = []
325 for i, vertex in enumerate(verticesEdgePeauFiss):
327 for edge in demiCerclesExternes:
328 if geompy.MinDistance(vertex, edge) < 0.1:
330 group = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["EDGE"])
331 geompy.UnionList(group, demis)
333 geomPublishInFather(initLog.debug,pipeFondFiss, group , name)
334 groupsDemiCerclesPipe.append(group)
336 # --- faces fissure dans le pipe
339 generFissId = getSubshapeIds(pipeFondFiss, generFiss)
340 logging.debug("generatrice fissure %s", generFissId)
341 for face in facesPipeOnplan:
342 edges =geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], False)
343 edgesId = getSubshapeIds(pipeFondFiss, edges)
344 logging.debug(" edges %s", edgesId)
345 for i,edgeId in enumerate(edgesId):
346 if edgeId in generFissId:
347 logging.debug("face found")
348 facesFissinPipe.append(face)
349 name = "faceFissInPipe_%d"%i
350 geomPublishInFather(initLog.debug,pipeFondFiss, face, name)
352 groupFaceFissInPipe = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["FACE"])
353 geompy.UnionList(groupFaceFissInPipe, facesFissinPipe)
354 name = "FaceFissInPipe"
355 geomPublishInFather(initLog.debug,pipeFondFiss, groupFaceFissInPipe , name)
357 # --- edges de fond de fissure
360 for i, edge in enumerate(edgesInside):
361 anEdge = geompy.GetInPlace(pipeFondFiss, edge)
362 logging.debug(" edge %s ", anEdge)
363 edgesFondFiss.append(anEdge)
364 name ="edgeFondFissure_%d"%i
365 geomPublishInFather(initLog.debug,pipeFondFiss, anEdge, name)
366 groupEdgeFondFiss = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["EDGE"])
367 geompy.UnionList(groupEdgeFondFiss, edgesFondFiss)
369 geomPublishInFather(initLog.debug,pipeFondFiss, groupEdgeFondFiss , name)
371 # -------------------------------------------------------------------------
374 # --- edges de bord face defaut à respecter
376 aFilterManager = smesh.CreateFilterManager()
377 nbAdded, internalBoundary, _NoneGroup = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [ ])
379 unCritere = smesh.GetCriterion(SMESH.EDGE,SMESH.FT_FreeBorders,SMESH.FT_Undefined,0)
380 criteres.append(unCritere)
381 filtre = smesh.GetFilterFromCriteria(criteres)
382 bordsLibres = internalBoundary.MakeGroupByFilter( 'bords', filtre )
383 smesh.SetName(bordsLibres, 'bordsLibres')
385 # --- pour aider l'algo hexa-tetra a ne pas mettre de pyramides a l'exterieur des volumes replies sur eux-memes
386 # on designe les faces de peau en quadrangles par le groupe "skinFaces"
388 skinFaces = internalBoundary.CreateEmptyGroup( SMESH.FACE, 'skinFaces' )
389 nbAdd = skinFaces.AddFrom( internalBoundary.GetMesh() )
391 # --- maillage pipe fond fissure
393 meshFondFiss = smesh.Mesh(pipeFondFiss)
394 algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.QUADRANGLE)
395 algo3d = meshFondFiss.Prism()
396 putName(algo3d.GetSubMesh(), "pipe")
397 putName(algo3d, "algo3d_pipe")
398 putName(algo2d, "algo2d_pipe")
400 for i, face in enumerate(disques):
401 algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.RADIAL_QUAD,geom=face)
402 putName(algo2d.GetSubMesh(), "disque", i)
403 putName(algo2d, "algo2d_disque", i)
405 for i, edge in enumerate(rayons):
406 algo1d = meshFondFiss.Segment(geom=edge)
407 hypo1d = algo1d.NumberOfSegments(4)
408 putName(algo1d.GetSubMesh(), "rayon", i)
409 putName(algo1d, "algo1d_rayon", i)
410 putName(hypo1d, "hypo1d_rayon", i)
412 for i, edge in enumerate(demiCercles):
413 algo1d = meshFondFiss.Segment(geom=edge)
414 hypo1d = algo1d.NumberOfSegments(6)
415 putName(algo1d.GetSubMesh(), "demiCercle", i)
416 putName(algo1d, "algo1d_demiCercle", i)
417 putName(hypo1d, "hypo1d_demiCercle", i)
419 generSorted, minlg, maxlg = sortEdges(generatrices)
420 nbSegGenLong = int(math.sqrt(3.0)*maxlg/(profondeur - rayonPipe)) # on veut 2 triangles equilateraux dans la largeur de la face
422 logging.info("min %s, max %s, nombre de segments %s, nombre de generatrices %s", minlg, maxlg, nbSegGenLong, len(generSorted))
423 for i, edge in enumerate(generSorted):
424 algo1d = meshFondFiss.Segment(geom=edge)
426 hypo1d = algo1d.NumberOfSegments(nbSegGenBout)
428 hypo1d = algo1d.NumberOfSegments(nbSegGenLong)
429 putName(algo1d.GetSubMesh(), "generatrice", i)
430 putName(algo1d, "algo1d_generatrice", i)
431 putName(hypo1d, "hypo1d_generatrice", i)
432 isDone = meshFondFiss.Compute()
433 logging.info("meshFondFiss computed")
436 for i, face in enumerate(disques[:4]):
438 disks.append(meshFondFiss.GroupOnGeom(face, name, SMESH.FACE))
439 peauext_pipe = meshFondFiss.GetMesh().UnionListOfGroups( disks, 'PEAUEXT' )
441 grpPFOR = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[0], "PFOR", SMESH.NODE)
442 grpPFEX = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[1], "PFEX", SMESH.NODE)
444 grp = meshFondFiss.GroupOnGeom(groupFaceFissInPipe, "fisInPi", SMESH.FACE)
445 group_edgeFondFiss = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "FONDFISS", SMESH.EDGE)
446 noeudsFondFissure = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "nfondfis", SMESH.NODE)
447 groups_demiCercles = []
448 groupnodes_demiCercles = []
449 for i, group in enumerate(groupsDemiCerclesPipe):
451 groups_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.EDGE))
453 groupnodes_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.NODE))
454 group_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.EDGE)
455 groupnode_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.NODE)
456 grpNode0 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[0], "Node0")
457 grpNode1 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[1], "Node1")
458 idNode0 = grpNode0.GetID(1)
459 idNode1 = grpNode1.GetID(1)
461 coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode0))
462 coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode1))
464 for vertex in verticesEdgePeauFiss:
465 coord = geompy.PointCoordinates(vertex);
466 if distance2(coord, coordsMesh[0]) < 0.1:
467 meshFondFiss.MoveNode(idNode0, coord[0], coord[1], coord[2])
468 if distance2(coord, coordsMesh[1]) < 0.1:
469 meshFondFiss.MoveNode(idNode1, coord[0], coord[1], coord[2])
471 for groupNodes in groupnodes_demiCercles:
472 for idNode in groupNodes.GetListOfID():
473 coordMesh = meshFondFiss.GetNodeXYZ(idNode)
474 vertex = geompy.MakeVertex(coordMesh[0], coordMesh[1], coordMesh[2])
478 for i, edge in enumerate(demiCerclesPeau):
479 discoord = geompy.MinDistanceComponents(vertex, edge)
480 if discoord[0] <minDist:
481 minDist = discoord[0]
482 minCoord = discoord[1:]
484 if imin >= 0 and minDist > 1.E-6:
485 logging.debug("node id moved : %s distance=%s", idNode, minDist)
486 meshFondFiss.MoveNode(idNode, coordMesh[0] + minCoord[0], coordMesh[1] + minCoord[1], coordMesh[2] + minCoord[2])
489 # --- maillage face de peau
491 meshFacePeau = smesh.Mesh(facePeau)
492 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_2D)
493 hypo2d = algo2d.Parameters()
494 hypo2d.SetMaxSize( 1000 )
495 hypo2d.SetOptimize( 1 )
496 hypo2d.SetFineness( 2 )
497 hypo2d.SetMinSize( 2 )
498 hypo2d.SetQuadAllowed( 0 )
499 putName(algo2d.GetSubMesh(), "facePeau")
500 putName(algo2d, "algo2d_facePeau")
501 putName(hypo2d, "hypo2d_facePeau")
503 lenEdgePeauFiss = geompy.BasicProperties(edgePeauFiss)[0]
504 frac = profondeur/lenEdgePeauFiss
505 nbSeg = nbSegGenLong +2*nbSegGenBout
506 ratio = (nbSegGenBout/float(profondeur)) / (nbSegGenLong/lenEdgePeauFiss)
507 logging.info("lenEdgePeauFiss %s, profondeur %s, nbSegGenLong %s, nbSegGenBout %s, frac %s, ratio %s", lenEdgePeauFiss, profondeur, nbSegGenLong, nbSegGenBout, frac, ratio)
508 algo1d = meshFacePeau.Segment(geom=edgePeauFiss)
509 hypo1d = algo1d.NumberOfSegments(nbSeg,[],[ ])
510 hypo1d.SetDistrType( 2 )
511 hypo1d.SetConversionMode( 1 )
512 hypo1d.SetTableFunction( [ 0, ratio, frac, 1, (1.-frac), 1, 1, ratio ] )
513 putName(algo1d.GetSubMesh(), "edgePeauFiss")
514 putName(algo1d, "algo1d_edgePeauFiss")
515 putName(hypo1d, "hypo1d_edgePeauFiss")
517 algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
518 hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
519 putName(algo1d.GetSubMesh(), "bordsLibres")
520 putName(algo1d, "algo1d_bordsLibres")
521 putName(hypo1d, "hypo1d_bordsLibres")
524 algo1d = meshFacePeau.UseExisting1DElements(geom=groupsDemiCerclesPeau[i])
525 hypo1d = algo1d.SourceEdges([ groups_demiCercles[i] ],0,0)
526 putName(algo1d.GetSubMesh(), "DemiCercles", i)
527 putName(algo1d, "algo1d_groupDemiCercles", i)
528 putName(hypo1d, "hypo1d_groupDemiCercles", i)
530 isDone = meshFacePeau.Compute()
531 logging.info("meshFacePeau computed")
532 grpTHOR = meshFacePeau.GroupOnGeom(verticesOutCercles[0], "THOR", SMESH.NODE)
533 grpTHEX = meshFacePeau.GroupOnGeom(verticesOutCercles[1], "THEX", SMESH.NODE)
535 groupEdgesPeauFiss = meshFacePeau.GroupOnGeom(edgePeauFiss, "PeauFis", SMESH.EDGE)
537 peauext_face = meshFacePeau.CreateEmptyGroup( SMESH.FACE, 'PEAUEXT' )
538 nbAdd = peauext_face.AddFrom( meshFacePeau.GetMesh() )
541 # --- maillage face de fissure
543 meshFaceFiss = smesh.Mesh(faceFiss)
544 algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.NETGEN_2D)
545 hypo2d = algo2d.Parameters()
546 hypo2d.SetMaxSize( (profondeur - rayonPipe)/math.sqrt(3.0) ) # pour avoir deux couches de triangles equilateraux partout sur la fissure
547 hypo2d.SetOptimize( 1 )
548 hypo2d.SetFineness( 2 )
549 hypo2d.SetMinSize( 2 )
550 hypo2d.SetQuadAllowed( 0 )
551 putName(algo2d.GetSubMesh(), "faceFiss")
552 putName(algo2d, "algo2d_faceFiss")
553 putName(hypo2d, "hypo2d_faceFiss")
555 algo1d = meshFaceFiss.UseExisting1DElements(geom=edgePeauFiss)
556 hypo1d = algo1d.SourceEdges([ groupEdgesPeauFiss ],0,0)
557 putName(algo1d.GetSubMesh(), "edgeFissPeau")
558 putName(algo1d, "algo1d_edgeFissPeau")
559 putName(hypo1d, "hypo1d_edgeFissPeau")
561 algo1d = meshFaceFiss.UseExisting1DElements(geom=groupEdgesFaceFissPipe)
562 hypo1d = algo1d.SourceEdges([ group_generFiss ],0,0)
563 putName(algo1d.GetSubMesh(), "edgeFissPeau")
564 putName(algo1d, "algo1d_edgeFissPeau")
565 putName(hypo1d, "hypo1d_edgeFissPeau")
567 isDone = meshFaceFiss.Compute()
568 logging.info("meshFaceFiss computed")
570 grp = meshFaceFiss.GroupOnGeom(faceFiss, "fisOutPi", SMESH.FACE)
572 meshBoiteDefaut = smesh.Concatenate([internalBoundary.GetMesh(),
573 meshFondFiss.GetMesh(),
574 meshFacePeau.GetMesh(),
575 meshFaceFiss.GetMesh()],
577 # pour aider l'algo hexa-tetra a ne pas mettre de pyramides a l'exterieur des volumes replies sur eux-memes
578 # on designe les faces de peau en quadrangles par le groupe "skinFaces"
579 group_faceFissOutPipe = None
580 group_faceFissInPipe = None
581 groups = meshBoiteDefaut.GetGroups()
583 if grp.GetType() == SMESH.FACE:
584 #if "internalBoundary" in grp.GetName():
585 # grp.SetName("skinFaces")
586 if grp.GetName() == "fisOutPi":
587 group_faceFissOutPipe = grp
588 elif grp.GetName() == "fisInPi":
589 group_faceFissInPipe = grp
591 # le maillage NETGEN ne passe pas toujours ==> utiliser GHS3D
594 algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.GHS3D)
596 algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.NETGEN)
597 hypo3d = algo3d.MaxElementVolume(1000.0)
598 putName(algo3d.GetSubMesh(), "boiteDefaut")
599 putName(algo3d, "algo3d_boiteDefaut")
600 isDone = meshBoiteDefaut.Compute()
601 logging.info("meshBoiteDefaut computed")
602 putName(meshBoiteDefaut, "boiteDefaut")
604 groups = maillageSain.GetGroups()
605 grps1 = [ grp for grp in groups if grp.GetName() == 'P1']
606 grps2 = [ grp for grp in groups if grp.GetName() == 'P2']
607 coords1 = maillageSain.GetNodeXYZ(grps1[0].GetID(1))
608 coords2 = maillageSain.GetNodeXYZ(grps2[0].GetID(1))
609 logging.info("coords1 %s, coords2 %s",coords1, coords2)
611 faceFissure = meshBoiteDefaut.GetMesh().UnionListOfGroups( [ group_faceFissOutPipe, group_faceFissInPipe ], 'FACE1' )
612 maillageSain = enleveDefaut(maillageSain, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges)
613 putName(maillageSain, nomFicSain+"_coupe")
614 extrusionFaceFissure, normfiss = shapeSurFissure(facePorteFissure)
615 maillageComplet = RegroupeSainEtDefaut(maillageSain, meshBoiteDefaut, extrusionFaceFissure, facePorteFissure, 'COUDE')
617 groups = maillageComplet.GetGroups()
618 grps1 = [ grp for grp in groups if grp.GetName() == 'P1']
619 grps2 = [ grp for grp in groups if grp.GetName() == 'P2']
620 nodeid1 = maillageComplet.AddNode(coords1[0], coords1[1], coords1[2])
621 nodeid2 = maillageComplet.AddNode(coords2[0], coords2[1], coords2[2])
622 grps1[0].Add([nodeid1])
623 grps2[0].Add([nodeid2])
624 ma0d1 = maillageComplet.Add0DElement(nodeid1)
625 ma0d2 = maillageComplet.Add0DElement(nodeid2)
626 grpma0d1 = maillageComplet.CreateEmptyGroup( SMESH.ELEM0D, 'P1' )
627 nbAdd = grpma0d1.Add( [ma0d1] )
628 grpma0d2 = maillageComplet.CreateEmptyGroup( SMESH.ELEM0D, 'P2' )
629 nbAdd = grpma0d2.Add( [ma0d2] )
631 # grps = [ grp for grp in groups if grp.GetName() == 'affectedEdges']
632 # grps[0].SetName('affEdges')
633 # grps = [ grp for grp in groups if grp.GetName() == 'affectedFaces']
634 # grps[0].SetName('affFaces')
635 # grps = [ grp for grp in groups if grp.GetName() == 'affectedVolumes']
636 # grps[0].SetName('affVols')
638 maillageComplet.ConvertToQuadratic( 1 )
639 grps = [ grp for grp in groups if grp.GetName() == 'FONDFISS']
640 fond = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FONDFISS' )
642 grps = [ grp for grp in groups if grp.GetName() == 'FACE1']
643 nb = maillageComplet.Reorient2D( grps[0], normfiss, grps[0].GetID(1))
645 plansim = geompy.MakePlane(O, normfiss, 10000)
646 fissnorm = geompy.MakeMirrorByPlane(normfiss, plansim)
647 grps = [ grp for grp in groups if grp.GetName() == 'FACE2']
648 nb = maillageComplet.Reorient2D( grps[0], fissnorm, grps[0].GetID(1))
649 #isDone = maillageComplet.ReorientObject( grps[0] )
650 fond = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FACE2' )
652 maillageComplet.ExportMED(fichierMaillageFissure)
653 putName(maillageComplet, nomFicFissure)
654 logging.info("fichier maillage fissure %s", fichierMaillageFissure)
656 if salome.sg.hasDesktop():
657 salome.sg.updateObjBrowser()
659 return maillageComplet