Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Chapter 8.

a:

A Few Tips
on
Finite Element Programming

Jayadeep U. B.
M.E.D., NIT Calicut1
Department of Mechanical Engineering, National Institute of Technology Calicut

Size of Elemental and Global System


The number of degrees of freedom (d.o.f.) per node depends
on the problem – e.g. the heat transfer problem has 1 d.o.f
(temperature) per node, while a general 3D stress analysis
problem has 3 d.o.f. (displacements) per node.
The size of elemental system = (nodes per element) × (d.o.f.
per node).
The size of Global system = (total number of nodes) × (d.o.f.
per node), provided all nodes have same number of d.o.f.

The size of global system to be solved could get modified due


to the method we use for enforcing the B.C.

Lecture - 01 2
Department of Mechanical Engineering, National Institute of Technology Calicut

Element Connectivity Matrix


To facilitate the assembly process, we can store the nodes of
all the elements as a matrix – The element connectivity
matrix.
For example, consider the 2D mesh as shown below:
The connectivity matrix is:
9 10 11 12
1 1 2 6 5
4 5 6

Element numbers
2 2 3 7 6
5 6 7 8 3 3 4 8 7 Node -
Numbers
1 2 3 4 5 6 10 9
5 6 7 11 10
1 2 3 4
6 7 8 12 11
The node numbering order in an element is significant.
The node numbering scheme decides the bandwidth of the
stiffness matrix. The above node numbering scheme may not
be the one to give the smallest bandwidth.
Lecture - 01 3
Department of Mechanical Engineering, National Institute of Technology Calicut

Nodal Coordinate Matrix


The calculation of shape functions and integration requires
the coordinates of the nodes. This can be conveniently stored
as a matrix – The nodal coordinate matrix.
For example, consider the 2D mesh as earlier and the size of
domain be 15 x 12:
y The Coordinate Matrix:
9 10 11 12 1 0 0

Node numbers
4 5 6 2 5 0
3 10 0 Nodal -
5 6 7 8 Coordinates
4 15 0
1 2 3 5 0 6
x
1 2 3 4 ⋯ ⋯ ⋯
In both these matrices, the element or node number, given as
first column in above cases, could be the row index of the
matrix (or the 2D array).
Lecture - 01 4
Department of Mechanical Engineering, National Institute of Technology Calicut

The Elemental System


The shape functions, which are non-zero over any element
will be the ones corresponding to the nodes of that element.
Hence, we need to know the nodes of any given element – it
is given by the connectivity matrix.
To create the shape function corresponding to any node, we
need to have the coordinates of the node – it is given by the
nodal coordinate system
Also, since the vertices will be used as nodes (there may be
additional internal nodes), the domain (coordinates) of the
element can be obtained, provided a specific local node
numbering scheme (order in which the nodes are given in a
row of the connectivity matrix).
Hence, connectivity and nodal coordinate matrices, along
with problem specification (say, d.o.f per node) and element
type (linear, quadratic etc.) can create the elemental system.
Lecture - 01 5
Department of Mechanical Engineering, National Institute of Technology Calicut

Assembly Procedure
All the elemental matrices need not be formed before
assembly, rather the individual element matrix could be added
to the global matrix directly after it is formed. Hence, the
space required for elemental system could just be that
required for one system.
In some cases, even an elemental matrix need not be created
completely – individual values could be added to global
system directly.
If there are identical elements, measures could be taken to
avoid the duplication of elemental calculations.
If the d.o.f. per node is known, the element connectivity
matrix can be used for assembling the global system, by
calculating the position, where each value from element
system need to be assembled.

Lecture - 01 6
Department of Mechanical Engineering, National Institute of Technology Calicut

Assembly Procedure - Example


Consider the finite element mesh as in earlier figure
(reproduced below):

Considering the elemental system corresponding to the


element 2:
l=6 k=7

2
i=2 j=3

Lecture - 01 7
Department of Mechanical Engineering, National Institute of Technology Calicut

Assembly Procedure – Example contd. …


Considering a problem, where there are two d.o.f. per node,
we have the elemental system:
 k112 k122 ⋯ k182  φ12   f12 
 2 2  2  2
 k21 k22 ⋯ k28  φ2   f 2 
2

  = 
 ⋮ ⋮ ⋱ ⋯ ⋮   ⋮ 
 2 2  2
 k81 k82 ⋯ k88  φ8   f82 
2

How to use the connectivity matrix to do the assembly?


Consider the value at: k234. We know 3 corresponds to the
first d.o.f. of second node and 4 gives the second d.o.f. of
second node of the element 2.
The connectivity matrix gives the global node number
corresponding to the second node of element 2 (or in general
for any node of any element) as 3.
Hence, k234 should be assembled (added) at K56 in the global
system.
Lecture - 01 8
Department of Mechanical Engineering, National Institute of Technology Calicut

Assembly Procedure – C Code


A generalized assembler can be written, quite easily as:
for (i= 1; i< m *n; i+ +) {
gbl_f ( (i+1 ) m * con_m [k ][i]) + (i+1 ) %m  + = ele_f [i;
]
for (j= 1; j< m *n; j+ +)
gbl_m ( (i+1 ) m * con_m [k ][i]) + (i+1 ) %m 
( (j+1 ) m * con_m [k ][j]) + (j+1 ) %m  + = ele_m [i][j];
 
}
where: m = d.o.f/node, n = nodes / element, gbl_f: Global force vector,
gbl_m: Global stiffness matrix, ele_f: Elemental force vector,
ele_m: Elemental stiffness matrix & con_m: Connectivity matrix

Note: In C, the array index numbering starts with 0.

Lecture - 01 9
Department of Mechanical Engineering, National Institute of Technology Calicut

Few More Tips…


We may have the analysis domain comprising of many
different materials. In such cases, we may append the
material information to the connectivity matrix, along with
the nodes, as additional columns.
Similarly we can add additional information like the element
characteristics to the connectivity matrix, for making the
program more general purpose.
Similarly, the load and B.C. data may be appended in the
nodal coordinate matrix.

It is best to have a modular structure for the program, for


easy readability and maintainability.

Lecture - 01 10
Department of Mechanical Engineering, National Institute of Technology Calicut

Solvers
A finite element solver performs the simple task of solving
the matrix equation (one or more times) or finding the Eigen
values and Eigen vectors.
What makes it such an important task is the size of matrices
commonly encountered in FEA – solving for 1 million
unknowns is not at all rare in today’s world of FEM!!!
Therefore, it becomes extremely important to use the special
features like symmetry, bandedness etc., during solution
(refer to Special Features of Finite Element Stiffness Matrices
in Additional Resources folder).
In other words, any method, which can reduce the number of
computations or computational resource requirements,
becomes the preferred method for solution.
Nowadays, iterative methods like Conjugate Gradient
Methods are considered to be the best for solving huge
matrices.
Lecture - 01 11

You might also like