Salome HOME
Fix the command running the tests
[plugins/gmshplugin.git] / doc / salome / examples / gmshdemo.py
1 # -*- coding: iso-8859-1 -*-
2
3 import salome
4
5 salome.salome_init()
6
7 from salome.geom import geomBuilder
8 geompy = geomBuilder.New()
9
10 from salome.smesh import smeshBuilder
11 smesh = smeshBuilder.New()
12
13 from salome.GMSHPlugin import GMSHPluginBuilder
14
15 # create a box
16 Box = geompy.MakeBoxDXDYDZ(10, 10, 10)
17 geompy.addToStudy( Box, 'Box' )
18
19 # 1. Create a 2D mesh on the box with GMSH_2D algorithm
20 Mesh_2D = smesh.Mesh(Box, "Box : 2D mesh by GMSH_2D")
21 # create a Gmsh 2D algorithm for solids
22 Algo_2D = Mesh_2D.Triangle(algo=smeshBuilder.GMSH_2D)
23 # define hypotheses
24 Param_2D = Algo_2D.Parameters()
25 # define algorithm
26 Param_2D.Set2DAlgo( 0 )
27 # define min element
28 Param_2D.SetMinSize( 0 )
29 # define max element
30 Param_2D.SetMaxSize( 2 )
31
32 # 2. Create a 3D mesh on the box with GMSH_3D algorithm
33 Mesh_3D = smesh.Mesh(Box, "Box : 3D mesh by GMSH_3D")
34 # create a Gmsh 3D algorithm for solids
35 Algo_3D = Mesh_3D.Tetrahedron(algo=smeshBuilder.GMSH)
36 # define hypotheses
37 Param_3D = Algo_3D.Parameters()
38 # define algorithms
39 Param_3D.Set2DAlgo( 0 )
40 Param_3D.SetIs2d( 0 )
41 Param_3D.Set3DAlgo( 0 )
42 # define min element size
43 Param_3D.SetMinSize( 0 )
44 # define max element size
45 Param_3D.SetMaxSize( 2 )
46
47 # compute the meshes
48 Mesh_2D.Compute()
49 Mesh_3D.Compute()
50
51 if salome.sg.hasDesktop():
52   salome.sg.updateObjBrowser()