2013-02-12 20:37:44 +06:00
|
|
|
# Editing of a mesh
|
|
|
|
|
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
|
|
|
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
|
|
|
|
|
|
|
def PrintMeshInfo(theMesh):
|
|
|
|
aMesh = theMesh.GetMesh()
|
2017-03-20 17:27:30 +05:00
|
|
|
print("Information about mesh:")
|
|
|
|
print("Number of nodes : ", aMesh.NbNodes())
|
|
|
|
print("Number of edges : ", aMesh.NbEdges())
|
|
|
|
print("Number of faces : ", aMesh.NbFaces())
|
|
|
|
print("Number of volumes : ", aMesh.NbVolumes())
|
2013-02-12 20:37:44 +06:00
|
|
|
pass
|
|
|
|
|
|
|
|
# create a box
|
2022-04-11 18:28:01 +05:00
|
|
|
box = geom_builder.MakeBox(0., 0., 0., 20., 20., 20.)
|
|
|
|
geom_builder.addToStudy(box, "box")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# select one edge of the box for definition of a local hypothesis
|
2022-04-11 18:28:01 +05:00
|
|
|
subShapeList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["EDGE"])
|
2013-02-12 20:37:44 +06:00
|
|
|
edge = subShapeList[0]
|
2022-04-11 18:28:01 +05:00
|
|
|
name = geom_builder.SubShapeName(edge, box)
|
|
|
|
geom_builder.addToStudyInFather(box, edge, name)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# create a mesh
|
2022-04-11 18:28:01 +05:00
|
|
|
tria = smesh_builder.Mesh(box, "Mesh 2D")
|
2013-02-12 20:37:44 +06:00
|
|
|
algo1D = tria.Segment()
|
|
|
|
hyp1 = algo1D.NumberOfSegments(3)
|
|
|
|
algo2D = tria.Triangle()
|
|
|
|
hyp2 = algo2D.MaxElementArea(10.)
|
|
|
|
|
|
|
|
# create a sub-mesh
|
|
|
|
algo_local = tria.Segment(edge)
|
|
|
|
hyp3 = algo_local.Arithmetic1D(1, 6)
|
|
|
|
hyp4 = algo_local.Propagation()
|
|
|
|
|
|
|
|
# compute the mesh
|
|
|
|
tria.Compute()
|
|
|
|
PrintMeshInfo(tria)
|
|
|
|
|
|
|
|
# remove a local hypothesis
|
2016-03-17 17:30:10 +05:00
|
|
|
tria.RemoveHypothesis(hyp4, edge)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# compute the mesh
|
|
|
|
tria.Compute()
|
|
|
|
PrintMeshInfo(tria)
|
|
|
|
|
|
|
|
# change the value of the 2D hypothesis
|
|
|
|
hyp2.SetMaxElementArea(2.)
|
|
|
|
|
|
|
|
# compute the mesh
|
|
|
|
tria.Compute()
|
|
|
|
PrintMeshInfo(tria)
|