1 # -*- coding: utf-8 -*-
4 from .geomsmesh import geompy, smesh
5 from .geomsmesh import geomPublish
6 from .geomsmesh import geomPublishInFather
18 from .fissureGenerique import fissureGenerique
20 from .initEtude import initEtude
21 from .triedreBase import triedreBase
22 from .genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut
23 from .creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain
24 from .construitFissureGenerale import construitFissureGenerale
26 O, OX, OY, OZ = triedreBase()
28 class casStandard(fissureGenerique):
30 problème de fissure standard, défini par :
31 - un maillage sain (hexaèdres),
32 - une face géométrique de fissure, qui doit légèrement dépasser hors du volume maillé
33 - les numéros d'arêtes (edges géométriques) correspondant au fond de fissure
34 - les paramètres de maillage de la fissure
37 # ---------------------------------------------------------------------------
38 def __init__ (self, dicoParams, references = None, numeroCas = 0):
40 self.references = references
41 self.dicoParams = dicoParams
42 if 'nomCas' in self.dicoParams:
43 self.nomCas = self.dicoParams['nomCas']
44 elif 'nomres' in self.dicoParams:
45 self.nomCas = os.path.splitext(os.path.split(self.dicoParams['nomres'])[1])[0]
47 self.nomCas = 'casStandard'
48 if 'reptrav' in self.dicoParams:
49 self.reptrav = self.dicoParams['reptrav']
52 self.numeroCas = numeroCas
53 if self.numeroCas != 0:
54 self.nomCas = self.nomProbleme +"_%d"%(self.numeroCas)
56 self.nomProbleme = self.nomCas
57 if 'lenSegPipe' in self.dicoParams:
58 self.lenSegPipe = self.dicoParams['lenSegPipe']
60 self.lenSegPipe =self.dicoParams['rayonPipe']
61 if 'step' in self.dicoParams:
62 step = self.dicoParams['step']
64 step = -1 # exécuter toutes les étapes
65 if 'aretesVives' not in self.dicoParams:
66 self.dicoParams['aretesVives'] = 0
67 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
68 self.executeProbleme(step)
70 # ---------------------------------------------------------------------------
71 def genereMaillageSain(self, geometriesSaines, meshParams):
72 logging.info("genereMaillageSain %s", self.nomCas)
74 ([objetSain], status) = smesh.CreateMeshesFromMED(self.dicoParams['maillageSain'])
75 smesh.SetName(objetSain.GetMesh(), 'objetSain')
77 return [objetSain, True] # True : maillage hexa
79 # ---------------------------------------------------------------------------
80 def setParamShapeFissure(self):
82 paramètres de la fissure pour méthode insereFissureGenerale
83 lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage)
84 rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure
85 convexe : True : la face est convexe (vue de l'exterieur) sert si on ne donne pas de point interne
86 pointIn_x : optionnel : coordonnée x d'un point dans le solide sain (pour orienter la face - idem avec y,z)
88 logging.info("setParamShapeFissure %s", self.nomCas)
89 if 'pointInterieur' in self.dicoParams:
90 self.shapeFissureParams = dict(lgInfluence = self.dicoParams['lgInfluence'],
91 rayonPipe = self.dicoParams['rayonPipe'],
92 lenSegPipe = self.lenSegPipe,
93 pointIn_x = self.dicoParams['pointInterieur'][0],
94 pointIn_y = self.dicoParams['pointInterieur'][1],
95 pointIn_z = self.dicoParams['pointInterieur'][2])
97 self.shapeFissureParams = dict(lgInfluence = self.dicoParams['lgInfluence'],
98 rayonPipe = self.dicoParams['rayonPipe'],
99 lenSegPipe = self.lenSegPipe)
101 # ---------------------------------------------------------------------------
102 def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams):
103 logging.info("genereShapeFissure %s", self.nomCas)
105 lgInfluence = shapeFissureParams['lgInfluence']
107 shellFiss = geompy.ImportFile( self.dicoParams['brepFaceFissure'], "BREP")
108 fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"])
109 geompy.UnionIDs(fondFiss, self.dicoParams['edgeFissIds'] )
110 geomPublish(initLog.debug, shellFiss, 'shellFiss' )
111 geomPublishInFather(initLog.debug, shellFiss, fondFiss, 'fondFiss' )
114 coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, self.dicoParams['meshBrep'][0] ,self.dicoParams['meshBrep'][1])
117 return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss]
119 # ---------------------------------------------------------------------------
120 def setParamMaillageFissure(self):
121 self.maillageFissureParams = dict(nomRep = self.reptrav,
122 nomFicSain = self.nomCas +'_sain',
123 nomFicFissure = self.nomCas,
124 nbsegRad = self.dicoParams['nbSegRad'],
125 nbsegCercle = self.dicoParams['nbSegCercle'],
126 areteFaceFissure = self.dicoParams['areteFaceFissure'],
127 aretesVives = self.dicoParams['aretesVives'])
129 # ---------------------------------------------------------------------------
130 def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams):
131 elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams)
132 return elementsDefaut
134 # ---------------------------------------------------------------------------
135 def genereMaillageFissure(self, geometriesSaines, maillagesSains,
136 shapesFissure, shapeFissureParams,
137 maillageFissureParams, elementsDefaut, step):
138 maillageFissure = construitFissureGenerale(maillagesSains,
139 shapesFissure, shapeFissureParams,
140 maillageFissureParams, elementsDefaut, step)
141 return maillageFissure
143 # ---------------------------------------------------------------------------
144 def setReferencesMaillageFissure(self):
145 if self.references is not None:
146 self.referencesMaillageFissure = self.references
148 self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 0,
149 Entity_Quad_Triangle = 0,
150 Entity_Quad_Edge = 0,
151 Entity_Quad_Penta = 0,
152 Entity_Quad_Hexa = 0,
154 Entity_Quad_Tetra = 0,
155 Entity_Quad_Quadrangle = 0)