4 This file creates a compound solid of cube and a sphere. Then meshes them with
5 Gmsh using compound mesh feature of Gmsh.
10 #-------------------------------------
12 #-------------------------------------
14 from salome.shaper import model
16 partSet = model.moduleDocument()
19 Part_1 = model.addPart(partSet)
20 Part_1_doc = Part_1.document()
23 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
26 Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 5)
29 Fuse_1 = model.addFuse(Part_1_doc, [model.selection("COMPOUND", "all-in-Box_1"), model.selection("COMPOUND", "all-in-Sphere_1")], keepSubResults = True)
32 Group_1_objects = [model.selection("FACE", "Box_1_1/Front"),
33 model.selection("FACE", "Box_1_1/Top"),
34 model.selection("FACE", "Fuse_1_1/Modified_Face&Box_1_1/Left"),
35 model.selection("FACE", "Box_1_1/Right"),
36 model.selection("FACE", "Fuse_1_1/Modified_Face&Box_1_1/Back"),
37 model.selection("FACE", "Fuse_1_1/Modified_Face&Box_1_1/Bottom")]
38 Group_1 = model.addGroup(Part_1_doc, "Faces", Group_1_objects)
42 #-------------------------------------
43 ### SHAPERSTUDY component
44 #-------------------------------------
46 model.publishToShaperStudy()
48 Fuse_1_1, Group_1_1, = SHAPERSTUDY.shape(model.featureStringId(Fuse_1))
51 #-------------------------------------
53 #-------------------------------------
55 import SMESH, SALOMEDS
56 from salome.smesh import smeshBuilder
58 smesh = smeshBuilder.New()
60 Mesh_1 = smesh.Mesh(Fuse_1_1)
61 GMSH_2D = Mesh_1.Triangle(algo=smeshBuilder.GMSH_2D)
62 Gmsh_Parameters = GMSH_2D.Parameters()
63 Gmsh_Parameters.Set2DAlgo( 0 )
64 Gmsh_Parameters.SetMaxSize( 10 )
65 Gmsh_Parameters.SetMinSize( 5 )
66 Gmsh_Parameters.SetIs2d( 1 )
67 Gmsh_Parameters.SetCompoundOnShape(Group_1_1)
68 isDone = Mesh_1.Compute()
69 GMSH = Mesh_1.Tetrahedron(algo=smeshBuilder.GMSH_3D)
70 Gmsh_Parameters = GMSH.Parameters()
71 Gmsh_Parameters.Set2DAlgo( 0 )
72 Gmsh_Parameters.SetMinSize( 0.5 )
73 Gmsh_Parameters.SetMaxSize( 1 )
74 Gmsh_Parameters.SetIs2d( 0 )
75 Gmsh_Parameters.SetCompoundOnShape(Group_1_1)
76 Group_1_2 = Mesh_1.GroupOnGeom(Group_1_1,'Group_1',SMESH.FACE)
82 #-------------------------------------
83 # Test: Frontal Delaunay
84 #-------------------------------------
86 isDone = Mesh_1.Compute()
88 errorMsg+= '\n ERROR: failed to mesh the compound cube-sphere surface using Delaunay algorithm from Gmsh\n'
90 okMsg+= '\n PASSED: Successfully meshed the compound cube-sphere surface using Delaunay algorithm from Gmsh\n'
92 errorMsg+='\n ERROR: Exception raised in Mesh computation'
94 #-------------------------------------
95 # Message that test are OK or not
96 #-------------------------------------
102 raise RuntimeError (errorMsg + "\n Test is KO.")
106 if salome.sg.hasDesktop():
107 smesh.SetName(GMSH.GetAlgorithm(), 'GMSH')
108 smesh.SetName(Group_1_2, 'Group_1')
109 smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
110 smesh.SetName(Gmsh_Parameters, 'Gmsh Parameters')
111 salome.sg.updateObjBrowser()