Contents     Functions         Previous Next     PDF Index



Finite element mesh handling utilities.


[out,out1] = feutil('CommandString',model,...)


feutil provides a number of tools for mesh creation and manipulation.

Some commands return the model structure whereas some others return only the element matrix. To mesh a complex structure one can mesh each subpart in a different model structure (model, mo1, ...) and combine each part using AddTest command. To handle complex model combination (not only meshes but whole models with materials, bases, ...), one can use the CombineModel command.

Available feutil commands are


Advanced command with non trivial input/output formats or detailed options are listed under feutila.



This command can be used to add new elements to a model. EltName gives the element name used to fill the header. data describes elements to add (one row per element). Following example adds celas elements to the basis of a simple cube model.

% Adding elements to a model 
femesh('Reset'); model=femesh('Testhexa8'); % simple cube model
data=[1 0 123 0 0 1 1e3; 2 0 123 0 0 1 1e3;
      3 0 123 0 0 1 1e3; 4 0 123 0 0 1 1e3]; % n1 n2 dof1 dof2 EltId ProId k

AddNode[,New] [, From i] [,epsl val]


Combine (without command option New) or append (with command option New) NewNode to OldNode. Without command option New, AddNode combines NewNode to OldNode: it finds nodes in NewNode that coincide with nodes in OldNode and appends other nodes to form AllNode. With command option New, AddNode simply appends NewNode to OldNode.

AllNode is the new node matrix with added nodes. ind (optional) gives the indices of the NewNode nodes in the AllNode matrix.

NewNode can be specified as a matrix with three columns giving xyz coordinates. The minimal distance below which two nodes are considered identical is given by sdtdef epsl (default 1e-6).

[AllNode,ind]=feutil('AddNode From 10000',OldNode,NewNode); gives node numbers starting at 10000 for nodes in NewNode that are not in OldNode.

SDT uses an optimized algorithm available in feutilb.

By default, nodes that repeated in NewNode are coalesced onto the same node (a single new node is added). If there is not need for that coalescence, you can get faster results with AddNode-nocoal.

ind=feutilb('AddNode -near epsl value',n1,n2); returns a sparse matrix with non zero values in a given colum indicating of n1 nodes that are within epsl of each n2 node (rows/columns correspond to n1/n2 node numbers).

id=feutilb('AddNode -nearest epsl value',n1,xyz); returns vector giving the nearest n1 NodeId to each xyz node the search area being limited to epsl. When specified with a 7 column n2, the result is sparse(n2(:,1),1,n1_index). For fine meshes the algorithm can use a lot of memory. If n2 is not too large it is then preferable to use an AddNode command with a tolerance sufficient for a match [n3,ind]=feutil('AddNode epsl value',n1,n2);id=n3(ind,1).

AddSet[NodeId, EltId, FaceId, EdgeId]

Command AddSet packages the generation of sets in an SDT model. Depending on the type of set several command options can apply.

The option -id value can be added to the command to specify a set ID.

By default the generated set erases any previously existing set with the same name, regardless of the type. Command option New alters this behavior by incrementing the set name. One can use the command second output to recover the new name.

Command option -Append allows generation of a meta-set. The meta-set is an agglomeration of several sets of possibly various types, see set for more information.

By default command AddSet returns the model as a first output and possibly the set data structure in a second output. Command option -get alters this behavior returning the data set structure without adding it to the model. For FaceId or EdgeId sets, command option -get can output the elements selected by the FindEltString.

Following example defines a set of each type on the ubeam model:

% Defining node elements or face sets in a model
model=demosdt('demo ubeam'); 
% Add a set of NodeId, and recover set data structure
% Add a set of EltId 
model=feutil('AddSetEltId -id18',model,'eltset','WithNode{z==0}');
% Generate a set of EltId without model addition
data=feutil('AddSetEltId -id18 -get',model,'eltset','WithNode{z==0}');
% Generate a set of FaceId
model=feutil('AddSetFaceId',model,'faceset','SelFace & InNode{z==0}');
% Generate a set of FaceId without model addition
[data1,elt]=feutil('AddSetFaceId -get',model,'faceset','SelFace & WithNode{z==0}');

% Sample visalization commands
cf=feplot; % get feplot handle
[elt,ind]=feutil('FindElt setname  eltset',model); % FindElt based on set name
cf.sel='setname faceset'; % element selection based on a FaceId set

% Lower level set handling
% Generate a FaceSet from an EltSet
% Generate a DOF set from a node set
% Visualize set data in promodel stack
fecom(cf,'curtab Stack','eltset');

AddTest[,-EGID i][,NodeShift,Merge,Combine]

model=feutil('AddTest',mo1,mo2); Combine models. When combining test and analysis models you typically want to overlay a detailed finite element mesh with a coarse wire-frame representation of the test configuration. These models coming from different origins you will want combine the two models in model.

Note that the earlier objective of combining test and FEM models is now more appropriately dealt with using SensDof entries, see  section 4.6 for sensor definitions and section 3.1 for test/analysis correlation. If you aim at combining several finite element models into an assembly, with proper handling of materials, element IDs, bases,…, you should rather use the more appropriate CombineModel command.

Divide div1 div2 div3

model=feutil('Divide div1 div2 div3',model);
Mesh refinement by division of elements. Divide applies to all groups in model.Elt. To apply the division to a selection within the model use ObjectDivide.

Division directions div1 div2 div3 are here understood in the local element basis, thus depending on the declared node orders in the connectivity matrix that refer to the reference cell. Uneven divisions as function of the direction will thus require some care regarding the element declaration if the original mesh has been heterogeneously generated.

Currently supported divisions are

The Divide command applies element transformation schemes on the element parent topological structure. By default, the original element names are maintained. In case of trouble, element names can be controlled by declaring the proper parent name or use the SetGroupName command before and after divide.

The division preserves properties other than the node numbers, in addition final node numbering/ordering will depend on the MATLAB version. It is thus strongly recommended not to base meshing scripts on raw NodeId.

You can obtain unequal divisions by declaring additional arguments whose lines give the relative positions of dividers. Note that this functionality has not been implemented for quadb and tria3 elements.

For example, an unequal 2 by 3 division of a quad4 element would be obtained using
model=feutil('divide',[0 .1 1],[0 .5 .75 1],model) (see also the gartfe demo).

% Refining a mesh by dividing the elements
% Example 1 : beam1
femesh('Reset'); model=femesh('Testbeam1');  % build simple beam model
model=feutil('Divide 3',model); % divide by 3
cf=feplot(model); fecom('TextNode'); % plot model and display NodeId

% Example 2 : you may create a command string
femesh('Reset'); model=femesh('Testbeam1');  % build simple beam model
st=sprintf('Divide %f',number);
cf=feplot(model); fecom('TextNode')

% Example 3 : you may use uneven division
femesh('Reset'); model=femesh('Testquad4');  % one quad4 created
model=feutil('Divide',model,[0 .1 .2 1],[0 .3 1]); 

An inconsistency in division for quad elements was fixed with version 1.105, you can obtain the consistent behavior (first division along element x) by adding the option -new anywhere in the divide command.


Finds groups that are not connected (no common node) and places each of these groups in a single element group.

DivideGroup i ElementSelectors

elt=feutil('DivideGroup i ElementSelector',model);
Divides a single group i in two element groups. The first new element group is defined based on the element selectors (see section 7.12).

For example elt=feutil('divide group 1 withnode{x>10}',model);


[EltId]=feutil('EltId',elt) returns the element identifier for each element in elt. It currently does not fill EltId for elements which do not support it.
[EltId,elt]=feutil('EltIdFix',elt) returns an elt where the element identifiers have been made unique.
Command option -elt can be used to set new EltId.
Command option -model can be used to set new EltId and renumber model Stack data, a model structure must be input, and the output is then the model.

% Handling elements IDs, renumbering elements
[EltId,model.Elt]=feutil('EltIdFix',model.Elt); % Fix and get EltId
[model.Elt,EltIdPos]=feutil('eltid-elt',model,EltId*18); % Set new EltId
model.Elt(EltIdPos>0,EltIdPos(EltIdPos>0)) % New EltId
% Renumber EltId with stack data

Extrude nRep tx ty tz

Extrusion. Nodes, lines or surfaces of model are extruded nRep times with global translations tx ty tz. Elements with a mass1 parent are extruded into beams, element with a beam1 parent are extruded into quad4 elements, quad4 are extruded into hexa8, and quadb are extruded into hexa20.

You can create irregular extrusion. For example, model=feutil('Extrude 0 0 0 1',model,[0 logspace(-1,1,5)]) will create an exponentially spaced mesh in the z direction. The second argument gives the positions of the sections for an axis such that tx ty tz is the unit vector.

% Extruding mesh parts to build a model
% Example 1 : beam
femesh('Reset'); model=femesh('Testbeam1'); % one beam1 created
model=feutil('Extrude 2 1 0 0',model); % 2 extrusions in x direction

% Example 2 : you may create the command string
number=2;step=[1 0 0];
st=sprintf('Extrude %f %f %f %f',[number step]);
femesh('Reset'); model=femesh('Testbeam1'); % one beam1 created

% Example 3 : you may uneven extrusions in z direction
femesh('Reset'); model=femesh('Testquad4');
model=feutil('Extrude 0 0 0 1',model,[0 .1 .2 .5 1]);
     % 0 0 0 1        :  1 extrusion in z direction
     % [0 .1 .2 .5 1] :  where extrusions are made

GetDof ElementSelectors

Command to obtain DOF from a model, or from a list of NodeId and DOF.

Use mdof=feutil('GetDof',dof,NodeId); to generate a DOF vector from a list of DOF indices dof, a column vector (e.g. dof=[.01;.02;.03]), and a list of NodeId, a column vector. The result will be sorted by DOF, equivalent to mdof = [NodeId+dof(1);NodeId+dof(2);...].

Call mdof=feutil('GetDof',NodeId,dof); will output a DOF vector sorted by NodeId, equivalent to mdof = [NodeId(1)+dof;NodeId(2)+dof;...].

The nominal call to get DOFs used by a model is mdof=feutil('GetDOF',model). These calls are performed during assembly phases (fe_mk, fe_load, ...). This supports elements with variable DOF numbers defined through the element rows or the element property rows. To find DOFs of a part of the model, you should add a ElementSelector string to the GetDof command string.

Note that node numbers set to zero are ignored by feutil to allow elements with variable number of nodes.

FindElt ElementSelectors

Find elements based on a number of selectors described in section 7.12. The calling format is

[ind,elt] = feutil('FindElt ElementSelector',model);

where ind gives the row numbers of the elements in model.Elt (but not the header rows except for unique superelements which are only associated to a header row) and elt (optional) the associated element description matrix.

When operators are accepted, equality and inequality operators can be used. Thus group~=[3 7] or pro < 5 are acceptable commands. See also SelElt, RemoveElt and DivideGroup, the gartfe demo, fecom selections.

FindNode Selectors

Find node numbers based on a number of node selectors listed in section 7.11.

Different selectors can be chained using the logical operations & (finds nodes that verify both conditions), | (finds nodes that verify one or both conditions). Condition combinations are always evaluated from left to right (parentheses are not accepted).

The calling format is
[NodeId,Node] = feutil('FindNode NodeSelector',model);

Output arguments are the NodeId of the selected nodes and the selected nodes Node as a second optional output argument.

As an example you can show node numbers on the right half of the z==0 plane using the commands

fecom('TextNode',feutil('FindNode z==0 & x>0',model))

Following example puts markers on selected nodes

% Finding nodes and marking/displaying them in feplot
demosdt('demo ubeam'); cf=feplot; % load U-Beam model
fecom('ShowNodeMark',feutil('FindNode z>1.25',cf.mdl),'color','r')
fecom('ShowNodeMark-noclear',feutil('FindNode x>0.2*z|x<-0.2*z',cf.mdl),...

Note that you can give numeric arguments to the command as additional feutil arguments. Thus the command above could also have been written feutil('FindNode z== & x>=',0,0))

See also the gartfe demo.


These feutil commands are used to create a model containing the 1D edges or 2D faces of a model. A typical call is

 % Generate a contour (nD-1) model from a nD model
 femesh('reset'); model=femesh('Testubeam');
 elt=feutil('GetEdgeLine',model); feutil('infoelt',elt)

GetEdgeLine supports the following variants MatId retains inter material edges, ProId retains inter property edges, Group retains inter group edges, all does not eliminate internal edges, InNode only retains edges whose node numbers are in a list given as an additional feutil argument.

These commands are used for SelEdge and SelFace element selection commands. Selface preserves the EltId and adds the FaceId after it to allow face set recovery.


Header row parsing. In an element description matrix, element groups are separated by header rows (see section 7.2) which for the current group jGroup is given by elt(EGroup(jGroup),:) (one can obtain EGroup - the positions of the headers in the element matrix - using [EGroup,nGroup]=getegroup(model.Elt)). The GetElemF command, whose proper calling format is

[ElemF,opt,ElemP] = feutil('GetElemF',elt(EGroup(jGroup),:),[jGroup])

returns the element/superelement name ElemF, element options opt and the parent element name ElemP. It is expected that opt(1) is the EGID (element group identifier) when defined.


Line=feutil('GetLine',node,elt) returns a matrix of lines where each row has the form [length(ind)+1 ind] plus trailing zeros, and ind gives node indices (if the argument node is not empty) or node numbers (if node is empty). elt can be an element description matrix or a connectivity line matrix (see feplot). Each row of the Line matrix corresponds to an element group or a line of a connectivity line matrix. For element description matrices, redundant lines are eliminated.

Patch=feutil('GetPatch',Node,Elt) returns a patch matrix where each row (except the first which serves as a header) has the form [n1 n2 n3 n4 EltN GroupN]. The ni give node indices (if the argument Node is not empty) or node numbers (if Node is empty). Elt must be an element description matrix. Internal patches (it is assumed that a patch declared more than once is internal) are eliminated.

The all option skips the internal edge/face elimination step. These commands are used in wire-frame and surface rendering.

GetNode Selectors

Node=feutil('GetNode Selectors',model) returns a matrix containing nodes rather than NodeIds obtained with the FindNode command. The indices of the nodes in model.Node can be returned as a 2nd optional output argument. This command is equivalent to the feutil call

[NodeId,Node]=feutil('FindNode Selectors',model).


[normal,cg]=feutil('GetNormal[elt,node]',model) returns normals to elements/nodes in model.
CG=feutil('GetCG',model) returns the CG locations. Command option -dir i can be used to specify a local orientation direction other than the normal (this is typically used for composites).
MAP=feutil('getNormal Map',model) returns a data structure with the following fields

IDcolumn of identifier (as many as rows in the .normal field). For .opt=2 contains the NodeId. For .opt=1 contains the EltId.
normalN× 3 where each row specifies a vector at ID or vertex.
opt1 for MAP at element center, 2 for map at nodes.
colorN× 1 optional real value used for color selection associated with the axes color limits.
DefLenoptional scalar giving arrow length in plot units.

The MAP data structure may be viewed using


Info[ ,Elt, Nodei]

feutil('Info',model); Information on model. Info by itself gives general information about model. InfoNodei gives information about all elements that are connected to node of NodeId i.

Join[group i, EltName]

Join the groups i or all the groups of type EltName. JoinAll joins all the groups that have the same element name. Note that with the selection by group number, you can only join groups of the same type (with the same element name). JoinAll joins all groups with identical element names.

You may join groups using there ID

% Joining groups of similar element types
femesh('Reset'); model=femesh('Test2bay');
% Join using group ID
feutil('Info',model);   % 2 groups at this step
model=feutil('JoinGroup1:2',model)  % 1 group now
% Join using element types
% Note you can give model (above) or element matrix (below)
femesh('Reset'); model=femesh('Test2bay'); 
model.Elt=feutil('Joinbeam1',model.Elt);  % 1 group now


MatId=feutil('MatId',model) returns the element material identifier for each element in model.Elt.
One can also modify MatId of the model giving a third argument. model=feutil('MatId',model,r1) r1 can be a global shift on all non zero MatId or a matrix whose first column gives old MatId and second new MatId. MatId renumbering is applyed to elements, and model.Stack 'mat' entries. The ProId command works similarly.
MPId returns a matrix with three columns MatId, ProId and group numbers.
model.Elt=feutil('mpid',model,mpid) can be used to set properties of elements in model.Elt matrix.


The command feutil('node [trans,rot,mir]',model,RO) allows to move model nodes (or part of a model with a provided selection) with standard transformations :

For each call, it is possible to either provide inputs as text string or as structure given on third argument with the field name corresponding to the wanted transformation.

An element selection can be provided in the text command (sel"EltSel") or as a text in a .sel field of the RO stucture to apply the transformation on only a part of the model. See FindElt.

Here is an exhaustive list of examples

model=femesh('test tetra4'); % Load model wontaining a tetrahedron
model.Node=feutil('addnode',model.Node,[0-1 0 0]); % Add a node
model.Elt=feutil('addelt',model.Elt,'mass1',5); % Set this node as a mass1 element
feplot(model); % Display
% Displacement transformations
% translation in the direction [1 0 0] sepcified in the text command
model=feutil('node trans 1 0 0',model); feplot(model); 
% rotation of 180deg arround the axis defined by node [1 0 0] and vector [0 0 1]
RO=struct('rot',[1 0 0  0 0 1 180]); % Structure defining the rotation as last argument
model=feutil('node -sel"group1"',model,RO); feplot(model); % Only node in "group1" are moved
% Rigid body transformation (matrix in field rb) on nodes in group1
RO=struct('rb',[1 0 0 -1;0 1 0 0;0 0 1 0;0 0 0 1],'sel','group1');
model=feutil('node',model,RO); feplot(model); 
% mirror transformation
% Plane y=0
model=feutil('node mir y',model); feplot(model); 
% Same plane definined with node [0 0 0] and normal [0 1 0]
model=feutil('node mir "o 0 0 0 0 1 0"',model); feplot(model); 
% Same plane definined with nodeid 1 2 4
model=feutil('node mir "nodeid 1 2 4"',model); feplot(model);
% Same plane definined with equation 0*x+1*y+0*z+0=0, given as last
% argument in a structure
RO=struct('eq',[0 1 0 0]);
model=feutil('node mir',model,RO); feplot(model);
% Mirror with respect to the "best" plane passing through the node list 
RO=struct('node',[0 -0.1 0;1 0 0;0 0 1;1 0.3 1],'sel','group1');
model=feutil('node mir',model,RO); feplot(model); 
fecom('shownodemark',[0 -0.1 0;1 0 0;0 0 1;1 0.3 1]); % Show nodes defining the plane

ObjectBeamLine i, ObjectMass i

elt=feutil('ObjectBeamLine i'); Create a group of beam1 elements. The node numbers i define a series of nodes that form a continuous beam (for discontinuities use 0), that is placed in elt as a single group of beam1 elements.

For example elt=feutil('ObjectBeamLine 1:3 0 4 5') creates a group of three beam1 elements between nodes 1 2, 2 3, and 4 5.

An alternate call is elt=feutil('ObjectBeamLine',ind) where ind is a vector containing the node numbers. You can also specify a element name other than beam1 and properties to be placed in columns 3 and more using elt=feutil('ObjectBeamLine -EltName',ind,prop).

elt=feutil('ObjectMass 1:3') creates a group of concentrated mass1 elements at the declared nodes.

% Build a mesh by addition of defined beam lines and masses
model=struct('Node',[1 0 0 0  0  0 0;   2 0 0 0  0  0 .15; ... 
                     3 0 0 0 .4  1 .176;4 0 0 0 .4 .9 .176], 'Elt',[]);
prop=[100 100 1.1 0 0]; % MatId ProId nx ny nz
model.Elt=feutil('ObjectBeamLine 1 2 0 2 3 0 3 4',prop);
% or model.Elt=feutil('ObjectBeamLine',1:4);
model.Elt=feutil('ObjectMass',model,3,[1.1 1.1 1.1]);
feplot(model);fecom textnode


model=feutil('ObjectHoleInPlate ...',model);

Create a quad4 mesh of a hole in a plate. The format is 'ObjectHoleInPlate N0 N1 N2 r1 r2 ND1 ND2 NQ' giving the center node, two nodes to define the edge direction and distance, two radiuses in the direction of the two edge nodes (for elliptical holes), the number of divisions along a half quadrant of edge 1 and edge 2, the number of quadrants to fill (the figure shows 2.5 quadrants filled).
% Build a model of a plate with a hole
model=struct('Node',[1 0 0 0  0 0 0; 2 0 0 0  1 0 0; 3 0 0 0  0 2 0],'Elt',[]);
model=feutil('ObjectHoleInPlate 1 2 3 .5 .5 3 4 4',model);
model=feutil('Divide 3 4',model); % 3 divisions around, 4 divisions along radii
% You could also use the call
model=struct('Node',[1 0 0 0  0 0 0; 2 0 0 0  1 0 0; 3 0 0 0  0 2 0],'Elt',[]);
%   n1 n2 n3 r1 r2 nd1 nd2 nq
r1=[ 1  2  3 .5 .5  3   4   4];
st=sprintf('ObjectHoleInPlate %f %f %f %f %f %f %f %f',r1);


model=feutil('ObjectHoleInBlock ...'); Create a hexa8 mesh of a hole in a rectangular block. The format is 'ObjectHoleInBlock x0 y0 z0 nx1 ny1 nz1 nx3 ny3 nz3 dim1 dim2 dim3 r nd1 nd2 nd3 ndr' giving the center of the block (x0 y0 z0), the directions along the first and third dimensions of the block (nx1 ny1 nz1 nx3 ny3 nz3, third dimension is along the hole), the 3 dimensions (dim1 dim2 dim3), the radius of the cylinder hole (r), the number of divisions of each dimension of the cube (nd1 nd2 nd3, the 2 first should be even) and the number of divisions along the radius (ndr).

% Build a model of a cube with a cylindrical hole
model=feutil('ObjectHoleInBlock 0 0 0  1 0 0  0 1 1  2 3 3 .7  8 8 3 2') 

Object[Quad,Beam,Hexa] MatId ProId

model=feutil('ObjectQuad MatId ProId',model,nodes,div1,div2) Create or add a model containing quad4 elements. The user must define a rectangular domain delimited by four nodes and the division in each direction (div1 and div2). The result is a regular mesh.

For example model=feutil('ObjectQuad 10 11',nodes,4,2) returns model with 4 and 2 divisions in each direction with a MatId 10 and a ProId 11.

An alternate call is model=feutil('ObjectQuad 1 1',model,nodes,4,2): the quadrangular mesh is added to the model.

% Build a mesh based on the refinement of a single quad element
node = [0  0  0; 2  0  0; 2  3  0; 0  3  0];
model=feutil('Objectquad 1 1',node,4,3); % creates model 

node = [3  0  0; 5  0  0; 5  2  0; 3  2  0];
model=feutil('Objectquad 2 3',model,node,3,2); % matid=2, proid=3

Divisions may be specified using a vector between [0,1] :

% Build a mesh based on the custom refinement of a single quad element
node = [0  0  0; 2  0  0; 2  3  0; 0  3  0];
model=feutil('Objectquad 1 1',node,[0 .2 .6 1],linspace(0,1,10)); 

Other supported object topologies are beams and hexahedrons. For example

% Build a mesh based on the custom refinement of a single element
node = [0  0  0; 2  0  0;1  3  0; 1  3  1];
model=feutil('Objectbeam 3 10',node(1:2,:),4); % creates model 
model=feutil('Objecthexa 4 11',model,node,3,2,5); % creates model 

Object [Arc, Annulus, Circle, Cylinder, Disk]

These object constructors follow the format

model=feutil('ObjectAnnulus x y z r1 r2 nx ny nz Nseg NsegR',model) with x y z the coordinates of the center, nx ny nz the coordinates of the normal to the plane containing the annulus, Nseg the number of angular subdivisions, and NsegR the number of segments along the radius. The resulting model is in quad4 elements.

model=feutil('ObjectArc x y z x1 y1 z1 x2 y2 z2 Nseg obt',model) with x y z the coordinates of the center, xi yi zi the coordinates of the first and second points defining the arc boundaries, Nseg the number of angular subdivisions, and obt for obtuse, set to 1 to get the shortest arc between the two points or -1 to get the complementary arc. The resulting model is in beam1 elements.

model=feutil('ObjectCircle xc yc zc r nx ny nz Nseg',model) with xc yc zc the coordinates of the center, r the radius, nx ny nz the coordinates of the normal to the plane containing the circle, and Nseg the number of angular subdivisions. The resulting model is in beam1 elements.

model=feutil('ObjectCylinder x1 y1 z1 x2 y2 z2 r divT divZ',model) with xi yi zi the coordinates of the centers of the cylinder base and top circles, r the cylinder radius, divT the number of angular subdivisions, and divZ the number of subdivisions in the cylinder height. The resulting model is in quad4 elements.

model=feutil('ObjectDisk x y z r nx ny nz Nseg NsegR',model) with x y z, the coordinates of the center, r the disk radius, nx ny nz the coordinates of the normal to the plane containing the disk, Nseg the number of angular subdivisions, and NsegR the number of segments along the radius. The resulting model is in quad4 elements. Command option -nodeg avoids degenerate    elements by transforming them into tria3 elements.

For example:

% Build a mesh based on simple circular topologies
model=feutil('object arc 0 0 0 1 0 0 0 1 0 30 1');
model=feutil('object arc 0 0 0 1 0 0 0 1 0 30 1',model);
model=feutil('object circle 1 1 1 2 0 0 1 30',model);
model=feutil('object circle 1 1 3 2 0 0 1 30',model);
model=feutil('object cylinder 0 0 0  0 0 4 2 10 20',model);
model=feutil('object disk 0 0 0 3 0 0 1 10 3',model);
model=feutil('object disk -nodeg 1 0 0 3 0 0 1 10 3',model);
model=feutil('object annulus 0 0 0 2 3 0 0 1 10 3',model);


Applies a Divide command to a selection within the model. This is a packaged call to RefineCell, one thus has access to the following command options:

% Perform local mesh refinement
node = [0  0  0; 2  0  0; 2  3  0; 0  3  0];
model=feutil('Objectquad 1 1',node,4,3); % creates model 
model=feutil('ObjectDivide 3 2',model,'WithNode 1');

% Perform a non uniform local mesh refinement with MPC
node = [0  0  0; 2  0  0; 2  3  0; 0  3  0];
model=feutil('Objectquad 1 1',node,4,3); % creates model 
model=feutil('ObjectDivide 3 2 -MPC',model,...
 'WithNode 1',[0 .2 1],[0 .25 .8 1]);
% display model and MPC constraint

Optim[Model, NodeNum, EltCheck]

model.Node=feutil('OptimModel',model) removes nodes unused in model.Elt from model.Node.
This command is very partial, a thorough model optimization is obtained using feutilb SubModel with groupall selection. model=feutilb('SubModel',model,'groupall');. To recover used nodes the most complete command is feutilb GetUsedNodes. model.Node=feutil('OptimNodeNum',model) does a permutation of nodes in model.Node such that the expected matrix bandwidth is smaller. This is only useful to export models, since here DOF renumbering is performed by fe_mk.
model=feutil('OptimEltCheck',model) attempts to fix geometry pathologies (warped elements) in quad4, hexa8 and penta6 elements.

model=feutil('OptimDegen',model) detects degenerate elements and replaces them by the proper lower node number case hexa -> penta.

Orient, Orient i [ , n nx ny nz]

Orient elements. For volumes and 2-D elements which have a defined orientation model.Elt=feutil('Orient',model) calls element functions with standard material properties to determine negative volume orientation and permute nodes if needed. This is in particular needed when generating models via Extrude or Divide operations which do not necessarily result in appropriate orientation (see integrules). When elements are too distorted, you may have a locally negative volume. A warning about warped volumes is then passed. You should then correct your mesh.

Note that for 2D meshes you need to use 2D element names (q4p, t3p, ...) rather than quad4, tria3, .... Typically model.Elt=feutil('setgroup1 name q4p',model).

Orient normal of shell elements. For plate/shell elements (elements with parents of type quad4, quadb or tria3) in groups i of model.Elt, model.Elt=feutil('Orient i n nx ny nz',model) command computes the local normal and checks whether it is directed towards the node located at nx ny nz. If not, the element nodes are permuted to that a proper orientation is achieved. A -neg option can be added at the end of the command to force orientation away rather than towards the nearest node.

model.Elt=feutil('Orient i',model,node) can also be used to specify a list of orientation nodes. For each element, the closest node in node is then used for the orientation. node can be a standard 7 column node matrix or just have 3 columns with global positions.

For example

% Specify element orientation
% Load example
femesh('Reset'); model=femesh('Testquad4'); 
model=feutil('Divide 2 3',model);
model.Elt=feutil('Dividegroup1 WithNode1',model); 
% Orient elements in group 2 away from [0 0 -1]
model.Elt=feutil('Orient 2 n 0 0 -1 -neg',model);
MAP=feutil('GetNormal MAP',model);MAP.normal

Quad2Lin, Lin2Quad, Quad2Tria, etc.

Basic element type transformations.

model=feutil('Lin2Quad epsl .01',model) is the generic command to generate second order meshes.
Lin2QuadCyl places the mid-nodes on cylindrical arcs.
Lin2QuadKnownNew can be used to get much faster results if it is known that none of the new mid-edge nodes is coincident with an existing node. Quad2Lin performs the inverse operation.
For this specific command many nodes become unecessary, command option -optim performs a cleanup by removing these nodes from the model, and its Stack and Case entries. Quad2Tria searches elements for quad4 element groups and replaces them with equivalent tria3 element groups.
Hexa2Tetra replaces each hexa8 element by four tetra4 elements (this is really not a smart thing to do).
Hexa2Penta replaces each hexa8 element by six tetra4 elements (warning : this transformation may lead to incompatibilities on the triangular faces).
Penta2Tetra replaces each penta6 element by 11 tetra4 elements.

Command option KnownNew can be used for Hexa2Tetra, Hexa2Penta, and Penta2Tetra. Since these commands add nodes to the structure, quicker results can be obtained if it is known that none of the new nodes are coincident with existing ones. In a more general manner, this command option is useful if the initial model features coincident but free surfaces (e.g. two solids non connected by topology, when using coupling matrices). The default behavior will add only one node for both surfaces thus coupling them, while the KnownNew alternative will add one for each.

% Transforming elements in a mesh, element type and order
% create 2x3 quad4 
femesh('Reset'); model=femesh('Testquad4'); 
model=feutil('Divide 2 3',model); 
model=feutil('Quad2Tria',model); % conversion
% create a quad, transform to triangles, divide each triangle in 4
femesh('Reset'); model=femesh('Testquad4');
cf=feplot(model); cf.model
% create a hexa8 and transform to hexa20
femesh('Reset'); model=femesh('Testhexa8');
model=feutil('Lin2Quad epsl .01',model);

RefineCell, Beam l, ToQuad

RemoveElt ElementSelectors

[model.Elt,RemovedElt]=feutil('RemoveElt ElementSelectors',model);

Element removal. This function searches model.Elt for elements which verify certain properties selected by ElementSelectors and removes these elements from the model description matrix. 2nd output argument RemovedElt is optional and contains removed elements. A sample call would be

% Removing elements in a model
% create 3x2 quad4 
femesh('Reset'); model=femesh('Testquad4');model=feutil('Divide 2 3',model); 
[model.Elt,RemovedElt]=feutil('RemoveElt WithNode 1',model);

Remove [Pro, Mat] MatId, ProId

Mat, Pro removal This function takes in argument the ID of a material or integration property and removes the corresponding entries in the model pl/il fields and in the stack mat/pro entries.

This call supports the info, Rayleigh stack entry (see sdtweb damp), so that the data entries referring to removed IDs will also be removed. By default, the non-linear properties are treated like normal properties. Care must thus be taken if a non-linear property that is not linked to specific elements is used. Command option -unused will alter this behavior and keep non-linear properties.

Sample calls are provided in the following to illustrate the use.

% Removing material and integration properties in a model
model=stack_set(model,'mat','steel',m_elastic('default steel'));
model=feutil('remove pro 110',model);
model=feutil('remove pro',model,111);
model=feutil('remove mat 100',model);
model=feutil('remove mat 100 pro 1',model);
model=feutil('remove pro -all',model); % Command option -all
model=feutil('remove mat pro -all',model);
model=femesh('testhexa8'); % Command option -unused
model=feutil('remove mat pro -unused',model);


model=feutil('Renumber',model'NewNodeNumbers) can be used to change the node numbers in the model. Currently nodes, elements, DOFs and deformations , nodeset, par, cyclic and other Case entries are renumbered.

NewNodeNumbers is the total new NodeIds vector. NewNodeNumbers can also be a scalar and then defines a global NodeId shifting. If NewNodeNumbers has two columns, first giving old NodeIds and second new NodeIds, a selective node renumbering is performed.

If NewNodeNumbers is not provided values 1:size(model.Node,1) are used. This command can be used to meet the OpenFEM requirement that node numbers be less than 2^31/100. Another application is to joint disjoint models with coincident nodes using

Command option -NoOri asks not to add the info,OrigNumbering data in the model stack. info,OrigNumbering is only useful when the user needs to convert something specific linked to the new node numerotation that is outside model.

% Finding duplicate nodes and merging them

Renumbering can also be applied to deformation curves, using the same syntax. Be aware however that to keep coherence between a deformation curve and a renumbered model, one should input NewNodeNumbers as the renumbered model stack entry info,OrigNumbering.

% Renumering the nodes of a model, and its data
% simple model
% simple curve
def=fe_eig(model,[5 5 1e3]);
% first renumber model
% then renumber def with renumbering info

RepeatSel nITE tx ty tz

Element group translation/duplication. RepeatSel repeats the elements of input model nITE times with global axis translations tx ty tz between each repetition of the group. If needed, new nodes are added to model.Node. An example is treated in the d_truss demo.

% Build a mesh by replicating and moving sub-parts
femesh('Reset'); model=femesh('Testquad4');
model=feutil('Divide 2 3',model); 
model=feutil('RepeatSel 3 2 0 0',model); % 3 repetitions, tx=2
% an alternate call would be
%                                            number, direction
% model=feutil(sprintf('Repeatsel %f %f %f %f', 3,  [2 0 0]))

Rev nDiv OrigID Ang nx ny nz

Revolution. The elements of model are taken to be the first meridian. Other meridians are created by rotating around an axis passing trough the node of number OrigID (or the origin of the global coordinate system) and of direction [nx ny nz] (the default is the z axis [0 0 1]). nDiv+1 (for closed circle cases ang=360, the first and last are the same) meridians are distributed on a sector of angular width Ang (in degrees). Meridians are linked by elements in a fashion similar to extrusion. Elements with a mass1 parent are extruded into beams, element with a beam1 parent are extruded into quad4 elements, quad4 are extruded into hexa8, and quadb are extruded into hexa20.

The origin can also be specified by the x y z values preceded by an o using a command like model=feutil('Rev 10 o 1.0 0.0 0.0 360 1 0 0').

You can obtain an uneven distribution of angles using a second argument. For example model=feutil('Rev 0 101 40 0 0 1',model,[0 .25 .5 1]) will rotate around an axis passing by node 101 in direction z and place meridians at angles 0 10 20 and 40 degrees.

% Build a mesh by revolving a sub-part
model=struct('Node',[1 0 0 0  .2 0   0; 2 0 0 0  .5 1 0; ...  
                     3 0 0 0  .5 1.5 0; 4 0 0 0  .3 2 0],'Elt',[]);
model=feutil('Divide 3',model);
model=feutil('Rev 40 o 0 0 0 360 0 1 0',model);
fecom(';triax;view 3;showpatch')
% An alternate calling format would be
%      divi origin angle direct
% r1 = [40  0 0 0  360   0 1 0];
% model=feutil(sprintf('Rev %f o %f %f %f %f %f %f %f',r1))

RotateNode OrigID Ang nx ny nz

Rotation. The nodes of model are rotated by the angle Ang (degrees) around an axis passing trough the node of number OrigID (or the origin of the global coordinate system) and of direction [nx ny nz] (the default is the z axis [0 0 1]). The origin can also be specified by the x y z values preceded by an o model=feutil('RotateNode o 2.0 2.0 2.0 90 1 0 0',model) One can define as a second argument a list of NodeId or a FindNode string command to apply rotation on a selected set of nodes. model=feutil('RotateNode o 2.0 2.0 2.0 90 1 0 0',model,'x==1')

For example:

% Rotating somes nodes in a model
femesh('reset'); model=femesh('Testquad4'); model=feutil('Divide 2 3',model); 
% center is node 1, angle 30, aound axis z
%                                     Center angle  dir
st=sprintf('RotateNode %f %f %f %f %f',[1      30   0 0 1]);
feplot(model); fecom(';triax;textnode'); axis on

Similar operations can be realized using command basisgnode.

SelElt ElementSelectors

elt=feutil('SelElt ElementSelectors',model)

Element selection. SelElt extract selected element from model that verify certain conditions. Available element selection commands are described under the FindElt command and section 7.12.

SetGroup[i,name] [Mat j, Pro k, EGID e, Name s]

Set properties of a group. For group(s) selected by number i, name name, or all you can modify the material property identifier j, the element property identifier k of all elements and/or the element group identifier e or name s. For example

 % Assigning element properties by groups
 model.Elt=feutil('SetGroup1:3 Pro 4',model);
 model.Elt=feutil('SetGroup rigid Name celas',model) 

If you know the column of a set of element rows that you want to modify, calls of the form model.Elt(feutil('FindEltSelectors',model),Column)= Value can also be used. See MPID for higher level custom element properties assignments.

 % Low level assignment of element properties
 femesh('Reset'); model=femesh('Testubeamplot');
 model.Elt(feutil('FindElt WithNode{x==-.5}',model),9)=2;


Set an integration property data (ProId) or material property (MatId). You can modify an il or pl property of ID i by giving its name and its value using an integrated call of the type

% Specifying material/integration rule parameters in a model
 model=feutil('SetPro 111 IN=2',model,'MAP',struct('dir',1,'DOF',.01));
 mat=feutil('GetPl 100 -struct1',model) % Get Mat 100 as struct

The names related to the integration properties a documented in the p_functions, p_solid, p_shell, p_beam, ... To get a type use calls of the form p_pbeam('PropertyUnitTypeCell',1).

The command can also be used to define additional property information : pro.MAP for field at nodes (section ??), gstate for field at integration points and NLdata for non linear behavior data (nl_spring).

The GetPro and GetMat commands are the pending commands. For example:

 rho=feutil('GetMat 100 rho',model) % get volumic mass
 integ=feutil('GetPro 111 IN',model) % get the integ rule


The commands GetIl and GetPl respectively output the il and pl matrices of the model for the IDs used by elements. This command provides the values used during assembling procedures and aggregates the values stores in the, fields and pro, mat entries in the model stack.


feutil('stringdof',sdof) returns a cell array with cells containing string descriptions of the DOFs in sdof.

SymSel OrigID nx ny nz

Plane symmetry. SymSel replaces elements in FEel0 by elements symmetric with respect to a plane going through the node of number OrigID (node 0 is taken to be the origin of the global coordinate system) and normal to the vector [nx ny nz]. If needed, new nodes are added to FEnode. Related commands are TransSel, RotateSel and RepeatSel.


Convert the ldraw trace line matrix (see ufread 82 for format details) to element matrix with beam1 elements. For example:

% Build a beam model from a trace line matrix
TEST.Node=[1001 0 0 0 0 0 0    ; 1003 0 0 0 0.2 0 0 ;
           1007 0 0 0 0.6 0 0  ; 1009 0 0 0 0.8 0 0 ;
           1015 0 0 0 0 0.2 0  ; 1016 0 0 0 0.2 0.2 0;
           1018 0 0 0 0.6 0.2 0; 1019 0 0 0 0.8 0.2 0]; 
L=[1001 1003 1007 1009];  
ldraw(1,[1 82+[1:length(L)]])=[length(L) L]; 
L=[1015 1016 1018 1019];
ldraw(2,[1 82+[1:length(L)]])=[length(L) L]; 
L=[1015 1001 0 1016 1003 0 1018 1007 0 1019 1009 0];
ldraw(3,[1 82+[1:length(L)]])=[length(L) L];

TransSel tx ty tz

Translation of the selected element groups. TransSel replaces elements by their translation of a vector [tx ty tz] (in global coordinates). If needed, new nodes are added. Related commands are SymSel, RotateSel and RepeatSel.

% Translate and transform a mesh part
femesh('Reset'); model=femesh('Testquad4'); model=feutil('Divide 2 3',model); 
model=feutil('TransSel 3 1 0',model); % Translation of [3 1 0]
feplot(model); fecom(';triax;textnode')

Please, note that this command is usefull to translate only part of a model. If the full model must be translated, use basiscommand gnode. An example is given below.

% Translate all nodes of a model
femesh('Reset'); model=femesh('Testquad4'); model=feutil('Divide 2 3',model); 
feplot(model); fecom(';triax;textnode')

UnJoin Gp1 Gp2

Duplicate nodes which are common to two element ensembles. To allow the creation of interfaces with partial coupling of nodal degrees of freedom, UnJoin determines which nodes are common to the specified element ensembles.

The command duplicates the common nodes between the specified element ensembles, and changes the node numbers of the second element ensemble to correspond to the duplicate set of nodes. The optional second output argument provides a two column matrix that gives the correspondence between the initial nodes and the duplicate ones. This matrix is coherent with the OrigNumbering matrix format.

The following syntaxes are accepted

 % Generate a disjointed interface between to parts in a model
femesh('Reset'); model=femesh('Test2bay');
feutil('FindNode group1 & group2',model) % nodes 3 4 are common

% Implicit call for group
mo1=feutil('UnJoin 1 2',model);
feutil('FindNode group1 & group2',mo1) % no common nodes in unjoined model
% Variant by specifying selections
mo1=feutil('UnJoin',model,'group 1','group 2');
feutil('FindNode group1 & group2',mo1) % no common nodes in unjoined model

% Variant with structure input, type "group"
feutil('FindNode group1 & group2',mo1) % no common nodes in unjoined model

% Variant with structure input, type "eltid" and string selections
RA=struct('type','eltid','sel1','group1','sel2','group 2');
feutil('FindNode group1 & group2',mo1) % no common nodes in unjoined model

% Advanced variants with structure and with selections as vectors
% Clean model EltId
i1=feutil('findelt group1',model);
i2=feutil('findelt group2',model);

% type "eltid"
feutil('FindNode group1 & group2',mo1) % no common nodes in unjoined model

% type "eltind"
feutil('FindNode group1 & group2',mo1) % no common nodes in unjoined model

See also

feutila, fe_mk, fecom, feplot, section 4.5, demos gartfe, d_ubeam, beambar ...

©1991-2017 by SDTools
Previous Up Next