2013-02-12 20:37:44 +06:00
|
|
|
# Convert mesh to/from quadratic
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import salome
|
2021-08-12 14:38:10 +05:00
|
|
|
salome.salome_init_without_session()
|
2013-04-04 13:08:19 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
from salome.geom import geomBuilder
|
2013-04-04 13:08:19 +06:00
|
|
|
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
|
|
|
|
|
2023-02-21 18:59:44 +05:00
|
|
|
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.
|