2016-03-16 21:59:08 +05:00
|
|
|
# Construction of a Sub-mesh
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import salome
|
|
|
|
salome.salome_init()
|
|
|
|
import GEOM
|
|
|
|
from salome.geom import geomBuilder
|
2017-06-13 15:01:10 +05:00
|
|
|
geompy = geomBuilder.New()
|
2013-04-04 13:08:19 +06:00
|
|
|
|
|
|
|
import SMESH, SALOMEDS
|
|
|
|
from salome.smesh import smeshBuilder
|
2017-06-13 15:01:10 +05:00
|
|
|
smesh = smeshBuilder.New()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# create a box
|
2013-04-04 13:08:19 +06:00
|
|
|
box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
|
|
|
|
geompy.addToStudy(box, "Box")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# select one edge of the box for definition of a local hypothesis
|
2013-04-04 13:08:19 +06:00
|
|
|
p5 = geompy.MakeVertex(5., 0., 0.)
|
|
|
|
EdgeX = geompy.GetEdgeNearPoint(box, p5)
|
|
|
|
geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# create a hexahedral mesh on the box
|
2016-03-16 21:59:08 +05:00
|
|
|
mesh = smesh.Mesh(box, "Box : hexahedral 3D mesh")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2016-03-16 21:59:08 +05:00
|
|
|
# create a Regular_1D algorithm for discretization of edges
|
|
|
|
algo1D = mesh.Segment()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# define "NumberOfSegments" hypothesis to cut
|
|
|
|
# all the edges in a fixed number of segments
|
|
|
|
algo1D.NumberOfSegments(4)
|
|
|
|
|
|
|
|
# create a quadrangle 2D algorithm for the faces
|
2016-03-16 21:59:08 +05:00
|
|
|
mesh.Quadrangle()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2016-03-16 21:59:08 +05:00
|
|
|
# construct a sub-mesh on the edge with a local Regular_1D algorithm
|
|
|
|
algo_local = mesh.Segment(EdgeX)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2016-03-16 21:59:08 +05:00
|
|
|
# define "Arithmetic1D" hypothesis to cut EdgeX in several segments with length arithmetically
|
|
|
|
# increasing from 1.0 to 4.0
|
2013-02-12 20:37:44 +06:00
|
|
|
algo_local.Arithmetic1D(1, 4)
|
|
|
|
|
2016-03-16 21:59:08 +05:00
|
|
|
# define "Propagation" hypothesis that propagates algo_local and "Arithmetic1D" hypothesis
|
2016-08-02 00:15:36 +05:00
|
|
|
# from EdgeX to all parallel edges
|
2013-02-12 20:37:44 +06:00
|
|
|
algo_local.Propagation()
|
|
|
|
|
2016-03-16 21:59:08 +05:00
|
|
|
# assign a hexahedral algorithm
|
|
|
|
mesh.Hexahedron()
|
|
|
|
|
2016-08-02 00:15:36 +05:00
|
|
|
|
|
|
|
# any sub-shape can be meshed individually --
|
|
|
|
# compute mesh on two surfaces using different methods
|
|
|
|
|
|
|
|
# get surfaces
|
|
|
|
surfaces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
|
|
|
|
|
|
|
|
# method 1: no sub-mesh is created
|
|
|
|
mesh.Compute( surfaces[0] )
|
|
|
|
|
|
|
|
# method 2: a sub-mesh is created
|
|
|
|
submesh = mesh.GetSubMesh( surfaces[2], "submesh 2" )
|
|
|
|
submesh.Compute()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# compute the whole mesh
|
2016-03-16 21:59:08 +05:00
|
|
|
mesh.Compute()
|