Contents     Functions              PDF Index

## fe_gmsh

Purpose

Information about GMSH can be found at http://www.geuz.org/gmsh/

To call the GMSH mesher from SDT.

Syntax

```  model=fe_gmsh(command,model,...);
```

Description

The main operation is the automatic meshing of surfaces.

### Example

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=femesh('model0');
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);delete('temp.msh')
```

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',model,[1 2; 2 4; 4 3; 3 1]);
model=fe_gmsh('AddFullCircle',model,[.5 .5 0; .4 .5 0; 0 0 1]);

model.Stack{3}.LineLoop={'Line',[1 2 3 4];'Circle',[1 2 3 4]};
model.Stack{3}.PlaneSurface=[1 2];

mo2=fe_gmsh('write holeinplate.geo -lc .02 -run -2 -v 0',model)
feplot(mo2)
```

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

 .Line one line per row referencing NodeId. Can be defined using addline commands. .Circle define properties of circles. .LineLoop rows 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. .PlaneSurface rows 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. .SurfaceLoop rows 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. The option -lc .3 in the command resets the value for all nodes that do not have a prior value.

mdl=fe_gmsh('AddFullCircle',mdl,data) can be used to add to geometry in mdl the circle defined in data. First row of data is the center coordinates, second row is an edge node coordinates and the third row is the normal. 4 arcs of circle are added. One can then define the full circle as a row in the LineLoop field with {'Circle',[ind1 ind2 ind3 ind4]} where indi are the row indices of the 4 arcs of circle created in .Circle field.
mdl=fe_gmsh('AddCircleArc',mdl,data) can be used to add to geometry in mdl a circle arc defined in data. First row of data is the center coordinates, second and third rows are respectively the first and second edges defined by node coordinates. The geometry is added in field .Circle, and can be integrated in a lineloop.
mdl=fe_gmsh('AddLine',mdl,data) can be used to add to geometry in mdl the lines defined in data. data can be a 2 column matrix which each row defines a couple of points from their NodeId. data can also be a 2 by 3 matrix defining the 2 extremities coordinates. data can also be a string defining a line selection.

### config

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

``` setpref('OpenFEM','gmsh','\$HOME_GMSH/gmsh.exe')
```

### Write

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.

• Command option -lc allows specifying a characteristic length.
• Command option -multiple can be used for automated meshing of several closed contours. The default behavior will define a single Plane Surface combining all contours, while -mutliple variant will declare each contour as a single Plane Surface.
• .stl writing format is also supported, by using extension .stl instead of .geo in the command line.
• Command option -run allows to run gmsh on the written file for meshing. All characters in the command after -run will be passed to the gmsh batch call performed. fe_gmsh then outputs the model processed by gmsh, which is usually written in .msh file format.
• Conversion of files through fe_gmsh into .msh, or SDT/OpenFEM format is possible, for all input files readable by gmsh. Use command option -run and specify in second arguement the file name.
For example: model=fe_gmsh('write -run','FileName.stl)' will allow opening a .stl file in SDT/OpenFem. Some warning can occur if no FileName is given, but without effect on the result. You may have to specify the meshing dimension (-1 or -2 or -3) after the -run command option to obtain a proper conversion. It also possible to add a diffrent output file name NewFile.msh, using model=fe_gmsh('write NewFile.msh -run','FileName.stl)'.