Salome HOME
d9e2b31f9cc56400922037e515cb0fbe7d7743de
[modules/smesh.git] / doc / salome / gui / SMESH / input / tui_defining_hypotheses.doc
1 /*!
2
3 \page tui_defining_hypotheses_page Defining Hypotheses and Algorithms
4
5 This page provides example codes of \ref tui_defining_meshing_algos
6 "defining algorithms" and hypotheses. 
7 <ul>
8 <li>Wire discretisation 1D algorithm
9   <ul>
10     <li>\ref tui_1d_arithmetic "Arithmetic 1D" hypothesis</li>
11     <li>\ref tui_deflection_1d "Deflection 1D and Number of Segments" hypotheses</li>
12     <li>\ref tui_start_and_end_length "Start and End Length" hypotheses</li>
13     <li>\ref tui_average_length "Local Length"</li>
14     <li>\ref tui_propagation "Propagation" additional hypothesis </li>
15     <li>\ref tui_fixed_points "Fixed Points 1D" hypothesis</li>
16   </ul>
17 </li>
18 <li>Triangle (Mefisto) 2D algorithm
19   <ul>
20     <li>\ref tui_max_element_area "Max Element Area" hypothesis </li>
21     <li>\ref tui_length_from_edges "Length from Edges"
22     hypothesis </li>
23   </ul>
24 </li>
25 <li>Tetrahedron (Netgen) 3D algorithm
26   <ul>
27     <li> \ref tui_max_element_volume "Max. Element Volume"hypothesis </li>
28     <li> \ref tui_viscous_layers "Viscous layers"</li>
29   </ul>
30 </li>
31 <li>\ref tui_projection "Projection Algorithms"</li>
32 <li>\ref tui_radial_quadrangle "Radial Quadrangle 1D2D" algorithm</li>
33 <li>Quadrangle (Mapping) 2D algorithm
34   <ul>
35     <li> \ref tui_quadrangle_parameters "Quadrangle Parameters" hypothesis </li>
36   </ul>
37 </li>
38 <li>\ref tui_import "Use Existing Elements" algorithm</li>
39 </ul>
40 <br>
41
42 <h2>Defining 1D Hypotheses</h2>
43
44 <br>
45 \anchor tui_1d_arithmetic
46 <h3>Arithmetic 1D</h3>
47
48 \code
49 import geompy
50 import smesh
51
52 # create a box
53 box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
54 geompy.addToStudy(box, "Box")
55
56 # create a hexahedral mesh on the box
57 hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
58
59 # create a Regular 1D algorithm for edges
60 algo1D = hexa.Segment()
61
62 # optionally reverse node distribution on certain edges
63 allEdges = geompy.SubShapeAllSortedIDs( box, geompy.ShapeType["EDGE"])
64 reversedEdges = [ allEdges[0], allEdges[4] ]
65
66 # define "Arithmetic1D" hypothesis to cut all edges in several segments with increasing arithmetic length 
67 algo1D.Arithmetic1D(1, 4, reversedEdges)
68
69 # create a quadrangle 2D algorithm for faces
70 hexa.Quadrangle()
71
72 # create a hexahedron 3D algorithm for solids
73 hexa.Hexahedron()
74
75 # compute the mesh
76 hexa.Compute()
77 \endcode
78
79 <br>
80 \anchor tui_deflection_1d
81 <h3>Deflection 1D and Number of Segments</h3>
82
83 \code
84 import geompy
85 import smesh
86
87 # create a face from arc and straight segment
88 px = geompy.MakeVertex(100., 0.  , 0.  )
89 py = geompy.MakeVertex(0.  , 100., 0.  )
90 pz = geompy.MakeVertex(0.  , 0.  , 100.)
91
92 exy = geompy.MakeEdge(px, py)
93 arc = geompy.MakeArc(py, pz, px)
94
95 wire = geompy.MakeWire([exy, arc])
96
97 isPlanarFace = 1
98 face1 = geompy.MakeFace(wire, isPlanarFace)
99 geompy.addToStudy(face1,"Face1")
100
101 # get edges from the face
102 e_straight,e_arc = geompy.SubShapeAll(face1, geompy.ShapeType["EDGE"])
103 geompy.addToStudyInFather(face1, e_arc, "Arc Edge")
104
105 # create hexahedral mesh
106 hexa = smesh.Mesh(face1, "Face : triangle mesh")
107
108 # define "NumberOfSegments" hypothesis to cut a straight edge in a fixed number of segments
109 algo1D = hexa.Segment()
110 algo1D.NumberOfSegments(6)
111
112 # define "MaxElementArea" hypothesis
113 algo2D = hexa.Triangle()
114 algo2D.MaxElementArea(70.0)
115
116 # define a local "Deflection1D" hypothesis on the arc
117 algo_local = hexa.Segment(e_arc)
118 algo_local.Deflection1D(1.0)
119
120 # compute the mesh
121 hexa.Compute()
122 \endcode
123
124 <br>
125 \anchor tui_start_and_end_length
126 <h3>Start and End Length</h3>
127
128 \code
129 from geompy import *
130 import smesh
131
132 # create a box
133 box = MakeBoxDXDYDZ(10., 10., 10.)
134 addToStudy(box, "Box")
135
136 # get one edge of the box to put local hypothesis on
137 p5 = MakeVertex(5., 0., 0.)
138 EdgeX = GetEdgeNearPoint(box, p5)
139 addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
140
141 # create a hexahedral mesh on the box
142 hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
143
144 # set algorithms
145 algo1D = hexa.Segment()
146 hexa.Quadrangle()
147 hexa.Hexahedron()
148
149 # define "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
150 algo1D.NumberOfSegments(4)
151
152 # create a local hypothesis
153 algo_local = hexa.Segment(EdgeX)
154
155 # define "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
156 algo_local.StartEndLength(1, 6)
157
158 # define "Propagation" hypothesis that propagates all other hypothesis
159 # on all edges on the opposite side in case of quadrangular faces
160 algo_local.Propagation()
161
162 # compute the mesh
163 hexa.Compute()
164 \endcode
165
166 <br>
167 \anchor tui_average_length
168 <h3>Local Length</h3>
169
170 \code
171 from geompy import *
172 import smesh
173
174 # create a box
175 box = MakeBoxDXDYDZ(10., 10., 10.)
176 addToStudy(box, "Box")
177
178 # get one edge of the box to put local hypothesis on
179 p5 = MakeVertex(5., 0., 0.)
180 EdgeX = GetEdgeNearPoint(box, p5)
181 addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
182
183 # create a hexahedral mesh on the box
184 hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
185
186 # set algorithms
187 algo1D = hexa.Segment()
188 hexa.Quadrangle()
189 hexa.Hexahedron()
190
191 # define "NumberOfSegments" hypothesis to cut all edges in a fixed number of segments
192 algo1D.NumberOfSegments(4)
193
194 # create a sub-mesh
195 algo_local = hexa.Segment(EdgeX)
196
197 # define "LocalLength" hypothesis to cut an edge in several segments with the same length
198 algo_local.LocalLength(2.)
199
200 # define "Propagation" hypothesis that propagates all other hypothesis
201 # on all edges on the opposite side in case of quadrangular faces
202 algo_local.Propagation()
203
204 # compute the mesh
205 hexa.Compute()
206 \endcode
207
208 <br><h2>Defining 2D and 3D hypotheses</h2>
209
210 <br>
211 \anchor tui_max_element_area
212 <h3>Maximum Element Area</h3>
213
214 \code
215 import geompy
216 import smesh
217 import salome 
218
219 # create a face
220 px   = geompy.MakeVertex(100., 0.  , 0.  )
221 py   = geompy.MakeVertex(0.  , 100., 0.  )
222 pz   = geompy.MakeVertex(0.  , 0.  , 100.)
223
224 vxy = geompy.MakeVector(px, py)
225 arc = geompy.MakeArc(py, pz, px)
226 wire = geompy.MakeWire([vxy, arc])
227
228 isPlanarFace = 1
229 face = geompy.MakeFace(wire, isPlanarFace)
230
231 # add the face in the study
232 id_face = geompy.addToStudy(face, "Face to be meshed")
233
234 # create a mesh
235 tria_mesh = smesh.Mesh(face, "Face : triangulation")
236
237 # define 1D meshing:
238 algo = tria_mesh.Segment()
239 algo.NumberOfSegments(20)
240
241 # define 2D meshing:
242
243 # assign triangulation algorithm
244 algo = tria_mesh.Triangle()
245
246 # apply "Max Element Area" hypothesis to each triangle
247 algo.MaxElementArea(100)
248
249 # compute the mesh
250 tria_mesh.Compute()
251 \endcode
252
253 <br>
254 \anchor tui_max_element_volume
255 <h3>Maximum Element Volume</h3>
256
257 \code
258 import geompy
259 import smesh
260
261 # create a cylinder
262 cyl = geompy.MakeCylinderRH(30., 50.)
263 geompy.addToStudy(cyl, "cyl")
264
265 # create a mesh on the cylinder
266 tetra = smesh.Mesh(cyl, "Cylinder : tetrahedrical mesh")
267
268 # assign algorithms
269 algo1D = tetra.Segment()
270 algo2D = tetra.Triangle()
271 algo3D = tetra.Tetrahedron()
272
273 # assign 1D and 2D hypotheses
274 algo1D.NumberOfSegments(7)
275 algo2D.MaxElementArea(150.)
276
277 # assign Max Element Volume hypothesis
278 algo3D.MaxElementVolume(200.)
279
280 # compute the mesh
281 ret = tetra.Compute()
282 if ret == 0:
283     print "probleme when computing the mesh"
284 else:
285     print "Computation succeded"
286 \endcode
287
288 <br>
289 \anchor tui_length_from_edges
290 <h3>Length from Edges</h3>
291
292 \code
293 import geompy
294 import smesh
295
296 # create sketchers
297 sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")
298 sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
299
300 # create a face from two wires
301 isPlanarFace = 1
302 face1 = geompy.MakeFaces([sketcher1, sketcher2], isPlanarFace)
303 geompy.addToStudy(face1, "Face1")
304
305 # create a mesh
306 tria = smesh.Mesh(face1, "Face : triangle 2D mesh")
307
308 # Define 1D meshing
309 algo1D = tria.Segment()
310 algo1D.NumberOfSegments(2)
311
312 # create and assign the algorithm for 2D meshing with triangles
313 algo2D = tria.Triangle()
314
315 # create and assign "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire
316 algo2D.LengthFromEdges()
317
318 # compute the mesh
319 tria.Compute()
320 \endcode
321
322 <br><h2>Defining Additional Hypotheses</h2>
323
324 <br>
325 \anchor tui_propagation
326 <h3>Propagation</h3>
327
328 \code
329 from geompy import *
330 import smesh
331
332 # create a box
333 box = MakeBoxDXDYDZ(10., 10., 10.)
334 addToStudy(box, "Box")
335
336 # get one edge of the box to put local hypothesis on
337 p5 = MakeVertex(5., 0., 0.)
338 EdgeX = GetEdgeNearPoint(box, p5)
339 addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
340
341 # create a hexahedral mesh on the box
342 hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
343
344 # set global algorithms and hypotheses
345 algo1D = hexa.Segment()
346 hexa.Quadrangle()
347 hexa.Hexahedron()
348 algo1D.NumberOfSegments(4)
349
350 # create a sub-mesh with local 1D hypothesis and propagation
351 algo_local = hexa.Segment(EdgeX)
352
353 # define "Arithmetic1D" hypothesis to cut an edge in several segments with increasing length
354 algo_local.Arithmetic1D(1, 4)
355
356 # define "Propagation" hypothesis that propagates all other 1D hypotheses
357 # from all edges on the opposite side of a face in case of quadrangular faces
358 algo_local.Propagation()
359
360 # compute the mesh
361 hexa.Compute()
362 \endcode
363
364 <br>
365 \anchor tui_defining_meshing_algos
366 <h2>Defining Meshing Algorithms</h2>
367
368 \code
369 import geompy
370 import smesh
371
372 # create a box
373 box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
374 geompy.addToStudy(box, "Box")
375
376 # 1. Create a hexahedral mesh on the box
377 hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
378
379 # create a Regular 1D algorithm for edges
380 algo1D = hexa.Segment()
381
382 # create a quadrangle 2D algorithm for faces
383 algo2D = hexa.Quadrangle()
384
385 # create a hexahedron 3D algorithm for solids
386 algo3D = hexa.Hexahedron()
387
388 # define hypotheses
389 algo1D.Arithmetic1D(1, 4)
390
391 # compute the mesh
392 hexa.Compute()
393
394 # 2. Create a tetrahedral mesh on the box
395 tetra = smesh.Mesh(box, "Box : tetrahedrical mesh")
396
397 # create a Regular 1D algorithm for edges
398 algo1D = tetra.Segment()
399
400 # create a Mefisto 2D algorithm for faces
401 algo2D = tetra.Triangle()
402
403 # create a 3D algorithm for solids
404 algo3D = tetra.Tetrahedron()
405
406 # define hypotheses
407 algo1D.Arithmetic1D(1, 4)
408 algo2D.LengthFromEdges()
409
410 # compute the mesh
411 tetra.Compute()
412
413 \endcode
414
415 <br>
416 \anchor tui_projection
417 <h3>Projection Algorithms</h3>
418
419 \code
420 # Project prisms from one meshed box to another mesh on the same box
421
422 from smesh import *
423
424 # Prepare geometry
425
426 # Create a parallelepiped
427 box = geompy.MakeBoxDXDYDZ(200, 100, 70)
428 geompy.addToStudy( box, "box" )
429
430 # Get geom faces to mesh with triangles in the 1ts and 2nd meshes
431 faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
432 # 2 adjacent faces of the box
433 f1 = faces[2]
434 f2 = faces[0]
435 # face opposite to f2
436 f2opp = faces[1]
437
438 # Get vertices used to specify how to associate sides of faces at projection
439 [v1F1, v2F1] = geompy.SubShapeAll(f1, geompy.ShapeType["VERTEX"])[:2]
440 [v1F2, v2F2] = geompy.SubShapeAll(f2, geompy.ShapeType["VERTEX"])[:2]
441 geompy.addToStudyInFather( box, v1F1, "v1F1" )
442 geompy.addToStudyInFather( box, v2F1, "v2F1" )
443 geompy.addToStudyInFather( box, v1F2, "v1F2" )
444 geompy.addToStudyInFather( box, v2F2, "v2F2" )
445
446 # Make group of 3 edges of f1 and f2
447 edgesF1 = geompy.CreateGroup(f1, geompy.ShapeType["EDGE"])
448 geompy.UnionList( edgesF1, geompy.SubShapeAll(f1, geompy.ShapeType["EDGE"])[:3])
449 edgesF2 = geompy.CreateGroup(f2, geompy.ShapeType["EDGE"])
450 geompy.UnionList( edgesF2, geompy.SubShapeAll(f2, geompy.ShapeType["EDGE"])[:3])
451 geompy.addToStudyInFather( box, edgesF1, "edgesF1" )
452 geompy.addToStudyInFather( box, edgesF2, "edgesF2" )
453
454
455 # Make the source mesh with prisms
456 src_mesh = Mesh(box, "Source mesh")
457 src_mesh.Segment().NumberOfSegments(9,10)
458 src_mesh.Quadrangle()
459 src_mesh.Hexahedron()
460 src_mesh.Triangle(f1) # triangular sumbesh 
461 src_mesh.Compute()
462
463
464 # Mesh the box using projection algoritms
465
466 # Define the same global 1D and 2D hypotheses
467 tgt_mesh = Mesh(box, "Target mesh")
468 tgt_mesh.Segment().NumberOfSegments(9,10,UseExisting=True)
469 tgt_mesh.Quadrangle()
470
471 # Define Projection 1D algorithm to project 1d mesh elements from group edgesF2 to edgesF1
472 # It is actually not needed, just a demonstration
473 proj1D = tgt_mesh.Projection1D( edgesF1 )
474 # each vertex must be at the end of a connected group of edges (or a sole edge)
475 proj1D.SourceEdge( edgesF2, src_mesh, v2F1, v2F2 )
476
477 # Define 2D hypotheses to project triangles from f1 face of the source mesh to
478 # f2 face in the target mesh. Vertices specify how to associate sides of faces
479 proj2D = tgt_mesh.Projection2D( f2 )
480 proj2D.SourceFace( f1, src_mesh, v1F1, v1F2, v2F1, v2F2 )
481
482 # 2D hypotheses to project triangles from f2 of target mesh to the face opposite to f2.
483 # Association of face sides is default
484 proj2D = tgt_mesh.Projection2D( f2opp )
485 proj2D.SourceFace( f2 )
486
487 # 3D hypotheses to project prisms from the source to the target mesh
488 proj3D = tgt_mesh.Projection3D()
489 proj3D.SourceShape3D( box, src_mesh, v1F1, v1F2, v2F1, v2F2 )
490 tgt_mesh.Compute()
491
492 # Move the source mesh to visualy compare the two meshes
493 src_mesh.TranslateObject( src_mesh, MakeDirStruct( 210, 0, 0 ), Copy=False)
494
495 \endcode
496
497 <h3>Projection 1D2D</h3>
498
499 \code
500 # Project triangles from one meshed face to another mesh on the same box
501
502 from smesh import *
503
504 # Prepare geometry
505
506 # Create a box
507 box = geompy.MakeBoxDXDYDZ(100, 100, 100)
508
509 # Get geom faces to mesh with triangles in the 1ts and 2nd meshes
510 faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
511 # 2 adjacent faces of the box
512 Face_1 = faces[2]
513 Face_2 = faces[0]
514
515 geompy.addToStudy( box, 'box' )
516 geompy.addToStudyInFather( box, Face_1, 'Face_1' )
517 geompy.addToStudyInFather( box, Face_2, 'Face_2' )
518
519 # Make the source mesh with Netgem2D
520 src_mesh = Mesh(Face_1, "Source mesh")
521 src_mesh.Segment().NumberOfSegments(15)
522 src_mesh.Triangle()
523 src_mesh.Compute()
524
525 # Mesh the target mesh using the algoritm Projection1D2D
526 tgt_mesh = smesh.Mesh(Face_2, "Target mesh")
527 tgt_mesh.Projection1D2D().SourceFace(Face_1,src_mesh)
528 tgt_mesh.Compute()
529 \endcode
530
531 <br>
532
533 \anchor tui_fixed_points
534
535 <h2>1D Mesh with Fixed Points example</h2>
536
537 \code
538 import salome
539 import geompy
540 import smesh
541 import StdMeshers
542
543 # Create face and explode it on edges
544 face = geompy.MakeFaceHW(100, 100, 1)
545 edges = geompy.SubShapeAllSorted(face, geompy.ShapeType["EDGE"])
546 geompy.addToStudy( face, "Face" )
547
548 # get the first edge from exploded result
549 edge1 = geompy.GetSubShapeID(face, edges[0])
550
551 # Define Mesh on previously created face
552 Mesh_1 = smesh.Mesh(face)
553
554 # Create Fixed Point 1D hypothesis and define parameters.
555 # Note: values greater than 1.0 and less than 0.0 are not taken into account;
556 # duplicated values are removed. Also, if not specified explicitly, values 0.0 and 1.0
557 # add added automatically.
558 # The number of segments should correspond to the number of points (NbSeg = NbPnt-1);
559 # extra values of segments splitting parameter are not taken into account,
560 # while missing values are considered to be equal to 1.
561 Fixed_points_1D_1 = smesh.CreateHypothesis('FixedPoints1D')
562 Fixed_points_1D_1.SetPoints( [ 1.1, 0.9, 0.5, 0.0, 0.5, -0.3 ] )
563 Fixed_points_1D_1.SetNbSegments( [ 3, 1, 2 ] )
564 Fixed_points_1D_1.SetReversedEdges( [edge1] )
565
566 # Add hypothesis to mesh and define 2D parameters
567 Mesh_1.AddHypothesis(Fixed_points_1D_1)
568 Regular_1D = Mesh_1.Segment()
569 Quadrangle_2D = Mesh_1.Quadrangle()
570 # Compute mesh
571 Mesh_1.Compute()
572 \endcode
573
574 \anchor tui_radial_quadrangle
575 <h2> Radial Quadrangle 1D2D example </h2>
576 \code
577 from smesh import *
578
579 SetCurrentStudy(salome.myStudy)
580
581 # Create face from the wire and add to study
582 Face = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:R 90:C 20 90:WF", [0, 0, 0, 1, 0, 0, 0, 0, 1])
583 geompy.addToStudy(Face,"Face")
584 edges = geompy.SubShapeAllSorted(Face, geompy.ShapeType["EDGE"])
585 circle, radius1, radius2 = edges
586 geompy.addToStudyInFather(Face, radius1,"radius1")
587 geompy.addToStudyInFather(Face, radius2,"radius2")
588 geompy.addToStudyInFather(Face, circle,"circle")
589
590
591 # Define geometry for mesh, and Radial Quadrange algorithm
592 mesh = smesh.Mesh(Face)
593 radial_Quad_algo = mesh.Quadrangle(algo=RADIAL_QUAD)
594
595 # The Radial Quadrange algorithm can work without any hypothesis
596 # In this case it uses "Default Nb of Segments" preferences parameter to discretize edges
597 mesh.Compute()
598
599 # The Radial Quadrange uses global or local 1d hypotheses if it does
600 # not have its own hypotheses.
601 # Define global hypotheses to discretize radial edges and a local one for circular edge
602 global_Nb_Segments = mesh.Segment().NumberOfSegments(5)
603 local_Nb_Segments  = mesh.Segment(circle).NumberOfSegments(10)
604 mesh.Compute()
605
606 # Define own parameters of Radial Quadrange algorithm
607 radial_Quad_algo.NumberOfLayers( 4 )
608 mesh.Compute()
609 \endcode
610
611 \anchor tui_quadrangle_parameters
612 <h2>Quadrangle Parameters example 1 (meshing a face with 3 edges) </h2>
613 \code
614 from smesh import *
615 SetCurrentStudy(salome.myStudy)
616
617 # Get 1/4 part from the disk face.
618 Box_1 = geompy.MakeBoxDXDYDZ(100, 100, 100)
619 Disk_1 = geompy.MakeDiskR(100, 1)
620 Common_1 = geompy.MakeCommon(Disk_1, Box_1)
621 geompy.addToStudy( Disk_1, "Disk_1" )
622 geompy.addToStudy( Box_1, "Box_1" )
623 geompy.addToStudy( Common_1, "Common_1" )
624
625 # Set the Geometry for meshing
626 Mesh_1 = smesh.Mesh(Common_1)
627
628
629 # Define 1D hypothesis and compute the mesh
630 Regular_1D = Mesh_1.Segment()
631 Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
632 Nb_Segments_1.SetDistrType( 0 )
633
634 # Create Quadrangle parameters and define the Base Vertex.
635 Quadrangle_2D = Mesh_1.Quadrangle().TriangleVertex( 8 )
636
637 Mesh_1.Compute()
638 \endcode
639
640 <h2>Quadrangle Parameters example 2 (using different types) </h2>
641 \code
642 import geompy
643 import smesh
644 import StdMeshers
645
646 # Make quadrangle face and explode it on edges.
647 Vertex_1 = geompy.MakeVertex(0, 0, 0)
648 Vertex_2 = geompy.MakeVertex(40, 0, 0)
649 Vertex_3 = geompy.MakeVertex(40, 30, 0)
650 Vertex_4 = geompy.MakeVertex(0, 30, 0)
651 Quadrangle_Face_1 = geompy.MakeQuad4Vertices(Vertex_1, Vertex_4, Vertex_3, Vertex_2)
652 [Edge_1,Edge_2,Edge_3,Edge_4] = geompy.SubShapeAllSorted(Quadrangle_Face_1, geompy.ShapeType["EDGE"])
653 geompy.addToStudy( Vertex_1, "Vertex_1" )
654 geompy.addToStudy( Vertex_2, "Vertex_2" )
655 geompy.addToStudy( Vertex_3, "Vertex_3" )
656 geompy.addToStudy( Vertex_4, "Vertex_4" )
657 geompy.addToStudy( Quadrangle_Face_1, "Quadrangle Face_1" )
658 geompy.addToStudyInFather( Quadrangle_Face_1, Edge_2, "Edge_2" )
659
660 # Set the Geometry for meshing
661 Mesh_1 = smesh.Mesh(Quadrangle_Face_1)
662
663 # Create Quadrangle parameters and
664 # define the Type as Quadrangle Preference
665 Quadrangle_Parameters_1 = smesh.CreateHypothesis('QuadrangleParams')
666 Quadrangle_Parameters_1.SetQuadType( StdMeshers.QUAD_QUADRANGLE_PREF )
667
668 # Define other hypotheses and algorithms
669 Regular_1D = Mesh_1.Segment()
670 Nb_Segments_1 = Regular_1D.NumberOfSegments(4)
671 Nb_Segments_1.SetDistrType( 0 )
672 status = Mesh_1.AddHypothesis(Quadrangle_Parameters_1)
673 Quadrangle_2D = Mesh_1.Quadrangle()
674
675 # Define submesh on one edge to provide different number of segments
676 Regular_1D_1 = Mesh_1.Segment(geom=Edge_2)
677 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(10)
678 Nb_Segments_2.SetDistrType( 0 )
679 SubMesh_1 = Regular_1D_1.GetSubMesh()
680
681 # Compute mesh (with Quadrangle Preference type)
682 isDone = Mesh_1.Compute()
683
684 # Change type to Reduced and compute again
685 Quadrangle_Parameters_1.SetQuadType( StdMeshers.QUAD_REDUCED )
686 isDone = Mesh_1.Compute()
687 \endcode
688
689 \anchor tui_import
690 <h2>"Use Existing Elements" example </h2>
691 \code
692
693 from smesh import *
694 SetCurrentStudy(salome.myStudy)
695
696 # Make a patritioned box
697
698 box = geompy.MakeBoxDXDYDZ(100,100,100)
699
700 N = geompy.MakeVectorDXDYDZ( 1,0,0 )
701 O = geompy.MakeVertex( 50,0,0 )
702 plane = geompy.MakePlane( O, N, 200 ) # plane YOZ
703
704 shape2boxes = geompy.MakeHalfPartition( box, plane )
705 boxes = geompy.SubShapeAllSorted(shape2boxes, geompy.ShapeType["SOLID"])
706
707 geompy.addToStudy( boxes[0], "boxes[0]")
708 geompy.addToStudy( boxes[1], "boxes[1]")
709 midFace0 = geompy.SubShapeAllSorted(boxes[0], geompy.ShapeType["FACE"])[5]
710 geompy.addToStudyInFather( boxes[0], midFace0, "middle Face")
711 midFace1 = geompy.SubShapeAllSorted(boxes[1], geompy.ShapeType["FACE"])[0]
712 geompy.addToStudyInFather( boxes[1], midFace1, "middle Face")
713
714 # Mesh one of boxes with quadrangles. It is a source mesh
715
716 srcMesh = Mesh(boxes[0], "source mesh") # box coloser to CS origin
717 nSeg1 = srcMesh.Segment().NumberOfSegments(4)
718 srcMesh.Quadrangle()
719 srcMesh.Compute()
720 srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", FACE )
721
722 # Import faces from midFace0 to the target mesh
723
724 tgtMesh = Mesh(boxes[1], "target mesh")
725 importAlgo = tgtMesh.UseExisting2DElements(midFace1)
726 import2hyp = importAlgo.SourceFaces( [srcFaceGroup] )
727 tgtMesh.Segment().NumberOfSegments(3)
728 tgtMesh.Quadrangle()
729 tgtMesh.Compute()
730
731 # Import the whole source mesh with groups
732 import2hyp.SetCopySourceMesh(True,True)
733 tgtMesh.Compute()
734 \endcode
735
736 \anchor tui_viscous_layers
737 <h2>Viscous layers construction</h2>
738
739 \code
740 from smesh import *
741 SetCurrentStudy(salome.myStudy)
742
743 X = geompy.MakeVectorDXDYDZ( 1,0,0 )
744 O = geompy.MakeVertex( 100,50,50 )
745 plane = geompy.MakePlane( O, X, 200 ) # plane YZ
746
747 box = geompy.MakeBoxDXDYDZ(200,100,100)
748
749 shape = geompy.MakeHalfPartition( box, plane )
750
751 faces = geompy.SubShapeAllSorted(shape, geompy.ShapeType["FACE"])
752 face1 = faces[1]
753 ignoreFaces = [ faces[0], faces[-1]]
754
755 geompy.addToStudy( shape, "shape" )
756 geompy.addToStudyInFather( shape, face1, "face1")
757
758
759 mesh = Mesh(shape, "CFD")
760
761 mesh.Segment().NumberOfSegments( 4 )
762
763 mesh.Triangle()
764 mesh.Quadrangle(face1)
765 mesh.Compute()
766 algo3D = mesh.Tetrahedron()
767
768 thickness = 20
769 numberOfLayers = 10
770 stretchFactor = 1.5
771 layersHyp = algo3D.ViscousLayers(thickness,numberOfLayers,stretchFactor,ignoreFaces)
772
773 mesh.Compute()
774
775 mesh.MakeGroup("Tetras",VOLUME,FT_ElemGeomType,"=",Geom_TETRA)
776 mesh.MakeGroup("Pyras",VOLUME,FT_ElemGeomType,"=",Geom_PYRAMID)
777 mesh.MakeGroup("Prims",VOLUME,FT_ElemGeomType,"=",Geom_PENTA)
778
779 \endcode
780
781 */