Skip to content
Snippets Groups Projects
gmsh.texi 206 KiB
Newer Older
Christophe Geuzaine's avatar
Christophe Geuzaine committed
\input texinfo.tex @c -*-texinfo-*-
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@c Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@c See the LICENSE.txt file for license information. Please report all
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@c bugs and problems to the public mailing list <gmsh@geuz.org>.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@c =========================================================================
@c
@c This is the Gmsh documentation texinfo source file
@c
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c Things to do -> "Ctrl+s todo:" 
@c
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c Indexing:
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@c
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c * @cindex = concept index, e.g. "File formats"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c * @tindex + @findex = type + function index, e.g. "Sqrt(expression)"
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@c
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c Before release, run C-u C-c C-u C-a in GNU Emacs. This updates all node
@c pointers and menus.
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@c 
@c =========================================================================
@c %**start of header
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@setfilename gmsh.info
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@set GMSH-VERSION 2.7
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@set COPYRIGHT @copyright{} 1997-2013 Christophe Geuzaine, Jean-Fran@,{c}ois Remacle
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@settitle Gmsh @value{GMSH-VERSION}
@footnotestyle separate
@setchapternewpage odd
@paragraphindent 0
@finalout
@c %**end of header

@c merge function index into type index
@syncodeindex fn tp

@c =========================================================================
@c Info directives
@c =========================================================================

@ifinfo
@dircategory Math
@direntry
* Gmsh: (gmsh).  3D finite element mesh generator with built-in pre- and
post-processing facilities
@end direntry
@noindent
This is the @cite{Gmsh Reference Manual} for Gmsh @value{GMSH-VERSION}
(@today{}).
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@noindent
Copyright @value{COPYRIGHT}
@end ifinfo

@c =========================================================================
@c Title page
@c =========================================================================

@shorttitlepage Gmsh

@titlepage

@title Gmsh Reference Manual

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@subtitle The documentation for Gmsh @value{GMSH-VERSION}
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@subtitle A finite element mesh generator with built-in pre- and post-processing facilities
@subtitle 
@subtitle @today{}
Christophe Geuzaine's avatar
Christophe Geuzaine committed

@author Christophe Geuzaine
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@author Jean-Fran@,{c}ois Remacle
Christophe Geuzaine's avatar
Christophe Geuzaine committed

@page
@vskip 0pt plus 1filll
Copyright @value{COPYRIGHT}
@sp 1
Permission is granted to make and distribute verbatim copies of this manual
provided the copyright notice and this permission notice are preserved on
all copies.

@end titlepage

@c =========================================================================
@c Table of contents
@c =========================================================================

Christophe Geuzaine's avatar
Christophe Geuzaine committed
@summarycontents
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@contents

@c =========================================================================
@c Top node (for all output, except TeX)
@c =========================================================================

@ifnottex
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@node Top, Obtaining Gmsh, (dir), (dir)
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@top Gmsh

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Christophe Geuzaine and Jean-Fran@,{c}ois Remacle
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Gmsh is an automatic 3D finite element mesh generator with build-in pre-
and post-processing facilities. This is the @cite{Gmsh Reference Manual}
for Gmsh @value{GMSH-VERSION} (@today{}).
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@end ifnottex

@c =========================================================================
@c Master menu
@c =========================================================================

@menu
Christophe Geuzaine's avatar
Christophe Geuzaine committed
* Obtaining Gmsh::              Where to get your copy of Gmsh
* Copying conditions::          Terms and conditions of use
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Overview::                    What is Gmsh?
* How to read this manual?::    Which parts of this manual should you read (if any)?
Christophe Geuzaine's avatar
Christophe Geuzaine committed
* Running Gmsh on your system::  How can you run Gmsh on your machine?
* General tools::               Description of general commands and options
* Geometry module::             Description of all Geometry commands
* Mesh module::                 Description of all Mesh commands
* Solver module::               Description of all Solver commands
* Post-processing module::      Description of all Post-Processing commands
* File formats::                Input and output file formats
* Tutorial::                    A step-by-step tutorial
* Options::                     List of all available options
* Information for developers::  Info for Gmsh developers
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Frequently asked questions::  The Gmsh FAQ
* Version history::             Changelog
* Copyright and credits::       Copyright information and list of contributors
* License::                     Complete copy of the license
* Concept index::               Index of concepts
* Syntax index::                Index of reserved keywords in the Gmsh language
Christophe Geuzaine's avatar
Christophe Geuzaine committed

@detailmenu
 --- The Detailed Node Listing ---

Overview

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Geometry::                    
* Mesh::                        
* Solver::                      
* Post-processing::             
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* What Gmsh is pretty good at::  
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* and what Gmsh is not so good at::  

How to read this reference manual?

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Syntactic rules::             
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Running Gmsh on your system

* Interactive mode::            
* Non-interactive mode::        
* Command-line options::        
* Mouse actions::               
* Keyboard shortcuts::          

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
General tools

* Comments::                    
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Expressions::                 
* Operators::                   
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Built-in functions::          
* User-defined functions::      
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Loops and conditionals::      
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* General commands::            
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* General options::             

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Expressions 

* Floating point expressions::  
* Character expressions::       
* Color expressions::           

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Geometry module

* Geometry commands::           
* Geometry options::            

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Geometry commands

* Points::                      
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Lines::                       
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Surfaces::                    
* Volumes::                     
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Extrusions::                  
* Transformations::             
* Miscellaneous geometry commands::  
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Mesh module

Christophe Geuzaine's avatar
Christophe Geuzaine committed
* Choosing the right unstructured algorithm::  
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Elementary vs physical entities::  
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Mesh commands::               
* Mesh options::                

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Mesh commands

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Structured grids::            
* Miscellaneous mesh commands::  

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Solver module

* Solver options::              

Post-processing module

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Post-processing commands::    
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Post-processing plugins::     
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Post-processing options::     
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
File formats

* MSH ASCII file format::       
* MSH binary file format::      
* Node ordering::               
* Legacy formats::              
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

* MSH file format version 1.0::  
* POS ASCII file format::       
* POS binary file format::      
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Tutorial

* t1.geo::                      
* t2.geo::                      
* t3.geo::                      
* t4.geo::                      
* t5.geo::                      
* t6.geo::                      
* t7.geo::                      
* t8.geo::                      
* t9.geo::                      
Christophe Geuzaine's avatar
Christophe Geuzaine committed
* t10.geo::                     
* t11.geo::                     
* t12.geo::                     
Christophe Geuzaine's avatar
Christophe Geuzaine committed
* t13.geo::                     
Christophe Geuzaine's avatar
Christophe Geuzaine committed
* t14.geo::                     
Options

* General options list::        
* Geometry options list::       
* Mesh options list::           
* Solver options list::         
* Post-processing options list::  

Information for developers
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

* Getting the source::          
* Source code structure::       
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Coding style::                
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Frequently asked questions

* The basics::                  
* Installation problems::       
* General questions::           
* Geometry module questions::   
* Mesh module questions::       
* Solver module questions::     
* Post-processing module questions::  

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@end detailmenu
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@end menu

Christophe Geuzaine's avatar
Christophe Geuzaine committed
@c =========================================================================
@c Obtaining Gmsh
@c =========================================================================

@node Obtaining Gmsh, Copying conditions, Top, Top
@unnumbered Obtaining Gmsh

@cindex Web site
@cindex Internet address
@cindex Download

Christophe Geuzaine's avatar
Christophe Geuzaine committed
The source code and various pre-compiled versions of Gmsh (for Windows,
Mac and Unix) can be downloaded from @uref{http://geuz.org/gmsh/}.
Christophe Geuzaine's avatar
Christophe Geuzaine committed
Gmsh is also directly available in pre-packaged form in various Linux
and BSD distributions (Debian, Ubuntu, FreeBSD, ...).

If you use Gmsh, we would appreciate that you mention it in your work by
citing the following paper: ``C. Geuzaine and J.-F. Remacle, @emph{Gmsh:
a three-dimensional finite element mesh generator with built-in pre- and
post-processing facilities}. International Journal for Numerical Methods
in Engineering, Volume 79, Issue 11, pages 1309-1331, 2009''.  A
preprint of that paper as well as other references and the latest news
about Gmsh development are available on
@uref{http://geuz.org/gmsh/}. 

Christophe Geuzaine's avatar
Christophe Geuzaine committed
@c =========================================================================
@c Copying Conditions
@c =========================================================================

Christophe Geuzaine's avatar
Christophe Geuzaine committed
@node Copying conditions, Overview, Obtaining Gmsh, Top
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@unnumbered Copying conditions

@cindex Copyright
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@cindex License
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Gmsh is ``free software''; this means that everyone is free to use it and
to redistribute it on a free basis. Gmsh is not in the public domain; it is
copyrighted and there are restrictions on its distribution, but these
restrictions are designed to permit everything that a good cooperating
citizen would want to do.  What is not allowed is to try to prevent others
from further sharing any version of Gmsh that they might get from you.

Specifically, we want to make sure that you have the right to give away
copies of Gmsh, that you receive source code or else can get it if you want
it, that you can change Gmsh or use pieces of Gmsh in new free programs,
and that you know you can do these things.

To make sure that everyone has such rights, we have to forbid you to deprive
anyone else of these rights.  For example, if you distribute copies of
Gmsh, you must give the recipients all the rights that you have.  You must
make sure that they, too, receive or can get the source code.  And you must
tell them their rights.

Also, for our own protection, we must make certain that everyone finds out
that there is no warranty for Gmsh.  If Gmsh is modified by someone else
and passed on, we want their recipients to know that what they have is not
what we distributed, so that any problems introduced by others will not
reflect on our reputation.

The precise conditions of the license for Gmsh are found in the General
Public License that accompanies the source code (@pxref{License}). Further
information about this license is available from the GNU Project webpage
@uref{http://www.gnu.org/copyleft/gpl-faq.html}.  Detailed copyright
information can be found in @ref{Copyright and credits}.

Christophe Geuzaine's avatar
Christophe Geuzaine committed
If you want to integrate parts of Gmsh into a closed-source software, or
want to sell a modified closed-source version of Gmsh, you will need to
obtain a different license. Please @uref{http://geuz.org, contact us
directly} for more information.
Christophe Geuzaine's avatar
Christophe Geuzaine committed

@c =========================================================================
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c Overview
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@c =========================================================================

@node Overview, How to read this manual?, Copying conditions, Top
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@chapter Overview
Christophe Geuzaine's avatar
Christophe Geuzaine committed

@cindex Introduction
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@cindex Overview
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Gmsh is a three-dimensional finite element grid generator with a
build-in CAD engine and post-processor. Its design goal is to provide
a fast, light and user-friendly meshing tool with parametric input and
advanced visualization capabilities.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Gmsh is built around four modules: geometry, mesh, solver and
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
post-processing. All geometrical, mesh, solver and post-processing
instructions are prescribed either interactively using the graphical
user interface (GUI) or in text files using Gmsh's own scripting
language.  Interactive actions generate language bits in the input
files, and vice versa. This makes it possible to automate all
treatments, using loops, conditionals and external system calls. A brief
description of the four modules is given hereafter.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@menu
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* Geometry::                    
* Mesh::                        
* Solver::                      
* Post-processing::             
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* What Gmsh is pretty good at::  
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
* and what Gmsh is not so good at::  
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@end menu
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c -------------------------------------------------------------------------
@c Geometry: geometrical entity definition
@c -------------------------------------------------------------------------

@node Geometry, Mesh, Overview, Overview
@section Geometry: geometrical entity definition

Gmsh uses a boundary representation (``BRep'') to describe geometries.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Models are created in a bottom-up flow by successively defining points,
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
oriented lines (line segments, circles, ellipses, splines, @dots{}),
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
oriented surfaces (plane surfaces, ruled surfaces, triangulated
Christophe Geuzaine's avatar
Christophe Geuzaine committed
surfaces, @dots{}) and volumes. Groups of geometrical entities (called
``physical groups'') can also be defined, based on these elementary
geometric entities. Gmsh's scripting language allows all geometrical
entities to be fully parametrized.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

@c -------------------------------------------------------------------------
@c Mesh: finite element mesh generation
@c -------------------------------------------------------------------------

@node Mesh, Solver, Geometry, Overview
@section Mesh: finite element mesh generation

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
A finite element mesh is a tessellation of a given subset of the
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
three-dimensional space by elementary geometrical elements of various
shapes (in Gmsh's case: lines, triangles, quadrangles, tetrahedra,
prisms, hexahedra and pyramids), arranged in such a way that if two of
them intersect, they do so along a face, an edge or a node, and never
otherwise. All the finite element meshes produced by Gmsh are considered
as ``unstructured'', even if they were generated in a ``structured'' way
(e.g., by extrusion). This implies that the elementary geometrical
elements are defined only by an ordered list of their nodes but that no
predefined order relation is assumed between any two elements.

The mesh generation is performed in the same bottom-up flow as the
geometry creation: lines are discretized first; the mesh of the lines is
then used to mesh the surfaces; then the mesh of the surfaces is used to
mesh the volumes. In this process, the mesh of an entity is only
constrained by the mesh of its boundary. For example, in three
dimensions, the triangles discretizing a surface will be forced to be
faces of tetrahedra in the final 3D mesh only if the surface is part of
the boundary of a volume; the line elements discretizing a curve will be
forced to be edges of tetrahedra in the final 3D mesh only if the curve
is part of the boundary of a surface, itself part of the boundary of a
volume; a single node discretizing a point in the middle of a volume
will be forced to be a vertex of one of the tetrahedra in the final 3D
mesh only if this point is connected to a curve, itself part of the
boundary of a surface, itself part of the boundary of a volume. This
automatically assures the conformity of the mesh when, for example, two
surfaces share a common line. But this also implies that the
discretization of an ``isolated'' (@var{n}-1)-th dimensional entity
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
inside an @var{n}-th dimensional entity does @emph{not} constrain the
@var{n}-th dimensional mesh---unless it is explicitly told to do so
(@pxref{Miscellaneous mesh commands}).  Every meshing step is
constrained by a ``size field'' (sometimes called ``characteristic
length field''), which prescribes the desired size of the elements in
the mesh. This size field can be uniform, specified by values associated
with points in the geometry, or defined by general ``fields'' (for
example related to the distance to some boundary, to a arbitrary scalar
field defined on another mesh, etc.).
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
For each meshing step, all structured mesh directives are executed
first, and serve as additional constraints for the unstructured parts
@footnote{Note that mixing structured volume grids with unstructured
volume grids generated with the default 3D Delaunay algorithm can
result, in certain cases, to non-conform surface meshes on their shared
boundary. If this happens, you may consider using the frontal algorithm
for the unstructured part.}.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

@c -------------------------------------------------------------------------
@c Solver: external solver interface
@c -------------------------------------------------------------------------

@node Solver, Post-processing, Mesh, Overview
@section Solver: external solver interface

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
External solvers can be interfaced with Gmsh through Unix or TCP/IP
Christophe Geuzaine's avatar
Christophe Geuzaine committed
sockets, which permits to modify solver parameters, launch external
computations and process the results directly from within Gmsh's
post-processing module. The default solver interfaced with Gmsh is GetDP
(@uref{http://geuz.org/getdp/}). Examples on how to interface other
solvers are available in the source distribution (in the
@file{utils/solvers/} directory).
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

@c -------------------------------------------------------------------------
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c Post-processing: scalar, vector and tensor field visualization
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c -------------------------------------------------------------------------

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@node Post-processing, What Gmsh is pretty good at, Solver, Overview
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@section Post-processing: scalar, vector and tensor field visualization

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Gmsh can load and manipulate multiple post-processing scalar, vector or
tensor maps along with the geometry and the mesh. Scalar fields are
represented by iso-value lines/surfaces or color maps, while vector
fields are represented by three-dimensional arrows or displacement
maps. Post-processing functions include section computation, offset,
elevation, boundary and component extraction, color map and range
modification, animation, vector graphic output, etc. All the
post-processing options can be accessed either interactively or through
the input script files. Scripting permits to automate all
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
post-processing operations, as for example to create
animations. User-defined operations can also be performed on
post-processing views through dynamically loadable plugins.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c -------------------------------------------------------------------------
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c What Gmsh is pretty good at...
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c -------------------------------------------------------------------------

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@node What Gmsh is pretty good at, and what Gmsh is not so good at, Post-processing, Overview
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@section What Gmsh is pretty good at @dots{}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Here is a tentative list of what Gmsh does best:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@itemize @bullet
@item
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
quickly describe simple and/or ``repetitive'' geometries, thanks to
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
user-defined functions, loops, conditionals and includes (see
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@ref{User-defined functions}, @ref{Loops and conditionals}, and @ref{General
commands});
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@item
parametrize these geometries. Gmsh's scripting language enables all
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
commands and command arguments to depend on previous calculations (see
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@ref{Expressions}, and @ref{Geometry commands});
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@item
generate 1D, 2D and 3D simplicial (i.e., using line segments, triangles
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
and tetrahedra) finite element meshes for CAD models in their native
format (without translations) when linked with the appropriate CAD
kernel (see @ref{Mesh module});
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@item
Christophe Geuzaine's avatar
Christophe Geuzaine committed
specify target element sizes accurately. Gmsh provides several
mechanisms to control the size of the elements in the final mesh:
through interpolation from sizes specified at geometry points or using
flexible mesh size fields (@pxref{Mesh commands});
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@item
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
create simple extruded geometries and meshes (see @ref{Geometry commands},
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
and @ref{Mesh commands});
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@item
Christophe Geuzaine's avatar
Christophe Geuzaine committed
interact with external solvers through a simple client-server
architecture (@pxref{Solver module});
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@item
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
visualize and export computational results in a great variety of
ways. Gmsh can display scalar, vector and tensor datasets, perform
various operations on the resulting post-processing views
Christophe Geuzaine's avatar
Christophe Geuzaine committed
(@pxref{Post-processing module}), can export plots in many different
formats (@pxref{General options list}), and can generate complex
animations (see @ref{General tools}, and @ref{t8.geo});
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@item
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
run on low end machines and/or machines with no graphical
interface. Gmsh can be compiled with or without the GUI, and all
versions can be used either interactively or directly from the command
line (@pxref{Running Gmsh on your system});
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@item
configure your preferred options. Gmsh has a large number of
configuration options that can be set interactively using the GUI,
scattered inside command files, changed on the fly in scripts, set in
per-user configuration files, or specified on the command-line (see
@ref{Running Gmsh on your system} and @ref{Options});
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@item
and do all the above on various platforms (Windows, Mac and Unix), for
free (@pxref{Copying conditions}), using simple script files and/or a
small but powerful GUI.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@end itemize
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c -------------------------------------------------------------------------
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c ... and what Gmsh is not so good at
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c -------------------------------------------------------------------------
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

@node and what Gmsh is not so good at, Bug reports, What Gmsh is pretty good at, Overview
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@section @dots{} and what Gmsh is not so good at
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
Christophe Geuzaine committed
As of version 2.7, here are some known weaknesses of Gmsh:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@itemize @bullet
@item
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
the BRep approach for describing geometries can become
inconvenient/inefficient for large models. For complex models, or if you
want to use a solid-modeler approach, you should link Gmsh with an
external CAD kernel and import native files directly. (The binary
versions available on @uref{http://geuz.org/gmsh/} are linked with the
free CAD kernel OpenCASCADE, which enables native BREP import as well as
STEP and IGES import.)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@item
Christophe Geuzaine's avatar
Christophe Geuzaine committed
Gmsh's internal CAD engine is fairly limited: it only handles simple
primitives and does not perform any complex geometrical operations
(e.g. no calculation of intersections). For such features you should
link Gmsh with an external CAD kernel (see above).
@item
Gmsh is not a multi-bloc mesh generator: all meshes produced by Gmsh are
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
conforming in the sense of finite element meshes;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@item
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Gmsh's user interface is only exposing a limited number of the available
features, and many aspects of the interface could be enhanced
(especially manipulators).
@item
Gmsh's scripting language is fairly limited, providing only very crude
loop controls and user-defined functions, with no local variables.
@item
there is no global ``undo'' capability. You will often need to edit a
text file to correct mistakes.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@end itemize
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

If you have the skills and some free time, feel free to join the
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
project: we gladly accept any code contributions (@pxref{Information for
developers}) to remedy the aforementioned (and all other) shortcomings!

@c -------------------------------------------------------------------------
@c Bug reports
@c -------------------------------------------------------------------------

@node Bug reports,  , and what Gmsh is not so good at, Overview
@section Bug reports

@cindex Bugs, reporting
@cindex Reporting bugs
@cindex Contact information
@cindex Mailing list
@cindex Authors, e-mail
@cindex E-mail, authors

Christophe Geuzaine's avatar
Christophe Geuzaine committed
If you think you have found a bug in Gmsh, you can report it by email to
Christophe Geuzaine's avatar
Christophe Geuzaine committed
the public Gmsh mailing list at @email{gmsh@@geuz.org}, or file it directly
Christophe Geuzaine's avatar
Christophe Geuzaine committed
into our bug tracking database at @url{https://geuz.org/trac/gmsh/report} 
(login: gmsh, password: gmsh). Please send as precise a description of
the problem as you can, including sample input files that produce the
bug. Don't forget to mention both the version of Gmsh and the version of
your operation system (@pxref{Command-line options} to see how to get
this information).
See @ref{Frequently asked questions}, and the bug tracking system to see
which problems we already know about.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

@c =========================================================================
@c How to read this manual?
@c =========================================================================

@node How to read this manual?, Running Gmsh on your system, Overview, Top
@chapter How to read this reference manual?

Gmsh can be used at three levels:

@enumerate
@item
as a stand-alone graphical program, driven by an interactive graphical
user interface (GUI);
@item 
as a stand-alone script-driven program;
@item
as a library.
@end enumerate

You can skip most of this reference manual if you only want to use Gmsh
at the first level (i.e., interactively with the GUI). Just read the
next chapter (@pxref{Running Gmsh on your system}) to learn how to
Christophe Geuzaine's avatar
Christophe Geuzaine committed
launch Gmsh on your system, then go experiment with the GUI and the
tutorial files (@pxref{Tutorial}) provided in the distribution.
Screencasts that show how to use the GUI are available here:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@uref{http://geuz.org/gmsh/screencasts/}.

The aim of the reference manual is to explain everything you need to use
Gmsh at the second level, i.e., using the built-in scripting language.
A Gmsh script file is an ASCII text file that contains instructions in
Gmsh's built-in scripting language. Such a file is interpreted by Gmsh's
parser, and can be given any extension (or no extension at all). By
convention, Gmsh uses the @file{.geo} extension for geometry scripts,
and the @file{.pos} extension for parsed post-processing datasets. Once
you master the tutorial (read the source files: they are heavily
commented!), start reading chapter @ref{General tools}, then proceed
with the next four chapters, which detail the syntax of the geometry,
mesh, solver and post-processing scripting commands. You will see that
most of the interactive actions in the GUI have a direct equivalent in
the scripting language. If you want to use Gmsh as a pre- or
post-processor for your own software, you will also want to learn about
the non-scripting input/output files that Gmsh can read/write. In
addition to Gmsh's native ``MSH'' file format (@pxref{File formats}),
Gmsh can read/write many standard mesh files, depending on how it was
built: check the `File->Save As' menu for a list of available formats.

Finally, to use Gmsh at the third level (i.e., to link the Gmsh library
with your own code), you will need to learn the internal Gmsh
Application Programming Interface (API). No complete documentation of
this API is available yet; a good starting point is @ref{Source code
structure}, which gives a short introduction to Gmsh's internal source
code structure. Then have a look e.g. at the examples in the
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@file{utils/api_demos/} directory in the source code. Due to the many
possible configuration options (and associated external dependencies),
we currently do not distibute precompiled versions of the Gmsh
library. To build the library see the instructions in the top-level
@file{README.txt} file in the source distribution.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c -------------------------------------------------------------------------
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c -------------------------------------------------------------------------

@menu
* Syntactic rules::             
@end menu

@node Syntactic rules,  , How to read this manual?, How to read this manual?
@section Syntactic rules used in the manual
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

@cindex Syntax, rules
@cindex Rules, syntactic
@cindex Document syntax

Here are the rules we tried to follow when writing this reference
manual. Note that metasyntactic variable definitions stay valid
throughout the manual (and not only in the sections where the
definitions appear).
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

@enumerate
@item 
Keywords and literal symbols are printed like @code{this}.
@item 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Metasyntactic variables (i.e., text bits that are not part of the syntax,
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
but stand for other text bits) are printed like @var{this}.
@item 
A colon (@code{:}) after a metasyntactic variable separates the variable
from its definition.
@item 
Optional rules are enclosed in @code{<} @code{>} pairs.
@item 
Multiple choices are separated by @code{|}.
@item 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
Three dots (@dots{}) indicate a possible (multiple) repetition of the
preceding rule.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@end enumerate

@c =========================================================================
@c Running Gmsh on your system
@c =========================================================================

@node Running Gmsh on your system, General tools, How to read this manual?, Top
@chapter Running Gmsh on your system

@cindex Operating system
@cindex Running Gmsh

@menu
* Interactive mode::            
* Non-interactive mode::        
* Command-line options::        
* Mouse actions::               
* Keyboard shortcuts::          
@end menu

@c -------------------------------------------------------------------------
@c Interactive mode
@c -------------------------------------------------------------------------

@node Interactive mode, Non-interactive mode, Running Gmsh on your system, Running Gmsh on your system
@section Interactive mode

@cindex Interactive mode

To launch Gmsh in interactive mode, just double-click on the Gmsh icon,
or type

@example
> gmsh
@end example

@noindent at your shell prompt in a terminal. This will open
Christophe Geuzaine's avatar
Christophe Geuzaine committed
the main Gmsh window, with a tree-like menu on the left, a graphic area
Christophe Geuzaine's avatar
Christophe Geuzaine committed
on the right, and a status bar at the bottom. (You can detach the tree
menu using `Window->Attach/Detach Menu'.)

To open the first tutorial file (@pxref{Tutorial}), select the
Christophe Geuzaine's avatar
Christophe Geuzaine committed
`File->Open' menu, and choose @file{t1.geo}. When using a terminal, you
can specify the file name directly on the command line, i.e.:

@example
> gmsh t1.geo
@end example

To perform the mesh generation, go to the mesh module (by selecting
Christophe Geuzaine's avatar
Christophe Geuzaine committed
`Mesh' in the tree) and choose the dimension (`1D' will mesh all the
lines; `2D' will mesh all the surfaces---as well as all the lines if
`1D' was not called before; `3D' will mesh all the volumes---and all the
surfaces if `2D' was not called before). To save the resulting mesh in
the current mesh format click on `Save', or select the appropriate
format and file name with the `File->Save As' menu. The default mesh
file name is based on the name of the current active model, with an
appended extension depending on the mesh format@footnote{Nearly all the
interactive commands have keyboard shortcuts: see @ref{Keyboard
shortcuts}, or select `Help->Keyboard and Mouse Usage' in the menu. For
example, to quickly save a mesh, you can press @kbd{Ctrl+Shift+s}.}.

To create a new geometry or to modify an existing geometry, select
Christophe Geuzaine's avatar
Christophe Geuzaine committed
'Geometry' in the tree.  For example, to create a spline, select
`Elementary', `Add', `New' and `Spline'. You will then be asked to
select a list of points, and to type @kbd{e} to finish the selection (or
@kbd{q} to abort it). Once the interactive command is completed, a text
string is automatically added at the end of the current script file. You
can edit the script file by hand at any time by pressing the `Edit'
button in the `Geometry' menu and then reloading the model by pressing
`Reload'. For example, it is often faster to define variables and points
directly in the script file, and then use the GUI to define the lines,
the surfaces and the volumes interactively.

Several files can be loaded simultaneously in Gmsh. When specified on
the command line, the first one defines the active model and the others
are `merged' into this model. You can merge such files with the
`File->Merge' menu. For example, to merge the post-processing views
contained in the files @file{view1.pos} and @file{view5.msh} together
with the geometry of the first tutorial @file{t1.geo}, you can type the
following command:

@example
> gmsh t1.geo view1.pos view5.msh
@end example

Christophe Geuzaine's avatar
Christophe Geuzaine committed
In the Post-Processing module (select `Post-Processing' in the tree),
three items will appear, respectively labeled `A scalar map', `Nodal
scalar map' and `Element 1 vector'. In this example the views contain
several time steps: you can loop through them with the small
``remote-control'' icons in the status bar. A mouse click on the view
name will toggle the visibility of the selected view, while a click on
the arrow button on the right will provide access to the view's options.

Note that all the options specified interactively can also be directly
specified in the script files. You can save the current options of the
Christophe Geuzaine's avatar
Christophe Geuzaine committed
current active model with the `File->Save Model Options'. This will
create a new option file with the same filename as the active model, but
with an extra @file{.opt} extension added. The next time you open this
model, the associated options will be automatically loaded, too.  To
save the current options as your default preferences for all future Gmsh
Christophe Geuzaine's avatar
Christophe Geuzaine committed
sessions, use the `File->Save Options As Default' menu instead. Finally,
you can also save the current options in an arbitrary file by choosing
the `Gmsh options' format in `File->Save As'.
For more information about available options (and how to reset them to
Christophe Geuzaine's avatar
Christophe Geuzaine committed
their default values), see @ref{Options}. A full list of options with
their current values is also available in the `Help->Current Options'
menu.
@c -------------------------------------------------------------------------
@c Non-interactive mode
@c -------------------------------------------------------------------------

@node Non-interactive mode, Command-line options, Interactive mode, Running Gmsh on your system
@section Non-interactive mode

@cindex Non-interactive mode

Gmsh can be run non-interactively in `batch' mode, without
GUI@footnote{If you compile Gmsh without the GUI, this is the only mode
you have access to.}. For example, to mesh the first tutorial in batch
mode, just type:

@example
> gmsh t1.geo -2
@end example

To mesh the same example, but with the background mesh available in the file
@file{bgmesh.pos}, type:

@example
> gmsh t1.geo -2 -bgm bgmesh.pos
@end example

For the list of all command-line options, see @ref{Command-line options}.

@c -------------------------------------------------------------------------
@c Command-line options
@c -------------------------------------------------------------------------

@node Command-line options, Mouse actions, Non-interactive mode, Running Gmsh on your system
@section Command-line options

@cindex Command-line options
@cindex Options, command-line

@include commandline.texi

@c -------------------------------------------------------------------------
@c Mouse actions
@c -------------------------------------------------------------------------

@node Mouse actions, Keyboard shortcuts, Command-line options, Running Gmsh on your system
@section Mouse actions

@cindex Mouse, actions
@cindex Bindings, mouse

@include mouse.texi
For a 2 button mouse, Middle button = Shift+Left button.
For a 1 button mouse, Middle button = Shift+Left button, Right button = Alt+Left button.

@c -------------------------------------------------------------------------
@c Keyboard shortcuts
@c -------------------------------------------------------------------------

@node Keyboard shortcuts,  , Mouse actions, Running Gmsh on your system
@section Keyboard shortcuts

@cindex Keyboard, shortcuts
@cindex Shortcuts, keyboard
@cindex Bindings, keyboard

(On Mac Ctrl is replaced by Cmd (the `Apple key') in the shortcuts
below.)

@include shortcuts.texi
@c =========================================================================
@c General tools
@c =========================================================================

@node General tools, Geometry module, Running Gmsh on your system, Top
@chapter General tools

This chapter describes the general commands and options that can be used
in Gmsh's script files. By ``general'', we mean ``not specifically
related to one of the geometry, mesh, solver or post-processing
modules''. Commands peculiar to these modules will be introduced in
@ref{Geometry module}, @ref{Mesh module}, @ref{Solver module}, and
@ref{Post-processing module}, respectively.

@menu
* Comments::                    
* Expressions::                 
* Operators::                   
* Built-in functions::          
* User-defined functions::      
* Loops and conditionals::      
* General commands::            
* General options::             
@end menu

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c -------------------------------------------------------------------------
@c Comments
@c -------------------------------------------------------------------------

@node Comments, Expressions, General tools, General tools
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@section Comments

@cindex Comments
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@cindex File, comments
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@findex /*, */
@findex //
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Gmsh script files support both C and C++ style comments:
Christophe Geuzaine's avatar
Christophe Geuzaine committed

@enumerate
@item
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
any text comprised between @code{/*} and @code{*/} pairs is ignored;
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@item
the rest of a line after a double slash @code{//} is ignored.
@end enumerate

These commands won't have the described effects inside double quotes or
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
inside keywords. Also note that `white space' (spaces, tabs, new line
characters) is ignored inside all expressions.
Christophe Geuzaine's avatar
Christophe Geuzaine committed

@c -------------------------------------------------------------------------
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c Expressions
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@c -------------------------------------------------------------------------

@node Expressions, Operators, Comments, General tools
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@section Expressions 
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@cindex Expressions, definition
@cindex Constants
Christophe Geuzaine's avatar
Christophe Geuzaine committed

The two constant types used in Gmsh scripts are @var{real} and
@var{string} (there is no integer type).  These types have the same
meaning and syntax as in the C or C++ programming languages.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

@menu
* Floating point expressions::  
* Character expressions::       
* Color expressions::           
@end menu

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@c .........................................................................
@c Floating point expressions
@c .........................................................................

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@node Floating point expressions, Character expressions, Expressions, Expressions
@subsection Floating point expressions

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@cindex Expressions, floating point
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@cindex Real numbers
@cindex Numbers, real
@cindex Floating point numbers

Floating point expressions (or, more simply, ``expressions'') are denoted by
the metasyntactic variable @var{expression} (remember the definition of the
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
syntactic rules in @ref{Syntactic rules}), and are evaluated during the
Christophe Geuzaine's avatar
Christophe Geuzaine committed

@example
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
@var{expression}:
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  @var{real} |
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  @var{string} |
  @var{string} [ @var{expression} ] |
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  # @var{string} [ ] |
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  ( @var{expression} ) |
  @var{operator-unary-left} @var{expression} |
  @var{expression} @var{operator-unary-right} |
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  @var{expression} @var{operator-binary} @var{expression} |
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  @var{expression} @var{operator-ternary-left} @var{expression} @var{operator-ternary-right} @var{expression} |
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  @var{built-in-function} |
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  @var{real-option} |
  StrFind(@var{char-expression}, @var{char-expression}) |
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  TextAttributes(@var{char-expression}<,@var{char-expression}@dots{}>)|
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  GetValue("@var{string}", @var{expression})
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@end example

Such @w{@var{expression}s} are used in most of Gmsh's scripting
commands.  The third and fourth cases in this definition permit to
extract one item from a list (see below) and get the size of a list,
respectively. The operators @var{operator-unary-left},
@var{operator-unary-right}, @var{operator-binary},
@var{operator-ternary-left} and @var{operator-ternary-right} are defined
in @ref{Operators}. For the definition of @w{@var{built-in-function}s},
see @ref{Built-in functions}. The various @w{@var{real-option}s} are
listed in @ref{Options}. @code{StrFind} searches the first
@var{char-expression} for any occurrence of the second
Christophe Geuzaine's avatar
Christophe Geuzaine committed
@var{char-expression}. @code{TextAttributes} creates attributes for text
strings.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
The last case in the definition allows to ask the user for a value
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
interactively. For example, inserting @code{GetValue("Value of parameter