smesh/doc/examples/defining_hypotheses_ex04.py

44 lines
1.2 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Local Length
import salome
salome.salome_init_without_session()
2022-04-11 18:28:01 +05:00
from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
2022-04-11 18:28:01 +05:00
geom_builder = geomBuilder.New()
smesh_builder = smeshBuilder.New()
2013-02-12 20:37:44 +06:00
# create a box
2022-04-11 18:28:01 +05:00
box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.)
geom_builder.addToStudy(box, "Box")
2013-02-12 20:37:44 +06:00
# get one edge of the box to put local hypothesis on
2022-04-11 18:28:01 +05:00
p5 = geom_builder.MakeVertex(5., 0., 0.)
EdgeX = geom_builder.GetEdgeNearPoint(box, p5)
geom_builder.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
2022-04-11 18:28:01 +05:00
hexa = smesh_builder.Mesh(box, "Box : hexahedrical mesh")
2013-02-12 20:37:44 +06:00
# set algorithms
algo1D = hexa.Segment()
hexa.Quadrangle()
hexa.Hexahedron()
# define "NumberOfSegments" hypothesis to cut all edges in a fixed number of segments
algo1D.NumberOfSegments(4)
# create a sub-mesh
algo_local = hexa.Segment(EdgeX)
# define "LocalLength" hypothesis to cut an edge in several segments with the same length
algo_local.LocalLength(2.)
# define "Propagation" hypothesis that propagates all other hypothesis
# on all edges on the opposite side in case of quadrangular faces
algo_local.Propagation()
# compute the mesh
if not hexa.Compute(): raise Exception("Error when computing Mesh")