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