1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2024 CEA, EDF, 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 # =======================================
29 from salome.geom import geomBuilder
30 geompy = geomBuilder.New()
32 import SMESH, SALOMEDS
33 from salome.smesh import smeshBuilder
34 smesh = smeshBuilder.New()
42 # grid compound of 3 x 3 elements
43 # an element is compound of 3 concentric cylinders
44 # an element is centered in a square of the grid
46 # prism the grid, and mesh it in hexahedral way
66 # Solids and rotation to prevent repair
67 # -------------------------------------
69 s_boite = geompy.MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete)
72 s_hauteur = 2*g_hauteur
73 s_centre = geompy.MakeVertex(g_x, g_y-g_hauteur, g_z)
74 s_dir = geompy.MakeVectorDXDYDZ(0, 1, 0)
76 s_cyl0 = geompy.MakeCylinder(s_centre, s_dir, g_rayon3, s_hauteur)
77 s_cyl1 = geompy.MakeRotation(s_cyl0, s_dir, s_pi4)
79 s_blo1 = geompy.MakeCut(s_boite, s_cyl1)
81 s_cyl0 = geompy.MakeCylinder(s_centre, s_dir, g_rayon2, s_hauteur)
82 s_cyl2 = geompy.MakeRotation(s_cyl0, s_dir, s_pi4)
84 s_blo2 = geompy.MakeCut(s_cyl1, s_cyl2)
86 s_cyl0 = geompy.MakeCylinder(s_centre, s_dir, g_rayon1, s_hauteur)
87 s_cyl3 = geompy.MakeRotation(s_cyl0, s_dir, s_pi4)
89 s_blo3 = geompy.MakeCut(s_cyl2, s_cyl3)
93 s_blo4 = geompy.MakeBox(g_x-s_arete, g_y-g_hauteur, g_z-s_arete, g_x+s_arete, g_y+g_hauteur, g_z+s_arete)
95 s_blo5 = geompy.MakeCut(s_cyl3, s_blo4)
101 p_tools.append(geompy.MakePlane(s_centre, geompy.MakeVectorDXDYDZ( 1, 0, 1), g_trim))
102 p_tools.append(geompy.MakePlane(s_centre, geompy.MakeVectorDXDYDZ(-1, 0, 1), g_trim))
104 p_partie = geompy.MakePartition([s_blo1, s_blo2, s_blo3, s_blo5], p_tools, [], [], geompy.ShapeType["SOLID"])
109 c_blocs = geompy.SubShapeAll(p_partie, geompy.ShapeType["SOLID"])
110 c_blocs.append(s_blo4)
112 c_cpd = geompy.MakeCompound(c_blocs)
114 c_element = geompy.MakeGlueFaces(c_cpd, 1e-4)
119 piece = geompy.MakeMultiTranslation2D(c_element, geompy.MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, geompy.MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
124 piece_id = geompy.addToStudy(piece, "ex12_grid17partition")
131 # Create a hexahedral mesh
132 # ------------------------
134 hexa = smesh.Mesh(piece, "ex12_grid17partition:hexa")
136 algo = hexa.Segment()
137 algo.NumberOfSegments(2)
146 isDone = hexa.Compute()
148 raise Exception("Error when computing Mesh")
152 print ("time geom",t2-t1)
153 print ("time mesh",t3-t2 )
155 # Update object browser
156 # ---------------------
158 salome.sg.updateObjBrowser()