Python API for SALOME Mesh module defines several classes that can be used for easy mesh creation and edition.
Documentation for SALOME Mesh module Python API is available in two forms:
With SALOME 7.2, the Python interface for Mesh has been slightly modified to offer new functionality.
You may have to modify your scripts generated with SALOME 6 or older versions.
Please see Modifing Mesh Python scripts from SALOME 6 and before.
Class smeshBuilder provides an interface to create and handle meshes. It can be used to create an empty mesh or to import mesh from the data file.
As soon as a mesh is created, it is possible to manage it via its own methods, described in class Mesh documentation.
Class SMeshStudyTools provides several methods to manipulate mesh objects in Salome study.
A usual workflow to generate a mesh on geometry is following:
from salome.smesh import smeshBuilder smesh = smeshBuilder.New( salome.myStudy )
mesh = smesh.Mesh( geometry )
regular1D = mesh.Segment() mefisto = mesh.Triangle( smeshBuilder.MEFISTO ) # use other triangle algorithm on a face -- a sub-mesh appears in the mesh netgen = mesh.Triangle( smeshBuilder.NETGEN_1D2D, face )
segLen10 = regular1D.LocalLength( 10. ) maxArea = mefisto.MaxElementArea( 100. ) netgen.SetMaxSize( 20. ) netgen.SetFineness( smeshBuilder.VeryCoarse )
mesh.Compute()
An easiest way to start with Python scripting is to do something in GUI and then to get a corresponding Python script via File > Dump Study menu item. Don't forget that you can get all methods of any object in hand (e.g. a mesh group or a hypothesis) by calling dir() Python built-in function.
All methods of the Mesh Group can be found in Create a Standalone Group sample script.
An example below demonstrates usage of the Python API for 3d mesh generation and for retrieving information on mesh nodes and elements.
Examples of Python scripts for Mesh operations are available by the following links: