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 = Mesh_1.Tetrahedron(algo=smeshBuilder.GMSH)
62 Gmsh_Parameters = GMSH.Parameters()
63 Gmsh_Parameters.Set2DAlgo( 0 )
64 Gmsh_Parameters.SetMinSize( 0.5 )
65 Gmsh_Parameters.SetMaxSize( 1 )
66 Gmsh_Parameters.SetIs2d( 0 )
67 Gmsh_Parameters.SetCompoundOnShape(Group_1_1)
68 Group_1_2 = Mesh_1.GroupOnGeom(Group_1_1,'Group_1',SMESH.FACE)
69 #isDone = Mesh_1.Compute()
70 #[ Group_1_2 ] = Mesh_1.GetGroups()
76 #-------------------------------------
77 # Test: Frontal Delaunay
78 #-------------------------------------
80 isDone = Mesh_1.Compute()
82 errorMsg+= '\n ERROR: failed to mesh the compound cube-sphere surface using Delaunay algorithm from Gmsh\n'
84 okMsg+= '\n PASSED: Successfully meshed the compound cube-sphere surface using Delaunay algorithm from Gmsh\n'
86 errorMsg+='\n ERROR: Exception raised in Mesh computation'
88 #-------------------------------------
89 # Message that test are OK or not
90 #-------------------------------------
96 raise RuntimeError (errorMsg + "\n Test is KO.")
100 if salome.sg.hasDesktop():
101 smesh.SetName(GMSH.GetAlgorithm(), 'GMSH')
102 smesh.SetName(Group_1_2, 'Group_1')
103 smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
104 smesh.SetName(Gmsh_Parameters, 'Gmsh Parameters')
105 salome.sg.updateObjBrowser()