2013-02-12 20:37:44 +06:00
|
|
|
# Viscous layers construction
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import salome
|
2021-08-12 14:38:10 +05:00
|
|
|
salome.salome_init_without_session()
|
2013-04-04 13:08:19 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
import SMESH
|
|
|
|
from salome.geom import geomBuilder
|
2013-04-04 13:08:19 +06:00
|
|
|
from salome.smesh import smeshBuilder
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
geom_builder = geomBuilder.New()
|
|
|
|
smesh_builder = smeshBuilder.New()
|
|
|
|
|
|
|
|
X = geom_builder.MakeVectorDXDYDZ( 1,0,0 )
|
|
|
|
O = geom_builder.MakeVertex( 100,50,50 )
|
|
|
|
plane = geom_builder.MakePlane( O, X, 200 ) # plane YZ
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
box = geom_builder.MakeBoxDXDYDZ(200,100,100)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
shape = geom_builder.MakeHalfPartition( box, plane )
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
faces = geom_builder.SubShapeAllSorted(shape, geom_builder.ShapeType["FACE"])
|
2013-02-12 20:37:44 +06:00
|
|
|
face1 = faces[1]
|
|
|
|
ignoreFaces = [ faces[0], faces[-1]]
|
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
geom_builder.addToStudy( shape, "shape" )
|
|
|
|
geom_builder.addToStudyInFather( shape, face1, "face1")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2013-05-31 17:55:38 +06:00
|
|
|
# 3D Viscous layers
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
mesh = smesh_builder.Mesh(shape, "CFD")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
mesh.Segment().NumberOfSegments( 4 )
|
|
|
|
|
|
|
|
mesh.Triangle()
|
|
|
|
mesh.Quadrangle(face1)
|
|
|
|
algo3D = mesh.Tetrahedron()
|
|
|
|
|
|
|
|
thickness = 20
|
|
|
|
numberOfLayers = 10
|
|
|
|
stretchFactor = 1.5
|
2019-10-25 18:55:08 +05:00
|
|
|
groupName = "Boundary layers"
|
|
|
|
layersHyp = algo3D.ViscousLayers(thickness,numberOfLayers,stretchFactor,
|
|
|
|
ignoreFaces, # optional
|
|
|
|
groupName = groupName) # optional
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2023-02-21 18:59:44 +05:00
|
|
|
if not mesh.Compute(): raise Exception("Error when computing Mesh")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2019-10-25 18:55:08 +05:00
|
|
|
# retrieve boundary prisms created by mesh.Compute()
|
|
|
|
boundaryGroup = mesh.GetGroupByName( layersHyp.GetGroupName() )[0]
|
|
|
|
print( "Nb boundary prisms", boundaryGroup.Size() )
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
mesh.MakeGroup("Tetras",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_TETRA)
|
|
|
|
mesh.MakeGroup("Pyras",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_PYRAMID)
|
|
|
|
mesh.MakeGroup("Prims",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_PENTA)
|
2013-05-31 17:55:38 +06:00
|
|
|
|
|
|
|
# 2D Viscous layers
|
|
|
|
|
|
|
|
# 3 edges of the 4 edges of face1
|
2022-04-11 18:28:01 +05:00
|
|
|
edgeIds = geom_builder.SubShapeAllIDs( face1, geom_builder.ShapeType["EDGE"])[:-1]
|
2013-05-31 17:55:38 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
mesh = smesh_builder.Mesh(face1,"VicsousLayers2D")
|
2013-05-31 17:55:38 +06:00
|
|
|
mesh.Segment().NumberOfSegments( 5 )
|
|
|
|
|
2019-10-25 18:55:08 +05:00
|
|
|
# viscous layers will be created on 1 edge, as we set 3 edges to ignore
|
|
|
|
vlHyp = mesh.Triangle().ViscousLayers2D( 2, 3, 1.5,
|
|
|
|
edgeIds, isEdgesToIgnore=True, # optional
|
|
|
|
groupName=groupName) # optional
|
2023-02-21 18:59:44 +05:00
|
|
|
if not mesh.Compute(): raise Exception("Error when computing Mesh")
|
2013-05-31 17:55:38 +06:00
|
|
|
|
2019-10-25 18:55:08 +05:00
|
|
|
# retrieve boundary elements created by mesh.Compute()
|
|
|
|
quadrangles = mesh.GetGroupByName( vlHyp.GetGroupName() )[0]
|
|
|
|
print( "Nb boundary quadrangles", quadrangles.Size() )
|
|
|
|
|
|
|
|
# viscous layers will be created on 3 edges, as we pass isEdgesToIgnore=False
|
2013-05-31 17:55:38 +06:00
|
|
|
vlHyp.SetEdges( edgeIds, False )
|
|
|
|
|
2023-02-21 18:59:44 +05:00
|
|
|
if not mesh.Compute(): raise Exception("Error when computing Mesh")
|