The class of algorithm has methods to set up meshing parameters.
Below you can see examples of usage of this class for tetrahedral mesh generation.
35 from salome.geom
import geomBuilder
36 geompy = geomBuilder.New(salome.myStudy)
39 from salome.smesh
import smeshBuilder
40 smesh = smeshBuilder.New(salome.myStudy)
43 box = geompy.MakeBoxDXDYDZ(200., 200., 200.)
44 geompy.addToStudy(box,
"box")
46 mgtetraMesh = smesh.Mesh(box,
"box: MG-Tetra and MG-CADSurf mesh")
48 mgtetraMesh.Triangle(algo=smeshBuilder.MG_CADSurf)
53 mgtetraMesh_wo_geometry = smesh.CopyMesh( mgtetraMesh,
'MG-Tetra w/o geometry', 0, 0)
56 MG_Tetra = mgtetraMesh.Tetrahedron( smeshBuilder.MG_Tetra )
57 MG_Tetra_Parameters = MG_Tetra.Parameters()
59 MG_Tetra_Parameters.SetEnforcedVertex( 50, 50, 100, 2)
68 MG_Tetra_Parameters_wo_geometry = smesh.CreateHypothesis(
'MG-Tetra Parameters',
'GHS3DEngine')
69 mgtetraMesh_wo_geometry.AddHypothesis( MG_Tetra )
70 mgtetraMesh_wo_geometry.AddHypothesis( MG_Tetra_Parameters_wo_geometry )
73 p1 = geompy.MakeVertex(150, 150, 100)
74 geompy.addToStudy(p1,
"p1")
75 MG_Tetra_Parameters_wo_geometry.SetEnforcedVertexGeomWithGroup( p1, 5 ,
"My special nodes")
79 mgtetraMesh_wo_geometry.Compute()
82 MG_Tetra_Parameters.ClearEnforcedVertices()
33 from salome.geom
import geomBuilder
34 geompy = geomBuilder.New(salome.myStudy)
36 import SMESH, SALOMEDS
37 from salome.smesh
import smeshBuilder
38 smesh = smeshBuilder.New(salome.myStudy)
40 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
41 geompy.addToStudy( box,
"box" )
42 cylindre = geompy.MakeCylinderRH(50, 50)
43 geompy.TranslateDXDYDZ(cylindre, 100, 100, 30)
44 face_cyl = geompy.ExtractShapes(cylindre, geompy.ShapeType[
"FACE"],
True)[1]
45 geompy.addToStudy( cylindre,
'cylindre' )
46 geompy.addToStudyInFather( cylindre, face_cyl,
'face_cyl' )
47 p1 = geompy.MakeVertex(20, 20, 20)
48 p2 = geompy.MakeVertex(180, 180, 20)
49 c = geompy.MakeCompound([p1,p2])
50 geompy.addToStudy( p1,
"p1" )
51 geompy.addToStudy( p2,
"p2" )
52 geompy.addToStudy( c,
"c" )
55 MG_CADSurf = smesh.CreateHypothesis(
'MG-CADSurf',
'BLSURFEngine')
57 MG_CADSurf_Parameters = smesh.CreateHypothesis(
'MG-CADSurf Parameters',
'BLSURFEngine')
58 MG_CADSurf_Parameters.SetPhysicalMesh( 1 )
59 MG_CADSurf_Parameters.SetPhySize( 200 )
61 MG_CADSurf_Parameters2 = smesh.CreateHypothesis(
'MG-CADSurf Parameters',
'BLSURFEngine')
62 MG_CADSurf_Parameters2.SetGeometricMesh( 1 )
65 MG_Tetra = smesh.CreateHypothesis(
'MG-Tetra',
'GHS3DEngine')
66 MG_Tetra_Parameters_node = smesh.CreateHypothesis(
'MG-Tetra Parameters',
'GHS3DEngine')
68 MG_Tetra_Parameters_edge = smesh.CreateHypothesis(
'MG-Tetra Parameters',
'GHS3DEngine')
70 MG_Tetra_Parameters_face = smesh.CreateHypothesis(
'MG-Tetra Parameters',
'GHS3DEngine')
71 MG_Tetra_Parameters_face.SetToMeshHoles( 1 )
72 MG_Tetra_Parameters_mesh = smesh.CreateHypothesis(
'MG-Tetra Parameters',
'GHS3DEngine')
73 MG_Tetra_Parameters_mesh.SetToMeshHoles( 1 )
76 Mesh_cylindre = smesh.Mesh(cylindre)
77 smesh.SetName(Mesh_cylindre,
"Mesh_cylindre")
78 Mesh_cylindre.AddHypothesis( MG_CADSurf )
79 Mesh_cylindre.AddHypothesis( MG_CADSurf_Parameters2 )
81 face_cyl_faces = Mesh_cylindre.GroupOnGeom(face_cyl,
'group_face_cyl', SMESH.FACE)
82 face_cyl_edges = Mesh_cylindre.GroupOnGeom(face_cyl,
'group_edge_cyl', SMESH.EDGE)
83 face_cyl_nodes = Mesh_cylindre.GroupOnGeom(face_cyl,
'group_node_cyl', SMESH.NODE)
84 Mesh_cylindre.Compute()
87 Mesh_box_tri = smesh.Mesh(box,
"Mesh_box_tri")
88 Mesh_box_tri.AddHypothesis( MG_CADSurf )
89 Mesh_box_tri.AddHypothesis( MG_CADSurf_Parameters )
90 Mesh_box_tri.Compute()
96 mesh_mesh = smesh.CopyMesh( Mesh_box_tri,
'Enforced by faces of mesh', 0, 0)
97 mesh_mesh.AddHypothesis( MG_Tetra )
98 mesh_mesh.AddHypothesis( MG_Tetra_Parameters_mesh)
100 mesh_node = smesh.CopyMesh( Mesh_box_tri,
'Enforced by group of nodes', 0, 0)
101 mesh_node.AddHypothesis( MG_Tetra )
102 mesh_node.AddHypothesis( MG_Tetra_Parameters_node)
104 mesh_edge = smesh.CopyMesh( Mesh_box_tri,
'Enforced by group of edges', 0, 0)
105 mesh_edge.AddHypothesis( MG_Tetra )
106 mesh_edge.AddHypothesis( MG_Tetra_Parameters_edge)
108 mesh_face = smesh.CopyMesh( Mesh_box_tri,
'Enforced by group of faces', 0, 0)
109 mesh_face.AddHypothesis( MG_Tetra )
110 mesh_face.AddHypothesis( MG_Tetra_Parameters_face)
113 MG_Tetra_Parameters_mesh.SetEnforcedMeshWithGroup(Mesh_cylindre.GetMesh(),SMESH.FACE,
"faces from cylinder")
114 MG_Tetra_Parameters_node.SetEnforcedMeshWithGroup(face_cyl_nodes,SMESH.NODE,
"nodes from face_cyl_nodes")
115 MG_Tetra_Parameters_edge.SetEnforcedMeshWithGroup(face_cyl_edges,SMESH.EDGE,
"edges from face_cyl_edges")
116 MG_Tetra_Parameters_face.SetEnforcedMeshWithGroup(face_cyl_faces,SMESH.FACE,
"faces from face_cyl_faces")
23 from salome.geom
import geomBuilder
24 geompy = geomBuilder.New(salome.myStudy)
26 from salome.smesh
import smeshBuilder
27 smesh = smeshBuilder.New(salome.myStudy)
30 disk = geompy.MakeDiskR(100., 1, theName=
"disk")
33 mesh = smesh.Mesh( disk )
34 cadsurf = mesh.Triangle( smeshBuilder.MG_CADSurf )
35 cadsurf.SetQuadAllowed(
True )
39 mesh.ExtrusionSweepObject( mesh, [0,0,10], 7 )
42 mesh.SplitVolumesIntoTetra( mesh )
46 optMesh = smesh.CopyMesh( mesh,
"optimization" )
49 mg_opt = optMesh.Tetrahedron( smeshBuilder.MG_Tetra_Optimization )
50 mg_opt.SetSmoothOffSlivers(
True )
51 mg_opt.SetOptimizationLevel( smeshBuilder.Strong_Optimization )
56 print "Nb tetra before optimization", mesh.NbTetras()
57 print "Nb tetra after optimization", optMesh.NbTetras()