Salome HOME
Merge branch 'occ/shaper2smesh'
[modules/smesh.git] / doc / salome / examples / defining_hypotheses_ex17.py
1 # Viscous layers construction
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New()
8
9 import SMESH, SALOMEDS
10 from salome.smesh import smeshBuilder
11 smesh =  smeshBuilder.New()
12
13 X = geompy.MakeVectorDXDYDZ( 1,0,0 )
14 O = geompy.MakeVertex( 100,50,50 )
15 plane = geompy.MakePlane( O, X, 200 ) # plane YZ
16
17 box = geompy.MakeBoxDXDYDZ(200,100,100)
18
19 shape = geompy.MakeHalfPartition( box, plane )
20
21 faces = geompy.SubShapeAllSorted(shape, geompy.ShapeType["FACE"])
22 face1 = faces[1]
23 ignoreFaces = [ faces[0], faces[-1]]
24
25 geompy.addToStudy( shape, "shape" )
26 geompy.addToStudyInFather( shape, face1, "face1")
27
28 # 3D Viscous layers
29
30 mesh = smesh.Mesh(shape, "CFD")
31
32 mesh.Segment().NumberOfSegments( 4 )
33
34 mesh.Triangle()
35 mesh.Quadrangle(face1)
36 algo3D = mesh.Tetrahedron()
37
38 thickness = 20
39 numberOfLayers = 10
40 stretchFactor = 1.5
41 groupName = "Boundary layers"
42 layersHyp = algo3D.ViscousLayers(thickness,numberOfLayers,stretchFactor,
43                                  ignoreFaces,           # optional
44                                  groupName = groupName) # optional
45
46 mesh.Compute()
47
48 # retrieve boundary prisms created by mesh.Compute()
49 boundaryGroup = mesh.GetGroupByName( layersHyp.GetGroupName() )[0]
50 print( "Nb boundary prisms", boundaryGroup.Size() )
51
52 mesh.MakeGroup("Tetras",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_TETRA)
53 mesh.MakeGroup("Pyras",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_PYRAMID)
54 mesh.MakeGroup("Prims",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_PENTA)
55
56 # 2D Viscous layers
57
58 # 3 edges of the 4 edges of face1
59 edgeIds = geompy.SubShapeAllIDs( face1, geompy.ShapeType["EDGE"])[:-1]
60
61 mesh = smesh.Mesh(face1,"VicsousLayers2D")
62 mesh.Segment().NumberOfSegments( 5 )
63
64 # viscous layers will be created on 1 edge, as we set 3 edges to ignore
65 vlHyp = mesh.Triangle().ViscousLayers2D( 2, 3, 1.5,
66                                          edgeIds, isEdgesToIgnore=True, # optional
67                                          groupName=groupName)           # optional
68 mesh.Compute()
69
70 # retrieve boundary elements created by mesh.Compute()
71 quadrangles = mesh.GetGroupByName( vlHyp.GetGroupName() )[0]
72 print( "Nb boundary quadrangles", quadrangles.Size() )
73
74 # viscous layers will be created on 3 edges, as we pass isEdgesToIgnore=False
75 vlHyp.SetEdges( edgeIds, False )
76
77 mesh.Compute()