1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 from .geomsmesh import geompy
24 from .geomsmesh import geomPublish
25 from .geomsmesh import geomPublishInFather
27 from .geomsmesh import smesh
28 from salome.smesh import smeshBuilder
31 from .putName import putName
33 def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut,
34 facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau,
35 bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives,
36 edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad):
38 maillage faces de peau
41 nbFacesFilling = len(partitionsPeauFissFond)
42 boutFromIfil = [None for i in range(nbFacesFilling)]
43 if idFillingFromBout[0] != idFillingFromBout[1]: # repérage des extremites du pipe quand elles débouchent sur des faces différentes
44 boutFromIfil[idFillingFromBout[0]] = 0
45 boutFromIfil[idFillingFromBout[1]] = 1
47 logging.debug("---------------------------- maillage faces de peau --------------")
49 for ifil in range(nbFacesFilling):
51 if partitionsPeauFissFond[ifil] is None: # face de peau maillage sain intacte
53 logging.debug("meshFacePeau %d intacte", ifil)
54 # --- edges de bord de la face de filling
55 filling = facesDefaut[ifil]
56 edgesFilling = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], False)
57 groupEdgesBordPeau = geompy.CreateGroup(filling, geompy.ShapeType["EDGE"])
58 geompy.UnionList(groupEdgesBordPeau, edgesFilling)
59 geomPublishInFather(initLog.debug,filling, groupEdgesBordPeau , "EdgesBords")
61 meshFacePeau = smesh.Mesh(facesDefaut[ifil])
63 algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
64 hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
65 putName(algo1d.GetSubMesh(), "bordsLibres", ifil)
66 putName(algo1d, "algo1d_bordsLibres", ifil)
67 putName(hypo1d, "hypo1d_bordsLibres", ifil)
71 logging.debug("meshFacePeau %d coupée par la fissure", ifil)
72 facePeau = facesPeaux[ifil] # pour chaque face : la face de peau finale a mailler (percée des faces débouchantes)
73 edgesCircPeau = edCircPeau[ifil] # pour chaque face de peau : [subshape edge circulaire aux débouchés du pipe]
74 verticesCircPeau = ptCircPeau[ifil] # pour chaque face de peau : [subshape point sur edge circulaire aux débouchés du pipe]
75 groupEdgesBordPeau = gpedgeBord[ifil] # pour chaque face de peau : groupe subshape des edges aux bords liés à la partie saine
76 bordsVifs = gpedgeVifs[ifil] # pour chaque face de peau : groupe subshape des edges aux bords correspondant à des arêtes vives
77 edgesFissurePeau = edFissPeau[ifil] # pour chaque face de peau : [subshape edge en peau des faces de fissure externes]
79 meshFacePeau = smesh.Mesh(facePeau)
81 algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
82 hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
83 putName(algo1d.GetSubMesh(), "bordsLibres", ifil)
84 putName(algo1d, "algo1d_bordsLibres", ifil)
85 putName(hypo1d, "hypo1d_bordsLibres", ifil)
87 algo1d = meshFacePeau.UseExisting1DElements(geom=geompy.MakeCompound(edgesFissurePeau))
88 hypo1d = algo1d.SourceEdges([ grpEdgesPeauFissureExterne ],0,0)
89 putName(algo1d.GetSubMesh(), "edgePeauFiss", ifil)
90 putName(algo1d, "algo1d_edgePeauFiss", ifil)
91 putName(hypo1d, "hypo1d_edgePeauFiss", ifil)
93 if bordsVifs is not None:
94 algo1d = meshFacePeau.UseExisting1DElements(geom=bordsVifs)
95 hypo1d = algo1d.SourceEdges([ grpAretesVives ],0,0)
96 putName(algo1d.GetSubMesh(), "bordsVifs", ifil)
97 putName(algo1d, "algo1d_bordsVifs", ifil)
98 putName(hypo1d, "hypo1d_bordsVifs", ifil)
100 for i, edgeCirc in enumerate(edgesCircPeau):
101 if edgeCirc is not None:
102 algo1d = meshFacePeau.UseExisting1DElements(geom=edgeCirc)
103 if boutFromIfil[ifil] is None:
104 hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[i] ],0,0)
106 hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[boutFromIfil[ifil]] ],0,0)
108 putName(algo1d.GetSubMesh(), name, ifil)
109 putName(algo1d, "algo1d_" + name, ifil)
110 putName(hypo1d, "hypo1d_" + name, ifil)
112 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_1D2D)
113 hypo2d = algo2d.Parameters()
114 hypo2d.SetMaxSize( dmoyen )
115 hypo2d.SetOptimize( 1 )
116 hypo2d.SetFineness( 2 )
117 hypo2d.SetMinSize( rayonPipe/float(nbsegRad) )
118 hypo2d.SetQuadAllowed( 0 )
119 putName(algo2d.GetSubMesh(), "facePeau", ifil)
120 putName(algo2d, "algo2d_facePeau", ifil)
121 putName(hypo2d, "hypo2d_facePeau", ifil)
123 isDone = meshFacePeau.Compute()
124 logging.info("meshFacePeau %d fini", ifil)
125 GroupFaces = meshFacePeau.CreateEmptyGroup( SMESH.FACE, "facePeau%d"%ifil )
126 nbAdd = GroupFaces.AddFrom( meshFacePeau.GetMesh() )
127 meshesFacesPeau.append(meshFacePeau)
129 return meshesFacesPeau