Salome HOME
Affichage
[modules/smesh.git] / src / Tools / blocFissure / materielCasTests / decoupeCylindre.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021  EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 """Géométries et maillages de base nécessaires aux cas-tests :
21 . cylindre
22 . cylindre_2
23 """
24
25 import os
26 import math
27
28 import logging
29
30 import salome
31 from salome.smesh import smeshBuilder
32 import GEOM
33 import SMESH
34 import SALOMEDS
35
36 from blocFissure import gmu
37 from blocFissure.gmu.geomsmesh import geompy
38 from blocFissure.gmu.geomsmesh import geomPublish
39 from blocFissure.gmu.geomsmesh import geomPublishInFather
40
41 from blocFissure.gmu.triedreBase import triedreBase
42 from blocFissure.gmu.putName import putName
43 from blocFissure.gmu import initLog
44
45 ###
46 ### GEOM component
47 ###
48
49 O, OX, OY, OZ = triedreBase()
50
51 Vertex_1 = geompy.MakeVertex(0, 0, 500)
52 Vertex_2 = geompy.MakeVertex(100, 0, 500)
53 Vertex_3 = geompy.MakeVertex(110, 0, 500)
54 Vertex_4 = geompy.MakeVertex(117.071068, -2.928932, 500)
55 Vertex_5 = geompy.MakeVertex(120, -10, 500)
56 Vertex_6 = geompy.MakeVertex(120, -30, 500)
57 Vertex_7 = geompy.MakeVertex(122.928932, -37.071068, 500)
58 Vertex_8 = geompy.MakeVertex(130, -40, 500)
59 Vertex_9 = geompy.MakeVertex(135, -40, 500)
60 Vertex_10 = geompy.MakeVertex(160, -40, 500)
61 Plane_1 = geompy.MakePlaneLCS(None, 2000, 2)
62 Mirror_1_1 = geompy.MakeMirrorByPlane(Vertex_2, Plane_1)
63 Mirror_1_2 = geompy.MakeMirrorByPlane(Vertex_3, Plane_1)
64 Mirror_1_3 = geompy.MakeMirrorByPlane(Vertex_4, Plane_1)
65 Mirror_1_4 = geompy.MakeMirrorByPlane(Vertex_5, Plane_1)
66 Mirror_1_5 = geompy.MakeMirrorByPlane(Vertex_6, Plane_1)
67 Mirror_1_6 = geompy.MakeMirrorByPlane(Vertex_7, Plane_1)
68 Mirror_1_7 = geompy.MakeMirrorByPlane(Vertex_8, Plane_1)
69 Mirror_1_8 = geompy.MakeMirrorByPlane(Vertex_9, Plane_1)
70 Mirror_1_9 = geompy.MakeMirrorByPlane(Vertex_10, Plane_1)
71 Curve_2 = geompy.MakeInterpol([Mirror_1_9, Mirror_1_8, Mirror_1_7, Mirror_1_6, Mirror_1_5, Mirror_1_4, Mirror_1_3, Mirror_1_2, Mirror_1_1, Vertex_1, Vertex_2, Vertex_3, Vertex_4, Vertex_5, Vertex_6, Vertex_7, Vertex_8, Vertex_9, Vertex_10], False, False)
72 Divided_Cylinder_1 = geompy.MakeDividedCylinder(145, 800, GEOM.SQUARE)
73 CylindreSain = geompy.MakeRotation(Divided_Cylinder_1, OZ, 45*math.pi/180.0)
74 [Compound_1, vertical, radial, Compound_4] = geompy.Propagate(CylindreSain)
75 geompy.addToStudy( CylindreSain, 'CylindreSain' )
76 geomPublishInFather(initLog.debug,CylindreSain, Compound_1, 'Compound_1' )
77 geompy.addToStudyInFather(CylindreSain, vertical, 'vertical' )
78 geompy.addToStudyInFather(CylindreSain, radial, 'radial' )
79 geompy.addToStudyInFather(CylindreSain, Compound_4, 'Compound_4' )
80
81 Circle_1 = geompy.MakeCircle(Vertex_1, None, 145)
82 Vertex_11 = geompy.MakeVertex(0, -165, 500)
83 Curve_2_vertex_2 = geompy.GetSubShape(Curve_2, [2])
84 Curve_2_vertex_3 = geompy.GetSubShape(Curve_2, [3])
85 Arc_1 = geompy.MakeArc(Curve_2_vertex_2, Vertex_11, Curve_2_vertex_3)
86 FissInCylindre = geompy.MakeFaceWires([Curve_2, Arc_1], 1)
87 geompy.addToStudy( FissInCylindre, 'cylindre_fissure' )
88
89 geompy.ExportBREP(FissInCylindre, os.path.join(gmu.pathBloc, "materielCasTests", "FissInCylindre.brep"))
90
91 Vertex_12 = geompy.MakeVertex(0, -145, 500)
92 Circle_2 = geompy.MakeCircle(Vertex_12, None, 145)
93 Face_1 = geompy.MakeFaceWires([Circle_2], 1)
94 Vertex_13 = geompy.MakeVertex(0, 0, 500)
95 Disk_1 = geompy.MakeDiskPntVecR(Vertex_13, OZ, 170)
96 FissInCylindre2 = geompy.MakeCommon(Face_1, Disk_1)
97 geompy.addToStudy( FissInCylindre2, 'cylindre_2_fissure' )
98
99 geompy.ExportBREP(FissInCylindre2, os.path.join(gmu.pathBloc, "materielCasTests", "FissInCylindre2.brep"))
100
101 geomPublish(initLog.debug, Vertex_1, 'Vertex_1' )
102 geomPublish(initLog.debug, Vertex_2, 'Vertex_2' )
103 geomPublish(initLog.debug, Vertex_3, 'Vertex_3' )
104 geomPublish(initLog.debug, Vertex_4, 'Vertex_4' )
105 geomPublish(initLog.debug, Vertex_5, 'Vertex_5' )
106 geomPublish(initLog.debug, Vertex_6, 'Vertex_6' )
107 geomPublish(initLog.debug, Vertex_7, 'Vertex_7' )
108 geomPublish(initLog.debug, Vertex_8, 'Vertex_8' )
109 geomPublish(initLog.debug, Vertex_9, 'Vertex_9' )
110 geomPublish(initLog.debug, Vertex_10, 'Vertex_10' )
111 geomPublish(initLog.debug, Plane_1, 'Plane_1' )
112 geomPublish(initLog.debug, Mirror_1_1, 'Mirror_1_1' )
113 geomPublish(initLog.debug, Mirror_1_2, 'Mirror_1_2' )
114 geomPublish(initLog.debug, Mirror_1_3, 'Mirror_1_3' )
115 geomPublish(initLog.debug, Mirror_1_4, 'Mirror_1_4' )
116 geomPublish(initLog.debug, Mirror_1_5, 'Mirror_1_5' )
117 geomPublish(initLog.debug, Mirror_1_6, 'Mirror_1_6' )
118 geomPublish(initLog.debug, Mirror_1_7, 'Mirror_1_7' )
119 geomPublish(initLog.debug, Mirror_1_8, 'Mirror_1_8' )
120 geomPublish(initLog.debug, Mirror_1_9, 'Mirror_1_9' )
121 geomPublish(initLog.debug, Curve_2, 'Curve_2' )
122 geomPublish(initLog.debug, Circle_1, 'Circle_1' )
123 geomPublish(initLog.debug, Vertex_11, 'Vertex_11' )
124 geomPublishInFather(initLog.debug, Curve_2, Curve_2_vertex_2, 'Curve_2:vertex_2' )
125 geomPublishInFather(initLog.debug, Curve_2, Curve_2_vertex_3, 'Curve_2:vertex_3' )
126 geomPublish(initLog.debug, Arc_1, 'Arc_1' )
127 geomPublish(initLog.debug, FissInCylindre, 'FissInCylindre' )
128 geomPublish(initLog.debug, Divided_Cylinder_1, 'Divided Cylinder_1' )
129 geomPublish(initLog.debug, Vertex_12, 'Vertex_12' )
130 geomPublish(initLog.debug, Circle_2, 'Circle_2' )
131 geomPublish(initLog.debug, Face_1, 'Face_1' )
132 geomPublish(initLog.debug, Vertex_13, 'Vertex_13' )
133 geomPublish(initLog.debug, Disk_1, 'Disk_1' )
134 geomPublish(initLog.debug, FissInCylindre2, 'FissInCylindre2' )
135
136 ###
137 ### SMESH component
138 ###
139
140 smesh = smeshBuilder.New()
141 CylindreSain_1 = smesh.Mesh(CylindreSain)
142 putName(CylindreSain_1.GetMesh(), 'CylindreSain')
143
144 Regular_1D = CylindreSain_1.Segment()
145 Nb_Segments_1 = Regular_1D.NumberOfSegments(15,[],[  ])
146 Nb_Segments_1.SetDistrType( 0 )
147 Quadrangle_2D = CylindreSain_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
148 Hexa_3D = CylindreSain_1.Hexahedron(algo=smeshBuilder.Hexa)
149 Regular_1D_1 = CylindreSain_1.Segment(geom=vertical)
150 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(30,[],[  ])
151 Nb_Segments_2.SetDistrType( 0 )
152 Regular_1D_2 = CylindreSain_1.Segment(geom=radial)
153 Nb_Segments_3 = Regular_1D_2.NumberOfSegments(6,[],[  ])
154 Nb_Segments_3.SetDistrType( 0 )
155
156 ## set object names
157 #smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
158 #smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
159 #smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
160 putName(Nb_Segments_1, 'Nb. Segments_1', i_pref='cylindre')
161 putName(Nb_Segments_2, 'Nb. Segments_2', i_pref='cylindre')
162 putName(Nb_Segments_3, 'Nb. Segments_3', i_pref='cylindre')
163
164 is_done = CylindreSain_1.Compute()
165 text = "CylindreSain_1.Compute"
166 if is_done:
167   logging.info(text+" OK")
168 else:
169   text = "Erreur au calcul du maillage.\n" + text
170   logging.info(text)
171   raise Exception(text)
172
173 CylindreSain_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "CylindreSain.med"))
174
175 if salome.sg.hasDesktop():
176   salome.sg.updateObjBrowser()