smesh/doc/examples/defining_hypotheses_ex01.py

44 lines
1.4 KiB
Python
Raw Normal View History

# Arithmetic Progression and Geometric Progression
2013-02-12 20:37:44 +06:00
import salome
salome.salome_init_without_session()
2014-01-15 15:41:17 +06: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
# 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
# create a Regular 1D algorithm for edges
algo1D = hexa.Segment()
# optionally reverse node distribution on certain edges
2022-04-11 18:28:01 +05:00
allEdges = geom_builder.SubShapeAllSorted( box, geom_builder.ShapeType["EDGE"])
2013-02-12 20:37:44 +06:00
reversedEdges = [ allEdges[0], allEdges[4] ]
# define "Arithmetic1D" hypothesis to cut all edges in several segments with increasing arithmetic length
algo1D.Arithmetic1D(1, 4, reversedEdges)
2014-01-15 15:41:17 +06:00
# define "Geometric Progression" hypothesis on one edge to cut this edge in segments with length increasing by 20% starting from 1
gpAlgo = hexa.Segment( allEdges[1] )
gpAlgo.GeometricProgression( 1, 1.2 )
# propagate distribution of nodes computed using "Geometric Progression" to parallel edges
gpAlgo.PropagationOfDistribution()
2013-02-12 20:37:44 +06:00
# create a quadrangle 2D algorithm for faces
hexa.Quadrangle()
# create a hexahedron 3D algorithm for solids
hexa.Hexahedron()
# compute the mesh
if not hexa.Compute(): raise Exception("Error when computing Mesh")