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