Salome HOME
IPAL21363 Compute hangs up on Hypothesis Distribution of Layers.
[modules/smesh.git] / src / SMESH_SWIG / ex16_cyl2complementary.py
1 #! /usr/bin/python
2 #  -*- coding: iso-8859-1 -*-
3 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
4 #
5 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 #
8 #  This library is free software; you can redistribute it and/or
9 #  modify it under the terms of the GNU Lesser General Public
10 #  License as published by the Free Software Foundation; either
11 #  version 2.1 of the License.
12 #
13 #  This library is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 #  Lesser General Public License for more details.
17 #
18 #  You should have received a copy of the GNU Lesser General Public
19 #  License along with this library; if not, write to the Free Software
20 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21 #
22 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #
24 # =======================================
25 #
26 from geompy import *
27
28 import smesh
29
30 # Geometry
31 # ========
32
33 # Create the hexahedrical block geometry of a holed parallelepipede.
34 # The hole has a T form composed by 2 cylinders with different radius, and their axis are normal.
35 # This piece is meshed in hexahedrical.
36
37 # Values
38 # ------
39
40 gx = 0
41 gy = 0
42 gz = 0
43
44 g_dx = 250
45 g_dy = 200
46 g_dz = 150
47
48 g_rayonGrand = 70
49 g_rayonPetit = 50
50
51 g_trim = 1000
52
53 # The parallelepipede
54 # -------------------
55
56 p_boite = MakeBox(gx-g_dx, gy-g_dy, gz-g_dz,  gx+g_dx, gy+g_dy, gz+g_dz)
57
58 # The great cylinder
59 # ------------------
60
61 g_base = MakeVertex(gx-g_dx, gy, gz)
62 g_dir  = MakeVectorDXDYDZ(1, 0, 0)
63 g_cyl  = MakeCylinder(g_base, g_dir, g_rayonGrand, g_dx*2)
64
65 # The first hole
66 # --------------
67
68 b_boite = MakeCut(p_boite , g_cyl)
69
70 # Partitioning
71 # ------------
72
73 p_base = MakeVertex(gx, gy, gz)
74
75 p_tools = []
76
77 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0,  1   , 0   ), g_trim))
78 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0,  g_dz, g_dy), g_trim))
79 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0, -g_dz, g_dy), g_trim))
80
81 p_tools.append(MakePlane(MakeVertex(gx-g_rayonPetit, gy, gz), g_dir, g_trim))
82 p_tools.append(MakePlane(MakeVertex(gx+g_rayonPetit, gy, gz), g_dir, g_trim))
83
84 p_piece = MakePartition([b_boite], p_tools, [], [], ShapeType["SOLID"])
85
86 # The small cylinder
87 # ------------------
88
89 c_cyl = MakeCylinder(p_base, MakeVectorDXDYDZ(0, 0, 1), g_rayonPetit, g_dz)
90
91 # The second hole
92 # ---------------
93
94 d_element = SubShapeAllSorted(p_piece, ShapeType["SOLID"])
95
96 d_element[ 8] = MakeCut(d_element[ 8], c_cyl)
97 d_element[10] = MakeCut(d_element[10], c_cyl)
98
99 # Compound
100 # --------
101
102 piece = RemoveExtraEdges(MakeCompound(d_element))
103
104 # Add piece in study
105 # ------------------
106
107 piece_id = addToStudy(piece, "ex16_cyl2complementary")
108
109 # Meshing
110 # =======
111
112 # Create a hexahedral mesh
113 # ------------------------
114
115 hexa = smesh.Mesh(piece, "ex16_cyl2complementary:hexa")
116
117 algo = hexa.Segment()
118 algo.NumberOfSegments(12)
119
120 hexa.Quadrangle()
121
122 hexa.Hexahedron()
123
124 # Define local hypothesis
125 # -----------------------
126
127 def local(x, y, z, d):
128     edge = GetEdgeNearPoint(piece, MakeVertex(x, y, z))
129     algo = hexa.Segment(edge)
130     algo.NumberOfSegments(d)
131     algo.Propagation()
132
133 local(gx     , gy+g_dy, gz+g_dz, 7)
134 local(gx+g_dx, gy+g_dy, gz     , 21)
135 local(gx+g_dx, gy-g_dy, gz     , 21)
136
137 # Mesh calculus
138 # -------------
139
140 hexa.Compute()