1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2023 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
25 from .geomsmesh import geompy, smesh
26 from .geomsmesh import geomPublish
27 from .geomsmesh import geomPublishInFather
31 from .fissureGenerique import fissureGenerique
33 from .initEtude import initEtude
34 from .triedreBase import triedreBase
35 from .genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut
36 from .creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain
37 from .construitFissureGenerale import construitFissureGenerale
38 from .putName import putName
40 O, OX, OY, OZ = triedreBase()
42 class casStandard(fissureGenerique):
43 """problème de fissure standard, défini par :
45 - un maillage sain (hexaèdres),
46 - une face géométrique de fissure, qui doit légèrement dépasser hors du volume maillé
47 - les noms des groupes d'arêtes ou leurs numéros d'arêtes (edges au sens de GEOM) correspondant au fond de fissure
48 - les paramètres de maillage de la fissure
50 referencesMaillageFissure = None
52 # ---------------------------------------------------------------------------
53 def __init__ (self, dicoParams, references = None, numeroCas = None):
55 self.references = references
56 self.dicoParams = dicoParams
57 self.numeroCas = numeroCas
59 if 'nomProbleme' in self.dicoParams:
60 self.nomProbleme = self.dicoParams['nomProbleme']
62 if 'nomCas' in self.dicoParams:
63 self.nomCas = self.dicoParams['nomCas']
64 elif 'nomres' in self.dicoParams:
65 self.nomCas = os.path.splitext(os.path.split(self.dicoParams['nomres'])[1])[0]
66 elif ( self.numeroCas is not None ):
67 self.nomCas = self.nomProbleme +"_%d"%(self.numeroCas)
69 self.nomCas = 'casStandard'
71 if 'reptrav' in self.dicoParams:
72 self.reptrav = self.dicoParams['reptrav']
74 self.reptrav = os.curdir
76 if 'lenSegPipe' in self.dicoParams:
77 self.lenSegPipe = self.dicoParams['lenSegPipe']
79 self.lenSegPipe = self.dicoParams['rayonPipe']
81 if 'step' in self.dicoParams:
82 step = self.dicoParams['step']
84 step = -1 # exécuter toutes les étapes
86 if 'aretesVives' not in self.dicoParams:
87 self.dicoParams['aretesVives'] = 0
89 # valeur par défaut : exécution immédiate, sinon execution différée dans le cas d'une liste de problèmes
90 if ( self.numeroCas is None ):
91 self.executeProbleme(step)
93 # ---------------------------------------------------------------------------
94 def genereMaillageSain(self, geometriesSaines, meshParams):
95 logging.info("genereMaillageSain %s", self.nomCas)
97 ([objetSain], _) = smesh.CreateMeshesFromMED(self.dicoParams['maillageSain'])
98 putName(objetSain.GetMesh(), objetSain.GetName(), i_pref=self.numeroCas)
100 return [objetSain, True] # True : maillage hexa
102 # ---------------------------------------------------------------------------
103 def setParamShapeFissure(self):
105 paramètres de la fissure pour méthode insereFissureGenerale
106 lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage)
107 rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure
108 convexe : True : la face est convexe (vue de l'exterieur) sert si on ne donne pas de point interne
109 pointIn_x : optionnel : coordonnée x d'un point dans le solide sain (pour orienter la face - idem avec y,z)
111 logging.info("setParamShapeFissure %s", self.nomCas)
112 if 'pointInterieur' in self.dicoParams:
113 self.shapeFissureParams = dict(lgInfluence = self.dicoParams['lgInfluence'],
114 rayonPipe = self.dicoParams['rayonPipe'],
115 lenSegPipe = self.lenSegPipe,
116 pointIn_x = self.dicoParams['pointInterieur'][0],
117 pointIn_y = self.dicoParams['pointInterieur'][1],
118 pointIn_z = self.dicoParams['pointInterieur'][2])
120 self.shapeFissureParams = dict(lgInfluence = self.dicoParams['lgInfluence'],
121 rayonPipe = self.dicoParams['rayonPipe'],
122 lenSegPipe = self.lenSegPipe)
124 # ---------------------------------------------------------------------------
125 def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams, \
126 mailleur="MeshGems"):
128 lgInfluence = shapeFissureParams['lgInfluence']
130 # Contrôle de 'brepFaceFissure' pour les anciennes versions
131 if ( 'brepFaceFissure' in self.dicoParams ):
132 self.dicoParams['CAOFaceFissure'] = self.dicoParams['brepFaceFissure']
133 cao_file = self.dicoParams['CAOFaceFissure']
134 suffix = os.path.basename(cao_file).split(".")[-1]
135 if ( suffix.upper() == "BREP" ):
136 shellFiss = geompy.ImportBREP(cao_file)
137 elif ( suffix.upper() == "XAO" ):
138 (_, shellFiss, _, l_groups, _) = geompy.ImportXAO(cao_file)
139 fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"])
140 # Contrôle de 'edgeFissIds' pour les anciennes versions
141 if ( 'edgeFissIds' in self.dicoParams ):
142 self.dicoParams['edgeFiss'] = self.dicoParams['edgeFissIds']
143 if isinstance(self.dicoParams['edgeFiss'][0],int):
144 geompy.UnionIDs(fondFiss, self.dicoParams['edgeFiss'] )
146 l_groups = geompy.GetGroups(shellFiss)
148 for group in l_groups:
149 if ( group.GetName() in self.dicoParams['edgeFiss'] ):
151 geompy.UnionList(fondFiss, l_aux )
152 geomPublish(initLog.debug, shellFiss, 'shellFiss' )
153 geomPublishInFather(initLog.debug, shellFiss, fondFiss, 'fondFiss' )
156 coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, self.dicoParams['meshBrep'][0] ,self.dicoParams['meshBrep'][1], \
157 mailleur, self.numeroCas)
160 return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss]
162 # ---------------------------------------------------------------------------
163 def setParamMaillageFissure(self):
164 self.maillageFissureParams = dict(nomRep = self.reptrav,
165 nomFicSain = self.nomCas,
166 nomFicFissure = self.nomProbleme + "_fissure",
167 nbsegRad = self.dicoParams['nbSegRad'],
168 nbsegCercle = self.dicoParams['nbSegCercle'],
169 areteFaceFissure = self.dicoParams['areteFaceFissure'],
170 aretesVives = self.dicoParams['aretesVives'])
172 # ---------------------------------------------------------------------------
173 def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams):
174 elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams, \
176 return elementsDefaut
178 # ---------------------------------------------------------------------------
179 def genereMaillageFissure(self, geometriesSaines, maillagesSains, \
180 shapesFissure, shapeFissureParams, \
181 maillageFissureParams, elementsDefaut, step, \
182 mailleur="MeshGems"):
183 maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
184 maillageFissureParams, elementsDefaut, \
185 mailleur, self.numeroCas)
186 return maillageFissure
188 # ---------------------------------------------------------------------------
189 def setReferencesMaillageFissure(self):
190 if self.references is not None:
191 self.referencesMaillageFissure = self.references
193 self.referencesMaillageFissure = dict( \
194 Entity_Quad_Quadrangle = 0, \
195 Entity_Quad_Hexa = 0, \
197 Entity_Quad_Edge = 0, \
198 Entity_Quad_Triangle = 0, \
199 Entity_Quad_Tetra = 0, \
200 Entity_Quad_Pyramid = 0, \
201 Entity_Quad_Penta = 0 \