0% found this document useful (0 votes)
6 views71 pages

FEM04

This document covers the Finite Element Method, focusing on the formulation of linear second-order ordinary differential equations (ODEs) and the use of shape functions, global stiffness matrices, and Gaussian quadrature in MATLAB programming. It includes detailed instructions for implementing the method in MATLAB, along with example problems and a quiz to reinforce learning. Additionally, it outlines project requirements and grading criteria for students.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views71 pages

FEM04

This document covers the Finite Element Method, focusing on the formulation of linear second-order ordinary differential equations (ODEs) and the use of shape functions, global stiffness matrices, and Gaussian quadrature in MATLAB programming. It includes detailed instructions for implementing the method in MATLAB, along with example problems and a quiz to reinforce learning. Additionally, it outlines project requirements and grading criteria for students.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 71

Finite Element Method

LECTURE 4

Yu-Ching Wu
Review

 The meaning and purpose of shape


functions
 Assemble of the global stiffness matrix
 The meaning of the element force array
 Matlab Programming
Chapter 4 Linear Second-Order ODEs

The general second order linear ODE

Boundary conditions:
at or
at or
4.1 Weak Form of the Governing Equation

Integration by part yields


Substitution back into the governing
equation yields
4.2 Finite Element Formulation
Substitution back into the
governing equation yields
Next we define
Moment of Area

But this time instead of calculating by hand,


it is written in the program(line 103).
The elemental matrix
equation can be written as
The global matrix
equation can be
written as
After being
assembled, right
hand side become
Finally,
If is known, then NPBC=0 and f=q*

If y is known, then NPBC=1 and y=y*


where
4.3 Constant Coefficients
4.4 Variable Coefficients
If A, B, C, and D are not constant, i.e.

how do we integrate to get


and ?
Gaussian Quadrature
Basic concept: integration matrix
1-Node Gaussian Quadrature
y y y
y(x) y(x)
𝑦0 𝑦0 𝑦0
y(x)

x x x
-1 0 +1 -1 0 +1 -1 0 +1
It is the same for every straight line
passing node .
This concept can be extended to
higher degree polynomials (curves).
2-Node Gaussian Quadrature
y y(x) y y
y(x)
y(x)

x x x
-1 0 +1 -1 0 +1 -1 0 +1
Gaussian points
Question: How do we know and
Answer: Corresponding weights

Take 4-node Gaussian quadrature as


an example.
y

y(x)
-1 +1 x
𝑎1 𝑎2 𝑎3 𝑎4
0

We define a 7-degree polynomial passing these 4


points and as follows:
Note:
① It satisfies and
② and are arbitrary constants.
If and are Gaussian points, then
Because and are arbitrary,

4 equations to solve 4 unknows


All Gaussian points and corresponding
weights have been calculated and
tabulated in many reference books of
numerical analysis.
We can take it and use it.
Transformation to unit coordinate system
Transformation to unit coordinate system
y(x) y(ξ)

x ξ
a b -1 +1
Matlab Programming

① Download/Unzip ode2_matlab.rar
② Main code: ode2.m
Function: nGauss.m; SF.m
Include: COEF.m
Input Data: MESH.txt; QUAD.txt
Main code: ode2.m

clear
% ---------------------
% INPUT DATA
% ---------------------
load MESH.txt -ASCII MESH.txt & QUAD.txt are input
load QUAD.txt -ASCII files
Main code: ode2.m

NUMNP = MESH(1,1); NUMNP Number of nodal


NUMEL = NUMNP-1; points
XORD = zeros(1,NUMNP); NUMEL Number of elements
NPBC = zeros(1,NUMNP); XORD x coordinates of nodes
Y = zeros(1,NUMNP); NPBC Nodal point B.Cs.
Q = zeros(1,NUMNP); Y Nodal point values
Q Right-hand side
Main code: ode2.m

for i=1:NUMNP Input Datas


XORD(i) = MESH(i+1,1);
NPBC(i) = MESH(i+1,2);
Y(i) = MESH(i+1,3);
Q(i) = MESH(i+1,4);
end
Main code: ode2.m

NQPTS = QUAD(1,1); NQPTS Number of quadrature


points
GPTS=zeros(1,NQPTS); GPTS Gauss points
GWTS=zeros(1,NQPTS); GWTS Gauss weights
for i=1:NQPTS
GPTS(i)=QUAD(i+1,1);
GWTS(i)=QUAD(i+1,2);
end

SK=zeros(NUMNP,3); SK Global stiffness


Main code: ode2.m

IB=3; IB Bandwidth of stiffness


for I=1:NUMEL matrix
The loop for each element
for J=1:NQPTS
⋮ The loop for each gauss point
for K=1:2
⋮ Assemble of the global
end matrix
end
end end
Main code: ode2.m

B = 0;
for I=1:NUMNP Boundary Conditions
for J=1:3
B = B+abs(SK(I,J));
end
end
Main code: ode2.m

B = B*(1.0E+04);
for I=1:NUMNP Blasting the diagonal
if NPBC(I) == 1
SK(I,2)=B;
Q(I)=Y(I)*B;
end
end
Main code: ode2.m

% ------------------------------
% CALL EQUATION SOLVER
% ------------------------------ nGAUSS Equation solver for
Y = nGAUSS(SK,Q,NUMNP,IB); banded, nonsymmetric
matrices
% ----------- IB Bandwidth=3
% OUTPUT DATA U Wire deflection
% -----------
save Y.txt Y -ASCII
plot(XORD,Y) Y.txt Output data
Function: SF.m

function s = SF(D,node,u)
% ---------------------
if D == 0 If D=0 Calculate shape
if node == 1 functions
s = (0.5 - 0.5*u);
elseif node == 2 N1=0.5-0.5u
s = (0.5 + 0.5*u);
else N2=0.5+0.5u
error('Error #1 in SF
function') Error massage
Function: SF.m

elseif D == 1 else if D=1


if node == 1 Calculate first derivative
s = -0.5; dN1/u=-0.5
elseif node == 2
s = +0.5;
dN2/du=+0.5
else
error('Error #2 in SF
function'); Error massage
end
else
error('Error #3 in SF function')
Quadrature Data: QUAD.txt

% Number of points dummy number


%----------------------------------------------
3 0
%----------------------------------------------
% Coordinates Weights
%----------------------------------------------
-0.77459666924148 0.55555555555556
0.0 0.88888888888889
+0.77459666924148 0.55555555555556
%----------------------------------------------
User’s Include: COEF.m

Sample coefficients to produce


% Coefficients for ode2.m the solution y(x) = 2x + 1
%==================
=======
A(x) = x3
AX = Xg^3; B(x) = -x2-x
BX = -Xg^2-Xg; C(x) = 3x
CX = 3*Xg; D(x) = -10x2 -x
DX = -10*Xg^2-Xg;
Input Data: MESH.txt

% NUMNP + 3 dummy To produce the solution


numbers y(x) = 2x + 1
%------------------------------------------
---
4 0 0 0
%------------------------------------------ y(1) = 3
---
% XORD NPBC U Q
%------------------------------------------
--- y(2) = 5
1 1 3 0
Function: nGauss.m

 nGAUSS.m is an equation solver for


banded, non-symmetric matrices using
Gauss elimination.
 Please read the code by yourselves.
Output plot for the test problem
Quiz

1. Please write the governing equation (the


strong form) of the problem
2. Please derive the weak form and the finite
element matrix form.
3. What is Gaussian quadrature?
4. Please illustrate transformation to unit
coordinate system.
Example 2

Part A
Determine a differential equation with non-zero coefficients A, B, C, and
D for which the solution is a linear function of x (i.e. y=C0+C1x. Define
three boundary value problems for this ODE:
a) y known at both boundaries.
b) y known at left end boundary and dy/dx known at right end boundary.
c) dy/dx known at left end boundary and y known at right end boundary.
Use program ode2.m to solve these three problems.
Part B
It is necessary to prevent water in a pipe from freezing during the
winter months. The pipe runs from an artesian well to a cabin 2.17
km down a hillside. The insulation for the pipe is partly ground
cover and partly some commercial wrapping material. A fair
approximation to the insulation can be given by
 x
h h0  1.3  
 L
where h is the coefficient of convective heat transfer, and L is the
total length of the pipe. The equation for the temperature in the
pipe can be described by the equation
d  d  d
k   v( C p )  h (  a   )  0 .0
dx  dx  dx
where

 is the temperature C )(
 a is the ambient temperature  30.0  C
υ is the velocity in the pipe (m/s)
3
ρ is the density = 1.0 E  03kg / m

C p is the capacity 4.211E  03 Nm / kg C

k is the thermal conductivity = 0 . 574 Nm / sm C
h is the coefficient of convective heat transfer Nm / m 3 s  C
In order to keep the water from freezing it is necessary to maintain
average velocity which will keep the water from freezing before it
reaches the cabin? The water enters the pipe from the well at a

temperature of 20 C .
It empties into a storage tank in the cabin which contains water at
approximately the temperature of the entering water. Assume,
3 
therefore, that kd  / dx  0 h
at the point. Take o  4. 5 Nm / m sC
Due: March 28, 2025
Hand in the following items to me in the
class:
1. Technical report with all answers;
2. The matlab codes which you have
written and modified.
Reading Assignment

J. N. Reddy
“Introduction to the Finite Element Method”
Chap 3 Problems
Project 1

Presentation Date: April 11, 2025


Draw lot to determine which problems your group can
choose to solve.
Give a 10-min presentation
Upload the following items and e-mail to
[email protected]
① Presentation ppt with all answers;
② The codes which you have written and modified.
Grade of Project 1

Performance Mark Grade


Absence D 60
Only finish Example 1 C 70
and Example 2 C+ 73
Start to solve the B- 77
problem you choose B 80
but can not finish
finally B+ 83
Finish the problem A- 87
you choose and A 90
obtain the nearly
correct solution A+ 93
Finite Element Method

LECTURE 4

Yu-Ching Wu

You might also like