1 # Viscous layers construction
4 salome.salome_init_without_session()
7 from salome.geom import geomBuilder
8 from salome.smesh import smeshBuilder
10 geom_builder = geomBuilder.New()
11 smesh_builder = smeshBuilder.New()
13 X = geom_builder.MakeVectorDXDYDZ( 1,0,0 )
14 O = geom_builder.MakeVertex( 100,50,50 )
15 plane = geom_builder.MakePlane( O, X, 200 ) # plane YZ
17 box = geom_builder.MakeBoxDXDYDZ(200,100,100)
19 shape = geom_builder.MakeHalfPartition( box, plane )
21 faces = geom_builder.SubShapeAllSorted(shape, geom_builder.ShapeType["FACE"])
23 ignoreFaces = [ faces[0], faces[-1]]
25 geom_builder.addToStudy( shape, "shape" )
26 geom_builder.addToStudyInFather( shape, face1, "face1")
30 mesh = smesh_builder.Mesh(shape, "CFD")
32 mesh.Segment().NumberOfSegments( 4 )
35 mesh.Quadrangle(face1)
36 algo3D = mesh.Tetrahedron()
41 groupName = "Boundary layers"
42 layersHyp = algo3D.ViscousLayers(thickness,numberOfLayers,stretchFactor,
43 ignoreFaces, # optional
44 groupName = groupName) # optional
46 if not mesh.Compute(): raise Exception("Error when computing Mesh")
48 # retrieve boundary prisms created by mesh.Compute()
49 boundaryGroup = mesh.GetGroupByName( layersHyp.GetGroupName() )[0]
50 print( "Nb boundary prisms", boundaryGroup.Size() )
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)
58 # 3 edges of the 4 edges of face1
59 edgeIds = geom_builder.SubShapeAllIDs( face1, geom_builder.ShapeType["EDGE"])[:-1]
61 mesh = smesh_builder.Mesh(face1,"VicsousLayers2D")
62 mesh.Segment().NumberOfSegments( 5 )
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 if not mesh.Compute(): raise Exception("Error when computing Mesh")
70 # retrieve boundary elements created by mesh.Compute()
71 quadrangles = mesh.GetGroupByName( vlHyp.GetGroupName() )[0]
72 print( "Nb boundary quadrangles", quadrangles.Size() )
74 # viscous layers will be created on 3 edges, as we pass isEdgesToIgnore=False
75 vlHyp.SetEdges( edgeIds, False )
77 if not mesh.Compute(): raise Exception("Error when computing Mesh")