Salome HOME
Update version number: 3.1.0a2
[modules/smesh.git] / src / SMESH_SWIG / ex12_grid17partition.py
1 # CEA/LGLS 2004-2005, Francis KLOSS (OCC)
2 # =======================================
3
4 from geompy import *
5
6 import smesh
7
8 # Geometry
9 # ========
10
11 # grid compound of 17 x 17 elements
12 # an element is compound of 3 concentric cylinders
13 # an element is centered in a square of the grid
14
15 # prism the grid, and mesh it in hexahedral way
16
17 # Values
18 # ------
19
20 g_x = 0
21 g_y = 0
22 g_z = 0
23
24 g_arete   = 50
25 g_hauteur = 30
26
27 g_rayon1 = 20
28 g_rayon2 = 30
29 g_rayon3 = 40
30
31 g_grid = 17
32
33 g_trim = 1000
34
35 # Solids and rotation to prevent repair
36 # -------------------------------------
37
38 s_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)
39
40 s_pi4     = 3.141592653/4
41 s_hauteur = 2*g_hauteur
42 s_centre  = MakeVertex(g_x, g_y-g_hauteur, g_z)
43 s_dir     = MakeVectorDXDYDZ(0, 1, 0)
44
45 s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon3, s_hauteur)
46 s_cyl1 = MakeRotation(s_cyl0, s_dir, s_pi4)
47
48 s_blo1 = MakeCut(s_boite, s_cyl1)
49
50 s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon2, s_hauteur)
51 s_cyl2 = MakeRotation(s_cyl0, s_dir, s_pi4)
52
53 s_blo2 = MakeCut(s_cyl1, s_cyl2)
54
55 s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon1, s_hauteur)
56 s_cyl3 = MakeRotation(s_cyl0, s_dir, s_pi4)
57
58 s_blo3 = MakeCut(s_cyl2, s_cyl3)
59
60 s_arete = g_rayon1/2
61
62 s_blo4 = MakeBox(g_x-s_arete, g_y-g_hauteur, g_z-s_arete,  g_x+s_arete, g_y+g_hauteur, g_z+s_arete)
63
64 s_blo5 = MakeCut(s_cyl3, s_blo4)
65
66 # Partition
67 # ---------
68
69 p_tools = []
70 p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim))
71 p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim))
72
73 p_partie = MakePartition([s_blo1, s_blo2, s_blo3, s_blo5], p_tools, [], [], ShapeType["SOLID"])
74
75 # Compound and glue
76 # -----------------
77
78 c_blocs = SubShapeAll(p_partie, ShapeType["SOLID"])
79 c_blocs.append(s_blo4)
80
81 c_cpd = MakeCompound(c_blocs)
82
83 c_element = MakeGlueFaces(c_cpd, 1e-4)
84
85 # Grid
86 # ----
87
88 piece = MakeMultiTranslation2D(c_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
89
90 # Add in study
91 # ------------
92
93 piece_id = addToStudy(piece, "ex12_grid17partition")
94
95 # Meshing
96 # =======
97
98 # Create a hexahedral mesh
99 # ------------------------
100
101 hexa = smesh.Mesh(piece, "ex12_grid17partition:hexa")
102
103 algo = hexa.Segment()
104 algo.NumberOfSegments(2)
105
106 hexa.Quadrangle()
107
108 hexa.Hexahedron()
109
110 # Mesh calculus
111 # -------------
112
113 hexa.Compute()