smesh/doc/examples/modifying_meshes_ex26.py

51 lines
1.3 KiB
Python
Raw Permalink Normal View History

2013-02-12 20:37:44 +06:00
# Convert mesh to/from quadratic
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 sphere of radius 100
2022-04-11 18:28:01 +05:00
Sphere = geom_builder.MakeSphereR( 100 )
geom_builder.addToStudy( Sphere, "Sphere" )
2013-02-12 20:37:44 +06:00
2022-04-15 20:49:22 +05:00
# create simple tetrahedral mesh
2013-02-12 20:37:44 +06:00
2022-04-11 18:28:01 +05:00
Mesh = smesh_builder.Mesh(Sphere)
2022-04-15 20:49:22 +05:00
Mesh.Segment().NumberOfSegments(5)
Mesh.Triangle()
Mesh.Tetrahedron()
2013-02-12 20:37:44 +06:00
# compute mesh
if not Mesh.Compute(): raise Exception("Error when computing Mesh")
2013-02-12 20:37:44 +06:00
# convert to quadratic
# theForce3d = 1; this results in the medium node lying at the
# middle of the line segments connecting start and end node of a mesh
# element
Mesh.ConvertToQuadratic( theForce3d=1 )
# revert back to the non-quadratic mesh
Mesh.ConvertFromQuadratic()
# convert to quadratic
# theForce3d = 0; this results in the medium node lying at the
# geometrical edge from which the mesh element is built
Mesh.ConvertToQuadratic( theForce3d=0 )
# to convert not the whole mesh but a sub-mesh, provide it as
# an additional argument to the functions:
# Mesh.ConvertToQuadratic( 0, subMesh )
# Mesh.ConvertFromQuadratic( subMesh )
#
# Note that the mesh becomes non-conformal at conversion of sub-mesh.