Contents     Functions              PDF Index

4.3  Building models with femesh

Declaration by hand is clearly not the best way to proceed in general.femesh provides a number of commands for finite element model creation. The first input argument should be a string containing a single femesh command or a string of chained commands starting by a ; (parsed by commode which also provides a femesh command mode).

To understand the examples, you should remember that femesh uses the following standard global variables

 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

In the example of the previous section (see also the d_truss demo), you could use femesh as follows: initialize, declare the 4 nodes of a single bay by hand, declare the beams of this bay using the objectbeamline command

``` FEel0=[]; FEelt=[];
FEnode=[1 0 0 0  0 0 0;2 0 0 0    0 1 0; ...
3 0 0 0  1 0 0;4 0 0 0    1 1 0]; ...
femesh('objectbeamline 1 3 0 2 4 0 3 4 0 1 4');
```

The model of the first bay in is now selected (stored in FEel0). You can now put it in the main model, translate the selection by 1 in the x direction and add the new selection to the main model

``` femesh(';addsel;transsel 1 0 0;addsel;info');
model=femesh('model');  % export FEnode and FEelt geometry in model
cf=feplot; cf.model=model;
fecom(';view2;textnode;triax;');
```

You could also build more complex examples. For example, one could remove the second bay, make the diagonals a second group of bar1 elements, repeat the cell 10 times, rotate the planar truss thus obtained twice to create a 3-D triangular section truss and show the result (see d_truss)

``` femesh('reset');
femesh('test2bay');
femesh('removeelt group2');
femesh('divide group 1 InNode 1 4');
femesh('set group1 name bar1');
femesh(';selgroup2 1;repeatsel 10 1 0 0;addsel');
femesh(';rotatesel 1 60 1 0 0;addsel;');
femesh(';selgroup3:4;rotatesel 2 -60 1 0 0;addsel;');
femesh(';selgroup3:8');
model=femesh('model0');  % export FEnode and FEel0 in model
cf=feplot; cf.model=model;
fecom(';triaxon;view3;view y+180;view s-10');
```

femesh allows many other manipulations (translation, rotation, symmetry, extrusion, generation by revolution, refinement by division of elements, selection of groups, nodes, elements, edges, etc.) which are detailed in the Reference section.

Other more complex examples are treated in the following demonstration scripts d_plate, beambar, d_ubeam, gartfe.

4.3.1  Automated meshing capabilities

While this is not the toolbox focus, SDT supports some free meshing capabilities.

fe_gmsh is an interface to the open source 3D mesher GMSH. Calls to this external program can be used to generate meshes by direct calls from MATLAB. Examples are given in the function reference.

fe_tetgen is an interface to the open source 3D tetrahedral mesh generator. See help fe_tetgen for commands.

fe_fmesh('qmesh') implements a 2D quad mesher which meshes a coarse mesh containing triangles or quads into quads of a target size. All nodes existing in the rough mesh are preserved. The -noTest option removes the initial mesh.

```% build rough mesh
model=feutil('Objectquad 1 1',[0 0 0;2 0 0; 2 3 0; 0 3 0],1,1);
model=feutil('Objectquad 1 1',model,[2 0 0;8 0 0; 8 1 0; 2 1 0],1,1);
% start the mesher with characteristic length of .1
model=fe_fmesh('qmesh .1',model.Node,model.Elt);
feplot(model);
```

Other resources in the MATLAB environment are initmesh from the PDE toolbox and the Mesh2D package.

4.3.2  Importing models from other codes

The base SDT supports reading/writing of test related Universal files. All other interfaces are packaged in the FEMLink extension. FEMLink is installed within the base SDT but can only be accessed by licensed users.

You can get a list of currently supported interfaces trough the

comgui('FileExportInfo'). You will find an up to date list of interfaces with other FEM codes at www.sdtools.com/tofromfem.html). Import of model matrices in discussed in section 4.3.3.

These interfaces evolve with user needs. Please don't hesitate to ask for a patch even during an SDT evaluation by sending a test case to info@sdtools.com.

Interfaces available when this manual was revised were

4.3.3  Importing model matrices from other codes

Reading of full matrices is supported for NASTRAN in the binary .op2 and .op4 formats (writing to .op4 is also available). For ANSYS, reading of .matrix ASCII format is supported. For ABAQUS, reading of ASCII .mtx format is supported.

Note that numerical precision is very important when importing model matrices. Storing matrices in 8 digit ASCII format is very often not sufficient.

To incorporate full FEM matrices in a SDT model, you can proceed as follows. A full FEM model matrix is most appropriately integrated as a superelement. The model would typically be composed of

• a mass m and stiffness matrix k linked to DOFs mdof which you have imported with your own code (for example, using nasread output2 or output4 and appropriate manipulations to create mdof). Note that the ofact object provides translation from skyline to sparse format.
• an equivalent mesh defined using standard SDT elements. This mesh will be used to plot the imported model and possibly for repeating the model in a periodic structure. If you have no mesh, define nodes and associated mass elements.

fesuper provides functions to handle superelements. In particular, fesuper SEAdd lets you define a superelement model, without explicitly defining nodes or elements (you can specify only DOFs and element matrices), and add it to another model.
Following example loads ubeam model, defines additional stiffness and mass matrices (that could have been imported) and a visualization mesh.

```% Load ubeam model :
model=demosdt('demo ubeam-pro');
cf=feplot; model=cf.mdl;
% Define superelement from element matrices :
SE=struct('DOF',[180.01 189.01]',...
'K',{{[.1 0; 0 0.1] 4e10*[1 -1; -1 1]}},...
'Klab',{{'m','k'}},...
'Opt',[1 0;2 1]); % Matrix types, sdtweb secms#SeStruct
% Define visualization mesh :
SE.Node=feutil('GetNode 180 | 189',model);
SE.Elt=feutil('ObjectBeamLine 180 189 -egid -1');
% Add as a superelement to model :
```

You can easily define weighting coefficient associated to matrices of the superelement, by defining an element property (see p_super for more details). Following line defines a weighting coefficient of 1 for mass and 2 for stiffness (1001 is the MatId of the superelement).

```model.il=[1001 fe_mat('p_super','SI',1) 1 2];
```

You may also want to repeat the superelement defined by element matrices. Following example shows how to define a model, from repeated superelement:

```% Define matrices (can be imported from other codes) :
model=femesh('testhexa8');
[m,k,mdof]=fe_mk(model);
% Define the superelement:
SE=struct('DOF',[180.01 189.01]',...
'K',{{[.1 0; 0 0.1] 4e10*[1 -1; -1 1]}},...
'Klab',{{'m','k'}},...
'Opt',[1 0;2 1]);
SE.Node=model.Node; SE.Elt=model.Elt;