Salome HOME
Merge from V6_main 01/04/2013
[modules/smesh.git] / doc / salome / examples / prism_3d_algo.py
1 # Use 3D extrusion meshing algorithm
2
3 import salome, smesh, SMESH, geompy
4
5 salome.salome_init()
6 smesh.SetCurrentStudy( salome.myStudy )
7
8 OX = geompy.MakeVectorDXDYDZ(1,0,0)
9 OY = geompy.MakeVectorDXDYDZ(0,1,0)
10 OZ = geompy.MakeVectorDXDYDZ(0,0,1)
11
12 #  Y ^       Make geometry of a "pipe" with the following base (cross section).
13 #    |       Big central quadrangles will be meshed with triangles, walls
14 #                         of the pipe will be meshed with quadrilaterals
15 #   +--+--+--+--+--+--+
16 #   |  |  |  |  |  |  |
17 #   +--+--+--+--+--+--+
18 #   |  |     |     |  |
19 #   +--+     |     +--+
20 #   |  |     |     |  |
21 #   +--+-----+-----+--+
22 #   |  |     |     |  |
23 #   +--+     |     +--+
24 #   |  |     |     |  |
25 #   +--+--+--+--+--+--+
26 #   |  |  |  |  |  |  |  -->
27 #   +--+--+--+--+--+--+   X
28
29 quadBig   = geompy.MakeFaceHW( 20,20, 1 )
30 quadBig   = geompy.MakeTranslation( quadBig, 15,15,0 )
31 quadSmall = geompy.MakeFaceHW( 10,10, 1 )
32 smallQuads1 = geompy.MakeMultiTranslation1D( quadSmall, OX, 10, 3 )
33 smallQuads2 = geompy.MakeMultiTranslation1D( quadSmall, OY, 10, 3 )
34 smallQuads2 = geompy.SubShapeAllSortedCentres( smallQuads2, geompy.ShapeType["FACE"])[1:]
35
36 base = geompy.MakeCompound( smallQuads2 + [smallQuads1, quadBig])
37 axis = geompy.MakeLine( geompy.MakeVertex( 25,25,0), OZ )
38 base = geompy.MultiRotate1DNbTimes( base, axis, 4)
39 base = geompy.MakePartition( [base], theName="base")
40 path = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 100:R 0:C -90 180:T 0 -150",[0,0,0, 0,-1,0, 1,0,0])
41
42 # Make the pipe, each quadrangle of the base turns into a prism with composite wall faces
43 pipe   = geompy.MakePipe( base, path )
44 prisms = geompy.MakePartition( [pipe], theName="prisms")
45
46
47 # get base faces of the prism to define sub-mesh on them
48 smallQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 0,0,0 ), "smallQuad")
49 bigQuad   = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 15,15,0 ), "bigQuad")
50
51
52 mesh = smesh.Mesh( prisms )
53
54 # assign Global hypotheses
55
56 # 1D algorithm and hypothesis for vertical division
57 mesh.Segment().NumberOfSegments(15)
58
59 # Extrusion 3D algo
60 mesh.Prism()
61
62 # assign Local hypotheses
63
64 # 1D and 2D algos and hyps to mesh smallQuad with quadrilaterals
65 mesh.Segment(smallQuad).LocalLength( 3 )
66 mesh.Quadrangle(smallQuad)
67
68 # 1D and 2D algos and hyps to mesh bigQuad with triangles
69 mesh.Segment(bigQuad).LocalLength( 3 )
70 mesh.Triangle(bigQuad)
71
72 # compute the mesh
73 mesh.Compute()