1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # ==================================
39 base = geo.MakeVertex(0, 0, 0)
40 direction = geo.MakeVectorDXDYDZ(0, 0, 1)
42 cylinder = geo.MakeCylinder(base, direction, radius, height)
44 geo.addToStudy(cylinder, "cylinder")
51 box_rot = geo.MakeBox(-size, -size, 0, +size, +size, height)
52 box_axis = geo.MakeLine(base, direction)
53 box = geo.MakeRotation(box_rot, box_axis, math.pi/4)
55 hole = geo.MakeCut(cylinder, box)
59 plane_a = geo.MakePlane(base, geo.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
60 plane_b = geo.MakePlane(base, geo.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
62 blocks_part = geo.MakePartition([hole], [plane_a, plane_b], [], [], geo.ShapeType["SOLID"])
63 blocks_list = [box] + geo.SubShapeAll(blocks_part, geo.ShapeType["SOLID"])
64 blocks_all = geo.MakeCompound(blocks_list)
65 blocks = geo.MakeGlueFaces(blocks_all, 0.0001)
67 geo.addToStudy(blocks, "cylinder:blocks")
69 # Build geometric groups
70 # ----------------------
72 def group(name, shape, type, base=None, direction=None):
73 t = geo.ShapeType[type]
74 g = geo.CreateGroup(shape, t)
76 geo.addToStudy(g, name)
80 l = geo.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, geo.GEOM.ST_ON)
85 group_a = group("baseA", blocks, "FACE", base, direction)
87 base_b = geo.MakeVertex(0, 0, height)
88 group_b = group("baseB", blocks, "FACE", base_b, direction)
90 group_1 = group("limit", blocks, "SOLID")
91 group_1_all = geo.SubShapeAllIDs(blocks, geo.ShapeType["SOLID"])
92 geo.UnionIDs(group_1, group_1_all)
93 group_1_box = geo.GetBlockNearPoint(blocks, base)
94 geo.DifferenceList(group_1, [group_1_box])
96 # Mesh the blocks with hexahedral
97 # -------------------------------
99 smesh.SetCurrentStudy(salome.myStudy)
101 def discretize(x, y, z, n, s=blocks):
102 p = geo.MakeVertex(x, y, z)
103 e = geo.GetEdgeNearPoint(s, p)
105 a.NumberOfSegments(n)
108 hexa = smesh.Mesh(blocks)
110 hexa_1d = hexa.Segment()
111 hexa_1d.NumberOfSegments(1)
113 discretize(+radius , +radius, 0, 5)
114 discretize(-radius , +radius, 0, 8)
115 discretize((radius+size)/2, 0, 0, 10)
116 discretize( +radius, 0, height/2, 20)