smesh/doc/examples/creating_meshes_ex07.py

87 lines
2.7 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Building a compound of meshes
import salome
salome.salome_init_without_session()
2022-04-13 12:01:14 +05:00
from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
2022-04-13 12:01:14 +05:00
geom_builder = geomBuilder.New()
smesh_builder = smeshBuilder.New()
2013-02-12 20:37:44 +06:00
## create a bottom box
2022-04-13 12:01:14 +05:00
Box_inf = geom_builder.MakeBox(0., 0., 0., 200., 200., 50.)
2013-02-12 20:37:44 +06:00
# get a top face
2022-04-13 12:01:14 +05:00
Psup1=geom_builder.MakeVertex(100., 100., 50.)
Fsup1=geom_builder.GetFaceNearPoint(Box_inf, Psup1)
2013-02-12 20:37:44 +06:00
# get a bottom face
2022-04-13 12:01:14 +05:00
Pinf1=geom_builder.MakeVertex(100., 100., 0.)
Finf1=geom_builder.GetFaceNearPoint(Box_inf, Pinf1)
2013-02-12 20:37:44 +06:00
## create a top box
2022-04-13 12:01:14 +05:00
Box_sup = geom_builder.MakeBox(100., 100., 50., 200., 200., 100.)
2013-02-12 20:37:44 +06:00
# get a top face
2022-04-13 12:01:14 +05:00
Psup2=geom_builder.MakeVertex(150., 150., 100.)
Fsup2=geom_builder.GetFaceNearPoint(Box_sup, Psup2)
2013-02-12 20:37:44 +06:00
# get a bottom face
2022-04-13 12:01:14 +05:00
Pinf2=geom_builder.MakeVertex(150., 150., 50.)
Finf2=geom_builder.GetFaceNearPoint(Box_sup, Pinf2)
2013-02-12 20:37:44 +06:00
## Publish in the study
2022-04-13 12:01:14 +05:00
geom_builder.addToStudy(Box_inf, "Box_inf")
geom_builder.addToStudyInFather(Box_inf, Fsup1, "Fsup")
geom_builder.addToStudyInFather(Box_inf, Finf1, "Finf")
2013-02-12 20:37:44 +06:00
2022-04-13 12:01:14 +05:00
geom_builder.addToStudy(Box_sup, "Box_sup")
geom_builder.addToStudyInFather(Box_sup, Fsup2, "Fsup")
geom_builder.addToStudyInFather(Box_sup, Finf2, "Finf")
2013-02-12 20:37:44 +06:00
2022-04-13 12:01:14 +05:00
smesh_builder.UpdateStudy()
2013-02-12 20:37:44 +06:00
## create a bottom mesh
2022-04-13 12:01:14 +05:00
Mesh_inf = smesh_builder.Mesh(Box_inf, "Mesh_inf")
2013-02-12 20:37:44 +06:00
algo1D_1=Mesh_inf.Segment()
algo1D_1.NumberOfSegments(10)
algo2D_1=Mesh_inf.Quadrangle()
algo3D_1=Mesh_inf.Hexahedron()
Mesh_inf.Compute()
# create a group on the top face
Gsup1=Mesh_inf.Group(Fsup1, "Sup")
# create a group on the bottom face
Ginf1=Mesh_inf.Group(Finf1, "Inf")
## create a top mesh
2022-04-13 12:01:14 +05:00
Mesh_sup = smesh_builder.Mesh(Box_sup, "Mesh_sup")
2013-02-12 20:37:44 +06:00
algo1D_2=Mesh_sup.Segment()
algo1D_2.NumberOfSegments(5)
algo2D_2=Mesh_sup.Quadrangle()
algo3D_2=Mesh_sup.Hexahedron()
Mesh_sup.Compute()
# create a group on the top face
Gsup2=Mesh_sup.Group(Fsup2, "Sup")
# create a group on the bottom face
Ginf2=Mesh_sup.Group(Finf2, "Inf")
## create compounds
# create a compound of two meshes with renaming namesake groups and
# merging elements with the given tolerance
2022-04-13 12:01:14 +05:00
Compound1 = smesh_builder.Concatenate([Mesh_inf, Mesh_sup], 0, 1, 1e-05,
name='Compound with RenamedGrps and MergeElems')
# create a compound of two meshes with uniting namesake groups and
2013-02-12 20:37:44 +06:00
# creating groups of all elements
2022-04-13 12:01:14 +05:00
Compound2 = smesh_builder.Concatenate([Mesh_inf, Mesh_sup], 1, 0, 1e-05, True,
name='Compound with UniteGrps and GrpsOfAllElems')
# copy Gsup1 into a separate mesh and translate it
groupMesh = Mesh_inf.TranslateObjectMakeMesh( Gsup1, [300,0,0] )
# add Ginf2 to groupMesh
2022-04-13 12:01:14 +05:00
smesh_builder.Concatenate([Ginf2], False, meshToAppendTo = groupMesh )
if salome.sg.hasDesktop():
2017-06-13 15:01:10 +05:00
salome.sg.updateObjBrowser()