smesh/doc/examples/defining_hypotheses_ex08.py

64 lines
2.0 KiB
Python
Raw Permalink Normal View History

2013-02-12 20:37:44 +06:00
# Propagation
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
base = geom_builder.MakeSketcher("Sketcher:F 0 0:TT 10 0:TT 20 10:TT 0 10:WF", theName="F")
box = geom_builder.MakePrismDXDYDZ( base, 0,0,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, "Propagation of hypothesis")
2013-02-12 20:37:44 +06:00
# set global algorithms and hypotheses
algo1D = hexa.Segment()
hexa.Quadrangle()
hexa.Hexahedron()
algo1D.NumberOfSegments(4)
2014-01-15 15:41:17 +06:00
# create a sub-mesh with local 1D hypothesis and "Propagation of 1D Hypothesis"
2013-02-12 20:37:44 +06:00
algo_local = hexa.Segment(EdgeX)
# define "Arithmetic1D" hypothesis to cut an edge in several segments with increasing length
algo_local.Arithmetic1D(1, 4)
2014-01-15 15:41:17 +06:00
# define "Propagation" hypothesis that propagates "Arithmetic1D" hypothesis
# from 'EdgeX' on opposite sides of all quadilateral faces
2013-02-12 20:37:44 +06:00
algo_local.Propagation()
2014-01-15 15:41:17 +06:00
# compute the mesh which contains prisms
if not hexa.Compute(): raise Exception("Error when computing Mesh")
2014-01-15 15:41:17 +06:00
# create another mesh on the box
2022-04-11 18:28:01 +05:00
mesh = smesh_builder.Mesh(box, "Propagation of distribution of nodes")
2014-01-15 15:41:17 +06:00
# set global algorithms and hypotheses
algo1D = mesh.Segment()
mesh.Quadrangle()
mesh.Hexahedron()
algo1D.NumberOfSegments(4)
# create a sub-mesh with local 1D hypothesis and "Propagation of Node Distribution"
algo_local = mesh.Segment(EdgeX)
algo_local.Arithmetic1D(1, 4)
# define "Propagation Of Distribution" hypothesis that propagates
# distribution of nodes generated by "Arithmetic1D" hypothesis
# from 'EdgeX' on opposite sides of all quadilateral faces
algo_local.PropagationOfDistribution()
# compute the mesh which contains hexahedra only
if not mesh.Compute(): raise Exception("Error when computing Mesh")