Salome HOME
Avoid empty items in the "Algorithm" combo-box in the "Create/Edit Mesh" dialog.
[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 <h3>Basic hypothesis</h3>
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 can be unpublished in study.
26 # They will then be automatically published.
27 geompy.addToStudyInFather(box,Face_1, "Face_1")
28 geompy.addToStudyInFather(box,Edge_1, "Edge_1")
29 geompy.addToStudyInFather(box,Vertex_1, "Vertex_1")
30
31 geompy.addToStudyInFather(box   ,Face_2, "Face_2")
32 geompy.addToStudyInFather(Face_2,Wire_1, "Wire_1")
33
34 # create a mesh on the box
35 blsurfMesh = smesh.Mesh(box,"box: BLSurf mesh")
36
37 # create a BLSurf algorithm for faces
38 algo2d = blsurfMesh.Triangle(algo=smesh.BLSURF)
39
40 # End of script
41 \endcode
42
43 <h3>Adding sizemaps</h3>
44 \code
45 # optional - set physical mesh to 2 = Size Map
46 algo2d.SetPhysicalMesh( 2 )
47
48 # optional - set global mesh size
49 algo2d.SetPhySize( 34.641 )
50
51 # set size on Face_1
52 algo2d.SetSizeMap(Face_1, 'def f(u,v): return 10' )
53 # set size on Edge_1
54 algo2d.SetSizeMap(Edge_1, 'def f(t): return 5' )
55 # set size on Vertex_1
56 algo2d.SetSizeMap(Vertex_1, 'def f(): return 2' )
57
58 # compute the mesh
59 blsurfMesh.Compute()
60
61 # End of script
62 \endcode
63
64 <h3>Adding enforced vertices</h3>
65 \code
66
67 # Add enforced vertex for Face_1 on (50, 50, 50)
68 # The projection coordinates will be (50, 50, 0)
69 algo2d.SetEnforcedVertex(Face_1, 50, 50, 50)
70
71 # Add another enforced vertex on (150, 150, 150)
72 algo2d.SetEnforcedVertex(Face_1, 150, 150, 150)
73
74 # Retrieve and print the list of enforced vertices defines on Face_1
75 enfList = algo2d.GetEnforcedVertices(Face_1)
76 print "List of enforced vertices for Face_1: "
77 print enfList
78
79 # compute the mesh
80 blsurfMesh.Compute()
81
82 # Remove an enforced vertex and print the list
83 algo2d.UnsetEnforcedVertex(Face_1, 50, 50, 50)
84 enfList = algo2d.GetEnforcedVertices(Face_1)
85 print "List of enforced vertices for Face_1: "
86 print enfList
87
88 # compute the mesh
89 blsurfMesh.Compute()
90
91 # Remove all enforced vertices defined on Face_1
92 algo2d.UnsetEnforcedVertices(Face_1)
93
94 # compute the mesh
95 blsurfMesh.Compute()
96
97 # End of script
98
99 \endcode
100
101 <h3>Adding an attractor</h3>
102 \code
103
104 # Add an attractor on Face_2, which shape is Wire_1
105
106 # The size on Wire_1 is 1 and will grow until a maximum of 36.641 (physical size set above) 
107 # The influence distance of the attractor is 20
108 # The size is kept constant until a distance of 10
109 algo2d.SetAttractorGeom(Face_2, Wire_1, 1, 36.641, 20, 10)
110
111 # In order to let the attractor control the growing of the mesh let set
112 # the gradation to its maximum
113 algo2d.SetGradation( 2.5 )
114
115 # compute the mesh
116 blsurfMesh.Compute()
117
118 # End of script
119
120 \endcode
121
122 <h3>Using internal vertices</h3>
123 \code
124
125 # Creating a geometry containing internal vertices
126 Face_3 = geompy.MakeFaceHW(1, 1, 1)
127 Vertex_2 = geompy.MakeVertex(0.2, 0.2, 0)
128 Partition_1 = geompy.MakePartition([Face_3, Vertex_2], [], [], [], geompy.ShapeType["FACE"], 0, [], 0)
129 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
130 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
131 Multi_Translation_1 = geompy.MakeMultiTranslation2D(Partition_1, OX, 1, 10, OY, 1, 10)
132 geompy.addToStudy( Face_3, 'Face_3' )
133 geompy.addToStudy( Vertex_2, 'Vertex_2' )
134 geompy.addToStudy( Partition_1, 'Partition_1' )
135 geompy.addToStudy( OX, 'OX' )
136 geompy.addToStudy( OY, 'OY' )
137 geompy.addToStudy( Multi_Translation_1, 'Multi-Translation_1' )
138
139 # The mesh on the geometry with internal vertices
140 blsurfMesh_internal = smesh.Mesh(Multi_Translation_1, "blsurfMesh_internal")
141 algo2d = blsurfMesh_internal.Triangle(algo=smesh.BLSURF)
142 algo2d.SetPhySize( 0.1 )
143
144 # Allows BLSURF to take into account internal vertices
145 algo2d.SetInternalEnforcedVertexAllFaces( True )
146
147 # Add the created nodes into a group
148 algo2d.SetInternalEnforcedVertexAllFacesGroup( "my group" )
149
150 # compute the mesh
151 blsurfMesh_internal.Compute()
152
153 # End of script
154 \endcode
155
156 */