슬라이드 1

Seoul National
University
Introduction to
Finite Element Method
Chapter 2
Development of a 1-D Finite Element
Program
Seoul National University
Aerospace Structures Laboratory
2-1. Computer Implementation of FEM
General purpose computer program
- Develop a FEM program that solves a class of
one dimensional Two Point Boundary Value Problems
Functional units of a finite element code
Preprocessor
Processor
Postprocessor
Read input data
Set up and solve equations
Calculate the necessary physical
Define problem-dependent
to obtain the values at nodes
quantities (stress or flux) from
parameters and data array
as the solutions
the solution obtained
by Processor.
Seoul National University
Aerospace Structures Laboratory
2-2. Description of 1D Code
General two point boundary value problem
Differential equation:

d
du ( x)
du ( x)
(k ( x)
)  c( x)
 b( x)u ( x)  f ( x) ,
dx
dx
dx
a xb
Boundary conditions:
u (a)  u a
u (b)  ub
du (a)
 a
dx
du (a)
k (a)
 pa [u (a)  u a ]
dx
 k (b)
k (a)
a
du (a)
  a u (a)   a
dx
Seoul National University
du (b)
 b
dx
du (b)
 k (b)
 pb [u (b)  ub ]
dx
b
du (b)
  b u (b)   b
dx
Aerospace Structures Laboratory
2-2. Description of 1D Code – Flow Charts
CODE 1*
Calls basic
functional units
SETINT*
Calculates
quadrature rule
data
PREP*
Preprocessor : calls
routines to read
and generate data
PROC
Processor: Forms
and solves finite
element equations
POST*
Postprocessor:
Prints solution and
evaluate errors
Prep*
RCON
Reads control
parameters
RNODE*
Reads and
generates
nodal point
coordinates
Seoul National University
RELEM
Reads and
generates
element data
RBC
Reads
boundary
condition data
RMAT
Reads
material
property data
Aerospace Structures Laboratory
2-2. Description of 1D Code – Flow Charts
PROC
FORMKF*
Sets up global matrix
K and vector F
ELEM*
Calculates element
matrix Ke and Fe
ASSMB*
Adds Ke to K, adds
Fe to F
APLYBC*
SOLVE*
Solves the linear
equations K U = F for
nodal-point values U
Modifies K and F to
account for boundary
conditions
DRCHLT*
Imposes essential
boundary
conditions
SHAPE*
Calculates shape
function values
TRI*
Performs
Gaussian
elimination on K
RHSUB*
Performs elimination
and back substitution
on right-hand side F
POST*
GETMAT
Calculates material
properties
EVAL*
Evaluates and prints
finite element and
exact solution
SHAPE*
Seoul National University
EXACT*
Calculates exact
solution and derivative
ENORMS*
Evaluates and prints
error norms ||u-uh||2
and ||u-uh||E
Aerospace Structures Laboratory
2-2. Description of 1D Code – Data Arrays
CONTROL PARAMETERS
COMMON/CCON/TITLE(60), NNODE NELEM, NMAT, NPOINT
TITLE – alphanumeric array containing problem title
NNODE – number of nodal points in problem
NELEM – number of elements in problem
NMAT – number of materials in problem
NPOINT – number of point loads in problem
NODAL-POINT DATA
COMMON/CNODE/X(1001),U(1001)
X – coordinates of nodal points
U – finite element solution at nodal points
ELEMENT DATA
COMMON/CELEM/KIND(1000),MAT(1000),NODES(11,1000), NINT(1000)
KIND – degree of polynomial in element shape function
MAT – number of material type of element
NODES – node numbers of nodes in element
NINT – number of integration points used in element calculations
Seoul National University
Aerospace Structures Laboratory
2-2. Description of 1D Code – Data Arrays
MATERIAL DATA
COMMON/CMATL/PROP(4,5)
PROP – coefficients k,c,b and f for the material
BOUNDARY – CONDITION DATA
COMMMON/CBC/VBC(2,3), KPOINT(100), POINT(100)
VBC – values of boundary-condition data
KPOINT – node number of point loads
POINT – value of point loads
MATRIX STORAGE
COMMON/CMATRX/GK(1001,11), GF(1001)
GK – global K matrix
GF – global F vector
NUMERICAL QUADRATURE DATA
COMMON/CINT/XI(6,6), W(6,6)
XI – locations of integration points for rules of order 1-4
W – weights for integration points for rules of order 1-4
Seoul National University
Aerospace Structures Laboratory
2-2-1. Preprocessing Routine
- The data required for the calculation of the stiffness matrix and load vector are
defined by routine PREP
- As a general rule,
1. Read the required data according to a convenient format
2. Store the data in the appropriate common block
3. Print the data in an easily interpreted format
Seoul National University
Aerospace Structures Laboratory
2-2-2. Control Data & Nodal-Point Coordinate Definition
- RCON reads the values of the control parameters NNODE, NELEM, NMAT and
NPOINT
- For example,
2 ≤ NNODE ≤ 1001
1 ≤ NELEM ≤ 1000
1 ≤ NMAT ≤ 5
0 ≤ NPOINT ≤ 1000
- RNODE reads data that allow the definition of the x-coordinates of all nodal points
- The nodes are numbered consecutively from 1 through NNODE
Seoul National University
Aerospace Structures Laboratory
2-2-3. Element Data, Material Property & Boundary Condition
Definition
- RELEM reads the data of all elements in the FE model
- Data record format for element definitions
NINT
order of the integration rule
KIND
kind of element (degree of polynomial in the shape functions)
MAT
number of the material that constitutes the element
NODE
nodal point numbers of nodes in element
-RMAT reads the data of material properties k(x), c(x), b(x) and f(x)
- RBC reads the data of boundary condition
KBC(1)
essential (Dirichlet) boundary condition
KBC(2)
flux (Neumann) boundary condition
KBC(3)
natural boundary condition
Seoul National University
Aerospace Structures Laboratory
2-2-4. Material-Property Routine - GETMAT
- This routine calculates the values of the material properties (coefficients in the
differential equation)
- The values of the properties XK, XC, XB and XF are returned
Seoul National University
Aerospace Structures Laboratory
2-3 Element Calculation
The most important parts in this programming are
- Efficient Integration procedure to generate
the element matrices and vectors
- Assembly of Global matrix from the generated
element quantities
Seoul National University
Aerospace Structures Laboratory
2.3.1 Mater Element, Mapping
The element matrix can be written by,
s2
K   g ( x)dx
e
ij
s1
And then, we transform this formulation to the mater element variables
defined in the domain, -1 ≤ ξ ≤ 1
The mapping function is x  M ( )
and the differential becomes
1
K   g[ M ( )]
1
dx 
dM
d
d
dM
d
d
1
  G ( )d
-1
Seoul National University
Aerospace Structures Laboratory
2.3.1 Mater Element, Mapping
therefore,
x

and then,
s1
-1
s2
x  M ( )
0
1
i (x)
ˆi ( )
i ( x)  i ( M ( ))  ˆ i ( )
di dˆ i d
i ' ( x) 

 ˆ i ' ( x) / M '
dx
d dx
Finally we have ,
ˆ( )
 kˆ( )

k
ˆ

ˆ
ˆ
ˆ
ˆ
ˆ
K  
 i ' j '
 i ( ) j 'b( ) i j  M ' d
1 M ' 2
M'


1
e
Fi   fˆ ( )ˆ i ( )M ' d
e
ij
1
1
Seoul National University
Aerospace Structures Laboratory
2.3.2 Numerical quadrature rule
•Numerical Quadrature : the numerical calculation of the area under a curve,
or more generally, using numerical integration to calculate a definite integral
General type of integration of function f is represented as following;
L[ f ]  
b
a
ba 1
f ( x)dx 
F ( )d
2 1
Numerical Integration methods;
ⅰ) Rectangular rule
ⅱ) Trapezoidal rule
ⅲ) Romberg integration rule
1st Romberg = Simpson's rule
i), ii), iii) are
Newton-Cotes type Integration
(equal interval) closed Type
iv) is open type integration rule
iv) Gauss quadrature rule
Basic idea : Determine integral points and weights to minimize
the integration error (in the case of polynomials)
1

1
Seoul National University
N
F ( )d   wi F ( i )
i 0
Aerospace Structures Laboratory
2.3.2 Numerical quadrature rule
1

1
N
F ( )d   wi F ( i )
i 0
F ( ) is (2n+1)th order, Pn ( ) is nth Legendre polynomial
then,
F ( )  Pn1 ( )S ( )  T ( )
where, S ( ) is nth order,
1

1
①
T ( ) is nth order
1
1
1
1
F ( )d   Pn1 ( )S ( )d   T ( )d
②
Write eq ② by integral points and weights;
n
n
n
 w F ( )   w P
i
i 0
i
i 0
i n 1
Select the points such as
( i ) S ( i )   wiT ( i )
i 0
and then
n
n
 w F ( )   w T ( )
i 0
Seoul National University
③
i
i
i 0
i
i
④
Aerospace Structures Laboratory
2.3.2 Numerical quadrature rule
S ( ) is LC of
{Pi }i 1,,n  0
n
S ( )    i Pi ( )
i 0
From the orthogonality of Legendre function,
1

1
n
Pn 1 ( ) S ( )d   Pn 1   i Pi ( )d  0
1
1
i 0
therefore eq ② becomes
1

1
1
F ( )d   T ( )d
1
⑤
Integral value becomes exact because it is determined exactly from Lagrange
interpolation if proper is selected when nth order polynomial
has (n+1)
integral points
Seoul National University
Aerospace Structures Laboratory
2.3.2 Numerical quadrature rule
therefore,
1

1
n
T ( )d   wiT ( i )
⑥
i 0
from ④ ⑤ ⑥
1

1
n
F ( )d   wi F ( i )
i 0
Conclusion;
(2n+1)th order polynomial can be integrated exactly
by using (n+1) integral points for (n+1)th order polynomial functions
Seoul National University
Aerospace Structures Laboratory
2.3.2 Numerical quadrature rule
Gauss Quadrature Rule
1 point :
1  0
2 points :
1  
3 points :
1
3
1
2 
3
1  
3
5
2  0
3 
Seoul National University
3
5
,
w1  2
,
w1  1
,
w2  1
,
w1 
5
9
,
w2 
8
9
,
w3 
5
9
Aerospace Structures Laboratory
2.3.2 Numerical quadrature rule
4 points :
 3  2 1.2 

7


1/2
1, 4   
 2,3
 3  2 1.2 
 

7


,
w1,4 
1
1

2 6 1.2
,
w 2,3 
1
1

2 6 1.2
w1,5 
5103
50(322  13 70 )
w 2,4 
5103
50(322  13 70 )
1/2
1/2
5 points :
 5  2 10 / 7 
1,5   
 ,
9


1/2
 5  2 10 / 7 
 2, 4   
 ,
9


 3  0,
Seoul National University
w3 
122
225
Aerospace Structures Laboratory
2-3-1. Integration Routine - SETINT
- The integrations are carried out using Gaussian quadrature
- The data for these rules are stored in common block CINT by subroutine SETINT
- This routine defines parameters for numerical integration
- These data are problem-independent
Seoul National University
Aerospace Structures Laboratory
2-3-2. Shape-Function Routine - SHAPE
- The values of the shape functions ψi(ξ) and their derivatives dψi/dξ are defined
- This routine is called by element matrix calculation routine ELMAT and by routine
EVAL in the postprocessor
- SHAPE calculates the values of the shape functions and their derivatives with
respect to the master element coordinate at a specified value of ξ
- The calculated values are returned in arrays PSI and DPSI
Seoul National University
Aerospace Structures Laboratory
2-3-2. Shape-Function Routine - SHAPE
PSI
1
(1   )
2
1
2 ( )  (1   )
2
1 ( ) 
Linear
Quadratic
1
1 ( )   (  1)
2
2 ( )  1   2
1
3 ( )   (  1)
2
9
1
(1   )( 2  )
16
9
27 2
1
2 ( ) 
(  1)(  )
16
3
27
1
3 ( ) 
(1   2 )(  )
16
3
9
1
4 ( )  (  1)( 2  )
16
9
1 ( ) 
Cubic
Seoul National University
DPSI
d1
1

d
2
d2 1

d
2
d1
1
 
d
2
d2
 1  2
d
d3
1
 
d
2
d1
d
d2
d
d3
d
d4
d
9
1
(3 2  2  )
16
9
27
2

(3 2    1)
16
3
27
2

(3 2    1)
16
3
9
1
  (3 2  2  )
16
9

Aerospace Structures Laboratory
2-4. Element Routine - ELEM
- The element stiffness matrix ke and the element load vector fe
in the global coordinate x ;
x2






kije   [k ( x)ie x   je  x   c( x)ie  x ie  x   b( x)ie  x ie  x ]dx
x1
f i e   f ( x) je  x dx
x1
x2
i, j  1,2, , N
- Calculate these quantities at the integration points by the following chain rule,
ˆ d d
ˆ
di d
2
i
i


dx
d dx d x2  x1
- The explicit formulas are ;
kije 
fi e 
ˆ ( ) d d
ˆ ( ) d
ˆ ( ) d

d
d
dx Nl 
j
l
j
l
i
l
ˆ
ˆ ( )
ˆ ( )




w
k
x

c
x

(

)
 b( xl )

l
l
l
i
l
i
l
j
l
d l 1 
d
d
dx dx
d
dx

dx Nl
ˆ ( ) f ( x )
wl 

i
l
1
d l 1
Seoul National University
Aerospace Structures Laboratory
2-3-3. Element Routine - ELEM
X1,X2
= coordinates x1 and x2 of the ends of the element
N
= number of nodal points (and shape functions) in the element
NL
= order of the integration rule
XI(L)
= ξl, the location of integration point, l
X
= the value of the global coordinate at an integration point
DX
= dx/dξ = (x2-x1)/2; Note that dξ /dx= (dx/dξ)-1
EK(I,J) = keij , entry in element stiffness matrix
EF(I)
= fei, entry in element load vector
W(L)
= wl, the integration weights
PSI(I),DPSI(I) = ˆ i (l ), dˆ i (l ) / d , the values of shape functions and their derivatives at
integration points
XK,XC,XB,XF = k(xl), c(xl), b(xl), f(xl), values of the material properties at xl = x(ξl)
Seoul National University
Aerospace Structures Laboratory
2-4-1. Finite Element Calculation Routines
- This unit consists of the calling routine PROC and the routines that calculate, assemble,
modify for boundary conditions, and solve the finite element equations
Ku=F
- This routine contains
FORMKF
calculate element stiffness matrices EK and load vectors EF
ASSEM
assembly procedure to make global matrix K and load vector F
APLYBC
modifications to the global matrix K and vector F required to impose
the boundary conditions at each end of the domain
SOLVE
calculate the solution to the FE equations by Gaussian elimination
method
Seoul National University
Aerospace Structures Laboratory
2-4-2. Element Stiffness Matrix & Load Vector – Sample Code
void element()
{
mapping
……
dx=(x2-x1)/2.;
for(l=0;l<(nl+1);l++) {
x=x1+(1.+xi[l][nl])*dx;
getmat(x,&xk,&xb,&xc,&xf);
calculate material properties
get shape function values
shape(xi[l][nl],(n-2),psi,dpsi);
for(i=0;i<n;i++) {
ef[i]+=psi[i]*xf*w[l][nl]*dx;
calculate element load vector
by gauss quadrature
for(j=0;j<n;j++) {
ek[i][j]+=(xk*dpsi[i]*dpsi[j]/dx/dx
+xc*psi[i]*dpsi[j]/dx+xb*psi[i]*psi[j])*w[l][nl]*dx;
}
}
}
……
calculate element stiffness matrix
by gauss quadrature
}
Seoul National University
Aerospace Structures Laboratory
2.5 Element Assembly
2.4.1 Square Assembly
Global Matrix and Vector can be written by
NN
K ij   K ij 
e 1
k l
l
 iN jN 
k 0
0
 i1 j1
k
k
Fi   f i e  fˆ inx  l  iN  0  i1
NN
e 1
Seoul National University
2
l
0
Aerospace Structures Laboratory
2.5.1 Square Assembly
Assemblage by Linear Elements
Seoul National University
Aerospace Structures Laboratory
2.5.2 Banded Assembly
N by N square Matrix becomes a banded N by M rectangular matrix
GK ( N , N )
GKB( N , M )
DO 1
I=1, N
IG=NODE(I)
GF(iG)=GF(iG)+EF(i)
DO 1
j=1, N
jG=NODE(j)-iG+1
IF(jG.LE.0) GOTO 1
GKB(iG,jG)=GKB(iG,jG)+EK(i,j)
1 CONTINUE
Seoul National University
Aerospace Structures Laboratory
2.5.2 Banded Assembly
Seoul National University
Aerospace Structures Laboratory
2.5.2 Banded Assembly
After assembly process, we have
K ij j  Fi
To prescribe the boundary conditions at i  1
K111 
k0  0
k0 0
1  K12 2  K13 3    Fi 
0
0
From the condition,  0u '  0u   0

 0  u  0  1
0
If we set
 0  10 30
( K111  K12 2  K13 3  ) 10 30  k0  01  F1 10 30  k0 0
 k0  01  k0 0
 1 
0
(numerical ly)
0
But, if
is not small enough, the answer could be wrong
because the penalty effect does not dominate the equation
Seoul National University
Aerospace Structures Laboratory
2-6. Postprocessing
- Evaluation of exact solutions and error norms
EVAL
ENORMS
calculates the value of the FE solution UH and the stress (flux) SIGH
at a given point in a given element
calculates two measures of the error in the FE solution
mean-square norm: e 0 
energy norm:
EXACT
e
E

 e dx
b
1/ 2
2
 [(e' )  (e) ]dx
b
a
2
2
1/ 2
where, e( x)  u( x)  uh ( x)
a
for a given value of X, the exact values of the solution U and the
stress are calculated
Seoul National University
Aerospace Structures Laboratory
2-6-1. Error Norm Calculation – Sample Code
void enorms ()
{
……
mapping
for (i=0;i<nelem;i++) {
dx=(x[i+1]-x[i])*.5;
get shape function values
for (j=0;j<nquad;j++) {
xx=x[i]+(1.+xi[j][nquad-1])*dx;
shape(xi[j][nquad-1],(kind[i]-1),psi,dpsi);
uh=0.; duh=0.;
for (k=0;k<(kind[i]+1);k++) {
gauss quadrature
uh+=psi[k]*gf[i*kind[i]+k];
duh+=dpsi[k]*gf[i*kind[i]+k]/dx;
}
exact(xx,&ux,&dux);
get exact solution
get material variables
getmat(xx,&xk,&xb,&xc,&xf);
energy norm calculation
square norm calculation
en+=(xk*pow((duh-dux),2.)+xb*pow((uh-ux),2.))*w[j][nquad-1]*dx;
sn+=pow((uh-ux),2.)*w[j][nquad-1]*dx;
}
}
en=sqrt(en); sn=sqrt(sn);
……
}
Seoul National University
Aerospace Structures Laboratory
2-7. Application (1)
Differential equation of general two point boundary value problem

d
du ( x)
du ( x)
(k ( x)
)  c( x)
 b( x)u ( x)  f ( x) ,
dx
dx
dx
a xb
When the coefficients are as follows:
k ( x) 
1

  ( x  x0 ) 2
b( x )  0
c( x)  0



f ( x)  2 1   ( x  x0 ) tan 1  ( x  x0 )  tan 1 (x0 )
The exact solution becomes,
u ( x)  (1  x)[tan 1  ( x  x0 )  tan 1 (x0 )]
Seoul National University
Aerospace Structures Laboratory
# of Node :
10
100
10
0.7
Blue circles : FEM solution
Red line : exact solution
0.6
α=5,
x0=0.5
0.5
(smooth
function)
0.4
0.3
0.2
0.1
0
0
0.1
0.2
Element :
4th
Seoul National University
0.3
0.4
3rd
0.5
0.6
0.7
2nd
0.8
0.9
1
1st
Aerospace Structures Laboratory
2-7. Application (2)
Elastic deformation of cylinders
- The problem of calculating the stresses and deformations in a body of
revolution with axisymmetric loadings can be reduced to a one-dimensional
problem in the case of a long circular cylinder (plane strain) or a thin circular
disk (plane stress)
- The quantities of interest are the radial displacement u, the radial stress σx
and the tangential stress σθ
- From the Hooke’s law
 x  c1u 'c2u / x  c3eT
   c1u / x  c2u 'c3eT
where, Plane Strain
c1  E (1  ) /(1   )(1  2 )
c2  E (1   )(1  2 )
c3  E /(1  2 )
Seoul National University
Plane Stress
Thermal Strain
c1  E /(1  2 )
eT  T
c2  E /(1  2 )
c3  E /(1  )
Aerospace Structures Laboratory
2-7. Application (2)
- The variational statement of the boundary value problem is to find u=u(x) in H1

xo
xi
[c1 xu' v'c2 (u ' v  uv' )  c1uv / x]dx
xo
  (vf1  v' f 2 )dx   x v( xo )   x v( xi )
o
xi
i
for all v  H 1
where, f1 and f2 are distributed loads due to temperature and spin
σxi and σxo are the prescribed values of σx at the inner and outer boundaries
f1   2 x 2  c3T
f 2  c3Tx
( ρ : mass density , ω : angular velocity )
Seoul National University
Aerospace Structures Laboratory