]> SALOME platform Git repositories - modules/smesh.git/blob - doc/salome/examples/creating_meshes_ex03.py
Salome HOME
[bos #23982] EDF 22984 - aspect ratio of hexa
[modules/smesh.git] / doc / salome / examples / creating_meshes_ex03.py
1 # Change priority of sub-meshes in Mesh
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New()
8
9 import SMESH, SALOMEDS
10 from salome.smesh import smeshBuilder
11 smesh =  smeshBuilder.New()
12
13 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
14 [Face_1,Face_2,Face_3,Face_4,Face_5,Face_6] = geompy.SubShapeAllSorted(Box_1, geompy.ShapeType["FACE"])
15
16 # create Mesh object on Box shape
17 Mesh_1 = smesh.Mesh(Box_1)
18
19 # assign mesh algorithms and hypotheses
20 Regular_1D = Mesh_1.Segment()
21 Nb_Segments_1 = Regular_1D.NumberOfSegments(20)
22 MEFISTO_2D = Mesh_1.Triangle()
23 Max_Element_Area_1 = MEFISTO_2D.MaxElementArea(1200)
24 Tetrahedron = Mesh_1.Tetrahedron()
25 Max_Element_Volume_1 = Tetrahedron.MaxElementVolume(40000)
26
27 # create sub-mesh and assign algorithms on Face_1
28 Regular_1D_1 = Mesh_1.Segment(geom=Face_1)
29 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(4)
30 MEFISTO_2D_1 = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO,geom=Face_1)
31 SubMesh_1 = MEFISTO_2D_1.GetSubMesh()
32
33 # create sub-mesh and assign algorithms on Face_2
34 Regular_1D_2 = Mesh_1.Segment(geom=Face_2)
35 Nb_Segments_3 = Regular_1D_2.NumberOfSegments(8)
36 MEFISTO_2D_2 = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO,geom=Face_2)
37 SubMesh_2 = MEFISTO_2D_2.GetSubMesh()
38
39 # create sub-mesh and assign algorithms on Face_3
40 Regular_1D_3 = Mesh_1.Segment(geom=Face_3)
41 Nb_Segments_4 = Regular_1D_3.NumberOfSegments(12)
42 MEFISTO_2D_3 = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO,geom=Face_3)
43 SubMesh_3 = MEFISTO_2D_3.GetSubMesh()
44
45 # check existing sub-mesh priority order
46 [ [ SubMesh_1, SubMesh_3, SubMesh_2 ] ] = Mesh_1.GetMeshOrder()
47 isDone = Mesh_1.Compute()
48 print("Nb elements at initial order of sub-meshes:", Mesh_1.NbElements())
49
50 # set new sub-mesh order
51 isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_1, SubMesh_2, SubMesh_3 ] ])
52 # compute mesh
53 isDone = Mesh_1.Compute()
54 print("Nb elements at new order of sub-meshes:", Mesh_1.NbElements())
55
56 # compute with other sub-mesh order
57 isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_2, SubMesh_1, SubMesh_3 ] ])
58 isDone = Mesh_1.Compute()
59 print("Nb elements at another order of sub-meshes:", Mesh_1.NbElements())