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