SDT-base Contents   Functions      PDF Index |
Purpose
Finite element mesh handling utilities.
Syntax
femesh CommandString femesh('CommandString') [out,out1] = femesh('CommandString',in1,in2)
Description
You should use feutil function that provides equivalent commands to femesh but using model data structure.
femesh provides a number of tools for mesh creation and manipulation. femesh uses global variables to define the proper object of which to apply a command. femesh uses the following standard global variables which are declared as global in your workspace when you call femesh
FEnode | main set of nodes |
FEn0 | selected set of nodes |
FEn1 | alternate set of nodes |
FEelt | main finite element model description matrix |
FEel0 | selected finite element model description matrix |
FEel1 | alternate finite element model description matrix |
By default, femesh automatically uses base workspace definitions of the standard global variables (even if they are not declared as global). When using the standard global variables within functions, you should always declare them as global at the beginning of your function. If you don't declare them as global modifications that you perform will not be taken into account, unless you call femesh from your function which will declare the variables as global there too. The only thing that you should avoid is to use clear (instead of clear global) within a function and then reinitialize the variable to something non-zero. In such cases the global variable is used and a warning is passed.
Available femesh commands are
Command chaining. Commands with no input (other than the command) or output argument, can be chained using a call of the form femesh(';Com1;Com2'). commode is then used for command parsing.
Combine two FE model description matrices. The characters i and j can specify any of the main t, selected 0 and alternate 1 finite element model description matrices. The elements in the model matrix FEelj are appended to those of FEeli.
AddSel is equivalent to AddFEeltFEel0 which adds the selection FEel0 to the main model FEelt.
This is an example of the creation of FEelt using 2 selections (FEel0 and FEel1)
femesh('Reset'); femesh('Testquad4'); % one quad4 created femesh('Divide',[0 .1 .2 1],[0 .3 1]); % divisions FEel0=FEel0(1:end-1,:); % suppress 1 element in FEel0 femesh('AddSel'); % add FEel0 into FEelt FEel1=[Inf abs('tria3');9 10 12 1 1 0];% create FEel1 femesh('Add FEelt FEel1'); % add FEel1 into FEelt femesh PlotElt % plot FEelt
Combine, append (without/with new) FEn0 to FEnode. Additional uses of AddNode are provided using the format
[AllNode,ind]=femesh('AddNode',OldNode,NewNode);
which combines NewNode to OldNode. AddNode finds nodes in NewNode that coincide with nodes in OldNode and appends other nodes to form AllNode. ind 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]=femesh('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. See feutil AddNode for more details.
Combine test and analysis 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 FEelt.
By default the node sets are considered to be disjoint. New nodes are added starting from max(FEnode(:,1))+1 or from NodeShift+1 if the argument is specified. Thus femesh('addtest NodeShift',TNode,TElt) adds test nodes TNode to FEnode while adding NodeShift to their initial identification number. The same NodeShift is added to node numbers in TElt which is appended to FEelt. TElt can be a wire frame matrix read with ufread.
With merge it is assumed that some nodes are common but their numbering is not coherent. femesh('addtest merge',NewNode,NewElt) can also be used to merge to FEM models. Non coincident nodes (as defined by the AddNode command) are added to FEnode and NewElt is renumbered according to the new FEnode. Merge-Edge is used to force mid-side nodes to be common if the end nodes are.
With combine it is assumed that some nodes are common and their numbering is coherent. Nodes with new NodeId values are added to FEnode while common NodeId values are assumed to be located at the same positions.
You can specify an EGID value for the elements that are added using AddTest -EGID -1. In particular negative EGID values are display groups so that they will be ignored in model assembly operations.
The combined models can then be used to create the test/analysis correlation using fe_sens. An application is given in the gartte demo, where a procedure to match initially different test and FE coordinate frames is outlined.
Mesh refinement by division of elements. Divide applies to all groups in FEel0.
See equivalent feutil Divide command.
% Example 1 : beam1 femesh('Reset'); femesh(';Testbeam1;Divide 3;PlotEl0'); % divide by 3 fecom TextNode % Example 2 : you may create a command string number=3; st=sprintf(';Testbeam1;Divide %f;PlotEl0',number); femesh('Reset'); femesh(st); fecom TextNode % Example 3 : you may use uneven division femesh('Reset');femesh('testquad4'); % one quad4 created femesh('DivideElt',[0 .1 .2 1],[0 .3 1]); femesh PlotEl0
Finds groups of FEel0 elements that are not connected (no common node) and places each of these groups in a single element group.
femesh('Reset');femesh('testquad4'); % one quad4 created femesh('RepeatSel 2 0 0 1'); % 2 quad4 in the same group femesh('DivideInGroups'); % 2 quad4 in 2 groups
Divides a single group i of FEelt in two element groups. The first new element group is defined based on the element selectors (see section 7.12).
Extrusion. Nodes, lines or surfaces that are currently selected (put in FEel0) are extruded nRep times with global translations tx ty tz.
You can create irregular extrusion giving a second argument (positions of the sections for an axis such that tx ty tz is the unit vector).
See feutil Extrude for more details.
% Example 1 : beam femesh('Reset'); femesh('Testbeam1'); % one beam1 created femesh(';Extrude 2 1 0 0;PlotEl0'); % 2 extrusions in x direction % Example 2 : you may create the command string number=2;step=[1 0 0]; st=sprintf(';Testbeam1;Extrude %f %f %f %f',[number step]); femesh('Reset'); femesh(st); femesh PlotEl0 % Example 3 : you may use uneven extrusions in z direction femesh('Reset'); femesh('Testquad4') femesh('Extrude 0 0 0 1', [0 .1 .2 .5 1]); % % 0 0 0 1 : 1 extrusion in z direction % [0 .1 .2 .5 1] : where extrusions are made femesh PlotEl0
Find elements based on a number of selectors described in section 7.12. The calling format is
[ind,elt] = femesh('FindElt withnode 1:10')
where ind gives the row numbers of the elements (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. FindEl0 applies to elements in FEel0.
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.
Find node numbers based on a number of 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).
Output arguments are the numbers 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',femesh('FindNode z==0 & x>0'))
Following example puts markers on selected nodes
model=demosdt('demo ubeam'); femesh(model); % load U-Beam model fecom('ShowNodeMark',femesh('FindNode z>1.25'),'color','r') fecom('ShowNodeMark',femesh('FindNode x>0.2*z|x<-0.2*z'),... 'color','g','marker','o')
Note that you can give numeric arguments to the command as additional femesh arguments. Thus the command above could also have been written
fecom('TextNode',femesh('FindNode z== & x>=',0,0)))
See also the gartfe demo.
Information on global variables. Info by itself gives information on all variables. The additional arguments FEelt ... can be used to specify any of the main t, selected 0 and alternate 1 finite element model description matrices. InfoNodei gives information about all elements that are connected to node i. To get information in FEelt and in FEnode, you may write
femesh('InfoElt') or femesh('InfoNode')
Join the groups i or all the groups of type EName. JoinAll joins all the groups that have the same element name. By default this operation is applied to FEelt but you can apply it to FEel0 by adding the el0 option to the command. Note that with the selection by group number, you can only join groups of the same type (with the same element name).
femesh('Reset'); femesh(';Test2bay;PlotElt'); % Join using group ID femesh('InfoElt'); % 2 groups at this step femesh JoinGroup1:2 % 1 group now % Join using element name femesh('Reset'); femesh('Test2bay;PlotElt'); femesh Joinbeam1 % 1 group now
model=femesh('Model') returns the FEM structure (see section 7.6) with fields model.Node=FEnode and model.Elt=FEelt as well as other fields that may be stored in the FE variable that is persistent in femesh. model=femesh('Model0') uses model.Elt=FEel0.
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 FEel0 as a single group of beam1 elements.
For example femesh('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 femesh('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 femesh('ObjectBeamLine -EltName',ind,prop).
femesh('ObjectMass 1:3') creates a group of concentrated mass1 elements at the declared nodes.
femesh('Reset') FEnode = [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]; prop=[100 100 1.1 0 0]; % MatId ProId nx ny nz femesh('ObjectBeamLine',1:4,prop);femesh('AddSel'); %or femesh(';ObjectBeamLine 1 2 0 2 3 0 3 4;AddSel'); % or femesh('ObjectBeamLine',1:4); femesh('ObjectMass',3,[1.1 1.1 1.1]) femesh AddSel femesh PlotElt; fecom TextNode
Create a quad4 mesh of a hole in a plate. The format is 'ObjectHoleInPlate N0 N1 N2 r1 r2 ND1 ND2 NQ'. See feutil ObjectHoleInPlate for more details.
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'); femesh('Divide 3 4'); % 3 divisions around, 4 divisions along radii femesh PlotEl0 % You could also use the call FEnode = [1 0 0 0 0 0 0; 2 0 0 0 1 0 0; 3 0 0 0 0 2 0]; % 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); femesh(st); femesh('PlotEl0')
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'. See feutil ObjectHoleInBlock for more details.
femesh('Reset') femesh('ObjectHoleInBlock 0 0 0 1 0 0 0 1 1 2 3 3 .7 8 8 3 2') femesh('PlotEl0')
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. The result is a regular mesh.
For example femesh('ObjectQuad 10 11',nodes,4,2) returns model with 4 and 2 divisions in each direction with a MatId 10 and a ProId 11.
femesh('reset'); node = [0 0 0; 2 0 0; 2 3 0; 0 3 0]; femesh('Objectquad 1 1',node,4,3); % creates model femesh('AddSel');femesh('PlotElt') node = [3 0 0; 5 0 0; 5 2 0; 3 2 0]; femesh('Objectquad 2 3',node,3,2); % matid=2, proid=3 femesh('AddSel');femesh('PlotElt');femesh Info
Divisions may be specified using a vector between [0,1] :
node = [0 0 0; 2 0 0; 2 3 0; 0 3 0]; femesh('Objectquad 1 1',node,[0 .2 .6 1],linspace(0,1,10)); femesh('PlotEl0');
Other supported object topologies are beams and hexahedrons. For example
femesh('Reset') node = [0 0 0; 2 0 0;1 3 0; 1 3 1]; femesh('Objectbeam 3 10',node(1:2,:),4); % creates model femesh('AddSel'); femesh('Objecthexa 4 11',node,3,2,5); % creates model femesh('AddSel'); femesh PlotElt; femesh Info
Build selected object in FEel0. See feutil Object for a list of available objects. For example:
femesh('Reset') femesh(';ObjectArc 0 0 0 1 0 0 0 1 0 30 1;AddSel'); femesh(';ObjectArc 0 0 0 1 0 0 0 1 0 30 1;AddSel'); femesh(';ObjectCircle 1 1 1 2 0 0 1 30;AddSel'); femesh(';ObjectCircle 1 1 3 2 0 0 1 30;AddSel'); femesh(';ObjectCylinder 0 0 0 0 0 4 2 10 20;AddSel'); femesh(';ObjectDisk 0 0 0 3 0 0 1 10 3;AddSel'); femesh(';ObjectAnnulus 0 0 0 2 3 0 0 1 10 3;AddSel'); femesh('PlotElt')
OptimModel removes nodes unused in FEelt from FEnode.
OptimNodeNum does a permutation of nodes in FEnode such that the expected matrix bandwidth is smaller. This is only useful to export models, since here DOF renumbering is performed by fe_mk.
OptimEltCheck attempts to fix geometry pathologies (warped elements) in quad4, hexa8 and penta6 elements.
Orient elements. For volumes and 2-D elements which have a defined orientation, femesh('Orient') 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 topology holders q4p, t3p, ....
Orient normal of shell elements. For plate/shell elements (elements with parents of type quad4, quadb or tria3) in groups i of FEelt, this 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 so 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.
femesh('Orient i',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
% Init example femesh('Reset'); femesh(';Testquad4;Divide 2 3;') FEelt=FEel0; femesh('DivideGroup1 withnode1'); % Orient elements in group 2 away from [0 0 -1] femesh('Orient 2 n 0 0 -1 -neg');
Plot selected model. PlotElt calls feplot to initialize a plot of the model contained in FEelt. PlotEl0 does the same for FEel0. This command is really just the declaration of a new model using feplot('InitModel',femesh('Model')).
Once the plot initialized you can modify it using feplot and fecom.
Basic element type transformations.
Element type transformation are applied to elements in FEel0. See feutil Lin2Quad fore more details and a list of transformations.
% create 4 quad4 femesh(';Testquad4;Divide 2 3'); femesh('Quad2Tria'); % conversion femesh PlotEl0 % create a quad, transform to triangles, divide each triangle in 4 femesh(';Testquad4;Quad2Tria;Divide2;PlotEl0;Info'); % lin2quad example: femesh('Reset'); femesh('Testhexa8'); femesh('Lin2Quad epsl .01'); femesh('Info')
Mesh refinement. This function searches FEel0 for beam elements and divides elements so that no element is longer than l.
Element removal. This function searches FEelt or FEel0 for elements which verify certain properties selected by ElementSelectors and removes these elements from the model description matrix. A sample call would be
% create 4 quad4 femesh('Reset'); femesh(';Testquad4;Divide 2 3'); femesh('RemoveEl0 WithNode 1') femesh PlotEl0
Element group translation/duplication. RepeatSel repeats the selected elements (FEel0) nITE times with global axis translations tx ty tz between each repetition of the group. If needed, new nodes are added to FEnode. An example is treated in the d_truss demo.
femesh('Reset'); femesh(';Testquad4;Divide 2 3'); femesh(';RepeatSel 3 2 0 0'); % 3 repetitions, translation x=2 femesh PlotEl0 % alternate call: % number, direction % femesh(sprintf(';repeatsel %f %f %f %f', 3, [2 0 0]))
Revolution of selected elements in FEel0. See feutil Rev for more details. For example:
FEnode = [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]; femesh('ObjectBeamLine',1:4); femesh('Divide 3') femesh('Rev 40 o 0 0 0 360 0 1 0'); femesh PlotEl0 fecom(';Triax;View 3;ShowPatch') % An alternate calling format would be % divi origin angle direct %r1 = [40 0 0 0 360 0 1 0]; %femesh(sprintf('Rev %f o %f %f %f %f %f %f %f',r1))
Rotation. The selected elements FEel0 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 xyz values preceded by an o
femesh('RotateSel o 2.0 2.0 2.0 90 1 0 0')
This is an example of the rotation of FEel0
femesh('Reset'); femesh(';Testquad4;Divide 2 3'); % center is node 1, angle 30, aound axis z % Center angle dir st=sprintf(';RotateSel %f %f %f %f %f',[1 30 0 0 1]); femesh(st); femesh PlotEl0 fecom(';Triax;TextNode'); axis on
Element selection. SelElt places in the selected model FEel0 elements of FEelt that verify certain conditions. You can also select elements within FEel0 with the SelEl0 command. Available element selection commands are described under the FindElt command and section 7.12.
femesh('SelElt ElementSelectors').
Element group selection. The element group i of FEelt is placed in FEel0 (selected model). SelGroupi is equivalent to SelEltGroupi.
Node selection. The node(s) i of FEnode are placed in FEn0 (selected nodes).
Set properties of a group. For group(s) of FEelt selector 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
femesh('SetGroup1:3 pro 4') femesh('SetGroup rigid name celas')
If you know the column of a set of element rows that you want to modify, calls of the form FEelt(femesh('FindEltSelectors'),Column)= Value can also be used.
model=femesh('Testubeamplot'); FEelt(femesh('FindEltwithnode {x==-.5}'),9)=2; femesh PlotElt; cf.sel={'groupall','colordatamat'};
You can also use femesh('set groupa 1:3 pro 4') to modify properties in FEel0.
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.
Some unique element model examples. See list with femesh('TestList').
For example a simple cube model can be created using
model=femesh('TestHexa8'); % hexa8 test element
Translation of the selected element groups. TransSel replaces elements of FEel0 by their translation of a vector [tx ty tz] (in global coordinates). If needed, new nodes are added to FEnode. Related commands are SymSel, RotateSel and RepeatSel.
femesh('Reset'); femesh(';Testquad4;Divide 2 3;AddSel'); femesh(';TransSel 3 1 0;AddSel'); % Translation of [3 1 0] femesh PlotElt fecom(';Triax;TextNode')
Duplicate nodes which are common to two groups. To allow the creation of interfaces with partial coupling of nodal degrees of freedom, UnJoin determines which nodes are common to the element groups Gp1 and Gp2 of FEelt, duplicates them and changes the node numbers in Gp2 to correspond to the duplicate set of nodes. In the following call with output arguments, the columns of the matrix InterNode give the numbers of the interface nodes in each group InterNode = femesh('UnJoin 1 2').
femesh('Reset'); femesh('Test2bay'); femesh('FindNode group1 & group2') % nodes 3 4 are common femesh('UnJoin 1 2'); femesh('FindNode group1 & group2') % no longer any common node
A more general call allows to separate nodes that are common to two sets of elements femesh('UnJoin','Selection1','Selection2'). Elements in Selection1 are left unchanged while nodes in Selection2 that are also in Selection1 are duplicated.
See also
fe_mk, fecom, feplot, section 4.5, demos gartfe, d_ubeam, beambar ...