1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # Tetrahedrization of the geometry generated by the Python script
26 # Hypothesis and algorithms for the mesh generation are global
31 import SMESH, SALOMEDS
32 from salome.smesh import smeshBuilder
33 smesh = smeshBuilder.New()
35 compshell = SMESH_fixation.compshell
36 idcomp = SMESH_fixation.idcomp
37 geompy = SMESH_fixation.geompy
38 salome = SMESH_fixation.salome
40 print("Analysis of the geometry to be meshed :")
41 subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"])
42 subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
43 subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
45 print("number of Shells in compshell : ", len(subShellList))
46 print("number of Faces in compshell : ", len(subFaceList))
47 print("number of Edges in compshell : ", len(subEdgeList))
49 status = geompy.CheckShape(compshell)
50 print(" check status ", status)
52 ### ---------------------------- SMESH --------------------------------------
55 # ---- init a Mesh with the compshell
57 mesh = smesh.Mesh(compshell, "MeshcompShell")
60 # ---- set Hypothesis and Algorithm
62 print("-------------------------- NumberOfSegments")
66 regular1D = mesh.Segment()
67 regular1D.SetName("Wire Discretisation")
68 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
69 print(hypNbSeg.GetName())
70 print(hypNbSeg.GetId())
71 print(hypNbSeg.GetNumberOfSegments())
72 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
74 ## print "-------------------------- MaxElementArea"
76 ## maxElementArea = 80
78 ## mefisto2D = mesh.Triangle()
79 ## mefisto2D.SetName("MEFISTO_2D")
80 ## hypArea = mefisto2D.MaxElementArea(maxElementArea)
81 ## print hypArea.GetName()
82 ## print hypArea.GetId()
83 ## print hypArea.GetMaxElementArea()
84 ## smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
86 print("-------------------------- LengthFromEdges")
88 mefisto2D = mesh.Triangle()
89 mefisto2D.SetName("MEFISTO_2D")
90 hypLengthFromEdges = mefisto2D.LengthFromEdges()
91 print(hypLengthFromEdges.GetName())
92 print(hypLengthFromEdges.GetId())
93 smesh.SetName(hypLengthFromEdges, "LengthFromEdges")
96 print("-------------------------- MaxElementVolume")
98 maxElementVolume = 1000
100 netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN)
101 netgen3D.SetName("NETGEN_3D")
102 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
103 print(hypVolume.GetName())
104 print(hypVolume.GetId())
105 print(hypVolume.GetMaxElementVolume())
106 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
108 print("-------------------------- compute compshell")
109 ret = mesh.Compute(mesh)
112 log = mesh.GetLog(0) # no erase trace
115 print("Information about the MeshcompShel:")
116 print("Number of nodes : ", mesh.NbNodes())
117 print("Number of edges : ", mesh.NbEdges())
118 print("Number of faces : ", mesh.NbFaces())
119 print("Number of triangles : ", mesh.NbTriangles())
120 print("Number of volumes : ", mesh.NbVolumes())
121 print("Number of tetrahedrons : ", mesh.NbTetras())
124 print("problem when computing the mesh")
126 salome.sg.updateObjBrowser()