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