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