1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2024 CEA, EDF
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"""
26 from salome.smesh import smeshBuilder
28 from .geomsmesh import geompy
29 from .geomsmesh import geomPublishInFather
30 from .geomsmesh import smesh
34 from .putName import putName
36 def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \
37 facesPeaux, edCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, \
38 bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives, \
39 edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad, \
40 mailleur="MeshGems", nro_cas=None):
41 """maillage faces de peau"""
43 logging.info("Maillage avec %s pour le cas n°%s", mailleur, nro_cas)
45 nbFacesFilling = len(partitionsPeauFissFond)
46 boutFromIfil = [None for _ in range(nbFacesFilling)]
47 # repérage des extremites du pipe quand elles débouchent sur des faces différentes :
48 if ( idFillingFromBout[0] != idFillingFromBout[1] ):
49 boutFromIfil[idFillingFromBout[0]] = 0
50 boutFromIfil[idFillingFromBout[1]] = 1
52 logging.info("---------------------------- maillage faces de peau --------------")
53 logging.info("nbFacesFilling = %d", nbFacesFilling)
54 meshesFacesPeau = list()
55 for ifil in range(nbFacesFilling):
57 if partitionsPeauFissFond[ifil] is None: # face de peau maillage sain intacte
58 logging.info("face de peau %d intacte", ifil)
59 facePeau = facesDefaut[ifil]
61 logging.info("face de peau %d coupée par la fissure", ifil)
62 # pour chaque face : la face de peau finale a mailler (percée des faces débouchantes)
63 facePeau = facesPeaux[ifil]
64 meshFacePeau = smesh.Mesh(facePeau)
65 putName(meshFacePeau.GetMesh(), "facePeau", ifil, nro_cas)
67 if ( mailleur == "MeshGems"):
68 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.MG_CADSurf)
69 hypo2d = algo2d.Parameters()
70 hypo2d.SetPhySize( dmoyen )
71 hypo2d.SetMinSize( rayonPipe/float(nbsegRad) )
72 hypo2d.SetMaxSize( dmoyen*2. )
73 hypo2d.SetChordalError( dmoyen*0.25 )
74 hypo2d.SetVerbosity( 0 )
76 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_1D2D)
77 hypo2d = algo2d.Parameters()
78 hypo2d.SetMaxSize( dmoyen )
79 hypo2d.SetOptimize( 1 )
80 hypo2d.SetFineness( 2 )
81 hypo2d.SetMinSize( rayonPipe/float(nbsegRad) )
82 hypo2d.SetChordalErrorEnabled (True)
83 hypo2d.SetChordalError( dmoyen*0.25 )
84 hypo2d.SetUseSurfaceCurvature (True)
85 hypo2d.SetQuadAllowed( 0 )
86 putName(hypo2d, "{}_2d_facePeau".format(mailleur), ifil, nro_cas)
88 if partitionsPeauFissFond[ifil] is None: # face de peau maillage sain intacte
90 logging.debug("face de peau %d intacte", ifil)
91 # --- edges de bord de la face de filling
92 filling = facesDefaut[ifil]
93 edgesFilling = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], False)
94 gpedgeBord[ifil] = geompy.CreateGroup(filling, geompy.ShapeType["EDGE"])
95 geompy.UnionList(gpedgeBord[ifil], edgesFilling)
96 geomPublishInFather(initLog.always, filling, gpedgeBord[ifil], "EdgesBords", nro_cas)
98 logging.info("UseExisting1DElements sur la géométrie '%s' avec les mailles de '%s'", \
99 gpedgeBord[ifil].GetName(), bordsLibres.GetName())
100 algo1d = meshFacePeau.UseExisting1DElements(geom=gpedgeBord[ifil])
101 putName(algo1d.GetSubMesh(), "bordsLibres", ifil, nro_cas)
102 hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
103 putName(hypo1d, "SourceEdges_{}".format(bordsLibres.GetName()), ifil, nro_cas)
107 logging.info("face de peau %d coupée par la fissure", ifil)
108 # edCircPeau[ifil] # pour chaque face de peau : [subshape edge circulaire aux débouchés du pipe]
109 # gpedgeBord[ifil] : pour chaque face de peau : groupe subshape des edges aux bords liés à la partie saine
110 # gpedgeVifs[ifil] : pour chaque face de peau : groupe subshape des edges aux bords correspondant à des arêtes vives
111 # edFissPeau[ifil] : pour chaque face de peau : [subshape edge en peau des faces de fissure externes]
113 logging.info("UseExisting1DElements sur la géométrie '%s' avec les mailles de '%s'", \
114 gpedgeBord[ifil].GetName(), bordsLibres.GetName())
115 algo1d = meshFacePeau.UseExisting1DElements(geom=gpedgeBord[ifil])
116 putName(algo1d.GetSubMesh(), "bordsLibres", ifil, nro_cas)
117 hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
118 putName(hypo1d, "SourceEdges_{}".format(bordsLibres.GetName()), i_pref=nro_cas)
120 objet = geompy.MakeCompound(edFissPeau[ifil])
121 geomPublishInFather(initLog.always, facePeau, objet, "edFissPeau_{}".format(ifil))
122 logging.info("UseExisting1DElements sur la géométrie '%s' avec les mailles de '%s'", \
123 objet.GetName(), grpEdgesPeauFissureExterne.GetName())
124 algo1d = meshFacePeau.UseExisting1DElements(geom=objet)
125 putName(algo1d.GetSubMesh(), objet.GetName(), i_pref=nro_cas)
126 hypo1d = algo1d.SourceEdges([ grpEdgesPeauFissureExterne ],0,0)
127 putName(hypo1d, "SourceEdges_{}".format(grpEdgesPeauFissureExterne.GetName()), i_pref=nro_cas)
129 if gpedgeVifs[ifil] is not None:
130 logging.info("UseExisting1DElements sur la géométrie '%s' avec les mailles de '%s'", \
131 gpedgeVifs[ifil].GetName(), grpAretesVives.GetName())
132 algo1d = meshFacePeau.UseExisting1DElements(geom=gpedgeVifs[ifil])
133 putName(algo1d.GetSubMesh(), "gpedgeVifs", ifil, nro_cas)
134 hypo1d = algo1d.SourceEdges([ grpAretesVives ],0,0)
135 putName(hypo1d, "SourceEdges_{}".format(grpAretesVives.GetName()), i_pref=nro_cas)
137 for i_aux, edgeCirc in enumerate(edCircPeau[ifil]):
138 texte = "i_aux = {}".format(i_aux)
140 if edgeCirc is not None:
141 if boutFromIfil[ifil] is None:
142 groupe = edgesCircPipeGroup[i_aux]
144 groupe = edgesCircPipeGroup[boutFromIfil[ifil]]
145 logging.info("UseExisting1DElements sur la géométrie '%s' avec les mailles de '%s'", \
146 edgeCirc.GetName(), groupe.GetName())
147 algo1d = meshFacePeau.UseExisting1DElements(geom=edgeCirc) # addToStudy() failed ?
148 putName(algo1d.GetSubMesh(), groupe.GetName(), i_pref=nro_cas)
149 hypo1d = algo1d.SourceEdges([ groupe ],0,0)
150 putName(hypo1d, "SourceEdges_{}".format(groupe.GetName()), i_pref=nro_cas)
152 is_done = meshFacePeau.Compute()
153 text = "meshFacePeau {} .Compute".format(ifil)
155 logging.info(text+" OK")
157 text = "Erreur au calcul du maillage.\n" + text
159 raise Exception(text)
161 groupe_des_faces = meshFacePeau.CreateEmptyGroup( SMESH.FACE, "facePeau%d"%ifil )
162 _ = groupe_des_faces.AddFrom( meshFacePeau.GetMesh() )
163 meshesFacesPeau.append(meshFacePeau)
165 return meshesFacesPeau