Salome HOME
Bug 0020072: GHS3DPRLPLUGIN update. Integrating the attached patch.
[modules/smesh.git] / src / SMESH_SWIG / ex14_cyl1holed.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 # =======================================
23 #
24 from geompy import *
25
26 import smesh
27
28 # Geometrie
29 # =========
30
31 # Creer un cylindre avec un trou cylindrique excentre, decoupage en hexahedre et mailler.
32
33 # Donnees
34 # -------
35
36 # unite: millimetre
37
38 g_ox = 0
39 g_oy = 0
40 g_oz = 0
41
42 g_cyl_rayon       = 1000
43 g_cyl_demiHauteur = 3000
44
45 g_trou_rayon       =   5
46 g_trou_centre      = 300
47
48 g_trim = 15000
49
50 # Construire le cylindre
51 # ----------------------
52
53 c_point    = MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
54 c_dir      = MakeVectorDXDYDZ(0, 0, 1)
55 c_hauteur  = 2*g_cyl_demiHauteur
56 c_cylindre = MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
57
58 # Trouer le cylindre par un minuscule cylindre excentre
59 # -----------------------------------------------------
60
61 t_hauteur = g_cyl_demiHauteur
62 t_point   = MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
63 t_trou    = MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
64
65 t_piece   = MakeCut(c_cylindre, t_trou)
66
67 # Geometrie hexahedrique
68 # ======================
69
70 # Decouper
71 # --------
72
73 h_outils = []
74 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(1, 0, 0), g_trim))
75 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(0, 1, 0), g_trim))
76
77 h_piece = MakePartition([t_piece], h_outils, [], [], ShapeType["SOLID"])
78
79 # Decouper pour les conditions locales
80 # ------------------------------------
81
82 l_outils = []
83 l_i = 1
84 l_n = 12
85 l_hauteur = c_hauteur/l_n
86
87 while l_i<l_n:
88     l_outils.append(MakePlane(MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur+l_i*l_hauteur), c_dir, g_trim))
89     l_i = l_i+1
90
91 piece = MakePartition([h_piece], l_outils, [], [], ShapeType["SOLID"])
92
93 # Ajouter la piece dans l'etude
94 # -----------------------------
95
96 piece_id = addToStudy(piece, "ex14_cyl1holed")
97
98 # Maillage
99 # ========
100
101 # Creer un maillage hexahedrique
102 # ------------------------------
103
104 hexa = smesh.Mesh(piece, "ex14_cyl1holed:hexa")
105
106 algo = hexa.Segment()
107 algo.NumberOfSegments(4)
108
109 hexa.Quadrangle()
110
111 hexa.Hexahedron()
112
113 # Poser les hypotheses locales
114 # ----------------------------
115
116 m_i = 0
117 m_n = 12
118 m_h = c_hauteur/m_n
119 m_d = [4, 6, 8, 10, 10, 9, 8, 7, 6, 5, 4, 3]
120
121 m_x = g_ox+g_cyl_rayon
122 m_y = g_oy
123 m_z = g_oz-g_cyl_demiHauteur+m_h/2
124
125 while m_i<m_n:
126     m_p = MakeVertex(m_x, m_y, m_z + m_i*m_h)
127     m_e = GetEdgeNearPoint(piece, m_p)
128     m_a = hexa.Segment(m_e)
129     m_a.NumberOfSegments(m_d[m_i])
130     m_a.Propagation()
131     m_i = m_i + 1
132
133 # Calculer le maillage
134 # --------------------
135
136 hexa.Compute()