1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2019 CEA/DEN, 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
22 from .geomsmesh import geompy, smesh
23 from .geomsmesh import geomPublish
24 from .geomsmesh import geomPublishInFather
36 from .fissureGenerique import fissureGenerique
38 from .initEtude import initEtude
39 from .triedreBase import triedreBase
40 from .genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut
41 from .creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain
42 from .construitFissureGenerale import construitFissureGenerale
44 O, OX, OY, OZ = triedreBase()
46 class casStandard(fissureGenerique):
48 problème de fissure standard, défini par :
49 - un maillage sain (hexaèdres),
50 - une face géométrique de fissure, qui doit légèrement dépasser hors du volume maillé
51 - les numéros d'arêtes (edges géométriques) correspondant au fond de fissure
52 - les paramètres de maillage de la fissure
55 # ---------------------------------------------------------------------------
56 def __init__ (self, dicoParams, references = None, numeroCas = 0):
58 self.references = references
59 self.dicoParams = dicoParams
60 if 'nomCas' in self.dicoParams:
61 self.nomCas = self.dicoParams['nomCas']
62 elif 'nomres' in self.dicoParams:
63 self.nomCas = os.path.splitext(os.path.split(self.dicoParams['nomres'])[1])[0]
65 self.nomCas = 'casStandard'
66 if 'reptrav' in self.dicoParams:
67 self.reptrav = self.dicoParams['reptrav']
70 self.numeroCas = numeroCas
71 if self.numeroCas != 0:
72 self.nomCas = self.nomProbleme +"_%d"%(self.numeroCas)
74 self.nomProbleme = self.nomCas
75 if 'lenSegPipe' in self.dicoParams:
76 self.lenSegPipe = self.dicoParams['lenSegPipe']
78 self.lenSegPipe =self.dicoParams['rayonPipe']
79 if 'step' in self.dicoParams:
80 step = self.dicoParams['step']
82 step = -1 # exécuter toutes les étapes
83 if 'aretesVives' not in self.dicoParams:
84 self.dicoParams['aretesVives'] = 0
85 if self.numeroCas == 0: # valeur par défaut : exécution immédiate, sinon execution différée dans le cas d'une liste de problèmes
86 self.executeProbleme(step)
88 # ---------------------------------------------------------------------------
89 def genereMaillageSain(self, geometriesSaines, meshParams):
90 logging.info("genereMaillageSain %s", self.nomCas)
92 ([objetSain], status) = smesh.CreateMeshesFromMED(self.dicoParams['maillageSain'])
93 smesh.SetName(objetSain.GetMesh(), 'objetSain')
95 return [objetSain, True] # True : maillage hexa
97 # ---------------------------------------------------------------------------
98 def setParamShapeFissure(self):
100 paramètres de la fissure pour méthode insereFissureGenerale
101 lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage)
102 rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure
103 convexe : True : la face est convexe (vue de l'exterieur) sert si on ne donne pas de point interne
104 pointIn_x : optionnel : coordonnée x d'un point dans le solide sain (pour orienter la face - idem avec y,z)
106 logging.info("setParamShapeFissure %s", self.nomCas)
107 if 'pointInterieur' in self.dicoParams:
108 self.shapeFissureParams = dict(lgInfluence = self.dicoParams['lgInfluence'],
109 rayonPipe = self.dicoParams['rayonPipe'],
110 lenSegPipe = self.lenSegPipe,
111 pointIn_x = self.dicoParams['pointInterieur'][0],
112 pointIn_y = self.dicoParams['pointInterieur'][1],
113 pointIn_z = self.dicoParams['pointInterieur'][2])
115 self.shapeFissureParams = dict(lgInfluence = self.dicoParams['lgInfluence'],
116 rayonPipe = self.dicoParams['rayonPipe'],
117 lenSegPipe = self.lenSegPipe)
119 # ---------------------------------------------------------------------------
120 def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams):
121 logging.info("genereShapeFissure %s", self.nomCas)
123 lgInfluence = shapeFissureParams['lgInfluence']
125 shellFiss = geompy.ImportFile( self.dicoParams['brepFaceFissure'], "BREP")
126 fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"])
127 geompy.UnionIDs(fondFiss, self.dicoParams['edgeFissIds'] )
128 geomPublish(initLog.debug, shellFiss, 'shellFiss' )
129 geomPublishInFather(initLog.debug, shellFiss, fondFiss, 'fondFiss' )
132 coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, self.dicoParams['meshBrep'][0] ,self.dicoParams['meshBrep'][1])
135 return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss]
137 # ---------------------------------------------------------------------------
138 def setParamMaillageFissure(self):
139 self.maillageFissureParams = dict(nomRep = self.reptrav,
140 nomFicSain = self.nomCas +'_sain',
141 nomFicFissure = self.nomCas,
142 nbsegRad = self.dicoParams['nbSegRad'],
143 nbsegCercle = self.dicoParams['nbSegCercle'],
144 areteFaceFissure = self.dicoParams['areteFaceFissure'],
145 aretesVives = self.dicoParams['aretesVives'])
147 # ---------------------------------------------------------------------------
148 def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams):
149 elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams)
150 return elementsDefaut
152 # ---------------------------------------------------------------------------
153 def genereMaillageFissure(self, geometriesSaines, maillagesSains,
154 shapesFissure, shapeFissureParams,
155 maillageFissureParams, elementsDefaut, step):
156 maillageFissure = construitFissureGenerale(maillagesSains,
157 shapesFissure, shapeFissureParams,
158 maillageFissureParams, elementsDefaut, step)
159 return maillageFissure
161 # ---------------------------------------------------------------------------
162 def setReferencesMaillageFissure(self):
163 if self.references is not None:
164 self.referencesMaillageFissure = self.references
166 self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 0,
167 Entity_Quad_Triangle = 0,
168 Entity_Quad_Edge = 0,
169 Entity_Quad_Penta = 0,
170 Entity_Quad_Hexa = 0,
172 Entity_Quad_Tetra = 0,
173 Entity_Quad_Quadrangle = 0)