1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020 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
20 """Géométrie et maillage de base nécessaire au cas-test :
24 __revision__ = "V02.07"
31 from SketchAPI import *
32 from salome.shaper import model
34 from salome.smesh import smeshBuilder
35 from salome.StdMeshers import StdMeshersBuilder
38 from blocFissure import gmu
39 from blocFissure.gmu.putName import putName
41 #=============== Options ====================
42 # 1. NOM_OBJET = nom de l'objet
45 # 2.1. Le tube : rayon intérieur, rayon extérieur, hauteur
56 # Nombre de segments du tube
60 #============================================
69 partSet = model.moduleDocument()
72 Part_1 = model.addPart(partSet)
73 Part_1_doc = Part_1.document()
74 model.addParameter(Part_1_doc, "R_I", "%f" % RAYON_INT)
75 model.addParameter(Part_1_doc, "R_E", "%f" % RAYON_EXT)
76 model.addParameter(Part_1_doc, "H", "%f" % HAUTEUR)
77 model.addParameter(Part_1_doc, "F_L_1", "{}".format(F_L_1))
78 model.addParameter(Part_1_doc, "F_THETA_1", "{}".format(F_THETA_1))
79 model.addParameter(Part_1_doc, "F_R_1", "{}*{}".format(F_C_1,RAYON_INT))
80 model.addParameter(Part_1_doc, "F_L_2", "{}".format(F_L_2))
81 model.addParameter(Part_1_doc, "F_D_3", "{}*{}".format(F_C_3,RAYON_INT))
84 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
87 SketchLine_1 = Sketch_1.addLine(11.11, -22.82842712474619, 9.84, -22.82842712474619)
90 SketchLine_2 = Sketch_1.addLine(9.84, -22.82842712474619, 9.84, 27.17157287525381)
93 SketchLine_3 = Sketch_1.addLine(9.84, 27.17157287525381, 11.11, 27.17157287525381)
96 SketchLine_4 = Sketch_1.addLine(11.11, 27.17157287525381, 11.11, -22.82842712474619)
97 Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
98 Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
99 Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
100 Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
101 Sketch_1.setHorizontal(SketchLine_1.result())
102 Sketch_1.setVertical(SketchLine_2.result())
103 Sketch_1.setHorizontal(SketchLine_3.result())
104 Sketch_1.setVertical(SketchLine_4.result())
105 Sketch_1.setLength(SketchLine_4.result(), "H")
107 ### Create SketchProjection
108 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
109 SketchPoint_1 = SketchProjection_1.createdFeature()
110 Sketch_1.setHorizontalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.endPoint(), "R_I")
111 Sketch_1.setHorizontalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.startPoint(), "R_E")
114 ### Create Revolution
115 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection("EDGE", "PartSet/OZ"), 180, 0)
116 Revolution_1.result().setName("Tube")
117 Revolution_1.result().setTransparency(0.37)
120 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
123 SketchArc_1 = Sketch_2.addArc(-80, 0, 10.10993798722564, 4.722461741385164, 10.10993798722563, -4.722461741385561, True)
125 ### Create SketchProjection
126 SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False)
127 SketchLine_5 = SketchProjection_2.createdFeature()
128 Sketch_2.setCoincident(SketchArc_1.center(), SketchLine_5.result())
130 ### Create SketchProjection
131 SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
132 SketchPoint_2 = SketchProjection_3.createdFeature()
133 Sketch_2.setHorizontalDistance(SketchArc_1.center(), SketchAPI_Point(SketchPoint_2).coordinates(), "F_L_1")
135 ### Create SketchPoint
136 SketchPoint_3 = Sketch_2.addPoint(10.2336, 0)
137 SketchPoint_3.setAuxiliary(True)
138 Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchArc_1.results()[1])
139 Sketch_2.setMiddlePoint(SketchPoint_3.coordinates(), SketchArc_1.results()[1])
140 Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchLine_5.result())
142 ### Create SketchProjection
143 SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
144 SketchPoint_4 = SketchProjection_4.createdFeature()
145 Sketch_2.setHorizontalDistance(SketchPoint_3.coordinates(), SketchAPI_Point(SketchPoint_4).coordinates(), "F_R_1")
147 ### Create SketchLine
148 SketchLine_6 = Sketch_2.addLine(-80, 0, 10.10993798722564, 4.722461741385164)
149 SketchLine_6.setAuxiliary(True)
150 Sketch_2.setCoincident(SketchArc_1.center(), SketchLine_6.startPoint())
151 Sketch_2.setCoincident(SketchArc_1.startPoint(), SketchLine_6.endPoint())
153 ### Create SketchConstraintAngle
154 Sketch_2.setAngle(SketchLine_5.result(), SketchLine_6.result(), "F_THETA_1", type = "Direct")
156 ### Create SketchEllipticArc
157 SketchEllipticArc_1 = Sketch_2.addEllipticArc(-20, 8.956370781951521e-27, -10.21629725685072, 9.783702743149284, 10.10993798723031, 4.722461741243296, 9.7416, 8.052073253504034, False)
158 [SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchPoint_8, SketchPoint_9, SketchPoint_10, SketchPoint_11, SketchLine_7, SketchLine_8] = \
159 SketchEllipticArc_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
160 Sketch_2.setCoincident(SketchEllipticArc_1.startPoint(), SketchLine_6.endPoint())
161 Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_5).coordinates(), SketchLine_5.result())
162 Sketch_2.setTangent(SketchEllipticArc_1.result(), SketchArc_1.results()[1])
164 ### Create SketchProjection
165 SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
166 SketchPoint_12 = SketchProjection_5.createdFeature()
167 Sketch_2.setHorizontalDistance(SketchAPI_Point(SketchPoint_5).coordinates(), SketchAPI_Point(SketchPoint_12).coordinates(), "F_L_2")
169 ### Create SketchConstraintAngle
170 Sketch_2.setAngle(SketchLine_5.result(), SketchLine_7.result(), 45, type = "Supplementary")
172 ### Create SketchProjection
173 SketchProjection_6 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
174 SketchPoint_13 = SketchProjection_6.createdFeature()
175 Sketch_2.setHorizontalDistance(SketchEllipticArc_1.endPoint(), SketchAPI_Point(SketchPoint_13).coordinates(), "F_D_3")
177 ### Create SketchConstraintMirror
178 SketchConstraintMirror_1 = Sketch_2.addMirror(SketchLine_5.result(), [SketchEllipticArc_1.result()])
179 [SketchEllipticArc_2] = SketchConstraintMirror_1.mirrored()
181 ### Create SketchLine
182 SketchLine_9 = Sketch_2.addLine(9.7416, 8.052073253504034, 9.7416, -8.052073253504034)
183 Sketch_2.setCoincident(SketchEllipticArc_1.endPoint(), SketchLine_9.startPoint())
184 Sketch_2.setCoincident(SketchAPI_EllipticArc(SketchEllipticArc_2).endPoint(), SketchLine_9.endPoint())
188 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_1_2r-SketchEllipticArc_1f-SketchLine_9f-SketchEllipticArc_2f")])
189 Face_1.result().setName("Fissure")
192 Group_1 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "Fissure/Modified_Edge&Sketch_2/SketchEllipticArc_1")])
195 Group_2 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "Fissure/Modified_Edge&Sketch_2/SketchArc_1_2")])
198 Group_3 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "Fissure/Modified_Edge&Sketch_2/SketchEllipticArc_2")])
201 Group_4 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "Fissure/Modified_Edge&Sketch_2/SketchLine_9")])
204 Group_5 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "[Tube/Generated_Face&Sketch_1/SketchLine_1][Tube/From_Face]")])
205 Group_5.setName("Epaisseur")
206 Group_5.result().setName("Epaisseur")
209 Group_6 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "[Tube/Generated_Face&Sketch_1/SketchLine_4][Tube/From_Face]")])
210 Group_6.setName("Hauteur")
211 Group_6.result().setName("Hauteur")
214 Group_7 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "[Tube/Generated_Face&Sketch_1/SketchLine_4][Tube/Generated_Face&Sketch_1/SketchLine_1]")])
215 Group_7.setName("Peripherie")
216 Group_7.result().setName("Peripherie")
219 ficcao = os.path.join(gmu.pathBloc, "materielCasTests", "{}Fiss.xao".format(NOM_OBJET))
220 text = ".. Exportation de la géométrie de la fissure dans le fichier '{}'".format(ficcao)
222 _ = model.exportToXAO(Part_1_doc, ficcao, model.selection("FACE", "Fissure"), 'XAO')
227 ### SHAPERSTUDY component
230 model.publishToShaperStudy()
232 l_aux = SHAPERSTUDY.shape(model.featureStringId(Revolution_1))
240 smesh = smeshBuilder.New()
241 Maillage_tube = smesh.Mesh(objet)
242 putName(Maillage_tube.GetMesh(), NOM_OBJET)
244 for groupe in l_groups:
245 groupe_nom = groupe.GetName()
246 if ( groupe_nom[:1] == "E" ):
248 elif ( groupe_nom[:1] == "H" ):
250 elif ( groupe_nom[:1] == "P" ):
252 _ = Maillage_tube.GroupOnGeom(groupe,groupe_nom,SMESH.EDGE)
254 Regular_1D = Maillage_tube.Segment()
255 Nb_Segments_1 = Regular_1D.NumberOfSegments(NB_S_P)
256 Nb_Segments_1.SetDistrType( 0 )
257 Quadrangle_2D = Maillage_tube.Quadrangle(algo=smeshBuilder.QUADRANGLE)
258 Hexa_3D = Maillage_tube.Hexahedron(algo=smeshBuilder.Hexa)
260 Regular_1D_1 = Maillage_tube.Segment(geom=group_e)
261 Number_of_Segments_1 = Regular_1D_1.NumberOfSegments(NB_S_E)
262 Propagation_of_1D_Hyp = Regular_1D_1.Propagation()
264 Regular_1D_2 = Maillage_tube.Segment(geom=group_h)
265 Number_of_Segments_2 = Regular_1D_2.NumberOfSegments(NB_S_H)
266 Propagation_of_1D_Hyp_1 = Regular_1D_2.Propagation()
269 #smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
270 #smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
271 #smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
272 putName(Nb_Segments_1, 'Nb. Segments_1', i_pref='tube')
273 putName(Number_of_Segments_1, 'Number_of_Segments_1', i_pref='tube')
274 putName(Number_of_Segments_2, 'Number_of_Segments_2', i_pref='tube')
275 putName(Propagation_of_1D_Hyp, 'Propagation', i_pref='tube')
277 is_done = Maillage_tube.Compute()
278 text = "Maillage_tube.Compute"
280 logging.info(text+" OK")
282 text = "Erreur au calcul du maillage.\n" + text
284 raise Exception(text)
286 ficmed = os.path.join(gmu.pathBloc, "materielCasTests","{}.med".format(NOM_OBJET))
287 text = ".. Archivage du maillage dans le fichier '{}'".format(ficmed)
289 Maillage_tube.ExportMED(ficmed)
291 if salome.sg.hasDesktop():
292 salome.sg.updateObjBrowser()