Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/smesh.git] / src / SMESH_SWIG / SMESH_fixation_hexa.py
1 #
2 # Hexahedrization of the geometry generated by the Python script
3 # SMESH_fixation.py
4 # Hypothesis and algorithms for the mesh generation are global
5 #
6
7 import SMESH_fixation
8
9 import StdMeshers
10
11 compshell = SMESH_fixation.compshell
12 idcomp = SMESH_fixation.idcomp
13 geompy = SMESH_fixation.geompy
14 salome = SMESH_fixation.salome
15
16 ShapeTypeShell     = 3
17 ShapeTypeFace      = 4
18 ShapeTypeEdge      = 6
19
20 print "Analysis of the geometry to be meshed :"
21 subShellList=geompy.SubShapeAll(compshell,ShapeTypeShell)
22 subFaceList=geompy.SubShapeAll(compshell,ShapeTypeFace)
23 subEdgeList=geompy.SubShapeAll(compshell,ShapeTypeEdge)
24
25 print "number of Shells in compshell : ",len(subShellList)
26 print "number of Faces in compshell : ",len(subFaceList)
27 print "number of Edges in compshell : ",len(subEdgeList)
28
29 status=geompy.CheckShape(compshell)
30 print " check status ", status
31
32 ### ---------------------------- SMESH --------------------------------------
33 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
34
35 smeshgui = salome.ImportComponentGUI("SMESH")
36 smeshgui.Init(salome.myStudyId)
37
38 ### ---- create Hypothesis
39
40 print "-------------------------- create Hypothesis"
41
42 print "-------------------------- NumberOfSegments"
43
44 numberOfSegments = 5
45
46 hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
47 hypNbSeg.SetNumberOfSegments(numberOfSegments)
48
49 print hypNbSeg.GetName()
50 print hypNbSeg.GetId()
51 print hypNbSeg.GetNumberOfSegments()
52
53 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_5")
54
55 # ---- create Algorithms
56
57 print "-------------------------- create Algorithms"
58
59 print "-------------------------- Regular_1D"
60
61 regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
62
63 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
64
65 print "-------------------------- Quadrangle_2D"
66
67 quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
68
69 smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D")
70
71 print "-------------------------- Hexa_3D"
72
73 hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
74
75 smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D")
76
77 # ---- init a Mesh with the compshell
78 shape_mesh = salome.IDToObject( idcomp  )
79
80 mesh=smesh.CreateMesh(shape_mesh)
81 smeshgui.SetName(salome.ObjectToID(mesh), "MeshCompShell")
82
83
84 # ---- add hypothesis to compshell
85
86 print "-------------------------- add hypothesis to compshell"
87
88 mesh.AddHypothesis(shape_mesh,regular1D)
89 mesh.AddHypothesis(shape_mesh,hypNbSeg)
90
91 mesh.AddHypothesis(shape_mesh,quad2D)
92 mesh.AddHypothesis(shape_mesh,hexa3D)
93
94 salome.sg.updateObjBrowser(1)
95
96 print "-------------------------- compute compshell"
97 ret=smesh.Compute(mesh, shape_mesh)
98 print ret
99 if ret != 0:
100     log=mesh.GetLog(0) # no erase trace
101     for linelog in log:
102         print linelog
103     print "Information about the MeshcompShel:"
104     print "Number of nodes       : ", mesh.NbNodes()
105     print "Number of edges       : ", mesh.NbEdges()
106     print "Number of faces       : ", mesh.NbFaces()
107     print "Number of quadrangles : ", mesh.NbQuadrangles()
108     print "Number of volumes     : ", mesh.NbVolumes()
109     print "Number of hexahedrons : ", mesh.NbHexas()
110 else:
111     print "problem when Computing the mesh"