# Finite Elements in Scilab

Contents

## Introduction

The goal of this page is to present the finite element tools which are available in the Scilab environment.

We present the following tools:

- the Femtruss module,
the FreeFem module for Scilab,

the OpenFem module for Scilab,

the GetFem module for Scilab,

- the CEMEF-UTN scripts,
- the connection between SAMCEF® and Scilab.

## Femtruss

The Femtruss module is a a Truss finite element code for scilab:

http://atoms.scilab.org/toolboxes/femtruss

It has been created by Yann Collette in 2009-2010 and is maintained as an open-source project under GPL on :

http://code.google.com/p/scilab-mip/

In the demos directory, you will find some demos related to structural optimization, computation of partial derivatives and display of structures.

The following is the list of functions in this module :

- build_fem_test : Create some test structures in 2 or 3 dimensions.
- dfemtruss_ana : Compute the analytical partial derivative of the nodal displacements.
- dfemtruss_smw : Compute the partial derivative of the nodal displacements.
- femmode : Computes the modes of a structure.
- femtruss : Computes the deformation of a truss structure.
- localise2d : Returns the position in the matrix of a given point (2D).
- localise3d : Returns the position in the matrix of a given point (3D).
- plot_truss : Plot a truss structure.
- plotdeforme : Plot a deformed truss structure.
- plotmesh : Plot a truss structure.
- plotsection : Plot the sections of a truss structure.
- rank_efficient_struct : Test the validity of a stiffness matrix.

To install this module:

atomsInstall("femtruss") atomsLoad("femtruss")

The following figure presents a 2D bridge before optimization.

The following figure presents the same bridge after optimization.

The following figure presents a 3D bridge before optimization.

The following figure presents the same bridge after optimization.

## GetFem

GetFEM++ is basically a generic C++ finite element library which aims to offer the widest range of finite element methods and elementary matrix computations for the approximation of linear or non-linear problems, possibly in hybrid form and possibly coupled. The dimension of the problem is arbitrary and may be a parameter of the problem. GetFEM++ offers a description of models in the form of bricks whose objective is to enable reusability of the approximations made. The system of bricks, now mature, is used to assemble components such as standard models (elasticity in small and large deformations, Helmholtz problem, scalar elliptic problem ...) to components representing the boundary conditions (Neumann, Dirichlet, Fourier-Robin, contact, friction...), also to components representing constraints (incompressibility, removing rigid motions ...) and to coupling components for coupled models.

Two strong points of GetFEM++ are structural mechanics (in particular contact mechanics) and taking into account discontinuities by fictitious domain methods of XFEM type (eg cracking).

It is proposed three interfaces (with Scilab, Matlab and Python) that allow to use of the main features of the software without the need of C++ programming and allowing graphical post-processing.

There is an interface from Scilab, created by Yann Collette in 2009 - 2010:

This module provides the following functions:

- Draw Command reference
- gf_colormap
- gf_plot
- gf_plot_1D
- gf_plot_mesh
- gf_plot_slice

- Command reference
- gf_asm
- gf_compute
- gf_cvstruct_get
- gf_delete
- gf_eltm
- gf_fem
- gf_fem_get
- gf_geotrans
- gf_geotrans_get
- gf_global_function
- gf_global_function_get
- gf_integ
- gf_integ_get
- gf_levelset
- gf_levelset_get
- gf_levelset_set
- gf_linsolve
- gf_mdbrick
- gf_mdbrick_get
- gf_mdbrick_set
- gf_mdstate
- gf_mdstate_get
- gf_mdstate_set
- gf_mesh
- gf_mesh_get
- gf_mesh_set
- gf_mesh_fem
- gf_mesh_fem_get
- gf_mesh_fem_set
- gf_mesh_im
- gf_mesh_im_get
- gf_mesh_im_set
- gf_mesh_levelset
- gf_mesh_levelset_get
- gf_mesh_levelset_set
- gf_model
- gf_model_get
- gf_model_set
- gf_poly
- gf_precond
- gf_precond_get
- gf_slice
- gf_slice_get
- gf_slice_set
- gf_spmat
- gf_spmat_get
- gf_spmat_set
- gf_undelete
- gf_util
- gf_workspace

This work is documented in :

"Scilab Interface, Release 4.1.1", Yann Colette, Yves Renard, Julien Pommier, November 03, 2011

which is available at:

http://download.gna.org/getfem/doc/scilab_interface.pdf

## FreeFem

FreeFem++ is an implementation of a language dedicated to the finite element method. It enables you to solve Partial Differential Equations (PDE) easily. Problems involving PDE (2d, 3d) from several branches of physics such as fluid-structure interactions require interpolations of data on several meshes and their manipulation within one program. FreeFem++ includes a fast 2^d-tree-based interpolation algorithm and a language for the manipulation of data on multiple meshes (as a follow up of bamg).

FreeFem++ is written in C++ and the FreeFem++ language is a C++ idiom. It runs on any Unix-like OS (with g++ version 3 or higher, X11R6 or OpenGL with GLUT) Linux, FreeBSD, Solaris 10, Microsoft Windows (95, 98, 2000, NT, XP, Vista) and MacOS X (native version using OpenGL). FreeFem++ replaces the older freefem and freefem+.

There has been several attempts to connect Scilab with FreeFem:

A module by par Yann Collette (2006) : Contribution #883

A module by Yann Collette (2006) : Contribution #879

A module by Frederic Hecht (2000) : Contribution #149

Yann Collette as suggested to work on this topic as a GSOC (Google Summer of Code) project:

## OpenFem

OpenFEM is an open-source software freely distributed under the terms of the "GNU Lesser Public License" (LGPL) co-owned by INRIA and SDTools.

OpenFEM is a general purpose multi-physic FEM environment. It addresses people familiar with FEM who want state of the art performance with the ease of use of MATLAB. Easier learning and more user friendly access is provided by SDTools in the OpenFEM version integrated in SDT. OpenFEM by itself is thus mostly used by academics who are willing to develop in a non graphical mode. SDTools is the main contributor to OpenFEM but has collaborations with a number of other developers, who need to rely on an Open Source environment.

A module by Yann Collette (2008) : Contribution #1077

A module by Yann Collette (2003) : Contribution #151

## July 2010: Mmodd for Partial Differential Equations

The MmodD project contains tools for the study and solution of partial differential equations (PDEs) in 2d and 3d. A set of command-line functions and a graphical user interface let you preprocess, solve, and postprocess generic PDEs for a broad range of engineering and science applications.

http://forgesitn.univ-lyon1.fr/projects/mmodd

The project is leaded by Thierry Clopeau, with the help of the following developpers :

- Sofian Smatti
- Marcel Ndeffo
- David Delanoue
- Wu Yiwen
- Kevin Vervier
- Amandine Berger
- Hocéane Kadio
- Laurence Siao
- Mbiengop Alex
- Yvon Goudron
- Feriel Ben Cheikh
- Simon Géraud
- Laurène Soyeux
- Yannick Meyapin
- Marion Neyroud
- Karine Mari
- Antoine Landra
- Ahmed Radji

The module provides the help pages of the following functions:

- line2d — Type declaration
- line3d — Type declaration
- p1_1d — Type declaration
- p1_2d — Type declaration
- square2d — Create a mesh on a square
- tri2d — Type declaration

The following functions are available:

- base
- base/assemble
- base/BiGradConj
- base/complement
- base/det2d
- base/GradConj
- base/GradConjPre
- base/interpol
- base/lsolve
- base/name
- base/p1
- base/spdiag

- devel
- devel/xmesh

- edp
- edp/assemble_edp
- edp/assemble_edp_df1d
- edp/assemble_edp_df2d
- edp/assemble_edp_df3d
- edp/assemble_edp_p1_1d
- edp/assemble_edp_p1_2d
- edp/assemble_edp_p1_3d
- edp/assemble_edp_p1nc3d
- edp/assemble_edp_q1p2d
- edp/assemble_edp_q1p3d
- edp/ConvDx
- edp/ConvDy
- edp/ConvDz
- edp/ConvGrad
- edp/D2x
- edp/D2y
- edp/D2z
- edp/Dir
- edp/Dirichlet
- edp/Dn
- edp/Dx
- edp/Dy
- edp/Dz
- edp/edp
- edp/Grad
- edp/Id
- edp/kId
- edp/kLaplace
- edp/Laplace
- edp/lsolve_edp
- edp/Neumann
- edp/upDx
- edp/upDy
- edp/upDz
- edp/xedp

- export
- export/Cell_gmv
- export/Cell_vtk
- export/CellRT_vtk
- export/dcomp3d_TETGEN
- export/dcomp3d_vtk
- export/exportGMV
- export/exportNETGEN
- export/exportNETGEN2
- export/exportSMESH
- export/exportSMESH2
- export/exportTETGEN
- export/exportVTK
- export/grid2d_gmv
- export/grid2d_vtk
- export/grid3d_gmv
- export/grid3d_vtk
- export/hex3d_gmv
- export/hex3d_vtk
- export/Node_gmv
- export/Node_vtk
- export/quad2d_gmv
- export/quad2d_vtk
- export/quad3d_vtk
- export/tet3d_gmv
- export/tet3d_vtk
- export/tri2d_gmv
- export/tri2d_vtk
- export/tri3d_gmv
- export/tri3d_vtk
- export/VCell_vtk
- export/vector_gmv
- export/VNode_vtk

- import
- import/importBAMG
- import/importGRUMMP
- import/importMESH
- import/importNETGEN
- import/importNETGEN_NC
- import/importTETGEN
- import/importTetra
- import/importTetraNC
- import/importTetraNC2
- import/importVMESH

- line2d
- line2d/line2d
- line2d/x_line2d_Cell
- line2d/x_line2d_Node
- line2d/y_line2d_Cell
- line2d/y_line2d_Node

- line3d
- line3d/line3d
- line3d/x_line3d_Cell
- line3d/x_line3d_Node
- line3d/y_line3d_Cell
- line3d/y_line3d_Node
- line3d/z_line3d_Cell
- line3d/z_line3d_Node

- meshtool
- meshtool/bamg_poly
- meshtool/menu_mesh_disp
- meshtool/mesh_disp
- meshtool/meshtool
- meshtool/tri2d_plot
- meshtool/tri2d_show_bnd
- meshtool/tri2d_show_cell
- meshtool/tri2d_show_face
- meshtool/tri2d_show_node
- meshtool/tri2d_show_rect
- meshtool/tri3d_plot

- p1_1d
- p1_1d/ConvDx_p1_1d_p1_1d
- p1_1d/Dn_p1_1d
- p1_1d/Dx_p1_1d
- p1_1d/Id_p1_1d
- p1_1d/interpol_p1_1d
- p1_1d/kId_p1_1d
- p1_1d/kLaplace_p1_1d
- p1_1d/Laplace_p1_1d
- p1_1d/p1_1d
- p1_1d/p1_1d_to_p0_1d

- p1_2d
- p1_2d/ConvDx_p1_2d_p1_2d
- p1_2d/ConvDy_p1_2d_p1_2d
- p1_2d/ConvGrad_p1_2d_p1_2d
- p1_2d/Dn_p1_2d
- p1_2d/Dx_p1_2d
- p1_2d/Dy_p1_2d
- p1_2d/Id_p1_2d
- p1_2d/interpol_p1_2d
- p1_2d/kId_p1_2d
- p1_2d/kLaplace_p1_2d
- p1_2d/Laplace_p1_2d
- p1_2d/p1_2d
- p1_2d/p1_2d_to_p0_2d

- tri2d
- tri2d/square2d
- tri2d/tri2d
- tri2d/tsquare2d
- tri2d/x_tri2d_Cell
- tri2d/x_tri2d_Node
- tri2d/y_tri2d_Cell
- tri2d/y_tri2d_Node

- vartool
- vartool/colorbar
- vartool/menu_var_disp
- vartool/p0_2d_plot2d
- vartool/p0_2d_plot3d
- vartool/p1_2d_plot2d
- vartool/p1_2d_plot3d
- vartool/rgbcolor
- vartool/var_disp
- vartool/var_plot
- vartool/var_plot3d
- vartool/vartool
- vartool/xcolorbar

## June 2011 : CEMEF-UTN

Marcos Cesar Ruggeri, from the Universidad Tecnológica Nacional in Argentina, developped CEMEF-UTN, a set of FEM scripts for Scilab.

This module implements the 3D Linear Bar Element (bar3d) formulation to solve truss structures for linear static stress-strain analysis.

Input data is imported from a .xls file, where the table of nodes, table of elements, nodal external loads vector and boundary conditions are stored.

This program only considers concentrated loads on the nodes. In case there be distributed loads or thermal loads, they must be calculated separately and then included into the nodal external loads vector. Flexion and shear effects are not considered due to the element formulation, which satisfy the hypothesis of the Finite Element Method.

This tool provides the following functions:

- stressbar3d: coordinates transformation for stress computation on each bar element
- stiffbar3d: local stiffness matrix and deformation matrix, transformation matrix of the element and global stiffness matrix
- spdverif: symmetric positive definite stiffness matrix verificator
- preplottruss3d: pre-plot of three dimensional truss structure
- postplottruss3d: contourplot of uni-dimensional normal stresses on each element of the structure
- bc: importation of boundary conditions and reduction of system
- assemb3d: table of connectivity and asssembly process
- inpbar3d: data migration and geometric and mechanical properties computation
- spdsolve: solve symmetric possitive definite system

The CEMEF-UTN scripts are available on ATOMS under the BSD license:

https://atoms.scilab.org/toolboxes/CEMEF-UTN

The following is an example, extracted from "CEMEF-UTN v1.1-6, High Voltage Tower Example" by Marcos C. Ruggeri. It is based on a structure which has 10 nodes.

cd F:\Downloads\cemef-utn_v1.1-6_comm\cemef-utn1.1-6 exec('inpbar3d.sci'); exec('stiffbar3d.sci'); exec('assemb3d.sci'); exec('preplottruss3d.sci'); exec('bc.sci'); exec('SPDverif.sci'); exec('SPDsolve.sci'); exec('stressbar3d.sci'); exec('postplottruss3d.sci'); [M,nod,elem,E,A,L,dircos,nn,ne]=inpbar3d('example_hvtower.xls'); [kL,B,T,kG]=stiffbar3d(E,A,L,dircos,ne); [tc,K0]=assemb3d(elem,3,6,kG,nn,ne); preplottruss3d(nod,elem,nn,ne,2) [K,P,cDOF,cDOFasc]=bc(M,K0); SPDverif(K0,cDOFasc,K); [u0,u,P0]=SPDsolve(K0,K,P,cDOF,cDOFasc,nn); [ue,sigma,f]=stressbar3d(E,A,B,T,tc,u0,ne); disp(sigma) postplottruss3d(nod,elem,nn,ne,2,sigma,u0,100,24)

The previous produces the following output:

## Connection to SAMCEF®

The SAMCEF® software is a Finite Elements tool developped by SAMTECH. The SAMCEF® suite is SAMTECH's general-purpose analysis software. It is based on the Finite Elements Method and covers a large range of applications, from basic to very advanced, in numerous industrial fields. See http://www.samtech.com/ for more details.

Paul Carrico, from ESTERLINE ADVANCED SENSORS, uses SAMCEF® from Scilab to design sensors. This analysis requires to perform a parameter fitting computation, based on results computed by SAMCEF®. The connection to SAMCEF® is based on simple file exchanges. In this case, Scilab is first used as a way to drive an external program, which is, here, a Finite Elements software. Moreover, the parameter fitting uses the *fminsearch* function of Scilab, a direct search method which does not require the derivatives of the objective function. The *fminsearch* function is based on the Nelder-Mead algorithm. In the case where the parameters are bounded, the function used is "neldermead".

Paul Carrico reported his experiments in the following report.

*"The Experiences of Esterline Advanced Sensors using SAMCEF® in the development of Aeronautic Sensors"*, Paul Carrico, Designer /Materials Expert, Esterline Advanced Sensors – AUXITROL SA – Bourges (France), 12th SAMTECH Conference, 15th & 16th November 2011 - Crowne Plaza, Liège Belgium

*Abstract*

"This presentation comprises 3 main discussion topics :

- A quick overview of FEA’s performance over the past few years using the SAMCEF® module for sensors development (THERMAL®, MECANO®, DYNAM®, REPDYN®, SPECTRAL®)
- The ability of SAMCEF® to interface with external routines for increased reliability i.e. leading to a good correlation of the modelling to the test measurements : a specific development including an hyperelastic material is presented for model analysis (modal analysis and dynamic response)
- A few examples which highlight gains in efficiency (the ability to launch multiple runs, automatic post-processing...)"

The paper of this event is provided here with authorization of ESTERLINE ADVANCED SENSORS:

This work has been performed with participation from the Scilab Consortium.

## Older Experiments

- There has been several attempts in the past, which are gathered in the former "Toolbox Repository" :