Salome HOME
Merge branch 'master' into gni/evolution
[modules/smesh.git] / src / Tools / blocFissure / gmu / mailleFacesPeau.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020  EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 """maillage faces de peau"""
22
23 import logging
24
25 from .geomsmesh import geompy
26 from .geomsmesh import geomPublish
27 from .geomsmesh import geomPublishInFather
28 from . import initLog
29 from .geomsmesh import smesh
30 from salome.smesh import smeshBuilder
31 import SMESH
32
33 from .putName import putName
34
35 def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut,
36                     facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau,
37                     bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives,
38                     edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad):
39   """maillage faces de peau"""
40   logging.info('start')
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
46
47   logging.debug("---------------------------- maillage faces de peau --------------")
48   meshesFacesPeau = []
49   for ifil in range(nbFacesFilling):
50     meshFacePeau = None
51     if partitionsPeauFissFond[ifil] is None: # face de peau maillage sain intacte
52
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")
60
61       meshFacePeau = smesh.Mesh(facesDefaut[ifil])
62
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)
68
69     else:
70
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]
78
79       meshFacePeau = smesh.Mesh(facePeau)
80
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)
86
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)
92
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)
99
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)
105           else:
106             hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[boutFromIfil[ifil]] ],0,0)
107           name = "cercle%d"%i
108           putName(algo1d.GetSubMesh(), name, ifil)
109           putName(algo1d, "algo1d_" + name, ifil)
110           putName(hypo1d, "hypo1d_" + name, ifil)
111
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)
122
123     is_done = meshFacePeau.Compute()
124     text = "meshFacePeau {} .Compute".format(ifil)
125     if is_done:
126       logging.info(text+" OK")
127     else:
128       text = "Erreur au calcul du maillage.\n" + text
129       logging.info(text)
130       raise Exception(text)
131
132     GroupFaces = meshFacePeau.CreateEmptyGroup( SMESH.FACE, "facePeau%d"%ifil )
133     nbAdd = GroupFaces.AddFrom( meshFacePeau.GetMesh() )
134     meshesFacesPeau.append(meshFacePeau)
135
136   return meshesFacesPeau