Finite Element Method
fprintf('node
displacements\n')
% displacements
for jj=1:gDof
fprintf('%2.0f:
%10.4e\n', jj, displacements(jj))
end
% reactions
F=stiffness*displacements;
reactions=F(pDof)-force(pDof);
disp('Reactions')
fprintf('node
reactions\n')
for jj=1:size(pDof,1)
fprintf('%2.0f:
%10.4e\n', pDof(jj), reactions(jj))
end
Results
We are now ready to run the MATLAB codes (a Sec2.4+1DBar.zip file containing a
problem1d.m file with one MAT file Sec2.4.mat and three functions,
elementStiffnessL2.m, solution.m, and outputDisplacementsReactions.m).
They are available on the course website. When running this code, we obtain detailed
information on matrices or results, depending on the user needs, for example, displacements
and reactions:
Displacements
node
displacements
1:
0.0000e+000
2:
2.0000e-003
3:
1.0000e-003
4:
0.0000e+000
Reactions
node
reactions
1:
-2.0000e+003
4:
-1.0000e+003
Remark: It is important for you to link the variables described in the MATLAB codes with
the notations established in Section 2.3 to reinforce your understanding.
2.5 Derivation of shape functions using Lagrange interpolation
The one-dimensional shape functions we have developed are called Lagrange interpolants (or
Lagrange interpolation functions). Recall that interpolants are functions that pass exactly
through the data. If you think of nodal values as data, shape functions are interpolants of the
nodal data.
The theory of Lagrange interpolation is very useful for constructing interpolants of various
30
Finite Element Method
orders, particularly higher-order functions, such as quadratic or cubic. Lagrange interpolants
can be developed more directly from the Kronecker delta property of the shape functions:
(2.7) 𝑁𝑖𝑒 (𝑥𝑗𝑒 ) = 𝛿𝑖𝑗
where 𝛿𝑖𝑗 is the Kronecker delta and is given by
1
𝛿𝑖𝑗 = {
0
if 𝑖 = 𝑗
if 𝑖 ≠ 𝑗
Q: What does the Kronecker delta property of the shape functions imply?
A:
Consider the quadratic shape functions for a three-node element to see how we use these
properties to construct the shape functions. Let’s first consider 𝑁1𝑒 (𝑥):
As the shape function 𝑁1𝑒 (𝑥) is quadratic in x, it consists of a product of two linear monomials
in x. The most general form of such a quadratic product of monomials is:
𝑁1𝑒 (𝑥) =
(𝑥 − 𝑎)(𝑥 − 𝑏)
𝑐
where a, b, and c are constants to be set to satisfy the Kronecker delta property.
1. We want 𝑁1𝑒 (𝑥) to vanish at 𝑥2𝑒 and 𝑥3𝑒 as follows:
(𝑥 − 𝑥2𝑒 )(𝑥 − 𝑥3𝑒 )
𝑐
2. We want 𝑁1𝑒 (𝑥) equals to 1 at 𝑥1𝑒 as follows:
(𝑥 − 𝑥2𝑒 )(𝑥 − 𝑥3𝑒 )
𝑒
𝑁1 (𝑥) = 𝑒
(𝑥1 − 𝑥2𝑒 )(𝑥1𝑒 − 𝑥3𝑒 )
𝑁1𝑒 (𝑥) =
You can do similar things for 𝑁2𝑒 (𝑥) and 𝑁3𝑒 (𝑥).
31
Finite Element Method
Q: What is 𝑁2𝑒 (𝑥)?
A:
The same procedure can be used to construct the cubic shape functions. The element with a
cubic shape function will have four nodes, as there are four constants in an arbitrary cubic
polynomial (𝑢𝑒 (𝑥) = 𝛼0𝑒 + 𝛼1𝑒 𝑥 + 𝛼2𝑒 𝑥 2 + 𝛼3𝑒 𝑥 3 ). The shape functions are:
𝑁1𝑒 (𝑥) =
(𝑥 − 𝑥2𝑒 )(𝑥 − 𝑥3𝑒 )(𝑥 − 𝑥4𝑒 )
(𝑥1𝑒 − 𝑥2𝑒 )(𝑥1𝑒 − 𝑥3𝑒 )(𝑥1𝑒 − 𝑥4𝑒 )
Q: How about 𝑁2𝑒 (𝑥) for the cubic shape function?
A:
These shape functions are plotted below:
In general, the Lagrange interpolants can be expressed as:
𝑛
𝑥 − 𝑥𝑗
𝑒
(2.40) 𝑁𝑖 (𝑥) = ∏
𝑥 − 𝑥𝑗
𝑗=1 𝑖
𝑗≠𝑖
𝑒
𝑒
(𝑥 − 𝑥1𝑒 )
(𝑥 − 𝑥2𝑒 )
(𝑥 − 𝑥𝑖−1
)
(𝑥 − 𝑥𝑖+1
)
(𝑥 − 𝑥𝑛𝑒 )
≡ 𝑒
×
×
⋯
×
×
×
⋯
×
𝑒
𝑒
(𝑥𝑖 − 𝑥1𝑒 ) (𝑥𝑖𝑒 − 𝑥2𝑒 )
(𝑥𝑖𝑒 − 𝑥𝑖−1
) (𝑥𝑖𝑒 − 𝑥𝑖+1
)
(𝑥𝑖𝑒 − 𝑥𝑛𝑒 )
The symbol Π indicates a product of terms. For writing the ith shape function, the product
includes all terms except the ith. Therefore, there are 𝑛 − 1 terms in the product, and each
interpolant is of degree 𝑛 − 1, where 𝑛 is the number of data points (in our cases, the number
of nodes in an element).
32
Finite Element Method
Example 2.3: Write Lagrange interpolants through four points. Plot the resulting function if
the nodal values and coordinates are as follows:
Coordinate
Data Value
0
1/2
1
1
2
3
5/2
-1/2
(Answer)
33
Finite Element Method
The obtained Lagrange interpolation function clearly passes through all four data points, as
shown in the following figure.
4
2
0
-2
-4
-6
-8
-10
0
0.5
1
1.5
2
2.5
3
2.6 Gauss quadrature
The element stiffness and external force matrices generally cannot be integrated into a closed
form. Therefore, numerical integration is needed. Although there are many numerical
integration techniques, Gauss quadrature, one of the most efficient techniques for functions
that are polynomials or nearly polynomials, is the natural choice for FEM.
2.6.1 Integration over the interval [−1, +1]
To explain Gauss quadrature, we first consider a one-dimensional problem without referencing
the finite element method. For a given polynomial function of degree 𝑝 ≤ 2𝑛𝑔𝑝 − 1:
(2.41) 𝑓(𝜉) = 𝛼0 + 𝛼1 𝜉 + 𝛼2 𝜉 2 + 𝛼3 𝜉 3 + ⋯ + 𝛼2𝑛𝑔𝑝 −1 𝜉 2𝑛𝑔𝑝 −1
where the 𝛼𝑖 are arbitrary constants, it can be proved (see details in Cook et al. (2002)) that
the Gauss quadrature can be used to exactly evaluate the integral of 𝑓(𝜉) over the interval [−1,
+1] using 𝑛𝑔𝑝 Gauss points (also called integration points):
34