2013-02-12 20:37:44 +06:00
|
|
|
# Sew Side Elements
|
|
|
|
|
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
|
2022-04-11 18:28:01 +05:00
|
|
|
|
|
|
|
geom_builder = geomBuilder.New()
|
|
|
|
smesh_builder = smeshBuilder.New()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# create two boxes
|
2022-04-11 18:28:01 +05:00
|
|
|
box1 = geom_builder.MakeBox(0., 0., 0., 10., 10., 10.)
|
|
|
|
box2 = geom_builder.MakeBox(0., 15., 0., 20., 25., 10.)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
EdgesList = geom_builder.SubShapeAll(box2, geom_builder.ShapeType["EDGE"])
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
aComp = geom_builder.MakeCompound([box1, box2])
|
|
|
|
geom_builder.addToStudy(aComp, "Two boxes")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# create a mesh on two boxes
|
2022-04-11 18:28:01 +05:00
|
|
|
mesh = smesh_builder.Mesh(aComp, "Sew Side Elements")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
algo1D = mesh.Segment()
|
|
|
|
algo1D.NumberOfSegments(2)
|
|
|
|
algo2D = mesh.Quadrangle()
|
|
|
|
|
|
|
|
algo_local = mesh.Segment(EdgesList[8])
|
|
|
|
algo_local.NumberOfSegments(4)
|
|
|
|
algo_local.Propagation()
|
|
|
|
|
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
|
|
|
|
|
|
|
# sew side elements
|
2015-07-16 22:52:26 +05:00
|
|
|
|
|
|
|
# find elements to sew
|
2022-04-11 18:28:01 +05:00
|
|
|
face1 = geom_builder.GetFaceNearPoint( aComp, geom_builder.MakeVertex( 5, 10, 5 ))
|
2015-07-16 22:52:26 +05:00
|
|
|
IDsOfSide1Elements = mesh.GetSubMeshElementsId( face1 )
|
2017-03-20 17:27:30 +05:00
|
|
|
print("side faces 1:",IDsOfSide1Elements)
|
2015-07-16 22:52:26 +05:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
face1Translated = geom_builder.MakeTranslation( face1, 0,5,0 )
|
|
|
|
faceFilter = smesh_builder.GetFilter( SMESH.FACE, SMESH.FT_BelongToGeom,'=', face1Translated )
|
2015-07-16 22:52:26 +05:00
|
|
|
IDsOfSide2Elements = mesh.GetIdsFromFilter( faceFilter )
|
2017-03-20 17:27:30 +05:00
|
|
|
print("side faces 2:",IDsOfSide2Elements)
|
2015-07-16 22:52:26 +05:00
|
|
|
|
|
|
|
# find corresponding nodes on sides
|
2022-04-11 18:28:01 +05:00
|
|
|
edge1 = geom_builder.GetEdgeNearPoint( aComp, geom_builder.MakeVertex( 0, 10, 5 ))
|
2015-07-16 22:52:26 +05:00
|
|
|
segs1 = mesh.GetSubMeshElementsId( edge1 ) # mesh segments generated on edge1
|
|
|
|
NodeID1OfSide1ToMerge = mesh.GetElemNode( segs1[0], 0 )
|
|
|
|
NodeID2OfSide1ToMerge = mesh.GetElemNode( segs1[0], 1 )
|
2017-03-20 17:27:30 +05:00
|
|
|
print("nodes of side1:", [NodeID1OfSide1ToMerge,NodeID2OfSide1ToMerge])
|
2015-07-16 22:52:26 +05:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
edge2 = geom_builder.GetEdgeNearPoint( aComp, geom_builder.MakeVertex( 0, 15, 5 ))
|
2015-07-16 22:52:26 +05:00
|
|
|
segs2 = mesh.GetSubMeshElementsId( edge2 ) # mesh segments generated on edge2
|
|
|
|
NodeID1OfSide2ToMerge = mesh.GetElemNode( segs2[0], 0 )
|
|
|
|
NodeID2OfSide2ToMerge = mesh.GetElemNode( segs2[0], 1 )
|
2017-03-20 17:27:30 +05:00
|
|
|
print("nodes of side2:", [NodeID1OfSide2ToMerge,NodeID2OfSide2ToMerge])
|
2015-07-16 22:52:26 +05:00
|
|
|
|
|
|
|
res = mesh.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
|
|
|
|
NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
|
|
|
|
NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
|
2017-03-20 17:27:30 +05:00
|
|
|
print(res)
|