Salome HOME
Fix small mistake
[modules/smesh.git] / doc / salome / gui / SMESH / input / tui_defining_blsurf_hypotheses.doc
1 /*!
2
3 \page tui_defining_blsurf_hypotheses_page Defining Hypotheses for BLSurf Algorithm
4
5 \anchor tui_blsurf
6 <h2>Construction of Mesh using BLSurf algorithm</h2>
7
8 \code
9 import geompy
10 import smesh
11 import BLSURFPlugin
12
13 # create a box
14 box = geompy.MakeBoxDXDYDZ(200., 200., 200.)
15 geompy.addToStudy(box, "box")
16
17 # get sub-shapes
18 Face_1   = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0]
19 Edge_1   = geompy.SubShapeAllSorted(box, geompy.ShapeType["EDGE"])[0]
20 Vertex_1 = geompy.SubShapeAllSorted(box, geompy.ShapeType["VERTEX"])[0]
21
22 Face_2   = geompy.SubShapeAllSorted(box,    geompy.ShapeType["FACE"])[5]
23 Wire_1   = geompy.SubShapeAllSorted(Face_2, geompy.ShapeType["WIRE"])[0]
24
25 # /!\ Geom object with sizemaps on them must be published in study
26 geompy.addToStudyInFather(box,Face_1, "Face_1")
27 geompy.addToStudyInFather(box,Edge_1, "Edge_1")
28 geompy.addToStudyInFather(box,Vertex_1, "Vertex_1")
29
30 geompy.addToStudyInFather(box   ,Face_2, "Face_2")
31 geompy.addToStudyInFather(Face_2,Wire_1, "Wire_1")
32
33 # create a mesh on the box
34 blsurfMesh = smesh.Mesh(box,"box: BLSurf mesh")
35
36 # create a BLSurf algorithm for faces
37 algo2d = blsurfMesh.Triangle(algo=smesh.BLSURF)
38
39 # optional - set physical mesh to 2 = Size Map
40 algo2d.SetPhysicalMesh( 2 )
41
42 # optional - set global mesh size
43 algo2d.SetPhySize( 34.641 )
44
45 # set size on Face_1
46 algo2d.SetSizeMap(Face_1, 'def f(u,v): return 10' )
47 # set size on Edge_1
48 algo2d.SetSizeMap(Edge_1, 'def f(t): return 5' )
49 # set size on Vertex_1
50 algo2d.SetSizeMap(Vertex_1, 'def f(): return 2' )
51
52 # compute the mesh
53 blsurfMesh.Compute()
54
55 # Add enforced vertex for Face_1 on (50, 50, 50)
56 # The projection coordinates will be (50, 50, 0)
57 algo2d.SetEnforcedVertex(Face_1, 50, 50, 50)
58
59 # Add another enforced vertex on (150, 150, 150)
60 algo2d.SetEnforcedVertex(Face_1, 150, 150, 150)
61
62 # Retrieve and print the list of enforced vertices defines on Face_1
63 enfList = algo2d.GetEnforcedVertices(Face_1)
64 print "List of enforced vertices for Face_1: "
65 print enfList
66
67 # compute the mesh
68 blsurfMesh.Compute()
69
70 # Remove an enforced vertex and print the list
71 algo2d.UnsetEnforcedVertex(Face_1, 50, 50, 50)
72 enfList = algo2d.GetEnforcedVertices(Face_1)
73 print "List of enforced vertices for Face_1: "
74 print enfList
75
76 # compute the mesh
77 blsurfMesh.Compute()
78
79 # Remove all enforced vertices defined on Face_1
80 algo2d.UnsetEnforcedVertices(Face_1)
81
82 # compute the mesh
83 blsurfMesh.Compute()
84
85
86 # Add an attractor on Face_2, which shape is Wire_1
87
88 # The size on Wire_1 is 1 and will grow until a maximum of 36.641 (physical size set above) 
89 # The influence distance of the attractor is 20
90 # The size is kept constant until a distance of 10
91 algo2d.SetAttractorGeom(Face_2, Wire_1, 1, 36.641, 20, 10)
92
93 # In order to let the attractor control the growing of the mesh let set
94 # the gradation to its maximum
95 algo2d.SetGradation( 2.5 )
96
97 # compute the mesh
98 blsurfMesh.Compute()
99
100 # End of script
101
102 \endcode
103
104 */