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_ghs3d_hypotheses.doc
1 /*!
2
3 \page tui_defining_ghs3d_hypotheses_page Defining Hypotheses for Ghs3D Algorithm
4
5 \anchor tui_ghs3d
6
7 <ol>
8 <li>\ref tui_ghs3d_basic "Construction of Mesh using Ghs3D algorithm"</li>
9 <li>\ref tui_ghs3d_enforced_vertices "Adding enforced vertices"</li>
10 <li>\ref tui_ghs3d_enforced_meshes "Adding enforced mesh"</li>
11 </ol>
12
13 \anchor tui_ghs3d_basic
14 <h2>Construction of Mesh using Ghs3D algorithm</h2>
15
16 \code
17 import geompy
18 import smesh
19 import BLSURFPlugin
20 import GHS3DPlugin
21
22 # create a box
23 box = geompy.MakeBoxDXDYDZ(200., 200., 200.)
24 geompy.addToStudy(box, "box")
25
26 # create a mesh on the box
27 ghs3dMesh = smesh.Mesh(box,"box: Ghs3D and BLSurf mesh")
28
29 # create a BLSurf algorithm for faces
30 BLSURF = ghs3dMesh.Triangle(algo=smesh.BLSURF)
31 GHS3D = ghs3dMesh.Tetrahedron(algo=smesh.GHS3D)
32
33 # compute the mesh
34 ghs3dMesh.Compute()
35
36 # End of script
37 \endcode
38
39 \image html ghs3d_screenshot.png Ghs3d mesh withtout hypothesis
40
41 \ref tui_ghs3d "Back to top"
42
43 \anchor tui_ghs3d_enforced_vertices
44 <h2>Adding enforced vertices</h2>
45
46 \code
47
48 # An enforced vertex can be added via:
49 # - the coordinates x,y,z
50 # - a GEOM vertex or compound (No geometry, TUI only)
51 #
52 # The created enforced nodes can also be stored in
53 # a group.
54 #
55 # This feature is available only on meshes without geometry.
56
57 # Ex1: Add one enforced vertex with coordinates (50,50,100) 
58 #      and physical size 2.
59
60 import geompy
61 import smesh
62 import BLSURFPlugin
63 import GHS3DPlugin
64
65 # create a box
66 box = geompy.MakeBoxDXDYDZ(200., 200., 200.)
67 geompy.addToStudy(box, "box")
68 # create a mesh on the box
69 ghs3dMesh = smesh.Mesh(box,"box: Ghs3D and BLSurf mesh")
70 # create a BLSurf algorithm for faces
71 ghs3dMesh.Triangle(algo=smesh.BLSURF)
72 # compute the mesh
73 ghs3dMesh.Compute()
74
75 # Make a copy of the 2D mesh
76 ghs3dMesh_wo_geometry = smesh.CopyMesh( ghs3dMesh, 'Ghs3D wo geometry', 0, 0)
77
78 # create a Ghs3D algorithm and hypothesis and assign them to the mesh
79 GHS3D = smesh.CreateHypothesis('GHS3D_3D', 'GHS3DEngine')
80 GHS3D_Parameters = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine')
81 ghs3dMesh.AddHypothesis( GHS3D )
82 ghs3dMesh.AddHypothesis( GHS3D_Parameters )
83 # Create the enforced vertex
84 GHS3D_Parameters.SetEnforcedVertex( 50, 50, 100, 2) # no group
85 # Compute the mesh
86 ghs3dMesh.Compute()
87
88
89 # Ex2: Add one vertex enforced by a GEOM vertex at (50,50,100) 
90 #      with physical size 5 and add it to a group called "My special nodes"
91
92 # Create another GHS3D hypothesis and assign it to the mesh without geometry
93 GHS3D_Parameters_wo_geometry = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine')
94 ghs3dMesh_wo_geometry.AddHypothesis( GHS3D )
95 ghs3dMesh_wo_geometry.AddHypothesis( GHS3D_Parameters_wo_geometry )
96
97 # Create the enforced vertex
98 p1 = geompy.MakeVertex(150, 150, 100)
99 geompy.addToStudy(p1, "p1")
100 GHS3D_Parameters_wo_geometry.SetEnforcedVertexGeomWithGroup( p1, 5 , "My special nodes")
101 #GHS3D_Parameters.SetEnforcedVertexGeom( p1, 5 ) # no group
102
103 # compute the mesh
104 ghs3dMesh_wo_geometry.Compute()
105
106 # Erase all enforced vertices
107 GHS3D_Parameters.ClearEnforcedVertices()
108
109 # End of script
110
111 \endcode
112
113 \image html ghs3d_screenshot_enf1.png Ghs3d mesh with enforced vertex
114 \image html ghs3d_screenshot_enf2.png Ghs3d mesh with enforced vertex from GEOM vertex
115
116 \ref tui_ghs3d "Back to top"
117
118 \anchor tui_ghs3d_enforced_meshes
119 <h2>Adding enforced mesh</h2>
120
121 \code
122
123 # It is possible to constrain GHS3D with another mesh or group.
124 # The constraint can refer to the nodes, edges or faces.
125 # This feature is available only on meshes without geometry.
126 # The constraining elements are called enforced elements for the mesh.
127 # They can be recovered using groups if necessary.
128
129 # In the following examples, a box and a cylinder are meshed.
130 # The mesh of the cylinder will be used as a constraint for the 
131 # 3D mesh of the box.
132
133 import geompy
134 import smesh
135 import BLSURFPlugin
136 import GHS3DPlugin
137
138 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
139 geompy.addToStudy( box, "box" )
140 cylindre = geompy.MakeCylinderRH(50, 50)
141 geompy.TranslateDXDYDZ(cylindre, 100, 100, 30)
142 face_cyl = geompy.ExtractShapes(cylindre, geompy.ShapeType["FACE"], True)[1]
143 geompy.addToStudy( cylindre, 'cylindre' )
144 geompy.addToStudyInFather( cylindre, face_cyl, 'face_cyl' )
145 p1 = geompy.MakeVertex(20, 20, 20)
146 p2 = geompy.MakeVertex(180, 180, 20)
147 c = geompy.MakeCompound([p1,p2])
148 geompy.addToStudy( p1, "p1" )
149 geompy.addToStudy( p2, "p2" )
150 geompy.addToStudy( c, "c" )
151
152 # Create the 2D algorithm and hypothesis
153 BLSURF = smesh.CreateHypothesis('BLSURF', 'BLSURFEngine')
154 # For the box
155 BLSURF_Parameters = smesh.CreateHypothesis('BLSURF_Parameters', 'BLSURFEngine')
156 BLSURF_Parameters.SetPhysicalMesh( 1 )
157 BLSURF_Parameters.SetPhySize( 200 )
158 # For the cylinder
159 BLSURF_Parameters2 = smesh.CreateHypothesis('BLSURF_Parameters', 'BLSURFEngine')
160 BLSURF_Parameters2.SetGeometricMesh( 1 )
161
162 # Create the 3D algorithm and hypothesis
163 GHS3D = smesh.CreateHypothesis('GHS3D_3D', 'GHS3DEngine')
164 GHS3D_Parameters_node = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine')
165 #GHS3D_Parameters_node.SetToMeshHoles( 1 )
166 GHS3D_Parameters_edge = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine')
167 #GHS3D_Parameters_edge.SetToMeshHoles( 1 )
168 GHS3D_Parameters_face = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine')
169 GHS3D_Parameters_face.SetToMeshHoles( 1 ) # to mesh inside the cylinder
170 GHS3D_Parameters_mesh = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine')
171 GHS3D_Parameters_mesh.SetToMeshHoles( 1 ) # to mesh inside the cylinder
172
173 # Create the mesh on the cylinder
174 Mesh_cylindre = smesh.Mesh(cylindre)
175 smesh.SetName(Mesh_cylindre,"Mesh_cylindre")
176 Mesh_cylindre.AddHypothesis( BLSURF )
177 Mesh_cylindre.AddHypothesis( BLSURF_Parameters2 )
178 # Create some groups
179 face_cyl_faces = Mesh_cylindre.GroupOnGeom(face_cyl,'group_face_cyl', smesh.FACE)
180 face_cyl_edges = Mesh_cylindre.GroupOnGeom(face_cyl,'group_edge_cyl', smesh.EDGE)
181 face_cyl_nodes = Mesh_cylindre.GroupOnGeom(face_cyl,'group_node_cyl', smesh.NODE)
182 Mesh_cylindre.Compute()
183
184 # Create the mesh on the cylinder
185 Mesh_box_tri = smesh.Mesh(box)
186 smesh.SetName(Mesh_box_tri,"Mesh_box_tri")
187 Mesh_box_tri.AddHypothesis( BLSURF )
188 Mesh_box_tri.AddHypothesis( BLSURF_Parameters )
189 Mesh_box_tri.Compute()
190
191 # Create 4 copies of the 2D mesh to test the 3 types of contraints (NODE, EDGE, FACE)
192 # from the whole mesh and from groups of elements.
193 # Then the 3D algo and hypothesis are assigned to them.
194
195 mesh_mesh = smesh.CopyMesh( Mesh_box_tri, 'Enforced by faces of mesh', 0, 0)
196 mesh_mesh.AddHypothesis( GHS3D )
197 mesh_mesh.AddHypothesis( GHS3D_Parameters_mesh)
198
199 mesh_node = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of nodes', 0, 0)
200 mesh_node.AddHypothesis( GHS3D )
201 mesh_node.AddHypothesis( GHS3D_Parameters_node)
202
203 mesh_edge = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of edges', 0, 0)
204 mesh_edge.AddHypothesis( GHS3D )
205 mesh_edge.AddHypothesis( GHS3D_Parameters_edge)
206
207 mesh_face = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of faces', 0, 0)
208 mesh_face.AddHypothesis( GHS3D )
209 mesh_face.AddHypothesis( GHS3D_Parameters_face)
210
211 # Add the enforced elements
212 GHS3D_Parameters_mesh.SetEnforcedMeshWithGroup(Mesh_cylindre.GetMesh(),smesh.FACE,"faces from cylinder")
213 GHS3D_Parameters_node.SetEnforcedMeshWithGroup(face_cyl_nodes,smesh.NODE,"nodes from face_cyl_nodes")
214 GHS3D_Parameters_edge.SetEnforcedMeshWithGroup(face_cyl_edges,smesh.EDGE,"edges from face_cyl_edges")
215 GHS3D_Parameters_face.SetEnforcedMeshWithGroup(face_cyl_faces,smesh.FACE,"faces from face_cyl_faces")
216
217 #Compute the meshes
218 mesh_node.Compute()
219 mesh_edge.Compute()
220 mesh_face.Compute()
221 mesh_mesh.Compute()
222
223 # End of script
224
225 \endcode
226
227 \image html ghs3d_screenshot_enf3.png
228 \image html ghs3d_screenshot_enf4.png
229 \image html ghs3d_screenshot_enf5.png
230 \image html ghs3d_screenshot_enf6.png
231
232 \ref tui_ghs3d "Back to top"
233
234 */