Contents     Functions         Previous Next     PDF Index



Information about GMSH can be found at

To call the GMSH mesher from SDT.




The main operation is the automatic meshing of surfaces.


This example illustrates the automatic meshing of a plate

 FEnode = [1 0 0 0  0 0 0; 2 0 0 0  1 0 0; 3 0 0 0  0 2 0];
 femesh('objectholeinplate 1 2 3 .5 .5 3 4 4');
 model.Elt=feutil('selelt seledge ',model);
 model.Node=feutil('getnode groupall',model);
 model.Node(:,4)=0; % reset default length
 mo1=fe_gmsh('write temp.geo -lc .3 -run -2 -v 0',model);

This other example makes a circular hole in a plate

% Hole in plate :
model=feutil('Objectquad 1 1',[0 0 0; 1 0 0;1 1 0;0 1 0],1,1); %
model=fe_gmsh('addline -loop1',model,[1 2; 2 4]);
model=fe_gmsh('addline -loop1',model,[4 3; 3 1]);
model=fe_gmsh('AddFullCircle -loop2',model,[.5 .5 0; .4 .5 0; 0 0 1]);
model.Stack{end}.PlaneSurface=[1 2]; 
mo1=fe_gmsh('write tmp.geo -lc .02 -run -2 -v 0',model)

To allow automated running of GMSH from MATLAB, this function uses a info,GMSH stack entry with the following fields

.Lineone line per row referencing NodeId. Can be defined using addline commands.
.Circledefine properties of circles.
.LineLooprows define a closed line as combination of elementary lines. Values are row indices in the .Line field. One can also define LineLoop from circle arcs (or mixed arcs and lines) using a cell array whose each row describes a lineloop as {'LineType',LineInd,...} where LineType can be Circle or Line and LineInd row indices in corresponding .Line or .Circle field.
.TransfiniteLinesDefines lines which seeding is controlled.
.PlaneSurfacerows define surfaces as a combination of line loops, values are row indices in the .LineLoop field. Negative values are used to reverse the line orientation. 1st column describes the exterior contour, and followings the interiors to be removed. As .PlaneSurface is a matrix, extra columns can be filled by zeros.
.EmbeddedLinesdefine line indices which do not define mesh contours but add additional constrains to the final mesh (see Line In Surface in the gmsh documentation.
.SurfaceLooprows define a closed surface as combination of elementary surfaces. Values are row indices in the .PlaneSurface field.

The local mesh size is defined at nodes by GMSH. This is stored in column 4 of the model.Node. Command option -lcval in the command resets the value val for all nodes that do not have a prior value.


Typical calls are of the form [mdl,RO]=fe_gmsh('Add Cmd',mdl,data). The optional second output argument can be used to obtain additional information like the LoopInfo. Accepted command options are


The fe_gmsh function uses the OpenFEM preference to launch the GMSH mesher.



Command Ver returns the version of gmsh, the version is transformed into a double to simplify hierarchy handling (e.g. version 2.5.1 is transformed into 251). This command alos provides a good test to check your gmsh setup as the output will be empty if gmsh could not be found.


fe_gmsh('read FileName.msh') reads a mesh from the GMSH output format.


fe_gmsh('write FileName.geo',model); writes a model (.Node, .Elt) and geometry data in model.Stack'info','GMSH' into a .geo file which root name is specified as FileName.

See also


©1991-2012 by SDTools
Previous Up Next