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