2012-08-09 16:03:55 +06:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2016-03-18 22:10:20 +05:00
|
|
|
# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
2009-02-17 10:27:49 +05:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2006-05-06 14:51:48 +06:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
2014-02-20 18:25:37 +06:00
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
2006-05-06 14:51:48 +06:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
2006-05-06 14:51:48 +06:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2006-05-06 14:51:48 +06:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2006-05-06 14:51:48 +06:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# =======================================
|
2009-02-17 10:27:49 +05:00
|
|
|
#
|
2013-04-04 13:08:19 +06:00
|
|
|
import salome
|
|
|
|
salome.salome_init()
|
|
|
|
import GEOM
|
|
|
|
from salome.geom import geomBuilder
|
|
|
|
geompy = geomBuilder.New(salome.myStudy)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import SMESH, SALOMEDS
|
|
|
|
from salome.smesh import smeshBuilder
|
|
|
|
smesh = smeshBuilder.New(salome.myStudy)
|
2005-03-21 13:38:22 +05:00
|
|
|
|
|
|
|
# Geometry
|
|
|
|
# ========
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# grid compound of 3 x 3 elements
|
|
|
|
# an element is compound of 3 cylinders concentriques
|
|
|
|
# an element is centered in a square of the grid
|
|
|
|
# the smaller cylinder is a hole
|
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# prism the grid, and mesh it in hexahedral way
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# Values
|
|
|
|
# ------
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
g_x = 0
|
|
|
|
g_y = 0
|
|
|
|
g_z = 0
|
|
|
|
|
|
|
|
g_arete = 50
|
|
|
|
g_hauteur = 30
|
|
|
|
|
|
|
|
g_rayon1 = 20
|
|
|
|
g_rayon2 = 30
|
|
|
|
g_rayon3 = 40
|
|
|
|
|
|
|
|
g_grid = 3
|
|
|
|
|
|
|
|
g_trim = 1000
|
|
|
|
|
|
|
|
# Element
|
|
|
|
# -------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
e_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)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
e_hauteur = 2*g_hauteur
|
2013-04-04 13:08:19 +06:00
|
|
|
e_centre = geompy.MakeVertex(g_x, g_y-g_hauteur, g_z)
|
|
|
|
e_dir = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
e_cyl1 = geompy.MakeCylinder(e_centre, e_dir, g_rayon3, e_hauteur)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
e_blo1 = geompy.MakeCut(e_boite, e_cyl1)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
e_cyl2 = geompy.MakeCylinder(e_centre, e_dir, g_rayon2, e_hauteur)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
e_blo2 = geompy.MakeCut(e_cyl1, e_cyl2)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
e_cyl3 = geompy.MakeCylinder(e_centre, e_dir, g_rayon1, e_hauteur)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
e_blo3 = geompy.MakeCut(e_cyl2, e_cyl3)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# Partition and repair
|
|
|
|
# --------------------
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
p_tools = []
|
2013-04-04 13:08:19 +06:00
|
|
|
p_tools.append(geompy.MakePlane(e_centre, geompy.MakeVectorDXDYDZ( 1, 0, 1), g_trim))
|
|
|
|
p_tools.append(geompy.MakePlane(e_centre, geompy.MakeVectorDXDYDZ(-1, 0, 1), g_trim))
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
p_part = geompy.MakePartition([e_blo1, e_blo2, e_blo3], p_tools, [], [], geompy.ShapeType["SOLID"])
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
p_element = geompy.RemoveExtraEdges(p_part, doUnionFaces=True)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# Grid and glue
|
|
|
|
# -------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
grid = geompy.MakeMultiTranslation2D(p_element, geompy.MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, geompy.MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
|
2005-03-21 13:38:22 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
piece = geompy.MakeGlueFaces(grid, 1e-5)
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Add in study
|
|
|
|
# ------------
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
piece_id = geompy.addToStudy(piece, "ex11_grid3partition")
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
# Meshing
|
|
|
|
# =======
|
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# Create a hexahedral mesh
|
|
|
|
# ------------------------
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
hexa = smesh.Mesh(piece, "ex11_grid3partition:hexa")
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
algo = hexa.Segment()
|
|
|
|
algo.NumberOfSegments(3)
|
|
|
|
|
|
|
|
hexa.Quadrangle()
|
|
|
|
|
|
|
|
hexa.Hexahedron()
|
|
|
|
|
|
|
|
# Mesh calculus
|
|
|
|
# -------------
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
hexa.Compute()
|
2015-02-20 12:08:10 +05:00
|
|
|
|
|
|
|
# Update object browser
|
|
|
|
# ---------------------
|
|
|
|
|
|
|
|
salome.sg.updateObjBrowser(1)
|