[ < ] [ > ]   [ << ] [ 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 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 elementary region number (and 0 as their physical region number(6); 9. File formats). This can sometimes be inconvenient:

To remedy these problems, the geometry module (see section 3. Geometry module) introduces the notion of "physical" entities (also called "physical groups"). 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. The introduction of 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.

In the MSH file format (see section 9. File formats), if physical entities are defined, the output mesh only contains those elements that belong to physical entities. Other file formats each treat physical entities in slightly different ways, depending on their capability to define groups.


[ < ] [ > ]   [ << ] [ 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

There are two 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 size of the mesh elements will then 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 specify characteristic lengths using mesh size "fields". Various fields exist: All target element sizes specified by fields can also be constrained by the characteristic lengths defined in the geometrical model if the Mesh.ConstrainedBackgroundMesh option is set.

    Fields are supported by all the algorithms except those based on Netgen.

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

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.
Field[expression] = string;
Field[expression].string = char-expression | expression | expression-list;
Background Field = expression;


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

4.2.2 Structured grids

Extrude { expression-list } { extrude-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 } | 
  Layers { { expression-list }, { expression-list } } | 
  Recombine; ...

In the first Layers form, expression gives the number of elements to be created in the (single) layer. In the second form, the first expression-list defines how many elements should be created in each extruded layer, and the second 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.

Please note that, starting with Gmsh 2.0, region numbers cannot be specified explicitly anymore in Layers commands. Instead, as with all other geometry commands, you must use the automatically created entity identifier created by the extrusion command. For example, the following extrusion command will return the id of the new "top" surface in num[0] and the id of the new volume in num[1]:
 
num[] = Extrude {0,0,1} { Surface{1}; Layers{10}; };

Extrude { { expression-list }, { expression-list }, expression } { extrude-list 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 { { expression-list }, { expression-list }, { expression-list }, expression } { extrude-list 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.

Extrude { Surface { expression-list }; layers }
Extrudes a boundary layer along the normals of the specified surfaces.

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 expression-list should contain the identification numbers of three or four points on the boundary of the surface, defining the corners of the transfinite interpolation. The optional argument specifies the way the triangles are oriented when the mesh is not recombined.

Transfinite Volume { expression } = { expression-list };
Selects a five- or six-face volume expression to be meshed with the 3D transfinite algorithm. The expression-list should contain the identification numbers of the six or eight points on the boundary of the volume that define the corners of the transfinite interpolation.


[ < ] [ > ]   [ << ] [ 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 difference (in degrees) allowed between the largest angle of a quadrangle and a right angle (a value of 0 would only accept quadrangles with right angles; a value of 90 would allow degenerate quadrangles; default value is 45).

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 "*").

Smoother Surface { expression-list } = expression;
Sets number of elliptic smoothing steps for the surfaces listed in expression-list (smothing only applies to transfinite meshes at the moment).


[ < ] [ > ]   [ << ] [ 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.Algorithm
2D mesh algorithm (1=MeshAdapt+Delaunay, 4=MeshAdapt, 5=Delaunay)
Default value: 1
Saved in: General.OptionsFileName

Mesh.Algorithm3D
3D mesh algorithm (1=Tetgen+Delaunay, 4=Netgen)
Default value: 1
Saved in: General.OptionsFileName

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

Mesh.AllowSwapAngle
Treshold angle (in degrees) between faces normals under which we allow an edge swap
Default value: 10
Saved in: General.OptionsFileName

Mesh.BdfFieldFormat
Field format for Nastran BDF files (0=free, 1=small, 2=large)
Default value: 1
Saved in: General.OptionsFileName

Mesh.C1Continuity
Impose C1 continuity to high order meshes (only valid in 2D plane and ElemenOrder = 2)
Default value: 0
Saved in: General.OptionsFileName

Mesh.CharacteristicLengthExtendFromBoundary
Extend characteristic lengths from the boundaries inside the surface/volume
Default value: 1
Saved in: General.OptionsFileName

Mesh.CharacteristicLengthFactor
Factor applied to all characteristic lengths
Default value: 1
Saved in: General.OptionsFileName

Mesh.CharacteristicLengthMin
Minimum characteristic length
Default value: 0
Saved in: General.OptionsFileName

Mesh.CharacteristicLengthMax
Maximum characteristic length
Default value: 1e+22
Saved in: General.OptionsFileName

Mesh.CharacteristicLengthFromCurvature
Compute characteristic lengths from curvature
Default value: 0
Saved in: General.OptionsFileName

Mesh.CharacteristicLengthFromPoints
Compute characteristic lengths from values given at geometry points
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.CpuTime
CPU time (in seconds) for the generation of the current mesh (read-only)
Default value: 0
Saved in: -

Mesh.DrawSkinOnly
Draw only the skin of 3D meshes?
Default value: 0
Saved in: General.OptionsFileName

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

Mesh.ElementOrder
Element order (1=linear elements, N (<6) = elements of higher order)
Default value: 1
Saved in: General.OptionsFileName

Mesh.Explode
Element shrinking factor (between 0 and 1)
Default value: 1
Saved in: General.OptionsFileName

Mesh.Format
Mesh output format (1=msh, 2=unv, 19=vrml, 27=stl, 30=mesh, 31=bdf, 32=cgns, 33=med)
Default value: 1
Saved in: General.OptionsFileName

Mesh.Hexahedra
Display mesh hexahedra?
Default value: 1
Saved in: General.OptionsFileName

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

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

Mesh.Light
Enable lighting for the mesh
Default value: 1
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 surfaces (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.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.MinimumCurvePoints
Minimum number of points used to mesh a (non-straight) curve
Default value: 3
Saved in: General.OptionsFileName

Mesh.MshBinary
Write MSH files in binary format?
Default value: 0
Saved in: General.OptionsFileName

Mesh.MshFileVersion
Version of the MSH file format to use
Default value: 2
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 to improve the quality of tetrahedral elements
Default value: 0
Saved in: General.OptionsFileName

Mesh.OptimizeNetgen
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: 0
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.Prisms
Display mesh prisms?
Default value: 1
Saved in: General.OptionsFileName

Mesh.Pyramids
Display mesh pyramids?
Default value: 1
Saved in: General.OptionsFileName

Mesh.Quadrangles
Display mesh quadrangles?
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: 2
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: 1e-09
Saved in: General.OptionsFileName

Mesh.RefineSteps
Number of refinement steps in the MeshAdapt-based 2D algorithms
Default value: 10
Saved in: General.OptionsFileName

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

Mesh.ReverseAllNormals
Reverse all the mesh normals (for display)
Default value: 0
Saved in: General.OptionsFileName

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

Mesh.SaveGroupsOfNodes
Save groups of nodes for each physical line and surface (UNV mesh format only)
Default value: 0
Saved in: -

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

Mesh.SecondOrderExperimental
Use experimental code to generate second order mesh
Default value: 0
Saved in: General.OptionsFileName

Mesh.SecondOrderIncomplete
Create incomplete second order elements? (8-node quads, 20-node hexas, etc.)
Default value: 1
Saved in: General.OptionsFileName

Mesh.SecondOrderLinear
Should second order vertices simply be created by linear interpolation?
Default value: 0
Saved in: General.OptionsFileName

Mesh.LcIntegrationPrecision
Accuracy of evaluation of the LC field for 1D mesh generation
Default value: 1e-09
Saved in: General.OptionsFileName

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

Mesh.SmoothInternalEdges
Number of smoothing steps of internal edges for high order meshes
Default value: 0
Saved in: General.OptionsFileName

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

Mesh.StlBinary
Save STL files in binary format?
Default value: 0
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.Tetrahedra
Display mesh tetrahedra?
Default value: 1
Saved in: General.OptionsFileName

Mesh.Triangles
Display mesh triangles?
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.Color.Points
Mesh node color
Default value: {0,0,255}
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,0,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: {255,120,0}
Saved in: General.OptionsFileName

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

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

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

Mesh.Color.Four
Color 4 in color carousel
Default value: {228,255,0}
Saved in: General.OptionsFileName

Mesh.Color.Five
Color 5 in color carousel
Default value: {188,255,0}
Saved in: General.OptionsFileName

Mesh.Color.Six
Color 6 in color carousel
Default value: {148,255,0}
Saved in: General.OptionsFileName

Mesh.Color.Seven
Color 7 in color carousel
Default value: {108,255,0}
Saved in: General.OptionsFileName

Mesh.Color.Eight
Color 8 in color carousel
Default value: {68,255,0}
Saved in: General.OptionsFileName

Mesh.Color.Nine
Color 9 in color carousel
Default value: {0,255,52}
Saved in: General.OptionsFileName

Mesh.Color.Ten
Color 10 in color carousel
Default value: {0,255,132}
Saved in: General.OptionsFileName

Mesh.Color.Eleven
Color 11 in color carousel
Default value: {0,255,192}
Saved in: General.OptionsFileName

Mesh.Color.Twelve
Color 12 in color carousel
Default value: {0,216,255}
Saved in: General.OptionsFileName

Mesh.Color.Thirteen
Color 13 in color carousel
Default value: {0,176,255}
Saved in: General.OptionsFileName

Mesh.Color.Fourteen
Color 14 in color carousel
Default value: {0,116,255}
Saved in: General.OptionsFileName

Mesh.Color.Fifteen
Color 15 in color carousel
Default value: {0,76,255}
Saved in: General.OptionsFileName

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

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

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

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


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

Back to geuz.org/gmsh