[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. Mesh module

Gmsh's mesh module regroups several 1D, 2D and 3D mesh algorithms, all producing grids conforming in the sense of finite elements (see section 1.2 Mesh: finite element mesh generation).

The 2D unstructured algorithms generate triangles or both triangles and quadrangles (when Recombine Surface is used: see 4.2.3 Miscellaneous). The 3D unstructured algorithms only generate tetrahedra.

The 2D structured algorithms (transfinite, elliptic and extrusion) generate triangles by default, but quadrangles can be obtained by using the Recombine commands (see 4.2.2 Structured grids, and 4.2.3 Miscellaneous). The 3D structured algorithms generate tetrahedra, hexahedra, prisms and pyramids, depending on the type of the surface meshes they are based on.

4.1 Elementary vs. physical entities  
4.2 Mesh commands  
4.3 Mesh options  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Elementary vs. physical entities

If only elementary geometrical entities are defined (or if the Mesh.SaveAll option is set; see 4.3 Mesh options), the grid produced by the mesh module will be saved "as is". That is, all the elements in the grid will be saved to disk using the identification number of the elementary entities they discretize as their region number (see section 9.1 Gmsh mesh file formats). This can sometimes be inconvenient:

To remedy these problems, the geometry module introduces the notion of "physical" entities (see section 3. Geometry module). The purpose of physical entities is to assemble elementary entities into larger, possibly overlapping groups, and to control the orientation of the elements in these groups. If physical entities are defined, the output mesh only contains those elements that belong to physical entities. The introduction of such physical entities in large models usually greatly facilitates the manipulation of the model (e.g., using `Tools->Visibility' in the GUI) and the interfacing with external solvers.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Mesh commands

The mesh module commands mostly permit to modify the characteristic lengths and specify structured grid parameters. The actual mesh "actions" (i.e., "mesh the lines", "mesh the surfaces" and "mesh the volumes") cannot be specified in the input ASCII text input files. They have to be given either in the GUI or on the command line (see 8. Running Gmsh, and 8.3 Command-line options).

4.2.1 Characteristic lengths  
4.2.2 Structured grids  
4.2.3 Miscellaneous  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2.1 Characteristic lengths

The `size' of a mesh element is defined as the length of the segment for a line segment, the radius of the circumscribed circle for a triangle and the radius of the circumscribed sphere for a tetrahedron. There are three main ways to specify the size of the mesh elements for a given geometry:

  1. You can specify characteristic lengths at the points of the geometrical model (with the Point command: see 3.1.1 Points). The actual size of the mesh elements will be computed by linearly interpolating these characteristic lengths on the initial mesh (see 1.2 Mesh: finite element mesh generation). This might sometimes lead to over-refinement in some areas, so that you may have to add "dummy" geometrical entities in the model in order to get the desired element sizes.

    This method works with all the algorithms implemented in the mesh module. The final element sizes are of course constrained by the structured algorithms for which the element sizes are explicitly specified (e.g., transfinite and extruded grids: see 4.2.2 Structured grids).

  2. You can use geometrical "attractors", an elaborate version of the method described in the preceding item: see the definition of the Attractor command below.

    Attractors only work with the 2D anisotropic algorithm (see the Mesh.Algorithm option in 4.3 Mesh options).

  3. You can give Gmsh an explicit background mesh in the form of a scalar post-processing view (see 6.1 Post-processing commands, and 9. File formats) in which the nodal values are the target element sizes. This method is very general but it requires a first (usually rough) mesh and a way to compute the target sizes on this mesh (usually through an error estimation procedure, in an iterative process of mesh adaptation). Note that the target element sizes can be constrained by the characteristic lengths defined in the geometrical model if the Mesh.ConstrainedBackgroundMesh option is set. To load a background mesh, use the -bgm command-line option (see section 8.3 Command-line options) or select `Apply as background mesh' in the post-processing view option menu.

    Background meshes are supported by all algorithms except the algorithms based on Netgen.

Here are the mesh commands that are related to the specification of characteristic lengths:

Attractor Point | Line { expression-list } = { expression, expression, expression };
Specifies a characteristic length attractor. The expression-list should contain the identification numbers of the elementary points or lines to serve as attractors; the two first expressions prescribe refinement factors in a coordinate system local to the entities, and the last expression a decay factor. This feature is still experimental, and only works with the 2D anisotropic algorithm (see Mesh.Algorithm in 4.3 Mesh options). An example of the use of attractors is given in 7.7 `t7.geo'.

Please note that attractors are an experimental feature (to be considered at most alpha-quality...). Use at your own risk.

Characteristic Length { expression-list } = expression;
Modifies the characteristic length of the points whose identification numbers are listed in expression-list. The new value is given by expression.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2.2 Structured grids

Extrude Point | Line | Surface { expression, { expression-list } } { layers; ... };
Extrudes both the geometry and the mesh using a translation (see section 3.1.5 Extrusions). The layers option determines how the mesh is extruded and has the following syntax:

 
layers:
  Layers { { expression-list }, < { expression-list }, >
           { expression-list } } | Recombine

The first expression-list defines how many elements should be created in each extruded layer. The (optional) second expression-list assigns a region number to each layer, which, if non-zero, overrides the elementary entity number of the extruded entity. This is useful when there is more than one layer, as the elements in each layer can then be identified in a unique way. If the region number is set to zero, or if the expression-list is omitted, the elements are associated with the automatically created elementary geometrical entity (line, surface or volume) created during the extrusion. The last expression-list gives the normalized height of each layer (the list should contain a sequence of n numbers 0 < h1 < h2 < ... < hn <= 1). See 7.3 `t3.geo', for an example.

For line extrusions, the Recombine option will recombine triangles into quadrangles when possible. For surface extrusions, the Recombine option will recombine tetrahedra into prisms, hexahedra or pyramids.

Extrude Point | Line | Surface { expression, { expression-list }, { expression-list }, expression } { layers; ... };
Extrudes both the geometry and the mesh using a rotation (see section 3.1.5 Extrusions). The layers option is defined as above.

Extrude Point | Line | Surface { expression, { expression-list }, { expression-list }, { expression-list }, expression } { layers; ... };
Extrudes both the geometry and the mesh using a combined translation and rotation (see section 3.1.5 Extrusions). The layers option is defined as above.

Transfinite Line { expression-list } = expression < Using Progression | Bump expression >;
Selects the lines in expression-list to be meshed with the 1D transfinite algorithm. The expression on the right hand side gives the number of nodes that will be created on the line (this overrides any characteristic length prescription--see 4.2.1 Characteristic lengths). The optional argument `Using Progression expression' instructs the transfinite algorithm to distribute the nodes following a geometric progression (Progression 2 meaning for example that each line element in the series will be twice as long as the preceding one). The optional argument `Using Bump expression' instructs the transfinite algorithm to distribute the nodes with a refinement at both ends of the line.

(A deprecated synonym for Progression is Power.)

Transfinite Surface { expression } = { expression-list } < Left | Right | Alternate > ;
Selects the surface expression to be meshed with the 2D transfinite algorithm (the surface can only have three or four sides). The expression-list should contain the identification numbers of the points on the boundary of the surface. The ordering of these point numbers defines the ordering and orientation of the mesh elements, and should thus follow the node ordering for triangles or quadrangles given in 9.3 Gmsh node ordering. The optional argument specifies the way the triangles are oriented when the mesh is not recombined.

Transfinite Volume { expression } = { expression-list };
Selects the volume expression to be meshed with the 3D transfinite algorithm (the volume can only have six or eight faces). The expression-list should contain the identification numbers of the points on the boundary of the volume. The ordering of these point numbers defines the ordering and orientation of the mesh elements, and should thus follow the node ordering for prisms or hexahedra given in 9.3 Gmsh node ordering.

Elliptic Surface { expression } = { expression-list };
Selects the surface expression to be meshed with the 2D elliptic algorithm (the surface can only have four sides). The expression-list should contain the identification numbers of the points on the boundary of the surface. The ordering of these point numbers defines the ordering and orientation of the mesh elements, and should thus follow the node ordering for triangles or quadrangles given in 9.3 Gmsh node ordering.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2.3 Miscellaneous

Here is a list of all other mesh commands currently available:

Color color-expression { Point | Line | Surface | Volume { expression-list }; ... }
Sets the mesh color of the entities in expression-list to color-expression.

Hide { Point | Line | Surface | Volume { expression-list }; ... }
Hides the mesh of the entities in expression-list, if General.VisibilityMode is set to 0 or 2.

Hide char-expression;
Hides the mesh of the entity char-expression, if General.VisibilityMode is set to 0 or 2 (char-expression can for example be "*").

Recombine Surface { expression-list } < = expression >;
Recombines the triangular meshes of the surfaces listed in expression-list into mixed triangular/quadrangular meshes. The optional expression on the right hand side specifies the maximum recombination angle allowed (a large expression leading to more triangle recombinations).

Save char-expression;
Saves the mesh in a file named char-expression, using the current Mesh.Format (see section 4.3 Mesh options). If the path in char-expression is not absolute, char-expression is appended to the path of the current file.

Show { Point | Line | Surface | Volume { expression-list }; ... }
Shows the mesh of the entities in expression-list, if General.VisibilityMode is set to 0 or 2.

Show char-expression;
Shows the mesh of the entity char-expression, if General.VisibilityMode is set to 0 or 2 (char-expression can for example be "*").


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3 Mesh options

Mesh options control the behavior of mesh commands, as well as the way meshes are displayed in the graphical user interface. For the signification of the `Saved in:' field in the following list, see 2.7 General options.

Mesh.TriangleOptions
Options for Jonathan Shewchuk's Triangle isotropic algorithm
Default value: "praqzBPY"
Saved in: General.OptionsFileName

Mesh.Algorithm
2D mesh algorithm (1=isotropic, 2=anisotropic, 3=triangle)
Default value: 1
Saved in: General.OptionsFileName

Mesh.Algorithm3D
3D mesh algorithm (1=isotropic, 4=netgen, 5=tetgen)
Default value: 1
Saved in: General.OptionsFileName

Mesh.AllowDegeneratedExtrude
Allow the generation of degenerated hexahedra or prisms during extrusion
Default value: 0
Saved in: -

Mesh.AngleSmoothNormals
Threshold angle below which normals are not smoothed
Default value: 180
Saved in: General.OptionsFileName

Mesh.CharacteristicLengthFactor
Factor applied to all characteristic lengths (and background meshes)
Default value: 1
Saved in: General.OptionsFileName

Mesh.ColorCarousel
Mesh coloring (0=by element type, 1=by elementary entity, 2=by physical entity, 3=by partition)
Default value: 1
Saved in: General.OptionsFileName

Mesh.ConstrainedBackgroundMesh
Should the background mesh be constrained by the characteristic lengths associated with the geometry?
Default value: 0
Saved in: General.OptionsFileName

Mesh.CpuTime
CPU time (in seconds) for the generation of the current mesh (read-only)
Default value: 0
Saved in: -

Mesh.CutPlane
Enable mesh cut plane
Default value: 0
Saved in: -

Mesh.CutPlaneAsSurface
Draw the intersection volume layer as a surface
Default value: 0
Saved in: -

Mesh.CutPlaneOnlyVolume
Cut only the volume elements
Default value: 0
Saved in: -

Mesh.CutPlaneA
First cut plane equation coefficient (`A' in `AX+BY+CZ+D=0')
Default value: 1
Saved in: -

Mesh.CutPlaneB
Second cut plane equation coefficient (`B' in `AX+BY+CZ+D=0')
Default value: 0
Saved in: -

Mesh.CutPlaneC
Third cut plane equation coefficient (`C' in `AX+BY+CZ+D=0')
Default value: 0
Saved in: -

Mesh.CutPlaneD
Fourth cut plane equation coefficient (`D' in `AX+BY+CZ+D=0')
Default value: 0
Saved in: -

Mesh.DihedralAngleTol
Dihedral angle tolerance for edge creation in the remesher
Default value: 22
Saved in: General.OptionsFileName

Mesh.Dual
Display the dual mesh obtained by barycentric subdivision
Default value: 0
Saved in: General.OptionsFileName

Mesh.EdgeProlongationThreshold
Edge prolongation threshold in the remesher
Default value: 1
Saved in: General.OptionsFileName

Mesh.ElementOrder
Element order (1=linear elements, 2=quadratic elements)
Default value: 1
Saved in: General.OptionsFileName

Mesh.Explode
Explode elements (between 0=point and 1=non-transformed)
Default value: 1
Saved in: General.OptionsFileName

Mesh.Format
Mesh output format (1=msh, 2=unv, 3=gref, 19=vrml)
Default value: 1
Saved in: General.OptionsFileName

Mesh.Interactive
Show the construction of 2D anisotropic mesh in real time
Default value: 0
Saved in: General.OptionsFileName

Mesh.LabelType
Type of element label (0=element number, 1=elementary entity number, 2=physical entity number, 3=partition number)
Default value: 0
Saved in: General.OptionsFileName

Mesh.Light
Enable lighting for the mesh
Default value: 0
Saved in: General.OptionsFileName

Mesh.LightLines
Enable lighting for mesh lines (element edges)
Default value: 1
Saved in: General.OptionsFileName

Mesh.LightTwoSide
Light both sides of mesh elements (leads to slower rendering)
Default value: 1
Saved in: General.OptionsFileName

Mesh.Lines
Display mesh lines (1D elements)?
Default value: 0
Saved in: General.OptionsFileName

Mesh.LineNumbers
Display mesh line numbers?
Default value: 0
Saved in: General.OptionsFileName

Mesh.LineType
Display mesh lines as solid color segments (0) or 3D cylinders (1)
Default value: 0
Saved in: General.OptionsFileName

Mesh.LineWidth
Display width of mesh lines (in pixels)
Default value: 1
Saved in: General.OptionsFileName

Mesh.MinimumCirclePoints
Minimum number of points used to mesh a circle
Default value: 7
Saved in: General.OptionsFileName

Mesh.MshFileVersion
Version of the `msh' file format to use
Default value: 1
Saved in: General.OptionsFileName

Mesh.NbElemsPerRadiusOfCurv
Number of elements per radius of curvature in the remesher
Default value: 5
Saved in: General.OptionsFileName

Mesh.TargetElmentSizeFact
Target element size factor in the Remesher
Default value: 20
Saved in: General.OptionsFileName

Mesh.MinimumElementSizeFact
Minimum element size factor in the Remesher
Default value: 500
Saved in: General.OptionsFileName

Mesh.BetaSmoothMetric
Maximum ratio of two consecutive edge lengths
Default value: 0.9
Saved in: General.OptionsFileName

Mesh.NbHexahedra
Number of hexahedra in the current mesh (read-only)
Default value: 0
Saved in: -

Mesh.NbNodes
Number of nodes in the current mesh (read-only)
Default value: 0
Saved in: -

Mesh.NbPrisms
Number of prisms in the current mesh (read-only)
Default value: 0
Saved in: -

Mesh.NbPyramids
Number of pyramids in the current mesh (read-only)
Default value: 0
Saved in: -

Mesh.NbQuadrangles
Number of quadrangles in the current mesh (read-only)
Default value: 0
Saved in: -

Mesh.NbTetrahedra
Number of tetrahedra in the current mesh (read-only)
Default value: 0
Saved in: -

Mesh.NbTriangles
Number of triangles in the current mesh (read-only)
Default value: 0
Saved in: -

Mesh.Normals
Display size of normal vectors (in pixels)
Default value: 0
Saved in: General.OptionsFileName

Mesh.Optimize
Optimize the mesh using Netgen to improve the quality of tetrahedral elements
Default value: 0
Saved in: General.OptionsFileName

Mesh.Points
Display mesh vertices (nodes)?
Default value: 1
Saved in: General.OptionsFileName

Mesh.PointsPerElement
Display mesh nodes per element (slower, but permits to visualize only a subset of the nodes)
Default value: 0
Saved in: General.OptionsFileName

Mesh.PointInsertion
Point insertion method for isotropic 2D algorithm (1=center of circumscribed circle, 2=center of gravity)
Default value: 1
Saved in: General.OptionsFileName

Mesh.PointNumbers
Display mesh node numbers?
Default value: 0
Saved in: General.OptionsFileName

Mesh.PointSize
Display size of mesh vertices (in pixels)
Default value: 4
Saved in: General.OptionsFileName

Mesh.PointType
Display mesh vertices as solid color dots (0) or 3D spheres (1)
Default value: 0
Saved in: General.OptionsFileName

Mesh.Quality
Target quality for tetrahedral elements (currently only used by Tetgen)
Default value: 1
Saved in: General.OptionsFileName

Mesh.QualityInf
Only display elements whose quality measure is greater than QualityInf
Default value: 0
Saved in: General.OptionsFileName

Mesh.QualitySup
Only display elements whose quality measure is smaller than QualitySup
Default value: 0
Saved in: General.OptionsFileName

Mesh.QualityType
Type of quality measure (0=gamma~vol/sum_face/max_edge, 1=eta~vol^(2/3)/sum_edge^2, 2=rho~min_edge/max_edge)
Default value: 0
Saved in: General.OptionsFileName

Mesh.RadiusInf
Only display elements whose longest edge is greater than RadiusInf
Default value: 0
Saved in: General.OptionsFileName

Mesh.RadiusSup
Only display elements whose longest edge is smaller than RadiusSup
Default value: 0
Saved in: General.OptionsFileName

Mesh.RandomFactor
Random factor used in 2D and 3D meshing algorithm (test other values when the algorithm fails)
Default value: 0.0001
Saved in: General.OptionsFileName

Mesh.RecombineAlgo
Recombine algorithm (1=mixed triangles-quadrangles, 2=all quadrangles)
Default value: 1
Saved in: General.OptionsFileName

Mesh.SaveAll
Ignore Physical definitions and save all elements
Default value: 0
Saved in: -

Mesh.ScalingFactor
Global scaling factor applied to the saved mesh
Default value: 1
Saved in: General.OptionsFileName

Mesh.Smoothing
Number of smoothing steps applied to the final mesh
Default value: 1
Saved in: General.OptionsFileName

Mesh.Partitioning
Number of partitions applied to the final mesh
Default value: 1
Saved in: General.OptionsFileName

Mesh.SmoothNormals
Smooth the mesh normals?
Default value: 0
Saved in: General.OptionsFileName

Mesh.SpeedMax
Disable dubious point insertion tests
Default value: 0
Saved in: General.OptionsFileName

Mesh.StlDistanceTol
Distance tolerance between two distinct vertices in STL meshes
Default value: 5e-07
Saved in: General.OptionsFileName

Mesh.SurfaceEdges
Display edges of surface mesh?
Default value: 1
Saved in: General.OptionsFileName

Mesh.SurfaceFaces
Display faces of surface mesh?
Default value: 0
Saved in: General.OptionsFileName

Mesh.SurfaceNumbers
Display surface mesh element numbers?
Default value: 0
Saved in: General.OptionsFileName

Mesh.Tangents
Display size of tangent vectors (in pixels)
Default value: 0
Saved in: General.OptionsFileName

Mesh.VertexArrays
Use OpenGL vertex arrays to draw triangular meshes?
Default value: 1
Saved in: General.OptionsFileName

Mesh.VolumeEdges
Display edges of volume mesh?
Default value: 1
Saved in: General.OptionsFileName

Mesh.VolumeFaces
Display faces of volume mesh?
Default value: 0
Saved in: General.OptionsFileName

Mesh.VolumeNumbers
Display volume mesh element numbers?
Default value: 0
Saved in: General.OptionsFileName

Mesh.LabelsFrequency
Labels display frequency?
Default value: 100
Saved in: General.OptionsFileName

Mesh.Color.Points
Mesh node color
Default value: {0,255,0}
Saved in: General.OptionsFileName

Mesh.Color.PointsSup
Second order mesh node color
Default value: {255,0,255}
Saved in: General.OptionsFileName

Mesh.Color.Lines
Mesh line color
Default value: {0,255,0}
Saved in: General.OptionsFileName

Mesh.Color.Triangles
Mesh triangle color (if Mesh.ColorCarousel=0)
Default value: {160,150,255}
Saved in: General.OptionsFileName

Mesh.Color.Quadrangles
Mesh quadrangle color (if Mesh.ColorCarousel=0)
Default value: {130,120,225}
Saved in: General.OptionsFileName

Mesh.Color.Tetrahedra
Mesh tetrahedron color (if Mesh.ColorCarousel=0)
Default value: {160,150,255}
Saved in: General.OptionsFileName

Mesh.Color.Hexahedra
Mesh hexahedron color (if Mesh.ColorCarousel=0)
Default value: {130,120,225}
Saved in: General.OptionsFileName

Mesh.Color.Prisms
Mesh prism color (if Mesh.ColorCarousel=0)
Default value: {232,210,23}
Saved in: General.OptionsFileName

Mesh.Color.Pyramids
Mesh pyramid color (if Mesh.ColorCarousel=0)
Default value: {217,113,38}
Saved in: General.OptionsFileName

Mesh.Color.Tangents
Tangent mesh vector color
Default value: {255,255,0}
Saved in: General.OptionsFileName

Mesh.Color.Normals
Normal mesh vector color
Default value: {255,0,0}
Saved in: General.OptionsFileName

Mesh.Color.Zero
Color 0 in color carousel
Default value: {9,3,103}
Saved in: General.OptionsFileName

Mesh.Color.One
Color 1 in color carousel
Default value: {35,0,111}
Saved in: General.OptionsFileName

Mesh.Color.Two
Color 2 in color carousel
Default value: {60,0,114}
Saved in: General.OptionsFileName

Mesh.Color.Three
Color 3 in color carousel
Default value: {83,0,114}
Saved in: General.OptionsFileName

Mesh.Color.Four
Color 4 in color carousel
Default value: {105,1,109}
Saved in: General.OptionsFileName

Mesh.Color.Five
Color 5 in color carousel
Default value: {126,10,102}
Saved in: General.OptionsFileName

Mesh.Color.Six
Color 6 in color carousel
Default value: {145,21,93}
Saved in: General.OptionsFileName

Mesh.Color.Seven
Color 7 in color carousel
Default value: {163,34,82}
Saved in: General.OptionsFileName

Mesh.Color.Eight
Color 8 in color carousel
Default value: {179,50,69}
Saved in: General.OptionsFileName

Mesh.Color.Nine
Color 9 in color carousel
Default value: {193,67,57}
Saved in: General.OptionsFileName

Mesh.Color.Ten
Color 10 in color carousel
Default value: {207,85,44}
Saved in: General.OptionsFileName

Mesh.Color.Eleven
Color 11 in color carousel
Default value: {219,104,32}
Saved in: General.OptionsFileName

Mesh.Color.Twelve
Color 12 in color carousel
Default value: {229,124,22}
Saved in: General.OptionsFileName

Mesh.Color.Thirtheen
Color 13 in color carousel
Default value: {238,143,13}
Saved in: General.OptionsFileName

Mesh.Color.Fourteen
Color 14 in color carousel
Default value: {246,162,8}
Saved in: General.OptionsFileName

Mesh.Color.Fifteen
Color 15 in color carousel
Default value: {252,181,5}
Saved in: General.OptionsFileName

Mesh.Color.Sixteen
Color 16 in color carousel
Default value: {255,198,6}
Saved in: General.OptionsFileName

Mesh.Color.Seventeen
Color 17 in color carousel
Default value: {255,214,11}
Saved in: General.OptionsFileName

Mesh.Color.Eighteen
Color 18 in color carousel
Default value: {255,228,22}
Saved in: General.OptionsFileName

Mesh.Color.Nineteen
Color 19 in color carousel
Default value: {255,240,38}
Saved in: General.OptionsFileName


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

Back to geuz.org/gmsh