Professional Documents
Culture Documents
05/20/2020
C a 4: I a a F a
4.1 I
In this chapter, e introd ce the isoparametric form lation, a s stematic a to de elop finite
element libraries for 2D and 3D problems. The form lation of isoparametric element is one of
the most important de elopment in finite elements. T a a a
a a a a a ab
, a a .
( x4e , y4e )
( x3e , y3e )
( x2e , y2e )
e e
(x , y )
1 1
4.2 F -N Q a a a E (Q4)
Altho gh the rectang lar element can be er sef l and is s all more acc rate than the
triang lar element, it is diffic lt to be emplo ed in problems ith geometries other than
rectangles. Therefore, its practical application is er limited. A m ch more practical and sef l
element o ld be the so-called a a a , that can ha e fo r nparalleled edges.
1
F E M
05/20/2020
Ho e er, there can be a problem for the integration of the stiffness matri for a q adrilateral
element d e to the irreg lar shape of the integration domain. The Ga ss integration scheme
cannot be implemented directl ith q adrilateral elements. Therefore, hat is req ired first is
to map the q adrilateral element into the nat ral coordinates s stem to become a a
(parent element), so that the shape f nctions and the integration method sed for the
rectang lar element can be tili ed. Hence, ke in the de elopment of a q adrilateral element
is the a a . Once the mapping is established, the rest of the proced re is the
same as that sed for form lating the rectang lar element in Section 3.9.
sing 𝐍𝑒 and 𝐁 𝑒 .
2
F E M
05/20/2020
𝑸𝟒
4.2.1 D a F I a 𝐍
( x4e , y4e )
( x3e , y3e )
( x2e , y2e )
e e
(x , y )
1 1
To de elop a q adrilateral element, e again consider the parent element be a sq are as sho n
in the fig re abo e. As there are t o DOFs at a node, a linear q adrilateral element has a total
of eight DOFs, like the rectang lar element.
4.1 𝐮𝑒 𝜉, 𝜂 𝐍 4
𝜉, 𝜂 𝐝𝑒
Or in matri form:
𝑢𝑥𝑒
𝑢𝑦𝑒
𝑒
𝑢𝑥1
𝑒
𝑢𝑦1
𝑒
𝑢𝑥2
4 4 4 4 𝑒
𝑁1 𝜉, 𝜂 0 𝑁2 𝜉, 𝜂 0 𝑁3 𝜉, 𝜂 0 𝑁4 𝜉, 𝜂 0 𝑢𝑦2
4 4 4 4 𝑒
0 𝑁1 𝜉, 𝜂 0 𝑁2 𝜉, 𝜂 0 𝑁3 𝜉, 𝜂 0 𝑁4 𝜉, 𝜂 𝑢𝑥3
𝑒
𝑢𝑦3
𝑒
𝑢𝑥4
𝑒
𝑢𝑦4
here the shape f nctions are the same as e ha e sed in de eloping the rectang lar element:
4 1
3.73 𝑁1 𝜉, 𝜂 1 𝜉 1 𝜂
4
1
𝑁2 4 𝜉, 𝜂 1 𝜉 1 𝜂
4
1
𝑁3 4 𝜉, 𝜂 1 𝜉 1 𝜂
4
4 1
𝑁4 𝜉, 𝜂 1 𝜉 1 𝜂
4
3
F E M
05/20/2020
or in a compact form
4 1
3.74 𝑁 𝜉, 𝜂 1 𝜉𝜉 1 𝜂𝜂
4
4.2.2 S a - a a 𝐁𝑒
We no ant to form late the strain-displacement matri 𝐁 𝑒 . The major diffic lt is to define
strains in terms of the deri ati es of the displacements ith respect to the x and coordinate.
Ho e er, the displacements in Eq. (4.1) 𝐮𝑒 𝜉, 𝜂 𝐍 4
𝜉, 𝜂 𝐝𝑒 are no f nctions of the 𝜉
and 𝜂.
Recall the simple coordinate mapping e ha e for the rectang lar element:
( 1,1) (1,1)
( xce , yce )
( 1, 1) (1, 1)
𝑥 𝑥𝑒 𝑦 𝑦𝑒
3.70 𝜉 ,𝜂
𝑎 𝑏
𝑑𝑥 𝑑𝑦
3.71 𝑑𝜉 , 𝑑𝜂
𝑎 𝑏
For the q adrilateral elements, the transformation and differential relationship bet een the
ph sical coordinates (x and ) and the nat ral coordinates ( 𝜉 and 𝜂 ) is no longer as
straightfor ard as in the case for rectang lar elements. It is not possible to e press 𝜉, 𝜂 as
f nctions of x, directl and e need to appl chain r le of differentiation.
𝜕𝑓 𝜕𝑓 𝜕𝑥 𝜕𝑓 𝜕𝑦
4.2
𝜕𝜉 𝜕𝑥 𝜕𝜉 𝜕𝑦 𝜕𝜉
𝜕𝑓 𝜕𝑓 𝜕𝑥 𝜕𝑓 𝜕𝑦
𝜕𝜂 𝜕𝑥 𝜕𝜂 𝜕𝑦 𝜕𝜂
4
F E M
05/20/2020
Or in matri form:
𝜕𝑓 𝜕𝑥 𝜕𝑦 𝜕𝑓 𝜕𝑓
𝜕𝜉 𝜕𝜉 𝜕𝜉 𝜕𝑥 𝜕𝑥
4.3 𝜕𝑓 𝐉𝑒 𝜕𝑓
𝜕𝑓 𝜕𝑥 𝜕𝑦
𝜕𝜂 𝜕𝜂 𝜕𝜂 𝜕𝑦 𝜕𝑦
here
𝜕𝑥 𝜕𝑦
𝜕𝜉 𝜕𝜉
4.4 𝐉𝑒 is the 𝐉𝐚𝐜𝐨𝐛𝐢𝐚𝐧 matrix
𝜕𝑥 𝜕𝑦
𝜕𝜂 𝜕𝜂
The 𝐁 𝑒 consists of deri ati es in the ph sical coordinates. The req ired deri ati es can be
obtained b in erting (4.3):
−1
𝜕𝑓 𝜕𝑥 𝜕𝑦 𝜕𝑓 𝜕𝑓
𝜕𝑥 𝜕𝜉 𝜕𝜉 𝜕𝜉 𝜕𝜉
4.5 𝜕𝑓 𝐉𝑒 −1
𝜕𝑥 𝜕𝑦 𝜕𝑓 𝜕𝑓
𝜕𝑦
( 𝜕𝜂 𝜕𝜂 ) 𝜕𝜂 𝜕𝜂
𝜕
0
𝜕𝑥
𝑒
𝜕 𝑁1 4 0 𝑁2
4
0 𝑁3
4
0 𝑁4
4
0
4.6 𝐁 3 8 0 4 4 4 4
𝜕𝑦 0 𝑁1 0 𝑁2 0 𝑁3 0 𝑁4
𝜕 𝜕
𝜕𝑦 𝜕𝑥
4 4 4 4
𝜕𝑁1 𝜕𝑁2 𝜕𝑁3 𝜕𝑁4
0 0 0 0
𝜕𝑥 𝜕𝑥 𝜕𝑥 𝜕𝑥
4 4 4 4
𝜕𝑁1 𝜕𝑁2 𝜕𝑁3 𝜕𝑁4
0 0 0 0
𝜕𝑦 𝜕𝑦 𝜕𝑦 𝜕𝑦
4 4 4 4 4 4 4 4
𝜕𝑁1 𝜕𝑁1 𝜕𝑁2 𝜕𝑁2 𝜕𝑁3 𝜕𝑁3 𝜕𝑁4 𝜕𝑁4
𝜕𝑦 𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑦 𝜕𝑥
5
F E M
05/20/2020
𝐽11𝑣 𝐽12𝑣
(D a E ) Let 𝐉 𝑒 −1
. Deri e 𝐁 𝑒 1,1 from 𝐁 𝑒 matri for the
𝐽21𝑣 𝐽22𝑣
4-node q adrilateral element from the abo e.
(A )
4.2.3 Ja b a a 𝐉𝒆
( x4e , y4e )
( x3e , y3e )
( x2e , y2e )
e e
(x , y )
1 1
𝜕𝑥 𝜕𝑦
𝜕𝜉 𝜕𝜉
We can f rther e plore the Jacobian matri 𝐉𝑒 𝜕𝑥 𝜕𝑦
thro gh coordinate interpolation.
𝜕𝜂 𝜕𝜂
𝑥1𝑒
𝑥2𝑒
4.7a 𝑥 𝜉, 𝜂 𝐍 4
𝜉, 𝜂 𝐱 𝑒 𝑁1 4 𝜉, 𝜂 𝑁2 4 𝜉, 𝜂 𝑁3 4 𝜉, 𝜂 𝑁4 4 𝜉, 𝜂
𝑥3𝑒
𝑥4𝑒
4
4 𝑒
𝑁 𝑥
=1
6
F E M
05/20/2020
𝑦1𝑒
𝑦2𝑒
4.7b 𝑦 𝜉, 𝜂 𝐍 4
𝜉, 𝜂 𝐱 𝑒 𝑁1 4 𝜉, 𝜂 𝑁2 4 𝜉, 𝜂 𝑁3 4 𝜉, 𝜂 𝑁4 4 𝜉, 𝜂
𝑦3𝑒
𝑦4𝑒
4
4 𝑒
𝑁 𝑦
=1
A:
A :
7
F E M
05/20/2020
R a :
1. E 2 3 a a a 2 3 a a
a a . The same can be obser ed for the other three edges.
Hence, e can see that the fo r straight edges of the q adrilateral in the ph sical coordinate
s stem correspond to the fo r straight edges of the sq are in the nat ral coordinate s stem.
Therefore, the f ll domain of the q adrilateral element is mapped onto a sq are one.
2. Note that not e er straight line in the nat ral coordinates maps into a straight line in the
ph sical coordinates. If the ph sical element is not a rectangle, the diagonal of the parent
element, here 𝜉 𝜂 and the bilinear term becomes q adratic in 𝜉, is a in
the ph sical element. In general, not all straight lines in the parent element map into straight
lines in the ph sical element, b t the edges al a s do.
3. T a a a E . (4.7a) a (4.7b) a
a a a a (E . (4.1)). S ch an element is
called an a a . If e se lo er order interpolants for the coordinates,
e call s ch element a s bparametric element (e.g., beam element). If e se higher
order interpolants for the coordinates, e call s ch element a s perparametric element.
𝜕𝑥 𝜕𝑦
𝜕𝜉 𝜕𝜉
No go back to the calc lation of the Jacobian matri 𝐉𝑒 𝜕𝑥 𝜕𝑦
. Using Eqs. (4.7a) and
𝜕𝜂 𝜕𝜂
(4.7b), e ha e:
4 4
𝜕𝑥 𝜕𝑦 𝜕𝑁 4 𝑒 𝜕𝑁 4 𝑒
𝑥 𝑦
𝜕𝜉 𝜕𝜉 𝜕𝜉 𝜕𝜉
=1 =1
4.8 𝐉𝑒 4 4
𝜕𝑥 𝜕𝑦 𝜕𝑁
4
𝜕𝑁
4
𝜕𝜂 𝜕𝜂 𝑥𝑒 𝑦𝑒
𝜕𝜂 𝜕𝜂
=1 =1
4 4 4 4
𝜕𝑁1 𝜕𝑁2 𝜕𝑁3 𝜕𝑁4 𝑥1𝑒 𝑦1𝑒
𝜕𝜉 𝜕𝜉 𝜕𝜉 𝜕𝜉 𝑥2𝑒 𝑦2𝑒
𝜕𝑁1
4
𝜕𝑁2
4
𝜕𝑁3
4
𝜕𝑁4
4 𝑥3𝑒 𝑦3𝑒
𝜕𝜂 𝜕𝜂 𝜕𝜂 𝜕𝜂 𝑥4𝑒 𝑦4𝑒
8
F E M
05/20/2020
1 𝜂 1 𝜂 1 𝜂 1 𝜂 𝑥1𝑒 𝑦1𝑒
4 4 4 4 𝑥2𝑒 𝑦2𝑒
1 𝜉 1 𝜉 1 𝜉 1 𝜉 𝑥3𝑒 𝑦3𝑒
4 4 4 4 𝑥4𝑒 𝑦4𝑒
4
S bstit te 𝑓 𝑁 into Eq. (4.5):
𝜕𝑁 4 𝜕𝑁 4
𝜕𝑥 𝜕𝜉 4 4
4.9 𝐉𝑒 −1
𝛁 𝑥,𝑦 𝑁 𝐉𝑒 −1
𝛁 𝜉,𝜂 𝑁
𝜕𝑁 4 𝜕𝑁 4
𝜕𝑦 𝜕𝜂
4 4 4 4
𝜕𝑁1 𝜕𝑁2 𝜕𝑁3 𝜕𝑁4
𝜕𝑥 𝜕𝑥 𝜕𝑥 𝜕𝑥
Define 𝐗𝐘𝐃𝐞𝐫𝐯 𝑒 4 4 4 4
𝜕𝑁1 𝜕𝑁2 𝜕𝑁3 𝜕𝑁4
𝜕𝑦 𝜕𝑦 𝜕𝑦 𝜕𝑦
⇒ 4.10 𝐗𝐘𝐃𝐞𝐫𝐯 𝑒 𝐉𝑒 −1
𝛁 𝜉,𝜂 𝐍 4
Or in matri form:
𝜕𝑦 𝜕𝑦 𝜕𝑦 𝜕𝑦 𝜕𝜂 𝜕𝜂 𝜕𝜂 𝜕𝜂
1 𝜂 1 𝜂 1 𝜂 1 𝜂
𝐉𝑒 −1 4 4 4 4
1 𝜉 1 𝜉 1 𝜉 1 𝜉
4 4 4 4
Therefore, b comp ting the deri ati e of shape f nctions ith respect to the ph sical
coordinates from in erse of Jacobian m ltiplied b the deri ati e of shape f nctions ith
respect to the nat ral coordinates, e can obtain the components in the strain-displacement
matri (i.e., Eq. (4.6)):
4 4 4 4
𝜕𝑁1 𝜕𝑁2 𝜕𝑁3 𝜕𝑁4
0 0 0 0
𝜕𝑥 𝜕𝑥 𝜕𝑥 𝜕𝑥
𝑒
𝜕𝑁1 4 𝜕𝑁2 4 𝜕𝑁3 4 𝜕𝑁4 4
4.6 𝐁 3 8 0 0 0 0
𝜕𝑦 𝜕𝑦 𝜕𝑦 𝜕𝑦
𝜕𝑁1 4 𝜕𝑁1 4 𝜕𝑁2 4 𝜕𝑁2 4 𝜕𝑁3 4 𝜕𝑁3 4 𝜕𝑁4 4 𝜕𝑁4 4
𝜕𝑦 𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑦 𝜕𝑥
9
F E M
05/20/2020
4.2.4 E S Ma
Once the strain-displacement matri 𝐁 𝑒 is obtained, e can proceed to e al ate the element
stiffness matri :
+1 +1
𝑒 𝑒 𝑒 𝑒
4.12 𝐊 𝑡 𝐁 𝐂 𝐁 𝑑Ω 𝑡 det 𝐉 𝑒 𝐁 𝑒 𝐂 𝑒 𝐁 𝑒 𝑑𝜉𝑑𝜂
Ω𝑒 −1 −1
𝑡 𝑊 𝑊 det 𝐉 𝑒 𝐁 𝑒 𝐂 𝑒 𝐁 𝑒
=1 =1
R a :
1. Eq ation (4.12) can be e al ated sing the Ga ss integration scheme. Notice ho the
coordinate mapping enables s to se the Ga ss integration scheme o er a simple sq ared
area.
2. (a) The shape f nction is a bilinear f nction of 𝜉 and 𝜂 . The elements in the strain-
displacement matri 𝐁 𝑒 are obtained b differentiating these bilinear f nctions ith
respect to 𝜉 and 𝜂, and b m ltipl ing 𝐉 𝑒 −1 (see Eqs. (4.6) and (4.11) and the one-
element e ample later).
(c) In practice, e ho e er se the g idance from the rectang lar elements to appl the
req ired Ga ss integration points.
4.2.5 E E a F Ma
The element e ternal force matri of a q adrilateral element ith a thickness t consists of t o
terms: one from the bod forces and the other from the tractions.
10
F E M
05/20/2020
- 𝐟 𝒆
b (𝐟𝛀𝒆 )
+1 +1
4.13 𝐟Ω𝑒 𝑒
𝐍 𝐛 𝑑Ω 𝐍 4
𝐛 det 𝐉 𝑒 𝑡𝑑𝜉𝑑𝜂 𝑊𝑊 𝐍 4
𝐛 𝑑𝑒𝑡 𝐉 𝑒 𝑡
Ω𝑒 −1 −1 =1 =1
- 𝐟𝒆 a (𝐟𝚪𝒆 )
The comp tation of element e ternal force matri d e to tractions req ires special attention
and e shall re isit the topic later.
4.3 Q4 MATLAB I a a I a
Consider a linear elasticit problem on the trape oidal panel domain as sho n in the follo ing
fig re.
The left edge is fi ed. The bottom and the right edges are traction free. Traction 𝑡𝑦
20 N/m is applied along the top edge. Material and sectional properties are Yo ng s mod l s
𝐸 3 107 Pa, Poisson s ratio 𝑣 0.3 and thickness = 1 m. Ass me plane stress conditions.
(Finite element discreti ation) The problem is discreti ed sing ONLY one q adrilateral
element (Q4). The finite element mesh and nodal coordinates in meters are sho n in the
follo ing fig re.
11
F E M
05/20/2020
(R T b)
1. Yo ill ne er get it right at the first time hen o codif finite elements.
We first tr to find the Jacobian matri from the deri ati e of shape f nctions and the
coordinate matri . Recall (4.8):
1 𝜂 1 𝜂 1 𝜂 1 𝜂 0 1
4 4 4 4 0 0
1 𝜉 1 𝜉 1 𝜉 1 𝜉 2 0.5
4 4 4 4 2 1
0 0.125𝜂 0.375
1 0.125𝜉 0.125
|𝐉 𝑒 | 0.125𝜂 0.375
1 𝜉
1
𝑒 −1 3 𝜂
𝐉
8
0
𝜂 3
12
F E M
05/20/2020
𝒆
The strain-displacement matri 𝐁 is
4 4 4 4
𝜕𝑁1 𝜕𝑁2 𝜕𝑁3 𝜕𝑁4
0 0 0 0
𝜕𝑥 𝜕𝑥 𝜕𝑥 𝜕𝑥
4 4 4 4
𝑒
𝜕𝑁1 𝜕𝑁2 𝜕𝑁3 𝜕𝑁4
𝐁 0 0 0 0
𝜕𝑦 𝜕𝑦 𝜕𝑦 𝜕𝑦
𝜕𝑁1 4 𝜕𝑁1 4 𝜕𝑁2 4 𝜕𝑁2 4 𝜕𝑁3 4 𝜕𝑁3 4 𝜕𝑁4 4 𝜕𝑁4 4
𝜕𝑦 𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑦 𝜕𝑥
The element stiffness matri ill be integrated sing 2 2 Ga ss q adrat re ith the
follo ing coordinates in the parent element and eights:
1 1 1 1
𝜉1 , 𝜉2 , 𝜂1 , 𝜂2 , 𝑊1 𝑊2 1
√3 √3 √3 √3
+1 +1 2 2
1 1
Let s first consider the Ga ss point at 𝜉1 , 𝜂1 , . We first comp te 𝐁 𝑒 𝜉1 , 𝜂1
√3 √3
Q: Comp te 𝐁 𝑒 𝜉1 , 𝜂1 matri .
A :
13
F E M
05/20/2020
1 1
The element stiffness contrib tion coming from this Ga ss point 𝜉1 , 𝜂1 , is
√3 √3
(𝑡 1):
𝐊 𝑒 𝜉1 , 𝜂1 𝑊1 𝑊1 |𝐉𝑒 𝜉1 , 𝜂1 |𝐁 𝑒 𝜉1 , 𝜂1 𝐂 𝑒 𝐁𝑒 𝜉1 , 𝜂1
We can repeat the same process for the remaining Ga ss points. S mming p the stiffness
contrib tion together from all the Ga ss points ields:
2 2
𝐊𝑒 𝐊𝑒 𝜉 , 𝜂
=1 =1
Q: We can find the bo ndar matri for this partic lar problem b (1) inspection; (2) tili ing
1D shape f nction interpolation and spread its contrib tion to all the degrees of freedom; or (3)
directl appl ing Eq. (4.14). Let s do it b directl appl ing Eq. (4.14).
A :
14
F E M
05/20/2020
Assembling the bo ndar matri and acco nting for the reactions ields
𝑟𝑥1 0
𝑟𝑦1 20 0
𝑟𝑥2 0
𝑟𝑦2 0
𝐟Γ𝑒 𝐫𝑒 ,𝐝 𝑢𝑥3
0
0 𝑢𝑦3
0 𝑢𝑥4
20 𝑢𝑦4
0
0
𝑢𝑥3 1.17 0
𝑢𝑦3 9.67 0
𝑢𝑥4 10−6 or 𝐝 10−6
2.67 1.17
𝑢𝑦4 9.94 9.67
2.67
9.94
15
F E M
05/20/2020
MATLAB Implementation
clear all;
% Input variables specified by user:
% Part = material, area, element type, and ngp for parts
% Part(p,1)=elastic modulus for part p
% Part(p,2)=poisson ratio for part p
% Part(p,3)=thickness for part p
% Part(p,4)=element type for part p
% (is 1 for 3-node triangle plane stress element, T3)
% (is 2 for 4-node quadrilateral plane stress
element, Q4)
% Part(p,5)=number of integration points used in Gauss
quadrature
%
% Element = element part and connectivity
% Element(e,1)=part for element e
% Element(e,2)=local node 1 for element e
% Element(e,3)=local node 2 for element e
% Element(e,4)=local node 3 for element e
% Element(e,5)=local node 4 for element e
%
% Node = nodal coordinates
% Node(n,1)=x-coordinate for node n
% Node(n,2)=y-coordinate for node n
%
% PrescribedDof = array containing information about essential
B.C.
% Essential(n,idof) = B.C. of node n in the idof
% degree of freedom (is 0 if free, 1 if disp. is
prescribed)
%
% NodalForce = array containing externally applied nodal forces
% NodalForce(n,idof) = force applied at node n in the idof
%
load('Example4.2+1.mat')
stiffness=zeros(gDof,gDof);
k = cell(numberElements,1);
force=reshape(NodalForce',[],1);
16
F E M
05/20/2020
switch elementType
case 1
elementDof=zeros(6,1);
for i = 1:3
elementDof(2*i-1)=2*Element(e,i+1)-1;
elementDof(2*i)=2*Element(e,i+1);
end
k{e}=elementStiffnessT3(e,Part,Element,Node);
case 2
elementDof=zeros(8,1);
for i = 1:4
elementDof(2*i-1)=2*Element(e,i+1)-1;
elementDof(2*i)=2*Element(e,i+1);
end
k{e}=elementStiffnessQ4(e,Part,Element,Node);
end
stiffness(elementDof,elementDof)=...
stiffness(elementDof,elementDof)+k{e};
end
% boundary conditions
% prescribed dofs
pDof=find(PrescribedDof'==1);
% solution
displacements = solution(gDof,pDof,stiffness,force);
% output displacements
outputDisplacements(displacements, numberNodes, gDof);
Displacements
Node UX UY
1 0.0000e+00 0.0000e+00
2 0.0000e+00 0.0000e+00
3 -1.1778e-06 -9.6697e-06
4 2.6743e-06 -9.9353e-06
Most of the goodies are hidden in the f nction elementStiffnessQ4 and its related
f nctions. We ill go thro gh them belo . Notice that those highlighted in bold are f nctions.
Note that the onl major difference from the elementStiffnessRec is the se of Jacobian
f nction.
elementStiffnessQ4.m
function elementStiffness =
elementStiffnessQ4(e,Part,Element,Node)
%function to compute stiffness of a 4-node quadrilateral plane
stress element
numberENodes=4;
elementStiffness=zeros(numberENodes*2,numberENodes*2);
17
F E M
05/20/2020
% E: modulus of elasticity
E = Part(Element(e,1),1);
% t: thickness
thickness = Part(Element(e,1),3);
% matrix C
C=E/(1-poisson^2)*[1 poisson 0;poisson 1 0;0 0 (1-poisson)/2];
% Gauss Quadrature
ngp=Part(Element(e,1),5);
[weights,locations]=gauss2d(ngp);
for ip=1:ngp*ngp
% B matrix
xi=locations(ip,1);
eta=locations(ip,2);
[shape,naturalDerivatives]=shapeFunctionQ4(xi,eta);
% Jacobian matrix, inverse of Jacobian,
% derivatives w.r.t. x,y
[Jacob,invJacobian,XYderivatives]=...
Jacobian(nodalCoordinates,naturalDerivatives);
B(1,1:2:numberENodes*2) = XYderivatives(1,:);
B(2,2:2:numberENodes*2) = XYderivatives(2,:);
B(3,1:2:numberENodes*2) = B(2,2:2:numberENodes*2);
B(3,2:2:numberENodes*2) = B(1,1:2:numberENodes*2);
elementStiffness=elementStiffness +
thickness*det(Jacob)*B'*C*B*weights(ip);
end
Jacobian.m
function [JacobianMatrix,invJacobian,XYDerivatives]=...
Jacobian(nodalCoordinates,naturalDerivatives)
JacobianMatrix=naturalDerivatives*nodalCoordinates;
invJacobian=inv(JacobianMatrix);
XYDerivatives=invJacobian*naturalDerivatives;
18
F E M
05/20/2020
ga ss2D.m
function [weights,locations]=gauss2d(ngp)
% Gauss quadrature in 2D
% locations: Gauss point locations
% weights: Gauss point weights
switch ngp
case 1
locations=[0 0];
weights=[4];
case 2
locations=...
[ -0.577350269189626 -0.577350269189626;
0.577350269189626 -0.577350269189626;
0.577350269189626 0.577350269189626;
-0.577350269189626 0.577350269189626];
weights=[ 1;1;1;1];
end
shapeF nctionQ4.m
function [shape,naturalDerivatives]=shapeFunctionQ4(xi,eta)
We can e tend o r MATLAB codes to ha e a different finite element discreti ation. Notice that
e ha e ren mbered the node n mber in the follo ing discreti ation. Ob io sl , it req ires
more efforts to create the inp t data file and is easier to make mistakes if o ant to enter the
ariables b hands, i.e. br te force processing. Yo ill ha e to ha e a good engineering
j dgement to j stif o r inp t file based on the calc lation res lts. The inp t file of the
follo ing discreti ation can be fo nd from the co rse ebsite.
19
F E M
05/20/2020
17 8 9
0.9
0.8
6
0.7
5
0.6
0.5 4 3
0.4
0.3
2
0.2
0.1
01
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Displacements
Node UX UY
1 0.0000e+00 0.0000e+00
2 -2.7321e-06 -6.7654e-06
3 -1.2329e-06 -1.8611e-05
4 0.0000e+00 0.0000e+00
5 4.2819e-07 -6.6965e-06
6 1.9583e-06 -1.8676e-05
7 0.0000e+00 0.0000e+00
8 3.9956e-06 -7.1385e-06
9 5.0961e-06 -1.8767e-05
Yo can do similar things for the follo ing discreti ation b t might NOT ant to do it in a
br te force manner for preprocessing.
1 21 22 23 24 25
0.9
20
19
0.8 18
17
16 15
0.7 14
13 10
0.6
12
9
0.5 11 5
8
0.4
4
7
0.3
6 3
0.2
2
0.1
01
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
20