Version: 8.3.0
 All Classes Namespaces Files Functions Variables Pages
Python Interface

Python package NETGENPluginBuilder defines several classes, destined for creation of the 2D and 3D meshes.

NETGEN meshing plugin dynamically adds several methods to the smeshBuilder.Mesh to create meshing algorithms.

Below you can see an example of usage of the NETGENPluginBuilder package for mesh generation:

Example of 2d and 3d mesh generation with NETGEN:

1 # 2d and 3d mesh generation with NETGEN
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 
9 import SMESH, SALOMEDS
10 from salome.smesh import smeshBuilder
11 smesh = smeshBuilder.New(salome.myStudy)
12 
13 # create a box
14 box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
15 geompy.addToStudy(box, "Box")
16 
17 
18 # 1. Create a triangular 2D mesh on the box with NETGEN_1D2D algorithm
19 triaN = smesh.Mesh(box, "Box : triangular mesh by NETGEN_1D2D")
20 
21 # create a NETGEN_1D2D algorithm for solids
22 algo2D = triaN.Triangle(smeshBuilder.NETGEN_1D2D)
23 
24 # define hypotheses
25 n12_params = algo2D.Parameters()
26 
27 # define number of segments
28 n12_params.SetNbSegPerEdge(19)
29 
30 # define max element
31 n12_params.SetMaxSize(300)
32 
33 # 2. Create a tetrahedral mesh on the box with NETGEN_1D2D3D algorithm (full netgen)
34 tetraN = smesh.Mesh(box, "Box : tetrahedrical mesh by NETGEN_1D2D3D")
35 
36 # create a NETGEN_1D2D3D algorithm for solids
37 algo3D = tetraN.Tetrahedron(smeshBuilder.FULL_NETGEN)
38 
39 # define hypotheses
40 n123_params = algo3D.Parameters()
41 
42 # define number of segments
43 n123_params.SetNbSegPerEdge(11)
44 
45 # define max element size
46 n123_params.SetMaxSize(300)
47 
48 # compute the meshes
49 triaN.Compute()
50 tetraN.Compute()

Download this script