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