2016-03-16 21:59:08 +05:00
|
|
|
# Change priority of sub-meshes in Mesh
|
2013-02-12 20:37:44 +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
|
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
|
|
|
|
2016-03-16 21:59:08 +05: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
|
|
|
|
2016-03-16 21:59:08 +05: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
|
|
|
|
2016-03-16 21:59:08 +05: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
|
|
|
|
2016-03-16 21:59:08 +05: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()
|
2023-02-21 18:59:44 +05:00
|
|
|
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()
|
2023-02-21 18:59:44 +05:00
|
|
|
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()
|
2023-02-21 18:59:44 +05:00
|
|
|
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())
|