Salome HOME
Merge from V6_main_20120808 08Aug12
[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 <br>
461
462 \anchor tui_fixed_points
463
464 <h2>1D Mesh with Fixed Points example</h2>
465
466 \code
467 import salome
468 import geompy
469 import smesh
470 import StdMeshers
471
472 # Create face and explode it on edges
473 face = geompy.MakeFaceHW(100, 100, 1)
474 edges = geompy.SubShapeAllSorted(face, geompy.ShapeType["EDGE"])
475 geompy.addToStudy( face, "Face" )
476
477 # get the first edge from exploded result
478 edge1 = geompy.GetSubShapeID(face, edges[0])
479
480 # Define Mesh on previously created face
481 Mesh_1 = smesh.Mesh(face)
482
483 # Create Fixed Point 1D hypothesis and define parameters.
484 # Note: values greater than 1.0 and less than 0.0 are not taken into account;
485 # duplicated values are removed. Also, if not specified explicitly, values 0.0 and 1.0
486 # add added automatically.
487 # The number of segments should correspond to the number of points (NbSeg = NbPnt-1);
488 # extra values of segments splitting parameter are not taken into account,
489 # while missing values are considered to be equal to 1.
490 Fixed_points_1D_1 = smesh.CreateHypothesis('FixedPoints1D')
491 Fixed_points_1D_1.SetPoints( [ 1.1, 0.9, 0.5, 0.0, 0.5, -0.3 ] )
492 Fixed_points_1D_1.SetNbSegments( [ 3, 1, 2 ] )
493 Fixed_points_1D_1.SetReversedEdges( [edge1] )
494
495 # Add hypothesis to mesh and define 2D parameters
496 Mesh_1.AddHypothesis(Fixed_points_1D_1)
497 Regular_1D = Mesh_1.Segment()
498 Quadrangle_2D = Mesh_1.Quadrangle()
499 # Compute mesh
500 Mesh_1.Compute()
501 \endcode
502
503 \anchor tui_radial_quadrangle
504 <h2> Radial Quadrangle 1D2D example </h2>
505 \code
506 from smesh import *
507
508 SetCurrentStudy(salome.myStudy)
509
510 # Create face from the wire and add to study
511 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])
512 geompy.addToStudy(Face,"Face")
513 edges = geompy.SubShapeAllSorted(Face, geompy.ShapeType["EDGE"])
514 circle, radius1, radius2 = edges
515 geompy.addToStudyInFather(Face, radius1,"radius1")
516 geompy.addToStudyInFather(Face, radius2,"radius2")
517 geompy.addToStudyInFather(Face, circle,"circle")
518
519
520 # Define geometry for mesh, and Radial Quadrange algorithm
521 mesh = smesh.Mesh(Face)
522 radial_Quad_algo = mesh.Quadrangle(algo=RADIAL_QUAD)
523
524 # The Radial Quadrange algorithm can work without any hypothesis
525 # In this case it uses "Default Nb of Segments" preferences parameter to discretize edges
526 mesh.Compute()
527
528 # The Radial Quadrange uses global or local 1d hypotheses if it does
529 # not have its own hypotheses.
530 # Define global hypotheses to discretize radial edges and a local one for circular edge
531 global_Nb_Segments = mesh.Segment().NumberOfSegments(5)
532 local_Nb_Segments  = mesh.Segment(circle).NumberOfSegments(10)
533 mesh.Compute()
534
535 # Define own parameters of Radial Quadrange algorithm
536 radial_Quad_algo.NumberOfLayers( 4 )
537 mesh.Compute()
538 \endcode
539
540 \anchor tui_quadrangle_parameters
541 <h2>Quadrangle Parameters example 1 (meshing a face with 3 edges) </h2>
542 \code
543 from smesh import *
544 SetCurrentStudy(salome.myStudy)
545
546 # Get 1/4 part from the disk face.
547 Box_1 = geompy.MakeBoxDXDYDZ(100, 100, 100)
548 Disk_1 = geompy.MakeDiskR(100, 1)
549 Common_1 = geompy.MakeCommon(Disk_1, Box_1)
550 geompy.addToStudy( Disk_1, "Disk_1" )
551 geompy.addToStudy( Box_1, "Box_1" )
552 geompy.addToStudy( Common_1, "Common_1" )
553
554 # Set the Geometry for meshing
555 Mesh_1 = smesh.Mesh(Common_1)
556
557
558 # Define 1D hypothesis and compute the mesh
559 Regular_1D = Mesh_1.Segment()
560 Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
561 Nb_Segments_1.SetDistrType( 0 )
562
563 # Create Quadrangle parameters and define the Base Vertex.
564 Quadrangle_2D = Mesh_1.Quadrangle().TriangleVertex( 8 )
565
566 Mesh_1.Compute()
567 \endcode
568
569 <h2>Quadrangle Parameters example 2 (using different types) </h2>
570 \code
571 import geompy
572 import smesh
573 import StdMeshers
574
575 # Make quadrangle face and explode it on edges.
576 Vertex_1 = geompy.MakeVertex(0, 0, 0)
577 Vertex_2 = geompy.MakeVertex(40, 0, 0)
578 Vertex_3 = geompy.MakeVertex(40, 30, 0)
579 Vertex_4 = geompy.MakeVertex(0, 30, 0)
580 Quadrangle_Face_1 = geompy.MakeQuad4Vertices(Vertex_1, Vertex_4, Vertex_3, Vertex_2)
581 [Edge_1,Edge_2,Edge_3,Edge_4] = geompy.SubShapeAllSorted(Quadrangle_Face_1, geompy.ShapeType["EDGE"])
582 geompy.addToStudy( Vertex_1, "Vertex_1" )
583 geompy.addToStudy( Vertex_2, "Vertex_2" )
584 geompy.addToStudy( Vertex_3, "Vertex_3" )
585 geompy.addToStudy( Vertex_4, "Vertex_4" )
586 geompy.addToStudy( Quadrangle_Face_1, "Quadrangle Face_1" )
587 geompy.addToStudyInFather( Quadrangle_Face_1, Edge_2, "Edge_2" )
588
589 # Set the Geometry for meshing
590 Mesh_1 = smesh.Mesh(Quadrangle_Face_1)
591
592 # Create Quadrangle parameters and
593 # define the Type as Quadrangle Preference
594 Quadrangle_Parameters_1 = smesh.CreateHypothesis('QuadrangleParams')
595 Quadrangle_Parameters_1.SetQuadType( StdMeshers.QUAD_QUADRANGLE_PREF )
596
597 # Define other hypotheses and algorithms
598 Regular_1D = Mesh_1.Segment()
599 Nb_Segments_1 = Regular_1D.NumberOfSegments(4)
600 Nb_Segments_1.SetDistrType( 0 )
601 status = Mesh_1.AddHypothesis(Quadrangle_Parameters_1)
602 Quadrangle_2D = Mesh_1.Quadrangle()
603
604 # Define submesh on one edge to provide different number of segments
605 Regular_1D_1 = Mesh_1.Segment(geom=Edge_2)
606 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(10)
607 Nb_Segments_2.SetDistrType( 0 )
608 SubMesh_1 = Regular_1D_1.GetSubMesh()
609
610 # Compute mesh (with Quadrangle Preference type)
611 isDone = Mesh_1.Compute()
612
613 # Change type to Reduced and compute again
614 Quadrangle_Parameters_1.SetQuadType( StdMeshers.QUAD_REDUCED )
615 isDone = Mesh_1.Compute()
616 \endcode
617
618 \anchor tui_import
619 <h2>"Use Existing Elements" example </h2>
620 \code
621
622 from smesh import *
623 SetCurrentStudy(salome.myStudy)
624
625 # Make a patritioned box
626
627 box = geompy.MakeBoxDXDYDZ(100,100,100)
628
629 N = geompy.MakeVectorDXDYDZ( 1,0,0 )
630 O = geompy.MakeVertex( 50,0,0 )
631 plane = geompy.MakePlane( O, N, 200 ) # plane YOZ
632
633 shape2boxes = geompy.MakeHalfPartition( box, plane )
634 boxes = geompy.SubShapeAllSorted(shape2boxes, geompy.ShapeType["SOLID"])
635
636 geompy.addToStudy( boxes[0], "boxes[0]")
637 geompy.addToStudy( boxes[1], "boxes[1]")
638 midFace0 = geompy.SubShapeAllSorted(boxes[0], geompy.ShapeType["FACE"])[5]
639 geompy.addToStudyInFather( boxes[0], midFace0, "middle Face")
640 midFace1 = geompy.SubShapeAllSorted(boxes[1], geompy.ShapeType["FACE"])[0]
641 geompy.addToStudyInFather( boxes[1], midFace1, "middle Face")
642
643 # Mesh one of boxes with quadrangles. It is a source mesh
644
645 srcMesh = Mesh(boxes[0], "source mesh") # box coloser to CS origin
646 nSeg1 = srcMesh.Segment().NumberOfSegments(4)
647 srcMesh.Quadrangle()
648 srcMesh.Compute()
649 srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", FACE )
650
651 # Import faces from midFace0 to the target mesh
652
653 tgtMesh = Mesh(boxes[1], "target mesh")
654 importAlgo = tgtMesh.UseExisting2DElements(midFace1)
655 import2hyp = importAlgo.SourceFaces( [srcFaceGroup] )
656 tgtMesh.Segment().NumberOfSegments(3)
657 tgtMesh.Quadrangle()
658 tgtMesh.Compute()
659
660 # Import the whole source mesh with groups
661 import2hyp.SetCopySourceMesh(True,True)
662 tgtMesh.Compute()
663 \endcode
664
665 \anchor tui_viscous_layers
666 <h2>Viscous layers construction</h2>
667
668 \code
669 from smesh import *
670 SetCurrentStudy(salome.myStudy)
671
672 X = geompy.MakeVectorDXDYDZ( 1,0,0 )
673 O = geompy.MakeVertex( 100,50,50 )
674 plane = geompy.MakePlane( O, X, 200 ) # plane YZ
675
676 box = geompy.MakeBoxDXDYDZ(200,100,100)
677
678 shape = geompy.MakeHalfPartition( box, plane )
679
680 faces = geompy.SubShapeAllSorted(shape, geompy.ShapeType["FACE"])
681 face1 = faces[1]
682 ignoreFaces = [ faces[0], faces[-1]]
683
684 geompy.addToStudy( shape, "shape" )
685 geompy.addToStudyInFather( shape, face1, "face1")
686
687
688 mesh = Mesh(shape, "CFD")
689
690 mesh.Segment().NumberOfSegments( 4 )
691
692 mesh.Triangle()
693 mesh.Quadrangle(face1)
694 mesh.Compute()
695 algo3D = mesh.Tetrahedron()
696
697 thickness = 20
698 numberOfLayers = 10
699 stretchFactor = 1.5
700 layersHyp = algo3D.ViscousLayers(thickness,numberOfLayers,stretchFactor,ignoreFaces)
701
702 mesh.Compute()
703
704 mesh.MakeGroup("Tetras",VOLUME,FT_ElemGeomType,"=",Geom_TETRA)
705 mesh.MakeGroup("Pyras",VOLUME,FT_ElemGeomType,"=",Geom_PYRAMID)
706 mesh.MakeGroup("Prims",VOLUME,FT_ElemGeomType,"=",Geom_PENTA)
707
708 \endcode
709
710 */