Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / SMESH_SWIG / ex11_grid3partition.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 # Geometry
29 # ========
30
31 # grid compound of 3 x 3 elements
32 # an element is compound of 3 cylinders concentriques
33 # an element is centered in a square of the grid
34 # the smaller cylinder is a hole
35
36 # prism the grid, and mesh it in hexahedral way
37
38 # Values
39 # ------
40
41 g_x = 0
42 g_y = 0
43 g_z = 0
44
45 g_arete   = 50
46 g_hauteur = 30
47
48 g_rayon1 = 20
49 g_rayon2 = 30
50 g_rayon3 = 40
51
52 g_grid = 3
53
54 g_trim = 1000
55
56 # Element
57 # -------
58
59 e_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete,  g_x+g_arete, g_y+g_hauteur, g_z+g_arete)
60
61 e_hauteur = 2*g_hauteur
62 e_centre  = MakeVertex(g_x, g_y-g_hauteur, g_z)
63 e_dir     = MakeVectorDXDYDZ(0, 1, 0)
64
65 e_cyl1 = MakeCylinder(e_centre, e_dir, g_rayon3, e_hauteur)
66
67 e_blo1 = MakeCut(e_boite, e_cyl1)
68
69 e_cyl2 = MakeCylinder(e_centre, e_dir, g_rayon2, e_hauteur)
70
71 e_blo2 = MakeCut(e_cyl1, e_cyl2)
72
73 e_cyl3 = MakeCylinder(e_centre, e_dir, g_rayon1, e_hauteur)
74
75 e_blo3 = MakeCut(e_cyl2, e_cyl3)
76
77 # Partition and repair
78 # --------------------
79
80 p_tools = []
81 p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim))
82 p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim))
83
84 p_part = MakePartition([e_blo1, e_blo2, e_blo3], p_tools, [], [], ShapeType["SOLID"])
85
86 p_element = RemoveExtraEdges(p_part)
87
88 # Grid and glue
89 # -------------
90
91 grid = MakeMultiTranslation2D(p_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
92
93 piece = MakeGlueFaces(grid, 1e-5)
94
95 # Add in study
96 # ------------
97
98 piece_id = addToStudy(piece, "ex11_grid3partition")
99
100 # Meshing
101 # =======
102
103 # Create a hexahedral mesh
104 # ------------------------
105
106 hexa = smesh.Mesh(piece, "ex11_grid3partition:hexa")
107
108 algo = hexa.Segment()
109 algo.NumberOfSegments(3)
110
111 hexa.Quadrangle()
112
113 hexa.Hexahedron()
114
115 # Mesh calculus
116 # -------------
117
118 hexa.Compute()