1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021 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
21 """maillage faces de peau"""
25 from .geomsmesh import geompy
26 from .geomsmesh import geomPublish
27 from .geomsmesh import geomPublishInFather
29 from .geomsmesh import smesh
30 from salome.smesh import smeshBuilder
33 from .putName import putName
35 def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \
36 facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, \
37 bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives, \
38 edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad, \
40 """maillage faces de peau"""
42 logging.info(mailleur)
43 nbFacesFilling = len(partitionsPeauFissFond)
44 boutFromIfil = [None for i in range(nbFacesFilling)]
45 if idFillingFromBout[0] != idFillingFromBout[1]: # repérage des extremites du pipe quand elles débouchent sur des faces différentes
46 boutFromIfil[idFillingFromBout[0]] = 0
47 boutFromIfil[idFillingFromBout[1]] = 1
49 logging.info("---------------------------- maillage faces de peau --------------")
50 logging.info("nbFacesFilling = %d", nbFacesFilling)
51 meshesFacesPeau = list()
52 for ifil in range(nbFacesFilling):
54 if partitionsPeauFissFond[ifil] is None: # face de peau maillage sain intacte
56 logging.debug("meshFacePeau %d intacte", ifil)
57 # --- edges de bord de la face de filling
58 filling = facesDefaut[ifil]
59 edgesFilling = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], False)
60 groupEdgesBordPeau = geompy.CreateGroup(filling, geompy.ShapeType["EDGE"])
61 geompy.UnionList(groupEdgesBordPeau, edgesFilling)
62 geomPublishInFather(initLog.debug,filling, groupEdgesBordPeau , "EdgesBords")
64 meshFacePeau = smesh.Mesh(facesDefaut[ifil])
66 algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
67 hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
68 putName(algo1d.GetSubMesh(), "bordsLibres", ifil)
69 putName(algo1d, "algo1d_bordsLibres", ifil)
70 putName(hypo1d, "hypo1d_bordsLibres", ifil)
74 logging.info("meshFacePeau %d coupée par la fissure", ifil)
75 facePeau = facesPeaux[ifil] # pour chaque face : la face de peau finale a mailler (percée des faces débouchantes)
76 edgesCircPeau = edCircPeau[ifil] # pour chaque face de peau : [subshape edge circulaire aux débouchés du pipe]
77 _ = ptCircPeau[ifil] # pour chaque face de peau : [subshape point sur edge circulaire aux débouchés du pipe]
78 groupEdgesBordPeau = gpedgeBord[ifil] # pour chaque face de peau : groupe subshape des edges aux bords liés à la partie saine
79 bordsVifs = gpedgeVifs[ifil] # pour chaque face de peau : groupe subshape des edges aux bords correspondant à des arêtes vives
80 edgesFissurePeau = edFissPeau[ifil] # pour chaque face de peau : [subshape edge en peau des faces de fissure externes]
83 meshFacePeau = smesh.Mesh(facePeau)
85 algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
86 hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
87 putName(algo1d.GetSubMesh(), "bordsLibres", ifil)
88 putName(algo1d, "algo1d_bordsLibres", ifil)
89 putName(hypo1d, "hypo1d_bordsLibres", ifil)
92 algo1d = meshFacePeau.UseExisting1DElements(geom=geompy.MakeCompound(edgesFissurePeau))
93 hypo1d = algo1d.SourceEdges([ grpEdgesPeauFissureExterne ],0,0)
94 putName(algo1d.GetSubMesh(), "edgePeauFiss", ifil)
95 putName(algo1d, "algo1d_edgePeauFiss", ifil)
96 putName(hypo1d, "hypo1d_edgePeauFiss", ifil)
98 if bordsVifs is not None:
99 algo1d = meshFacePeau.UseExisting1DElements(geom=bordsVifs)
100 hypo1d = algo1d.SourceEdges([ grpAretesVives ],0,0)
101 putName(algo1d.GetSubMesh(), "bordsVifs", ifil)
102 putName(algo1d, "algo1d_bordsVifs", ifil)
103 putName(hypo1d, "hypo1d_bordsVifs", ifil)
105 for i, edgeCirc in enumerate(edgesCircPeau):
106 logging.info("i = {}".format(i))
107 if edgeCirc is not None:
108 algo1d = meshFacePeau.UseExisting1DElements(geom=edgeCirc)
109 if boutFromIfil[ifil] is None:
110 hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[i] ],0,0)
112 hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[boutFromIfil[ifil]] ],0,0)
114 putName(algo1d.GetSubMesh(), name, ifil)
115 putName(algo1d, "algo1d_" + name, ifil)
116 putName(hypo1d, "hypo1d_" + name, ifil)
119 logging.info("Maillage avec %s", mailleur)
120 if ( mailleur == "MeshGems"):
121 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.MG_CADSurf)
122 hypo2d = algo2d.Parameters()
123 hypo2d.SetPhySize( dmoyen )
124 hypo2d.SetMinSize( rayonPipe/float(nbsegRad) )
125 hypo2d.SetMaxSize( dmoyen*2. )
126 hypo2d.SetChordalError( dmoyen*0.25 )
127 hypo2d.SetVerbosity( 0 )
129 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_1D2D)
130 hypo2d = algo2d.Parameters()
131 hypo2d.SetMaxSize( dmoyen )
132 hypo2d.SetOptimize( 1 )
133 hypo2d.SetFineness( 2 )
134 hypo2d.SetMinSize( rayonPipe/float(nbsegRad) )
135 hypo2d.SetQuadAllowed( 0 )
137 putName(algo2d.GetSubMesh(), "facePeau", ifil)
138 putName(algo2d, "algo2d_facePeau", ifil)
139 putName(hypo2d, "hypo2d_facePeau", ifil)
141 is_done = meshFacePeau.Compute()
142 text = "meshFacePeau {} .Compute".format(ifil)
144 logging.info(text+" OK")
146 text = "Erreur au calcul du maillage.\n" + text
148 raise Exception(text)
150 GroupFaces = meshFacePeau.CreateEmptyGroup( SMESH.FACE, "facePeau%d"%ifil )
151 _ = GroupFaces.AddFrom( meshFacePeau.GetMesh() )
152 meshesFacesPeau.append(meshFacePeau)
154 return meshesFacesPeau