Anda di halaman 1dari 4

Recent development of the CALFEM software

Per-Erik Austrell, Jonas Lindemann, Johan Lorentzon, Kent Persson, and


Göran Sandberg
Department of Structural Mechanics
Lund University, Lund, Sweden
e−mail: calfem@byggmek.lth.se

Summary Some new developments of the MATLAB based finite element software CALFEM are discussed.
Functions making it possible to generate arbitrary triangular and quadrilateral meshes are currently being
developed. Moreover, a stand-alone version of CALFEM is also in progress that makes use of the open source
PYTHON environment. This version of the program is shortly discussed with an example of the syntax, to show
the similarities. Finally a web site connection to improve the development work of CALFEM is discussed.

Introduction

The name of the finite element software CALFEM is an abbreviation of ‘Computer Aided Learning of
the Finite Element Method’. CALFEM has been used for several years in research and education at
Lund University and in many other places worldwide. The down-loads of this open-source software
are counted in thousands. CALFEM was originally developed at the division of structural mechanics
and the first versions were written in FORTRAN. But since 1993 it has been adapted to MATLAB by
a development work conducted at the division of Structural Mechanics and the division of Solid
Mechanics at the department of Construction Science, Lund University.

Although CALFEM is now very much used in research, it was at the beginning developed to be used
in education, for the purpose of giving a deeper understanding of the finite element method, without
requiring too much programming efforts from the students. This was accomplished by FORTRAN
subroutines, and is now accomplished by MATLAB-functions for the basic steps needed in solving
problems by finite elements. For example, there are functions for creating element matrices,
assembling them to a system of equations, and solving the global system for nodal quantities etc.

CALFEM is integrated in the education in several courses, given by Structural mechanics and Solid
mechanics departments on under-graduate as well as post-graduate level. This means that students do
exercises, projects and also master thesis works using CALFEM as the major tool. Moreover, post
graduate students also use it as a tool in their thesis work.

This presentation concerns the recent development of the software. The major new features concerns
mesh generation, a transcript of the code to PYTHON environment, and the use of the web-site
SourceForge to take advantage of development work done in other places.

Mesh generation

When students use CALFEM in education and in master thesis or PhD-works they look at idealized
model problems with simple geometry, but often also on more realistic problems with complex
geometry. Until recently the support for mesh generation in CALFEM has been very limited.
However, in a new development, one now has the option in CALFEM to generate two-dimensional
triangular or quadrilateral meshes, based upon a triangular or quadrilateral surface topology.

The basic geometry in the mesh generation consists of vertices and segments, defined from an oriented
polygon, i.e. the vertices are supposed to be oriented consecutively in clockwise direction on an
arbitrary polygon. Two consecutive vertices define a segment.
0.12

0.1

0.08

0.06

y
0.04

0.02

−0.02

0 0.05 0.1 0.15 0.2


x

Figure 1. Example of unstructured quad mesh generation on an L-shaped consol.

From this basic geometry definition (left hand side in Figure 1) a structured or unstructured triangular
mesh can be generated. The triangular mesh can then be further converted to a quadrilateral mesh.
This is shown on the right hand side of the figure above, in the case of an unstructured triangular mesh
as a base.

Tools to validate, extract degrees of freedom, smooth and correct the mesh provides the user with tools
to refine and handle the generated mesh.

Example of new functions for mesh generation, in the L-shaped beam case (figure above), is as
follows (preliminary syntax). The CALFEM code given here generates the geometry and the un-
deformed mesh shown in Figure 1:

 
 
% ‐‐‐‐‐‐‐‐‐‐‐ basic geometry definition ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 
l = 0.2; w = 0.05; h = 0.1; 
 
vertices = [0.0 h; l h; l 0.0; l‐w 0.0; l‐w h‐w; 0.0 h‐w]; 
 
segments = [1 2 1; 2 3 1; 3 4 1; 4 5 1; 5 6 1; 6 0 1]; 
 
nen=3; dofsPerNode=2; maxArea=1e‐4; 
 
mp=[maxArea dofsPerNode nen]; 
 
geomdraw2(vertices,segments,mp) 
 
% ‐‐‐‐‐ generation of unstructured triangular elements ‐‐‐‐‐‐ 
 
dbtri=unstri2d(vertices,segments,mp); 
 
% ‐‐‐‐‐‐ generation of quads from triangular elements ‐‐‐‐‐‐‐ 
 
dbquad=tri2quad(dbtri); 
 
% ‐‐‐‐‐‐‐‐‐‐‐‐‐ extraction of mesh quantities ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 
[coord edof dof nen]=extractdb(dbquad); 
A more complex example of two-dimensional meshing is shown in Figure 2. Several triangular
surfaces are seamlessly meshed with quadrilateral elements.

Figure 2. Several surfaces connected and meshed seamlessly along the edges.

CALFEM and Python:

To be dependent and connected to a big technical software like MATLAB, has advantages but also
some apparent disadvantages. Although there are student versions of MATLAB for free use, it is a
quite costly program for non students and say small companies that want to use it mainly for finite
element analysis trough the use of CALFEM.

In order to circumvent this problem a special version of CALFEM, pyCALFEM, is under


development. This version will implement all the CALFEM commands using the NumPy-library a
Python module providing the necessary matrix support.

The following code illustrates the pyCALFEM use for a two-dimensional truss of 12 dofs:
 
 
 
 
# ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
# PURPOSE:   Analysis of a plane 2D‐truss structure 
# ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 
from numpy import * 
from pycalfem import * 
 
# ‐‐‐‐‐ Topology, coordinate, and element properties ‐‐‐‐‐‐‐‐‐‐‐‐ 
 
K=zeros([12,12]) 
 
f=zeros([12,1]); f[10]=1e6 
 
A=25.0e‐4; E=2.1e11; ep=[E,A] 
 
ex = array([ 
    [0., 2.], 
    ... 
    [0., 2.], 
    [2., 4.]]) 
 
ey = array([ 
    [2., 2.], 
    ... 
    [2., 0.], 
    [2., 0.]]) 
 
Edof = array([ 
    [1, 2, 5, 6], 
    ... 
    [1, 2, 7, 8], 
    [5, 6, 11, 12]]) 
 
# ‐‐‐‐‐‐‐‐‐ Assemble and solve the system of equations ‐‐‐‐‐‐‐‐‐‐ 
 
for elx, ely, eltopo in zip(ex, ey, Edof): 
    Ke = bar2e(elx, ely,ep) 
    assem(eltopo,K,Ke) 
 
bc = array([1,2,3,4]) 
a, r = solveq(K,f,bc) 
 
# ‐‐‐‐‐‐‐‐‐‐‐‐ Evaluate the element forces ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 
ed=extract(Edof,a); 
N=zeros([Edof.shape[0]]) 
 
i = 0 
for elx, ely, eld in zip(ex, ey, ed): 
    N[i] = bar2s(elx,ely,ep,eld); 
    i=i+1 

CALFEM as a collaborative effort

To enable users to provide code as well as take advantage of new features which are not in the stable
releases, CALFEM is now available on SourceForge. This web-site provides services for open source
project such as:

• File release system for distributing stable packages.


• Source version management service providing source code control using subversion, enabling
multiple developers to work on the code simultaneously.
• Detailed statistics on the number of downloads and code commits in the version management
system.
• Forum for users of the package.

By using the SourceForge environment the development of CALFEM can be encouraged by third
party developers by providing them access to development code as well as stable releases.

References

[1] O. Dahlblom and P-E Austrell et. al. CALFEM A finite element toolbox to MATLAB. Department of
Structural mechanics report TVSM 9001, (1999).
[2] O.C. Zienkiewicz and R.L. Taylor. The Finite Element Method. McGraw-Hill, London, Fourth edition,
(1989).

Anda mungkin juga menyukai