Salome HOME
Mesh redesine. New fields added to specify whether hypothesis is main or additional...
[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 print "Analysis of the geometry to be meshed :"
17 subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"])
18 subFaceList  = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
19 subEdgeList  = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
20
21 print "number of Shells in compshell : ", len(subShellList)
22 print "number of Faces  in compshell : ", len(subFaceList)
23 print "number of Edges  in compshell : ", len(subEdgeList)
24
25 status = geompy.CheckShape(compshell)
26 print " check status ", status
27
28 ### ---------------------------- SMESH --------------------------------------
29 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
30
31 smeshgui = salome.ImportComponentGUI("SMESH")
32 smeshgui.Init(salome.myStudyId)
33
34 print "-------------------------- create Hypothesis"
35
36 print "-------------------------- NumberOfSegments"
37
38 numberOfSegments = 5
39
40 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
41 hypNbSeg.SetNumberOfSegments(numberOfSegments)
42
43 print hypNbSeg.GetName()
44 print hypNbSeg.GetId()
45 print hypNbSeg.GetNumberOfSegments()
46
47 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_5")
48
49 print "-------------------------- create Algorithms"
50
51 print "-------------------------- Regular_1D"
52
53 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
54
55 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
56
57 print "-------------------------- Quadrangle_2D"
58
59 quad2D = smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
60
61 smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D")
62
63 print "-------------------------- Hexa_3D"
64
65 hexa3D = smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
66
67 smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D")
68
69 # ---- init a Mesh with the compshell
70 shape_mesh = salome.IDToObject( idcomp  )
71
72 mesh = smesh.CreateMesh(shape_mesh)
73 smeshgui.SetName(salome.ObjectToID(mesh), "MeshCompShell")
74
75
76 print "-------------------------- add hypothesis to compshell"
77
78 mesh.AddHypothesis(shape_mesh,regular1D)
79 mesh.AddHypothesis(shape_mesh,hypNbSeg)
80
81 mesh.AddHypothesis(shape_mesh,quad2D)
82 mesh.AddHypothesis(shape_mesh,hexa3D)
83
84 salome.sg.updateObjBrowser(1)
85
86 print "-------------------------- compute compshell"
87 ret = smesh.Compute(mesh, shape_mesh)
88 print ret
89 if ret != 0:
90     log = mesh.GetLog(0) # no erase trace
91     for linelog in log:
92         print linelog
93     print "Information about the MeshcompShel:"
94     print "Number of nodes       : ", mesh.NbNodes()
95     print "Number of edges       : ", mesh.NbEdges()
96     print "Number of faces       : ", mesh.NbFaces()
97     print "Number of quadrangles : ", mesh.NbQuadrangles()
98     print "Number of volumes     : ", mesh.NbVolumes()
99     print "Number of hexahedrons : ", mesh.NbHexas()
100 else:
101     print "problem when Computing the mesh"