smesh/doc/examples/creating_meshes_ex03.py

52 lines
1.8 KiB
Python
Raw Normal View History

# Change priority of sub-meshes in Mesh
2013-02-12 20:37:44 +06:00
import salome
salome.salome_init_without_session()
2022-04-11 18:28:01 +05:00
from salome.geom import geomBuilder
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()
2022-04-15 20:49:22 +05:00
box = geom_builder.MakeBoxDXDYDZ(200, 200, 200)
[Face_1, Face_2, Face_3, Face_4, Face_5, Face_6] = geom_builder.SubShapeAllSorted(box, geom_builder.ShapeType["FACE"])
2013-02-12 20:37:44 +06:00
# create Mesh object on Box shape
2022-04-15 20:49:22 +05:00
mesh = smesh_builder.Mesh(box)
2013-02-12 20:37:44 +06:00
# assign mesh algorithms and hypotheses
2022-04-15 20:49:22 +05:00
mesh.Segment().NumberOfSegments(20)
mesh.Triangle().MaxElementArea(1200)
mesh.Tetrahedron().MaxElementVolume(40000)
2013-02-12 20:37:44 +06:00
# create sub-mesh and assign algorithms on Face_1
2022-04-15 20:49:22 +05:00
mesh.Segment(geom=Face_1).NumberOfSegments(4)
mesh.Triangle(geom=Face_1)
2013-02-12 20:37:44 +06:00
# create sub-mesh and assign algorithms on Face_2
2022-04-15 20:49:22 +05:00
mesh.Segment(geom=Face_2).NumberOfSegments(8)
mesh.Triangle(geom=Face_2)
2013-02-12 20:37:44 +06:00
# create sub-mesh and assign algorithms on Face_3
2022-04-15 20:49:22 +05:00
mesh.Segment(geom=Face_3).NumberOfSegments(12)
mesh.Triangle(geom=Face_3)
# get existing sub-mesh priority order: F1 -> F2 -> F3
[[SubMesh_F1, SubMesh_F3, SubMesh_F2]] = mesh.GetMeshOrder()
isDone = mesh.Compute()
if not isDone: raise Exception("Error when computing Mesh")
2022-04-15 20:49:22 +05:00
print("Nb elements at initial order of sub-meshes:", mesh.NbElements())
# set new sub-mesh order: F2 -> F1 -> F3
isDone = mesh.SetMeshOrder([[SubMesh_F2, SubMesh_F1, SubMesh_F3]])
isDone = mesh.Compute()
if not isDone: raise Exception("Error when computing Mesh")
2022-04-15 20:49:22 +05:00
print("Nb elements at new order of sub-meshes:", mesh.NbElements())
# compute with other sub-mesh order: F3 -> F2 -> F1
isDone = mesh.SetMeshOrder([[SubMesh_F3, SubMesh_F2, SubMesh_F1]])
isDone = mesh.Compute()
if not isDone: raise Exception("Error when computing Mesh")
2022-04-15 20:49:22 +05:00
print("Nb elements at another order of sub-meshes:", mesh.NbElements())