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
21 """Cas-test de blocFissure sur un tube"""
22 __revision__ = "V02.04"
32 from blocFissure import gmu
34 #=============== Options ====================
35 # 1. NOM_OBJET = nom de l'objet
38 # 2.1. Le tube : rayon intérieur, rayon extérieur, hauteur
48 # Nombre de segments du tube
52 #============================================
58 from SketchAPI import *
60 from salome.shaper import model
63 partSet = model.moduleDocument()
66 Part_1 = model.addPart(partSet)
67 Part_1_doc = Part_1.document()
68 model.addParameter(Part_1_doc, "R_I", "%f" % RAYON_INT)
69 model.addParameter(Part_1_doc, "R_E", "%f" % RAYON_EXT)
70 model.addParameter(Part_1_doc, "H", "%f" % HAUTEUR)
71 model.addParameter(Part_1_doc, "F_L_1", "{}".format(F_L_1))
72 model.addParameter(Part_1_doc, "F_THETA_1", "{}".format(F_THETA_1))
73 model.addParameter(Part_1_doc, "F_R_1", "{}*{}".format(F_C_1,RAYON_INT))
74 model.addParameter(Part_1_doc, "F_L_2", "{}".format(F_L_2))
77 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
80 SketchLine_1 = Sketch_1.addLine(11.11, -22.82842712474619, 9.84, -22.82842712474619)
83 SketchLine_2 = Sketch_1.addLine(9.84, -22.82842712474619, 9.84, 27.17157287525381)
86 SketchLine_3 = Sketch_1.addLine(9.84, 27.17157287525381, 11.11, 27.17157287525381)
89 SketchLine_4 = Sketch_1.addLine(11.11, 27.17157287525381, 11.11, -22.82842712474619)
90 Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
91 Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
92 Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
93 Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
94 Sketch_1.setHorizontal(SketchLine_1.result())
95 Sketch_1.setVertical(SketchLine_2.result())
96 Sketch_1.setHorizontal(SketchLine_3.result())
97 Sketch_1.setVertical(SketchLine_4.result())
98 Sketch_1.setLength(SketchLine_4.result(), "H")
100 ### Create SketchProjection
101 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
102 SketchPoint_1 = SketchProjection_1.createdFeature()
103 Sketch_1.setHorizontalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.endPoint(), "R_I")
104 Sketch_1.setHorizontalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.startPoint(), "R_E")
107 ### Create Revolution
108 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)
109 Revolution_1.result().setName("Tube")
110 Revolution_1.result().setTransparency(0.9399999999999999)
113 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
116 SketchArc_1 = Sketch_2.addArc(-80, 0, 10.10993798722564, 4.722461741385164, 10.10993798722563, -4.722461741385561, True)
118 ### Create SketchProjection
119 SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False)
120 SketchLine_5 = SketchProjection_2.createdFeature()
121 Sketch_2.setCoincident(SketchArc_1.center(), SketchLine_5.result())
123 ### Create SketchProjection
124 SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
125 SketchPoint_2 = SketchProjection_3.createdFeature()
126 Sketch_2.setHorizontalDistance(SketchArc_1.center(), SketchAPI_Point(SketchPoint_2).coordinates(), "F_L_1")
128 ### Create SketchPoint
129 SketchPoint_3 = Sketch_2.addPoint(10.2336, 0)
130 SketchPoint_3.setAuxiliary(True)
131 Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchArc_1.results()[1])
132 Sketch_2.setMiddlePoint(SketchPoint_3.coordinates(), SketchArc_1.results()[1])
133 Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchLine_5.result())
135 ### Create SketchProjection
136 SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
137 SketchPoint_4 = SketchProjection_4.createdFeature()
138 Sketch_2.setHorizontalDistance(SketchPoint_3.coordinates(), SketchAPI_Point(SketchPoint_4).coordinates(), "F_R_1")
140 ### Create SketchLine
141 SketchLine_6 = Sketch_2.addLine(-80, 0, 10.10993798722564, 4.722461741385164)
142 SketchLine_6.setAuxiliary(True)
143 Sketch_2.setCoincident(SketchArc_1.center(), SketchLine_6.startPoint())
144 Sketch_2.setCoincident(SketchArc_1.startPoint(), SketchLine_6.endPoint())
146 ### Create SketchConstraintAngle
147 Sketch_2.setAngle(SketchLine_5.result(), SketchLine_6.result(), "F_THETA_1", type = "Direct")
149 ### Create SketchProjection
150 SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
151 SketchPoint_5 = SketchProjection_5.createdFeature()
153 ### Create SketchEllipticArc
154 SketchEllipticArc_1 = Sketch_2.addEllipticArc(-20, 8.956370781951521e-27, -10.21629725685072, 9.783702743149284, 10.10993798723031, 4.722461741243296, 9.440921421952831, 9.565935245237778, False)
155 [SketchPoint_6, SketchPoint_7, SketchPoint_8, SketchPoint_9, SketchPoint_10, SketchPoint_11, SketchPoint_12, SketchLine_7, SketchLine_8] = SketchEllipticArc_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
156 Sketch_2.setCoincident(SketchEllipticArc_1.startPoint(), SketchLine_6.endPoint())
157 Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_6).coordinates(), SketchLine_5.result())
158 Sketch_2.setTangent(SketchEllipticArc_1.result(), SketchArc_1.results()[1])
160 ### Create SketchProjection
161 SketchProjection_6 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
162 SketchPoint_13 = SketchProjection_6.createdFeature()
163 Sketch_2.setHorizontalDistance(SketchAPI_Point(SketchPoint_6).coordinates(), SketchAPI_Point(SketchPoint_13).coordinates(), "F_L_2")
165 ### Create SketchLine
166 SketchLine_9 = Sketch_2.addLine(-20, 8.956370781951521e-27, 9.440921421952831, 9.565935245237778)
167 SketchLine_9.setAuxiliary(True)
168 Sketch_2.setCoincident(SketchEllipticArc_1.center(), SketchLine_9.startPoint())
169 Sketch_2.setCoincident(SketchEllipticArc_1.endPoint(), SketchLine_9.endPoint())
171 ### Create SketchConstraintAngle
172 Sketch_2.setAngle(SketchLine_9.result(), SketchLine_5.result(), "6.*F_THETA_1", type = "Direct")
174 ### Create SketchConstraintAngle
175 Sketch_2.setAngle(SketchLine_5.result(), SketchLine_7.result(), 45, type = "Supplementary")
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_10 = Sketch_2.addLine(9.440921421952831, 9.565935245237778, 9.440921421952837, -9.565935245237783)
183 Sketch_2.setCoincident(SketchEllipticArc_1.endPoint(), SketchLine_10.startPoint())
184 Sketch_2.setCoincident(SketchAPI_EllipticArc(SketchEllipticArc_2).endPoint(), SketchLine_10.endPoint())
188 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_1_2r-SketchEllipticArc_1f-SketchLine_10f-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_10")])
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 ficxao = 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(ficxao)
222 _ = model.exportToXAO(Part_1_doc, ficxao, model.selection("FACE", "Fissure"), 'XAO')
227 ### SHAPERSTUDY component
230 model.publishToShaperStudy()
232 l_aux = SHAPERSTUDY.shape(model.featureStringId(Revolution_1))
240 import SMESH, SALOMEDS
241 from salome.smesh import smeshBuilder
243 smesh = smeshBuilder.New()
244 from salome.StdMeshers import StdMeshersBuilder
245 Maillage_tube = smesh.Mesh(objet)
246 smesh.SetName(Maillage_tube, NOM_OBJET)
248 for groupe in l_groups:
249 groupe_nom = groupe.GetName()
250 if ( groupe_nom[:1] == "E" ):
252 elif ( groupe_nom[:1] == "H" ):
254 elif ( groupe_nom[:1] == "P" ):
256 _ = Maillage_tube.GroupOnGeom(groupe,groupe_nom,SMESH.EDGE)
258 Regular_1D = Maillage_tube.Segment()
259 Nb_Segments_1 = Regular_1D.NumberOfSegments(NB_S_P)
260 Nb_Segments_1.SetDistrType( 0 )
261 Quadrangle_2D = Maillage_tube.Quadrangle(algo=smeshBuilder.QUADRANGLE)
262 Hexa_3D = Maillage_tube.Hexahedron(algo=smeshBuilder.Hexa)
264 Regular_1D_1 = Maillage_tube.Segment(geom=group_e)
265 Number_of_Segments_1 = Regular_1D_1.NumberOfSegments(NB_S_E)
266 Propagation_of_1D_Hyp = Regular_1D_1.Propagation()
268 Regular_1D_2 = Maillage_tube.Segment(geom=group_h)
269 Number_of_Segments_2 = Regular_1D_2.NumberOfSegments(NB_S_H)
270 Propagation_of_1D_Hyp_1 = Regular_1D_2.Propagation()
272 is_done = Maillage_tube.Compute()
273 text = "Maillage_tube.Compute"
275 logging.info(text+" OK")
277 text = "Erreur au calcul du maillage.\n" + text
279 raise Exception(text)
281 ficmed = os.path.join(gmu.pathBloc, "materielCasTests","{}.med".format(NOM_OBJET))
282 text = ".. Archivage du maillage dans le fichier '{}'".format(ficmed)
284 Maillage_tube.ExportMED(ficmed)
287 smesh.SetName(Maillage_tube.GetMesh(), 'Maillage_tube')
288 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
289 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
290 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
291 smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
293 if salome.sg.hasDesktop():
294 salome.sg.updateObjBrowser()