smesh/doc/examples/defining_hypotheses_ex02.py

47 lines
1.3 KiB
Python
Raw Permalink Normal View History

# Deflection and Number of Segments
2013-02-12 20:37:44 +06:00
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 face from arc and straight segment
2022-04-11 18:28:01 +05:00
px = geom_builder.MakeVertex(100., 0. , 0. )
py = geom_builder.MakeVertex(0. , 100., 0. )
pz = geom_builder.MakeVertex(0. , 0. , 100.)
2013-02-12 20:37:44 +06:00
2022-04-11 18:28:01 +05:00
exy = geom_builder.MakeEdge(px, py)
arc = geom_builder.MakeArc(py, pz, px)
2013-02-12 20:37:44 +06:00
2022-04-11 18:28:01 +05:00
wire = geom_builder.MakeWire([exy, arc])
2013-02-12 20:37:44 +06:00
isPlanarFace = 1
2022-04-11 18:28:01 +05:00
face1 = geom_builder.MakeFace(wire, isPlanarFace)
geom_builder.addToStudy(face1,"Face1")
2013-02-12 20:37:44 +06:00
# get edges from the face
2022-04-11 18:28:01 +05:00
e_straight,e_arc = geom_builder.SubShapeAll(face1, geom_builder.ShapeType["EDGE"])
geom_builder.addToStudyInFather(face1, e_arc, "Arc Edge")
2013-02-12 20:37:44 +06:00
# create hexahedral mesh
2022-04-11 18:28:01 +05:00
hexa = smesh_builder.Mesh(face1, "Face : triangle mesh")
2013-02-12 20:37:44 +06:00
# define "NumberOfSegments" hypothesis to cut a straight edge in a fixed number of segments
algo1D = hexa.Segment()
algo1D.NumberOfSegments(6)
# define "MaxElementArea" hypothesis
algo2D = hexa.Triangle()
algo2D.MaxElementArea(70.0)
# define a local "Deflection1D" hypothesis on the arc
algo_local = hexa.Segment(e_arc)
algo_local.Deflection1D(1.0)
# compute the mesh
if not hexa.Compute(): raise Exception("Error when computing Mesh")