1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2022 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 #==============================================================================
26 # Bug (from script, bug) : SMESH_demo_hexa2_upd.py, PAL6781
27 # Modified : 25/11/2004
28 # Author : Kovaltchuk Alexey
29 # Project : PAL/SALOME
30 #==============================================================================
31 # Tetrahedrization of a geometry (box minus a inner cylinder).
32 # Hypothesis and algorithms for the mesh generation are not global:
33 # the mesh of some edges is thinner
38 from salome.geom import geomBuilder
39 geompy = geomBuilder.New()
41 import SMESH, SALOMEDS
42 from salome.smesh import smeshBuilder
43 smesh = smeshBuilder.New()
48 # -----------------------------------------------------------------------------
61 Orig = geompy.MakeVertex(zero,zero,zero)
62 P0 = geompy.MakeVertex(a,a,zero)
63 P1 = geompy.MakeVertex(zero,demi,zero)
64 P2 = geompy.MakeVertex(ma,a,zero)
65 P3 = geompy.MakeVertex(mun,un,zero)
66 P4 = geompy.MakeVertex(un,un,zero)
67 P5 = geompy.MakeVertex(zero,zero,un)
69 arc = geompy.MakeArc(P0,P1,P2)
70 e1 = geompy.MakeEdge(P2,P3)
71 e2 = geompy.MakeEdge(P3,P4)
72 e3 = geompy.MakeEdge(P4,P0)
80 wire = geompy.MakeWire(list)
81 face = geompy.MakeFace(wire,1)
83 dir = geompy.MakeVector(Orig,P5)
84 vol1 = geompy.MakePipe(face,dir)
87 #dir = geom.MakeVector(Orig,P5)
88 vol2 = geompy.MakeRotation(vol1,dir,angle)
90 vol3 = geompy.MakeRotation(vol2,dir,angle)
92 vol4 = geompy.MakeRotation(vol3,dir,angle)
100 volComp = geompy.MakeCompound(list)
103 vol = geompy.MakeGlueFaces(volComp,tol3d)
104 idVol = geompy.addToStudy(vol,"volume")
106 print("Analysis of the final volume:")
107 subShellList = geompy.SubShapeAllSorted(vol,ShapeTypeShell)
108 subFaceList = geompy.SubShapeAllSorted(vol,ShapeTypeFace)
109 subEdgeList = geompy.SubShapeAllSorted(vol,ShapeTypeEdge)
111 print("number of Shells in the volume : ",len(subShellList))
112 print("number of Faces in the volume : ",len(subFaceList))
113 print("number of Edges in the volume : ",len(subEdgeList))
116 for k in range(len(subEdgeList)):
117 idSubEdge.append(geompy.addToStudyInFather(vol,subEdgeList[k],"SubEdge"+str(k)))
120 edgeZ.append(subEdgeList[0])
121 edgeZ.append(subEdgeList[3])
122 edgeZ.append(subEdgeList[10])
123 edgeZ.append(subEdgeList[11])
124 edgeZ.append(subEdgeList[20])
125 edgeZ.append(subEdgeList[21])
126 edgeZ.append(subEdgeList[28])
127 edgeZ.append(subEdgeList[31])
131 idEdgeZ.append(geompy.addToStudyInFather(vol,edgeZ[i],"EdgeZ"+str(i+1)))
133 ### ---------------------------- SMESH --------------------------------------
136 # ---- init a Mesh with the volume
138 mesh = smesh.Mesh(vol, "meshVolume")
140 # ---- set Hypothesis and Algorithm to main shape
142 print("-------------------------- NumberOfSegments the global one")
144 numberOfSegments = 10
146 regular1D = mesh.Segment()
147 regular1D.SetName("Wire Discretisation")
148 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
149 print(hypNbSeg.GetName())
150 print(hypNbSeg.GetId())
151 print(hypNbSeg.GetNumberOfSegments())
152 smesh.SetName(hypNbSeg, "NumberOfSegments")
155 print("-------------------------- Quadrangle_2D")
157 quad2D=mesh.Quadrangle()
158 quad2D.SetName("Quadrangle_2D")
160 print("-------------------------- Hexa_3D")
162 hexa3D=mesh.Hexahedron()
163 hexa3D.SetName("Hexa_3D")
166 print("-------------------------- NumberOfSegments in the Z direction")
168 numberOfSegmentsZ = 40
171 print("-------------------------- add hypothesis to edge in the Z directions", (i+1))
173 algo = mesh.Segment(edgeZ[i])
174 hyp = algo.NumberOfSegments(numberOfSegmentsZ)
175 smesh.SetName(hyp, "NumberOfSegmentsZ")
176 smesh.SetName(algo.GetSubMesh(), "SubMeshEdgeZ_"+str(i+1))
179 salome.sg.updateObjBrowser()
181 print("-------------------------- compute the mesh of the volume")
187 ## log=mesh.GetLog(0) # no erase trace
188 ## for linelog in log:
190 print("Information about the MeshBox :")
191 print("Number of nodes : ", mesh.NbNodes())
192 print("Number of edges : ", mesh.NbEdges())
193 print("Number of faces : ", mesh.NbFaces())
194 print("Number of triangles : ", mesh.NbTriangles())
195 print("Number of volumes : ", mesh.NbVolumes())
196 print("Number of tetrahedrons: ", mesh.NbTetras())
198 print("problem when Computing the mesh")
200 salome.sg.updateObjBrowser()