4 This file creates a square using GEOM then meshes the same using Gmsh's different algorithms
6 1. Automatic ----> Gmsh_Parameters.Set2DAlgo( 0 )
7 2. mesh Adapt ----> Gmsh_Parameters.Set2DAlgo( 1 )
8 3. Delaunay ----> Gmsh_Parameters.Set2DAlgo( 2 )
9 4. Frontal ----> Gmsh_Parameters.Set2DAlgo( 3 )
10 5. Delaunay For Quads ----> Gmsh_Parameters.Set2DAlgo( 4 )
11 6. Packing Parallelograms ----> Gmsh_Parameters.Set2DAlgo( 5 )
13 This file is solely for the propose of testing and we do overwrite the meshes.
19 #------------------------------------
20 # GEOM: Creating a square of size 10^2
21 #------------------------------------
23 from salome.geom import geomBuilder
25 geompy = geomBuilder.New()
26 Face_1 = geompy.MakeFaceHW(10, 10, 1)
28 #------------------------------------
29 # SMESH: Using Gmsh algorithm with size (1,5) (min,max)
30 #------------------------------------
32 from salome.smesh import smeshBuilder
33 smesh = smeshBuilder.New()
35 Mesh_1 = smesh.Mesh(Face_1)
36 GMSH_2D = Mesh_1.Triangle(algo=smeshBuilder.GMSH_2D)
37 Gmsh_Parameters = GMSH_2D.Parameters()
38 Gmsh_Parameters.SetMinSize( 1 )
39 Gmsh_Parameters.SetMaxSize( 5 )
40 Gmsh_Parameters.SetIs2d( 1 )
46 #-------------------------------------
48 #-------------------------------------
50 Gmsh_Parameters.Set2DAlgo( 0 )
51 isDone = Mesh_1.Compute()
53 errorMsg+= '\n ERROR: failed to mesh the box using Automatic algorithm from Gmsh\n'
55 okMsg+= '\n PASSED: Successfully meshed the box using Automatic algorithm from Gmsh\n'
57 errorMsg+='\n ERROR: Exception raised in Mesh computation'
59 #-------------------------------------
61 #-------------------------------------
63 Gmsh_Parameters.Set2DAlgo( 1 )
64 isDone = Mesh_1.Compute()
66 errorMsg+= '\n ERROR: failed to mesh the box using Mesh Adapt algorithm from Gmsh\n'
68 okMsg+= '\n PASSED: Successfully meshed the box using Mesh Adapt algorithm from Gmsh\n'
70 errorMsg+='\n ERROR: Exception raised in Mesh computation'
72 #-------------------------------------
74 #-------------------------------------
76 Gmsh_Parameters.Set2DAlgo( 2 )
77 isDone = Mesh_1.Compute()
79 errorMsg+= '\n ERROR: failed to mesh the box using Delaunay algorithm from Gmsh\n'
81 okMsg+= '\n PASSED: Successfully meshed the box using Delaunay algorithm from Gmsh\n'
83 errorMsg+='\n ERROR: Exception raised in Mesh computation'
85 #-------------------------------------
86 # Test: Frontal Algorithm
87 #-------------------------------------
89 Gmsh_Parameters.Set2DAlgo( 3 )
90 isDone = Mesh_1.Compute()
92 errorMsg+= '\n ERROR: failed to mesh the box using Frontal algorithm from Gmsh\n'
94 okMsg+= '\n PASSED: Successfully meshed the box using Frontal algorithm from Gmsh\n'
96 errorMsg+='\n ERROR: Exception raised in Mesh computation'
98 #-------------------------------------
99 # Test: Delaunay For Quads Algorithm
100 #-------------------------------------
102 Gmsh_Parameters.Set2DAlgo( 4 )
103 isDone = Mesh_1.Compute()
105 errorMsg+= '\n ERROR: failed to mesh the box using Delaunay For Quads algorithm from Gmsh\n'
107 okMsg+= '\n PASSED: Successfully meshed the box using Delaunay For Quads algorithm from Gmsh\n'
109 errorMsg+='\n ERROR: Exception raised in Mesh computation'
112 #-------------------------------------
113 # Test: Packing Parallelolagrams Algorithm
114 #-------------------------------------
116 Gmsh_Parameters.Set2DAlgo( 5 )
117 isDone = Mesh_1.Compute()
119 errorMsg+= '\n ERROR: failed to mesh the box using Packing Parallelolagrams algorithm from Gmsh\n'
121 okMsg+= '\n PASSED: Successfully meshed the box using Packing Parallelolagrams algorithm from Gmsh\n'
123 errorMsg+='\n ERROR: Exception raised in Mesh computation'
126 #-------------------------------------
127 # Message that test are OK or not
128 #-------------------------------------
134 raise RuntimeError (errorMsg + "\n Test is KO.")
137 if salome.sg.hasDesktop():
138 salome.sg.updateObjBrowser()