Fortran library for FEM programs development

Fortran library for FEM programs development
Zitny R., CTU FME Prague, March 2001
1. Introduction
The following examples make use the FRONTAL METHOD for assembly and
simultaneous solution of equations derived by finite element methods. The frontal method is
implemented in subroutines of more than 15 years old fortran library INTERFOR1, designed
only for the FEM principles teaching, and not for development of efficient and large scale
programs. Primary aim is simplicity and transparency of programs.
XMKPE1 Plane stress analysis
XMKPE3 Flow in pipeline networks (laminar/turbulent)
XMKPE5 Temperature field in a liquid (cylindrical system,
prescribed velocity field)
XMKPE7 Rotationally symmetric shell
XMKPE9 Beams and trusses
XMKPE10 Pressure thermal forming (waffle baking)
2. Specific features of programs
All data - matrices, (coordinates of nodes, connectivity matrix, nodal parameters,
properties of elements, stiffness matrices and so on) are dynamically allocated in the
COMMON // area. In most of the examples the following lay-out of matrices in the
COMMON area will be used:
1.matrix directory of all matrices in the COMMON area (each column of this directory
describes dimensions, mapping function, etc by 9 integer numbers)
2.matrix NOE connectivity matrix (nodes of elements)
3.matrix XYZ coordinates of nodes
4.matrix IU indices of DOF corresponding to nodes
5.matrix U nodal parameters (vector of unknowns)
It is assumed that the vector U contains not only the unknown nodal parameters, but also the
parameters prescribed as a boundary condition. To distinguish between them the following
convention is adopted: if IUn,i> 0 the i-th parameter of n-th node is the calculated unknown,
while if IUn,i <0 the parameter is prescribed as a boundary condition. In the both cases the
absolute value |IUn,i| is an index of parameter in the vector U.
1
Jirasek F. et al: Aplikacni programove vybaveni I, skripta CVUT FSI Praha, (1989). See also Zitny R., Sik P.,
Petrucco R.: Interakcni fortranske knihovny Interfor, D-Data, Praha (1990)
XMKPE.DOC
1
The most important subroutines are
MEFRIN(noe,iu)
prefrontal algorithm, which identifies the last occurrence of a node in the connectivity matrix.
NOE – index of connectivity matrix (usually the second matrix in COMMON area, therefore
NOE=2, see above), and IU is the index of matrix containing indices of DOF (usually IU=4,
see above). The purpose of prefront is to identify the moment when all equations concerning a
certain node have been assembled and therefore the moment when the corresponding nodal
parameters can be eliminated even if the assembly of global system of equations has not been
completed. The last occurrence of a node in the list of elements is indicated by a negative sign
of its index in the connectivity matrix.
MEFRON(noe,iu,u,nfront,nloc,subloc,iwrite)
frontal solver, assembling local matrices and right hand side vectors defined in the subroutine
SUBLOC, and performs the elimination of unknowns as soon as the appropriate equation has
been completed2. In simple words, the MEFRON routine performs assembly of element
matrices and the solution of system simultaneously. The first three parameters of subroutine
MEFRON are indices of matrices (usually 2,4,5), NFRONT is maximum width of front, i.e.
maximum dimension of submatrix containing equations which can not be eliminated in
advance, NLOC is the maximum dimension of local element matrix and IWRITE is the
number of logical device used for storing temporary global matrix. If IWRITE=0 the matrix
will be allocated in the COMMON area.
Subroutine SUBLOC defines a specific problem and must have the following parameters
SUBROUTINE subloc(ie,nloc,nu,a,r)
where input parameters are IE (index of element), NLOC (max.dimension of element matrix),
and NU (number of nodes of element). Output parameters are A(NLOC x NLOC) element
matrix and R(NLOC) vector of loads, i.e. the right hand side vector.
Auxiliary subroutines
MTOOLS (maxdir,subkey)
management of data in COMMON area – interactive definition and modification of matrices
using MATRIX EDITOR. MAXDIR-size of directory, maximum number of matrices in the
COMMON area. Specifying MAXDIR=0 defines in fact directory for 32 matrices (this is the
smallest size of directory). SUBKEY is the name of user defined subroutine activated after
pressing Enter, function keys, arrows etc:
SUBROUTINE SUBKEY(imat,none,none,none,key)
Only the first and the last parameters are important inputs: IMAT- index of active matrix,
KEY identify the entry point (KEY=51, SUBKEY has been called after pressing arrow keys,
Enter, F1,F2,..., =52 before return, =53 after entry into MTOOLS, =54 before any keyboard
scanning, =55 after pressing F10).
Another auxiliary routines, see also examples
MTOBIR(file,ierr) - reading common// from FILE in a binary format
MINPR(ienv,label,nchar,irow,icol,value) - input real VALUE
MLOCR(imat,irow,icol, loc,ityp,length,istep) position LOC of a matrix entry in COMMON
SKBDR(inkey) read character from keyboard
3. Examples
2
Taylor C., Hughes T.G.: FE programming of the NS Equations. Pineridge Press Ltd., Swansea, 1981
XMKPE.DOC
2
All programs describing selected examples have the same basic structure
c Main program – reads COMMON, adjust input data, and calls frontal method routines
call mtobir('xmkpe.mat',iend)
call mtools(0,subkey)
call mefrin(2,4)
call mefron(2,4,5,50,4,subloc,0)
call mtools(0,subkey)
end
subroutine subloc(ie,nl,nu,a,r)
dimension a(nl,nl),r(nl)
c calculation of local matrix a and right hand side vector for the element IE
c data must be transferred from COMMON//
...
end
3.1. XMKPE1 – plane stress
Displacement ux, uy in the x ,y direction are primary unknown variables. In terms of ux, uy
the internal energy of deformation, as well as potential energy of external forces have to be
expressed. To do this, three component of deformation tensor and three component of stress
tensor have to calculated as a function of nodal displacements for a general element (triangle,
qudrilateral,... having arbitrary number of nodes and shape functions Ni(x,y))
Deformation tensor has in fact 4 components, however ezz has no contribution to energy

 



u x ( x , y )
N i ( x , y )

 
u xi
0


x
exx   x
x
 

 u ( x, y) 
u y ( x , y )
 
  
N i ( x , y )
 x
 

.
u yi
   e yy    0




y  u y ( x , y )  

y

y
e  




xy
 
u ( x , y )
N i ( x , y )
N i ( x , y ) 
 
 u x ( x , y )  y
 u xi



 u yi
y
x 
 y
x  
 y x 
 N 1 ( x , y )

 x

0

 N ( x , y )
 1
 y
0
N 1 ( x , y )
y
N 1 ( x , y )
x
N 2 ( x , y )
x
0
N 2 ( x , y )
y
0
...
N 2 ( x , y )
...
y
N 2 ( x , y )
...
x
  u x1 
 
  u y1 
. u    B 
1
  x2 
 u y 2 
  .... 
  

B 
2
u1 


... . u2    B.u
 ... 



(3.1.1)
Stresses are related to deformation according to Hook's law for the case of plane stress
(szz=0)




 sxx 
u1 
0  exx 
0 
1 
1 
 


E 
E



1
0 . e yy  
1
0 .[ B1   B2  ...]. u2    D. B.u
   syy  
2 
2 



1  
1    e  1   
1  
s 
 ... 

xy
xy
0 0
0 0


 
 




2 
2 

(3.1.2)
Energy of deformation
XMKPE.DOC
3
T
1
1
1
1
    dS    u T . B T . D. B. udS   u T .   B T . D. BdS . u   u T . K . u

2
2
2
2
(3.1.3)
Stiffness matrix K is therefore
 B T 
 K11   K12  ...
 1 T


T
 K     B . D. BdS    B2  . D.  B1   B2  ... dS   K21   K22  
 ... 
 ...





(3.1.4)
K matrix is composed of submatrices Kij of dimension 2 x 2 corresponding to the combination
of nodes i and j
 N j


0



N i 
 N i
x

1
0




0
 x

N
T
E
y  
j

 

.  1
Kij   Bi  .D. B j dS 
0 .  0
dS
2 


Ni
Ni  

y 
1 
 0


1
  N
N j 

y
x   0 0
j





2
 y
x 
 N i N j 1   N i N j
N N j 1   N i N j 

 i



E






x
x
2
y
y
x
y
2 y x 


dS
N i N j 1   N i N j 
1   2   N i N j 1   N i N j

  y x  2 x y
y y
2 x x 
(3.1.5)
Potential energy of external singular forces acting in nodes is simply
u x1
Ei 

 

 

E e  u xi Fxi  u yi Fyi  Fx1
Fy1
Fx 2
Fy 2

u y1
... . u x 2
uy2
(3.1.6)
...
Overall potential energy is therefore
1 T
T
E   u . K . u   F  . u
2
and minimum of this potential energy (Lagrangian principle) is achieved at
 K . u   F 
(3.1.7)
(3.1.8)
From now on we have to take into account specific form of element. The XMKPE1
program can be designed for different form of elements, for example 3 and 6 nodes triangles,
and 4 and 8 nodes quadrilaterals.
The simplest case is the 3-node triangle with linear shape functions; their derivatives are
constant, therefore no numerical integration is necessary.
1
N j ( x, y) 
[ x y  x j 2 y j 1  ( y j 1  y j 2 ) x  ( x j 2  x j 1 ) y ]
(3.1.9)
2S j 1 j  2
where S is the area of triangle and
XMKPE.DOC
4
1 x1
2 S  1 x2
1 x3
y1
y2  ( x2 y3  x3 y2 )  ( x1 y3  x3 y1 )  ( x1 y2  x2 y1 )
(3.1.10)
y3
More complicated are isoparametric elements.

4
y
7
3
6
8

x
1
5
2
1
N i ( , )  (1  i )(1  i )(i  i  1), i  1,2,3,4
4
1
N i ( , )  (1   2 )(1  i ),
i  5,7
2
1
N i ( , )  (1   2 )(1  i ),
i  6,8
2
In terms of these function the coordinate transformation is defined as
x   xi N i ( ,)
i
(3.1.11)
(3.1.12)
y   yi N i ( ,)
i
Derivatives are transformed
 N i   x y   N i 
 N i 
        x 
 x 


.  N    J .  N 
(3.1.13)
 N i   x y   i 
 i
 y 
        y 
and partial derivatives with respect x,y can be obtained by inversion of Jacobi transformation
matrix
y   N 
 y
 N i 
  i

 x 
1

 



(3.1.14)
 N  

x

x .  N i 
 i  det J 
 y 
      
where det J , called Jacobian, is determinant of Jacobi matrix. The Jacobian transforms area of
element in the (,) plane to the area in the (x,y) plane, which makes integration easier
1 1
 f ( x, y)dxdy    f ( ,)det Jdd
(3.1.15)
1 1
These equations are used in the following program XMKPE1.for
XMKPE.DOC
5
c
c
c
c
c
c
c
c
c
c
c
c
c
MKPE1 @Zitny 4/92
Plane stress analysis using
a) 3-nodal triangles,
b) 4/8-nodal isoparametric quadrilateral elements
Matrices:
2 - noe [connectivity matrix]
3 - xy
[x,y]
4 - ipu [indices of nodal parameters]
5 - rpu [nodal parameters u,v]
6 7 - help [text]
10
1
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
common /prop/E,rmi /scom/iss(50)
external lokal,sext
character *4 inkey
equivalence (kbdr,iss(13))
E=2.1e11
rmi=0.3
call scomin(-1)
call sintro('xmkpe1.for')
call mtobir('xmkpe1.mat',iend)
call sclear
call minpr(0,' Modulus of elasticity E=',25,14,2,E)
call minpr(0,' Poisson constant
mi=',25,15,2,rmi)
call mtools(0,sext)
Coordinates x,y
Indices of param.
Forces (entry),
IMI 2821
IMA 20000
MTOOLS
displacements
| Directory of matrices
|
|
1 MAP=2
2 MAP=1
3 MAP=1
4 MAP=1
5 MAP=1
|
|
1> 288
289> 1088
1089> 1888
1889> 2288
2289> 2688
|
|-IIIIIII--------IIII-----------RR-------------II-------------RR------------|
| IIIIIII
IIII
RR
II
RR
|
| IIIIIII
IIII_ 4
RR
II
RR
|
| IIIIIII_ 9
IIII
RR_ 9
II_ 9
RR_ 9
|
| IIIIIII
_ 4
RR
II
RR
|
| IIIIIII
RR
II
RR
|
| IIIIIII
RR
II
RR
|
| _ 7
_ 2
_ 2
_ 2
|
|
|
Connectivity matrix
no.2. MAP=1
|
7 MAP=1
6 means
MAP=0
|
|
2821
4 5entry
3
|
that the matrix2689>
is row-oriented.
First
|----------------------------------------------TTTTTTTTTTT----IIRRRR--------|
is
in
289-th
position,
last
1088
(the
matrix
|
TTTTTTTTTTT
IIRRRR
|
is dimensioned
for 1088-289+1IIRRRR
numbers).
|
Please prepare new data:
TTTTTTTTTTT
|
|
Created by COSMOS [ F10
]
|
Elements areTTTTTTTTTTT_
integer numbers7IIRRRR_
(I). Actual 9
|
or manually:
TTTTTTTTTTT
IIRRRR
|
number of rows
is 4 (4 elements),
and
|
Select matrix and [ Enter ]
TTTTTTTTTTT
IIRRRR
|
columns alsoTTTTTTTTTTT
4 (4-nodes quadrilaterals).
|
Start:
IIRRRR
|
Press Enter to edit
the matrix. _ 6
|
Computation - by [ F9
]
_ 19
|
(result)
F1-SED F2-Save F3-Load F4-Dim F5-Copy F6-Del F7-New F8-Zero F9-Exit F0-Ext
if(kbdr.eq.67)then
call mefrin(2,4)
c maximum dimension of global matrix 60x60, and local matrix 16x16 (for 8-node quadrilaterals)
call mefron(2,4,5,60,16,lokal,0)
endif
call grid(kbd)
if(kbd.eq.62) goto 10
if(kbd.ne.27) goto 1
call scwrit(16,2,28,23,' Do You want to Quit ? [Y/N]')
call skbdr(inkey)
if(inkey.ne.'Y
'.and.inkey.ne.'y
')goto 1
999
call sclear
end
subroutine lokal(ie,nl,nod,a,b)
c Input: IE-index of element, NL-dimension, NOD-number of nodes
dimension a(nl,nl),b(nl),
/ x(8),y(8),g(2),w(2),f(8),fx(8),fy(8),u(8),v(8),inod(8)
common /prop/e,rmi
c
data g,w,ngaus/-.77459666,0.,.77459666,
c
/.5555555,.8888888,.555555,3/
data g,w,ngaus/-.57735,.57735,
/1.,1.,2/
call get(ie,nod,x,y,u,v,inod)
XMKPE.DOC
6
c
c Type of element according to number of nodes of element
c
if(nod.eq.3)then
c triangular element (S2 is twice the triangle area), see Eq.(3.1.9)
S2=x(2)*y(3)-x(3)*y(2)-x(1)*y(3)+x(3)*y(1)+x(1)*y(2)-x(2)*y(1)
E1=S2/2.*E/(1-rmi**2)
do i=1,3
i1=mod(i,3)+1
i2=mod(i1,3)+1
fx(i)=(y(i1)-y(i2))/S2
fy(i)=(x(i2)-x(i1))/S2
enddo
do i=1,3
do j=1,3
c stiffness matrix according to Eq.(3.1.5)
a(2*i-1,2*j-1)=E1*(fx(i)*fx(j)+(1-rmi)/2.*fy(i)*fy(j))
a(2*i,2*j)=E1*(fy(i)*fy(j)+(1-rmi)/2.*fx(i)*fx(j))
a(2*i,2*j-1)=E1*(rmi*fy(i)*fx(j)+(1-rmi)/2.*fx(i)*fy(j))
a(2*i-1,2*j)=E1*(rmi*fx(i)*fy(j)+(1-rmi)/2.*fy(i)*fx(j))
enddo
enddo
elseif(nod.eq.4.or.nod.eq.8)then
c Isoparametric 4 or 8-node element. Gaussian integration 2 x 2
do i=1,nl
do j=1,nl
a(i,j)=0.
enddo
b(i)=0
enddo
do ig=1,ngaus
do jg=1,ngaus
call fdf(nod,x,y,g(ig),g(jg),f,fx,fy,det)
E1=det*w(ig)*w(jg)*E/(1-rmi**2)
do i=1,nod
i1=2*i-1
i2=2*i
do j=1,nod
j1=2*j-1
j2=2*j
a(i1,j1)=a(i1,j1)+E1*(fx(i)*fx(j)+(1-rmi)/2.*fy(i)*fy(j))
a(i2,j2)=a(i2,j2)+E1*(fy(i)*fy(j)+(1-rmi)/2.*fx(i)*fx(j))
a(i2,j1)=a(i2,j1)+E1*(rmi*fy(i)*fx(j)+(1-rmi)/2.*fx(i)*fy(j))
a(i1,j2)=a(i1,j2)+E1*(rmi*fx(i)*fy(j)+(1-rmi)/2.*fy(i)*fx(j))
enddo
enddo
enddo
enddo
endif
end
subroutine fdf(nod,x,y,rksi,rny,f,fx,fy,det)
c
c The subroutine calculates values [f] and first derivatives [fx,fy]
c of all shape functions (no. of shape functions = no. of nodal points)
c in point rksi,rny.
c
dimension x(*),y(*),f(*),fx(*),fy(*),dfksi(8),dfny(8),gx(8),gy(8)
data gx,gy/-1.,1.,1.,-1.,0.,1.,0.,-1.,-1.,-1.,1.,1.,-1.,0.,1.,0./
dxksi=0
dxny =0
dyksi=0
dyny =0
do 1 i=1,nod
xx=gx(i)*rksi
yy=gy(i)*rny
if(i.le.4.and.nod.eq.4)then
f(i)=(1+yy)*(1+xx)/4
dfksi(i)=gx(i)/4*(1+yy)
dfny (i)=gy(i)/4*(1+xx)
elseif(i.le.4)then
c Shape functions according to Eq.(3.1.11)
f(i)=(1+yy)*(1+xx)*(xx+yy-1)/4
dfksi(i)=gx(i)/4*(1+yy)*(2*xx+yy)
dfny (i)=gy(i)/4*(1+xx)*(2*yy+xx)
elseif(i.eq.5.or.i.eq.7)then
f(i)=(1-rksi**2)*(1+yy)/2
XMKPE.DOC
7
1
c
c
2
dfksi(i)=-rksi*(1+yy)
dfny(i)=gy(i)*(1-rksi**2)/2
else
f(i)=(1-rny**2)*(1+xx)/2
dfksi(i)=gx(i)*(1-rny**2)/2
dfny(i)=-rny*(1+xx)
endif
dxksi=dxksi+x(i)*dfksi(i)
dxny =dxny +x(i)*dfny (i)
dyksi=dyksi+y(i)*dfksi(i)
dyny =dyny +y(i)*dfny (i)
Jacobian, see Eq.(3.1.13)
det = dxksi*dyny-dxny*dyksi
Transformed derivatives, Eq.(3.1.14)
do 2 i=1,nod
fx(i)=(dyny*dfksi(i)-dyksi*dfny(i))/det
fy(i)=(dxksi*dfny(i)-dxny*dfksi(i))/det
end
subroutine get(ie,nod,x,y,u,v,inod)
c
c Extract data for element IE from COMMON area. Result: NOD-number of nodes, X,Y-coordinates,
c U,V-displacements, INOD-indices of nodes.
common z(20000)
dimension x(8),y(8),u(8),v(8),inod(8),iz(20000)
equivalence (z,iz)
c MLOCR is a library routine, identifying properties of element in the row IE and column 1
c of the connectivity matrix (number 2): LOC is position in COMMON, IT type, NOD-length of row
c (i.e. number of nodes of element IE), and IDIF is a "distance" between neighbouring elements
c in the matrix row.
call mlocr(2,ie,1,loc,it,nod,idif)
do i=1,nod
indu=iabs(iz(loc+(i-1)*idif))
inod(i)=indu
call mlocr(5,indu,1,locp,it,npu,idpu)
u(i)=z(locp)
v(i)=z(locp+idpu)
call mlocr(3,indu,1,locp,it,npu,idpu)
x(i)=z(locp)
y(i)=z(locp+idpu)
enddo
end
The following Fig. is an example of application of the three types of finite elements
simultaneously: triangles 1,2,3,4, quadrilaterals with 4 nodes 5,6, and one 8-node element
number 7. Graphics implemented in XMKPE1 draws actual shape of isoparametric elements
with sides defined by transformation (3.1.12).
XMKPE.DOC
8
3.2. XMKPE3 – flow in a pipeline
The program calculates pressures at nodes of pipeline networks. Network is defined as a
system of pipes (finite elements with two nodes). Each element, pipe, is characterised by
volumetric flow-rate and radius of pipe.
pj
Parameters of elements:
Reynolds number, Flow-rate [m3/s], radius R [m]
Qij
pi
Flow-rate in a pipe connecting nodes i and j is related to the pressure difference
Qij  ij (| pi  p j |).( pi  p j )
(3.2.1)
Sum of oriented flow-rates in any node must be zero – this is the continuity equation written
for example for node i
(3.2.2)
ij (| pi  p j |).( pi  p j )  0
j
Overall system is described by equations
11 12 ...  p1   Q1 

   
(3.2.3)
21 22 ....  p2   Q2 
 ...
  ...   ... 
where Q1, Q2, are non-zero only if a given node is a source, e.g. a pump supplying liquid into
the pipeline. The global matrix is assembly of the local element matrices
 ij  ij 
(3.2.4)
Kij  

 ij ij 
 
where
R 4
ij 
,
8Lij
or
for laminar flow Re<2300
(3.2.5)
4/7
 0.558 
(2 R )19/ 7
5

ij  
(3.2.6)
3/ 7 1/ 7 , for 2300<Re<10 (Blasius).
L
(

|

p
|)

 ij 
The problem would be simple for laminar flows because then the coefficients are constant,
and the system is linear. In the program XMKPE3 the coefficients ij are calculated from
(3.2.5) or (3.2.6) using values of pressures from previous iteration. The decision whether the
flow is laminar or turbulent is based upon Re calculated from assumption that the flow is
laminar,
R 3 | p|
Re 
.
(3.2.7)
4  2 Lij
The nonlinear system of equations is solved iteratively, using the so called flip-flap
technique for storing results of iterations.
c
c
c
c
c
c
c
MKPE3
Vypocet tlaku v potrubni siti. Laminarni/turbulentni proudeni.
Reseni soustavy nelinearnich rovnic metodou substituci.
Spolecne parametry pro vsechny elementy: rho-hustota, mi-viskozita
Vyznamy poli:
XMKPE.DOC
9
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
2 3 4 5 6 7 8 9 10
[indexy uzlu elementu, matice ma dva sloupce pro 2 uzly elementu]
[Re,Q-objemovy prutok,r-polomer trubky]
[x,y]
[indexy parametru uzlu, zaporna hodnota znamena predepsany tlak]
[parametry uzlu-tlaky]
[zadavane hodnoty tlaku a prutoku]
[parametry uzlu-tlaky]
& rpu2 [soucasne zobrazeni dvou iteraci]
[textove pole hlavicek matic]
Pozn. Pole 6 a 8 se vyuzivaji jako houpacka [stridave ukladani vysledku
v jednotlivych iteracich]. Pred kazdou iteraci je ve vektoru 7 ulozeno zadani (zadavane tlaky nebo prutoky) a ve vektoru 6 nebo 8
je vysledek predchozi iterace (tlaky ve vsech uzlech), ktere potrebujeme pro odhad Re.
111
1
noe
pe
xy
ipu
rpu1
rpu
rpu2
rpu1
common /cradle/ip1,ip2,rho,ami
character inkey*4
external lokal,sext
data ifl/1/
rho=1000.
ami=1.
call scomin(-1)
call sintro('xmkpe3.for')
call mtobir('XMKPE3.MAT',iend)
call mtools(0,sext)
call sclear
call minpr(0,' Density [kg/m^3]=',18,16,2,rho)
call minpr(0,' Viscosity [Pa.s]=',18,17,2,ami)
call mefrin(2,5)
ip1=7+ifl
ip2=7-ifl
ifl=-ifl
c
c presun vektoru zadavanych tlaku do vektoru IP1
c
call move(ip1,7)
call mefron(2,5,ip1,50,2,lokal,0)
call graf(kbd)
c F1-zoom F2-zoomout F3-tools F4-list F5-visc [Esc]-Exit
if(kbd.eq.61)then
call mtools(0,sext)
elseif(kbd.eq.62)then
call sintro('xmkpe3.for')
elseif(kbd.eq.63)then
goto111
elseif(kbd.eq.27)then
call scwrit(16,10,28,23,' Do You want to quit? (Y/N) ')
call skbdr(inkey)
if(inkey.eq.'Y
'.or.inkey.eq.'y
') goto999
endif
goto 1
999
call sclear
end
7 RHS vector of
prescribed flowrates
and pressures
IP1 (6 or 8) RHS vector for frontal
routine. Resulting pressures
overwrite boundary conditions.
IP2 (8 or 6) Values of pressures
from previous iteration serve for user
routine LOKAL(calculation of ij)
subroutine lokal(ie,nl,nn,a,b)
c
c Lokalni matice prutoku a(2,2) a vektor prutoku v uzlech b(2)
c
dimension a(nl,nl),b(nl),x(2),y(2),pres(2),ibound(2)
call gett3(ie,fi,x,y,pres,ibound,Re)
a(1,1)=fi
a(2,2)=fi
a(1,2)=-fi
a(2,1)=-fi
b(1)=0.
b(2)=0.
end
subroutine gett3(ie,fi,x,y,pres,ibound,re)
common z(10000) /cradle/ip1,ip2,rho,ami
dimension iz(10000),x(2),y(2),pres(2),ibound(2)
equivalence (iz,z)
c
c stanoveni polomeru trubky elementu IE
c
call mlocr(3,ie,1,loc,it,npe,idif)
XMKPE.DOC
10
r=z(loc+2*idif)
drsnost=z(loc+3*idif)
call mlocr(2,ie,1,locu,it,nue,idifu)
iu1=iabs(iz(locu))
iu2=iabs(iz(locu+idifu))
c
c zjisteni delky elementu IE ze souradnic x,y uzlu 1,2
c
call mlocr(4,iu1,1,lx1,idum,nxy,it1)
call mlocr(4,iu2,1,lx2,idum,nxy,it2)
x(1)=z(lx1)
x(2)=z(lx2)
y(1)=z(lx1+it1)
y(2)=z(lx2+it2)
h=sqrt((x(1)-x(2))**2+(y(1)-y(2))**2)
c
c indexy parametru uzlu ibound(i) elementu IE
c a hodnoty tlaku pres(i)
c
call mloc(5,iu1,1,lu1,it)
call mloc(5,iu2,1,lu2,it)
ibound(1)=iz(lu1)
ibound(2)=iz(lu2)
call mloc(ip2,iabs(iz(lu1)),1,lr1,it)
call mloc(ip2,iabs(iz(lu2)),1,lr2,it)
pres(1)=z(lr1)
pres(2)=z(lr2)
dp=abs(z(lr1)-z(lr2))
Re=r**3*dp*rho/(4*ami**2*h)
if(Re.lt.2300.)then
c
c Hagen Poisseuile Lamba=64/Re
c
fi=3.141*r**4/(8*ami*h)
else
c
c Blasius Lambda=0.316/Re^.25
c
fi=(.558/h)**(4./7.)*(2*r)**(19./7.)/
/
((rho*dp)**(3./7.)*ami**(1./7.))
endif
c
c Ulozeni vypocteneho prutoku Q jako druheho parametru elementu
c
z(loc+idif)=fi*dp
c
c Ulozeni vypocteneho Re jako prvniho parametru elementu
c
z(loc)=2*z(loc+idif)*rho/(3.141*r*ami)
end
Prescribed
zero pressure
Calculated pressure
0.25 MPa
Prescribed
pressure 1MPa
Prescribed
zero pressure
XMKPE.DOC
11
3.3. XMKPE5 – Heat transfer in a pipe (velocity profile prescribed)
The program solves the Fourier Kirchhoff equation written in cylindrical coordinate
system, assuming steady state and prescribed velocity field:
(u,v)
r
x
T
T  T 1 
T
v
 (a ) 
(ar )
(3.3.1)
x
r x x r r
r
Applying weighted residual method (w(x,r)) and Green's theorem we arrive to the weak
integral formulation
L
R
L R
R
L
T
T
T w T w
T 
T 
0 0 r[ w(u x  v r )  a( x x  r r )]drdx  0 arw x dr   0 arw r dx (3.3.2)
x 0
r 0
u
The first term is zero if temperatures are specified at inlet (then w=0) or if the temperature
profile is fully developed at outlet (dT/dx=0). The second term can be expressed using
boundary equation of the third kind at wall, i.e.
R
L
L
T 
Rw
arw
dx

(T  T )dx



r  r 0 0 c p e r  R
0
Using approximations
T ( x , r )   Tj N j ( x , r ), w( x , r )  N i ( x , r ),
j
u( x , r )   uk N k ( x , r ), v ( x , r )   v k N k ( x , r )
k
(3.3.3)
(3.3.4)
k
the Eq(3.3.2) is reduced to the linear algebraic equation
LR
L
L
N j
N j
Ni N j Ni N j
R
R
T
{
r
[
N
(
u
N

v
N
)

a
(

)]
drdx

N
N
dx
}

Ni Te dx
j j   i k k x k k r
i
j



x

x

r

r

c

c
p
p
0 0
0
0
(3.3.5)
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
MKPE5 @Zitny 4/92
Reseni Fourierovy Kirchhoffovy rovnice
u.dT/dx+v.dT/dr= d(a.dT/dx)/dx +d(a.r.dT/dr)dr/r
dvourozmerneho prenosu tepla v cylindr. s.s.
Pouziti bilinearnich obdelnikovych elementu a Gaussovy integrace 2 x 2
Vyznamy poli:
2 - noe [indexy uzlu elementu]
3 - xruv [x,r,u,v] v kazdem uzlu se zadavaji krome souradnic i rychlosti
4 - ipu [indexy parametru uzlu]
5 - rpu [parametry uzlu-teploty]
6 7 - help [textove pole]
common /prop/a /scom/iss(50)
external lokal,sext
character *4 inkey
XMKPE.DOC
12
10
1
999
1
20
3
2
equivalence (kbdr,iss(13))
a=1.
call scomin(-1)
call sintro('xmkpe5.for')
call mtobir('xmkpe5.mat',iend)
call sclear
call minpr(1,' Temperature conductivity a=',28,14,2,a)
call mtools(0,sext)
if(kbdr.eq.67)then
call mefrin(2,4)
call mefron(2,4,5,50,4,lokal,0)
endif
call grid(kbd)
if(kbd.eq.62) goto 10
if(kbd.ne.27) goto 1
call scwrit(16,2,28,23,' Do You want to Quit ? [Y/N]')
call skbdr(inkey)
if(inkey.ne.'Y
'.and.inkey.ne.'y
')goto 1
call sclear
end
subroutine lokal(ie,nl,nn,ak,b)
dimension ak(nl,nl),b(nl),
/ r(8),x(8),u(8),v(8),g(3),w(3),f(8),fx(8),fr(8),temp(8),ibound(8)
common /prop/a
data g,w,ngaus/-.77459666,0.,.77459666,
/.5555555,.8888888,.555555,3/
call gett4(ie,nl,x,r,u,v,temp,ibound)
do 1 i=1,nl
b(i)=0.
do 1 j=1,nl
ak(i,j)=0.
do 2 ig=1,ngaus
do 2 jg=1,ngaus
call fdf(nl,x,r,g(ig),g(jg),f,fx,fr,det)
rr=0
uu=0
vv=0
do 20 i=1,nl
rr=rr+r(i)*f(i)
uu=uu+u(i)*f(i)
vv=vv+v(i)*f(i)
rr=rr*det*w(ig)*w(jg)
do 3 i=1,nl
do 3 j=1,nl
ak(i,j)=ak(i,j)+rr*(f(i)*(uu*fx(j)+vv*fr(j))+a*(fx(i)*fx(j)+
/fr(i)*fr(j)))
continue
end
subroutine fdf(nl,x,r,rksi,rny,f,fx,fr,det)
c vypocet hodnot [f] a derivaci [fx,fr] bazovych funkci v bode rksi,rny.
dimension x(*),r(*),f(*),fx(*),fr(*),dfksi(8),dfny(8),gx(8),gr(8)
data gx,gr/-1,1,1,-1,0,1,0,-1,-1,-1,1,1,-1,0,1,0/
dxksi=0
dxny =0
drksi=0
drny =0
do 1 i=1,nl
f(i)=(1+gr(i)*rny)*(1+gx(i)*rksi)/4
dfksi(i)=gx(i)/4*(1+gr(i)*rny)
dfny (i)=gr(i)/4*(1+gx(i)*rksi)
dxksi=dxksi+x(i)*dfksi(i)
dxny =dxny +x(i)*dfny (i)
drksi=drksi+r(i)*dfksi(i)
1
drny =drny +r(i)*dfny (i)
det = dxksi*drny-dxny*drksi
do 2 i=1,nl
fx(i)=(drny*dfksi(i)-drksi*dfny(i))/det
2
fr(i)=(dxksi*dfny(i)-dxny*dfksi(i))/det
end
subroutine gett4(ie,nl,x,r,u,v,temp,ibound)
c
c data transfer
c
common z(10000)
XMKPE.DOC
13
1
dimension x(8),r(8),u(8),v(8),temp(8),ibound(8),iz(10000)
equivalence (z,iz)
call mlocr(2,ie,1,loc,it,np,idif)
do 1 i=1,nl
indu=iabs(iz(loc+(i-1)*idif))
call mlocr(4,indu,1,locp,it,npu,idpu)
ibound(i)=iz(locp)
call mlocr(5,iabs(iz(locp)),1,locp,it,npu,idpu)
temp(i)=z(locp)
call mlocr(3,indu,1,locp,it,npu,idpu)
x(i)=z(locp)
r(i)=z(locp+idpu)
u(i)=z(locp+2*idpu)
v(i)=z(locp+3*idpu)
end
3.4. XMKPE9 – Rotationally symmetric shell
This program implements finite elements (2-nodes) for rotationally symmetric shells,
described in textbook Schneider P., Vykutil J.: Stavba chemickych zarizeni II. VUT Brno,
1990.
Program calculates primary variables (3 DOF in a node):
ux - axial displacement
ur - radial displacement
 - rotation
and derived stresses and moments
Nm meridian force [N/m]
Nc circumferential force [N/m]
Q
transversal force in the normal direction [N/m]
Mm meridian moment [N]
Mc circumferential moment
c MKPE7 @Zitny 4/92
c Rotacne symetricka skorepina zatizena vnitrnim pretlakem
c
XMKPE.DOC
14
c
c
c
c
c
c
c
c
c
c
c
c
Pouzit dvouuzlovy prvek, popisovany v (opraveny 2 chyby v mat.tuh.):
Schneider P., Vykutil J.: Stavba chemickych zarizeni II, Brno 1990
Vyznamy poli:
2 - noe [indexy uzlu elementu]
3 - rx
[r,x]
4 - ipu [indexy parametru uzlu-matice se 3-mi sloupci u,w,beta]
5 - rpu [parametry uzlu- u,w,beta]
6 - pe
[parametry elementu-p/tlak/,t/tloustka/,
N1,N2,M1,M2,Q - vnitrni sily]
7 - help [textove pole]
common /prop/E,rmi /scom/iss(50)
external lokal,sext
character inkey*4
equivalence (ict,iss(3)),(kbdr,iss(13))
E=2.1e11
rmi=0.3
call scomin(-1)
call sintro('xmkpe7.for')
call mtobir('xmkpe7.mat',iend)
2
call sclear
call minpr(0,' Young modulus E
[Pa]=',24,15,2,E)
call minpr(0,' Poisson''s constant [-]=',24,16,2,rmi)
1
call mtools(0,sext)
if(kbdr.eq.67)then
call mefrin(2,4)
c Vypocet posunuti u,w,beta
call mefron(2,4,5,50,6,lokal,0)
c Vypocet zobecnenych sil v elementech
ict=1
call mefron(2,4,5,50,6,lokal,0)
ict=0
endif
call grid(kbd)
if(kbd.eq.61)then
goto 2
elseif(kbd.eq.27)then
call scwrit(16,10,28,23,' Do You want to quit? [Y/N] ')
call skbdr(inkey)
if(inkey.eq.'Y
'.or.inkey.eq.'y
')goto999
endif
goto 1
999
call sclear
end
subroutine lokal(ie,nl,nn,al,bl)
c
c ict=0 - lokalni matice tuhosti a vektor zatizeni tlakem
c ict=1 - vypocet vnitrnich sil v tezisti elementu
c
dimension al(nl,nl),bl(nl),r(2),x(2),u(2),w(2),beta(2),node(2),
/
forces(5)
common /prop/E,rmi /scom/iss(50)
equivalence (ict,iss(3))
call get(ie,x,r,u,w,beta,p,t,node,forces)
d11=e*t/(1-rmi**2)
d22=d11
d12=d11*rmi
d33=d11*t**2/12
d44=d33
d34=d33*rmi
d55=5*e*t/(12*(1+rmi))
rl=sqrt((r(1)-r(2))**2+(x(1)-x(2))**2)
c=(x(2)-x(1))/rl
s=(r(2)-r(1))/rl
rc=(r(1)+r(2))*.5
if(ict.eq.0)then
c frontalni metoda
s2=s**2
c2=c**2
rc4=4*rc**2
al(1,1)=rc*(d11*c2+d55*s2)/rl
al(4,4)=al(1,1)
al(1,4)=-al(1,1)
al(1,2)=c*rc*(s*(d11-d55)-rl*d12/(2*rc))/rl
al(2,4)=-al(1,2)
XMKPE.DOC
15
al(4,5)=c*rc*(s*(d11-d55)+rl*d12/(2*rc))/rl
al(1,5)=-al(4,5)
al(3,4)=rc*s/2*d55
al(1,6)=-al(3,4)
al(1,3)=-al(3,4)
al(4,6)=al(3,4)
al(2,3)=rc*c/2*d55
al(5,6)=-al(2,3)
al(3,5)=-al(2,3)
al(2,6)=al(2,3)
h1=s*d34/rc
h2=d33/rl+d55*rl/4+s2*rl*d44/rc4
al(3,3)=rc*(h2-h1)
al(6,6)=rc*(h2+h1)
w1=(s2*d11+c2*d55)/rl
w2=rl*d22/rc4
al(2,2)=rc*(w1+w2-s*d12/rc)
al(5,5)=rc*(w1+w2+s*d12/rc)
al(2,5)=rl*d22/(4*rc)-rc*w1
al(3,6)=rc*(-d33/rl+s2*rl*d44/rc4+d55*rl/4)
do1i=2,6
do1j=1,i-1
1
al(i,j)=al(j,i)
pl8=p*rl/8
bl(1)=-pl8*s*(3*r(1)+r(2))
bl(2)= pl8*c*(3*r(1)+r(2))
bl(3)=0
bl(4)=-pl8*s*(r(1)+3*r(2))
bl(5)= pl8*c*(r(1)+3*r(2))
bl(6)=0
else
c vnitrni sily: u-posun x
w-posun r
wm=u(2)-u(1)
um=w(2)-w(1)
up=w(1)+w(1)
bm=beta(2)-beta(1)
bp=beta(1)+beta(2)
rn1=c*d11/rl*wm+s*d11/rl*um+d12*up/(2*rc)
rn2=c*d12/rl*wm+s*d12/rl*um+d22*up/(2*rc)
rm1=d33*bm/rl+s*d34*bp/(2*rc)
rm2=d34/rl*bm+s*d33*bp/(2*rc)
q=s*d55*wm/rl+c*d55*um/rl+d55*bp/2
call put(ie,rn1,rn2,rm1,rm2,q)
endif
end
subroutine put(ie,rn1,rn2,rm1,rm2,q)
c
c ulozeni vnitrnich sil do matice 6-pe sloupcem 3 pocinaje
c
common ma(20000)
dimension ra(20000)
equivalence (ma,ra)
call mlocr(6,ie,3,loc,it,np,id)
ra(loc)
=rn1
ra(loc+id) =rn2
ra(loc+2*id)=rm1
ra(loc+3*id)=rm2
ra(loc+4*id)=q
end
subroutine get(ie,x,r,u,w,beta,p,t,node,forces)
c
c data transfer x(2),r(2),u(2),w(2),beta(2),press,thickness,node(2),forces(5)
c 2-nue 3-xr 4-ipu 5-rp 6-pe
c
common z(10000)
dimension x(2),r(2),u(2),w(2),beta(2),node(2),forces(5),iz(10000)
equivalence (z,iz)
call mlocr(2,ie,1,loc,it,np,idif)
do 1 i=1,2
indu=iabs(iz(loc+(i-1)*idif))
call mlocr(5,indu,1,locp,it,npu,idpu)
node(i)=indu
u(i)=z(locp)
w(i)=z(locp+idpu)
beta(i)=z(locp+2*idpu)
XMKPE.DOC
16
1
2
call mlocr(3,indu,1,locp,it,npu,idpu)
r(i)=z(locp)
x(i)=z(locp+idpu)
call mlocr(6,ie,1,locp,it,np,idpu)
p=z(locp)
locp=locp+idpu
t=z(locp)
do 2 i=1,5
locp=locp+idpu
forces(i)=z(locp)
end
subroutine sext(i,itx,j1,j2,ict)
c vysvetlivky jsou v poli cislo 7
common m(20000) /scom/iss(50)
character *16 ifile,jfile
equivalence (lab,m(55)),(nlab,m(62)),(iout,iss(12))
data ifile/'*.mod'/
if(ict.eq.54.or.ict.eq.53)then
call mpanel(1,2,7,7,m(lab+(i-1)*nlab),1,nlab,nlab,m)
call mpanel(16,2,23,7,
/
'
'//
/
' Please prepare new data:
'//
/
'$5Created by COSMOS$[$3F10 $] '//
/
' or manually:
'//
/
'$5Select matrix and$[$3Enter$] '//
/
' Start:
'//
/
'$5Computation$- by $[$3F9 $ ] ',7,8,8,m)
elseif(ict.eq.55)then
call minpf(1,' File MODINPUT:',15,14,2,ifile,16,10,40,24,
/
jfile,16,ires)
if(ires.gt.0)then
open(30,file=jfile)
call modinp(30, 2,2, 3,2, 4,3, 5, 6)
C
iue ixy ipu rp ipe
iout=3
close(30)
endif
else
call medcex(i,itx,j1,j2,ict)
endif
end
subroutine grid(kbd)
c
c graphics
c
dimension x(2),r(2),u(2),w(2),beta(2),node(2),forces(5)
character *9 label, lfor(6)*4
data lfor/'node','Nmer','Ncir','Mmer','Mcir','Q
'/
call mpara(2,kod,mat,ne,n,loc,len)
iforce=0
60
xmi=1e10
xma=-1e10
rmi=1e10
rma=-1e10
uma=1e-15
wma=1e-15
do1ie=1,ne
call get(ie,x,r,u,w,beta,p,t,node,forces)
do1i=1,2
xmi=amin1(xmi,x(i))
xma=amax1(xma,x(i))
rmi=amin1(rmi,r(i))
rma=amax1(rma,r(i))
uma=amax1(uma,abs(u(i)))
wma=amax1(wma,abs(w(i)))
1
continue
50
dx=amax1(uma,(xma-xmi)*.1)
dr=amax1(wma,(rma-rmi)*.1)
scaleu=dx/uma
scalew=dr/wma
call gmfin
call gmfst(1,0.,1.,0.1,1.,rmi-dr,rma+dr,xmi-dx,xma+dx)
call gmfsyl('R [m]',5,'X [m]',5)
51
call gmfaxl(1,3,11)
call scwrit(24,0,77,15,' [F1]-zooming [F2]-zoomout [F3]-E,mi [F4]-
XMKPE.DOC
17
40
30
2
31
22
/label:'//lfor(iforce+1)//' [Enter]-tools [Esc]-quit')
call gmfsw(1)
if(iforce.gt.0)then
fmax=1e-15
tmax=1e-10
imax=1
do40ie=1,ne
call get(ie,x,r,u,w,beta,p,t,node,forces)
aforce=abs(forces(iforce))
tmax=amax1(tmax,t)
if(aforce.gt.fmax)then
fmax=aforce
imax=ie
endif
continue
endif
do22ie=1,ne
call get(ie,x,r,u,w,beta,p,t,node,forces)
if(iforce.eq.0)then
call gmfpl(2,r,x,2+mod(ie,2))
do2i=2,1,-1
call gmfmrk(r(i),x(i),20)
write(label,30)node(i)
format(i2)
call gmftext(r(i),x(i),1,2,label)
x(i)=x(i)+u(i)*scaleu
r(i)=r(i)+w(i)*scalew
call gmfmrk(r(i),x(i),27)
continue
call gmfpl(2,r,x,4)
else
forc=forces(iforce)/fmax*.15
call gmfort(r,x,forc,forc,t*.007/tmax,1,4,12,rc,xc)
if(ie.eq.imax)then
call gmfmrk(rc,xc,10+iforce)
write(label,31)forces(iforce)
format(e9.2)
call gmftext(rc,xc,1,9,label)
endif
endif
continue
call skbdr(kbd)
if(kbd.eq.59)then
call gmflcw(rmi,rma,xmi,xma,rmi,rma,xmi,xma,kbd)
goto 50
elseif(kbd.eq.60)then
goto 60
elseif(kbd.eq.62)then
iforce=mod(iforce+1,6)
goto 51
endif
call gmfmon
end
XMKPE.DOC
18
3.5. XMKPE10 – Pressure thermal forming (expansion of a thin waffle during
baking)
This model is designed for the two dimensional modelling of thin-wall starch based
products during thermal processing in a mold. The model could be used for description of
temporary temperature and pressure in a "shell-like" finite element, e.g. in a quad or triangle,
see Fig.3.5.1.
y
pG3
10
5
s3
pG4
s4
pG
s2
D
s1
pG2
2
1
11
9
1
6
pG1
Possible application
15
14
4
3
17
8
2
1
1
6
3
4
13
12
7
5
16
x
-Nodal parameters - velocities ux,uy, pA, Tw
-Integral model - internal parameters - pressure pG and temperature T
There are some specific features in comparison with classical finite element methods used,
e.g., in metal or plastics moulding. First of all there is a lack of some verified principle
controlling the movement of shell, i.e., velocities ux, uy of grid points. So far the only solid
information concerns volumetric changes of the heated shell, described locally as a relative
change of element area during a time step t. This knowledge can be applied in the form of
continuity equation, written as
ux uy 1 S
(3.5.1)


x v S t
1 S
 ( t , x , y ) must be evaluated by a suitable physical model in each
and the value of
S t
element separately at any time step (it will be assumed as a known function in this example).
However, continuity Eq.(3.5.1) is not sufficient for unique description of the shell expansion,
and an additional condition has to be formulated: Probably the most general conditions is to
be derived from an energetic principle. The simplest formulation is
2
2
(3.5.2)
 (ux  uy )dxdy  min
S
which represents the principle of minimal work, done by frictional forces acting on the
surface of shell. It is assumed that these forces are directly proportional to the velocities of
shell and that the friction coefficient is constant.
As far as geometry a finite element concerns, the simplest form - triangle – will be used.
Velocities (or relative displacements) in a triangular element y
3
are linear functions of co-ordinates x,y
S
uz (t , x, y)  az (t )  bz (t ) x  cz (t ) y for directions z=x,y
2
x
1
(3.5.3)
where 6 coefficients az, bz ,cz are fully determined by 6 values of velocities uzj for coordinates
z=x,y and three vortices j=1,2,3:
XMKPE.DOC
19
az 
1 3
1 3
1 3
(
x
y

x
y
)
u
b

(
y

y
)
u
c

,
,
 j 1 j  2 j  2 j 1 zj z 2S 
 ( x j  2 x j 1 )uzj .(3.5.4)
j 1
j2
zj
z
2 S j 1
2S j 1
j 1
1 x1 y1
1
S denotes area of triangle 1,2,3: S  1 x2 y2
(3.5.5)
2
1 x3 y3
Approximation (3.5.3) can be rearranged in the form of linear combination of shape functions
Nj(x,y):
3
uz (t , x , y )   N j ( x , y )uzj (t ) ,
j 1
1
[ x j 1 y j  2  x j  2 y j 1  ( y j 1  y j  2 ) x  ( x j  2  x j 1 ) y ]
(3.5.6)
2S
Substituting functions (3.5.6) into Eq.(3.5.1) we conclude, that the continuity equation is
fulfilled pointwise if the function  is constant (this is advantage of triangles, not shared
e.g.by quads):
N j ( x, y) 
bx (t )  cy (t )  (t ) 
3
 [( y
j 1
 y j  2 ) uxj  ( x j  2  x j 1 ) uyj ]  2 S
(3.5.7)
j 1
Continuity equation (3.5.7) must be written for each element. There are 2M nodal values of
unknown velocities ux, uy in a mesh having N elements and M nodes. N equations are
continuity constraints (3.5.7) and remaining 2M-N equations could be obtained by
minimisation of functional (3.5.2), that is approximated by function of 2M variables uxi, uyi. In
principle it is possible to use N constraints (3.5.7) for elimination of N variables from the
minimised function (3.5.2), leaving only required number of unknowns 2M-N, but it
represents a very tedious and algorithmically difficult process. Such a situation is usually
solved by using the method of Lagrange multipliers, adding to function (3.5.2) the sum of Nconstraints multiplied by e
3
F (ux , uy ,  )   (ux2  uy2 )dxdy    e { [( y j 1  y j  2 ) e uxj  ( x j  2  x j 1 ) e uyj ]  2 Se e }  min
e
S
j 1
(subscript e denotes element, e=1,2,...N)
(3.5.8)
Multipliers e (e=1,2,...N) are new unknowns independent of ux, uy so that F is a function of
2M+N variables and has to be minimised with respect to all of them. But this time it is a free
optimisation, without constraints, so that
3
F
 0   [( y j 1  y j  2 )uxj  ( x j  2  x j 1 )uyj ]  2 S  0 , this are constraints (3.5.7) and
 e
j 1
N
F
 0  [2 uxi  Ni N j dxdy   e ( y j 1  y j  2 ) e ]  0
uxj
e 1
i
S
for j=1,2,...,M
(3.5.9)
F
 0  [2 uyi  Ni N j dxdy   e ( x j  2  x j 1 ) e ]  0
uyj
e 1
i
S
for j=1,2,...,M
(3.5.10)
e
N
e
Taken together, there are N-equations (3.5.7), M-equations (3.5.9) and M-equations (3.5.10),
i.e. 2M+N linear equations for 2M+N unknowns ux1,uy1,...., uxM,uyM, 1,...,N. This symmetric
system of linear algebraic equations has to be solved at each time step of simulation, e.g. by a
version of elimination method, tailored for finite element programs (we usually use the frontal
method). The surface integrals of products of shape functions in Eqs.(3.5.9,10) can be
calculated analytically using a general formula
XMKPE.DOC
20
a !b!c!
a b c
,
 L L L  2 S
1 2 3
(a  b  c  2)!
giving
N
[ u
e 1
xi
4S S
2S S

 ,  L2 
 L L 
i
i j 4! 12
4! 6
(3.5.11)
Kij  e ( y j 1  y j 2 ) e ]  0
i
S
S
Kij  , Kii 
6
3
(3.5.12)
Program
c
c
c
c
c
c
c
c
c
c
c
c
c
c
MKPE10 @Zitny 3/2001
Expansion of waffle in a mold solved by method of Lagrangian multipliers
4-nodal triangles (vertices u,v, center lambda)
Matrices:
2 - noe [connectivity matrix]
3 - xy
[x,y]
4 - pointers used by matrices 5,6
5 - ipu [indices of nodal parameters] variable length of rows
6 - rpu [nodal parameters u,v,lambda] the same mapping as IPU
7 - parameters of elements (relative expansion beta)
8 - help [text]
9 - xy-new [x+u.dtime, y+v.dtime]
common /prop/dtime /scom/iss(50)
external lokal,sext
character *4 inkey
equivalence (kbdr,iss(13))
dtime=1
call scomin(-1)
call sintro('xmkpe10.for')
call mtobir('xmkpe10.mat',iend)
10
call sclear
call minpr(0,' Time step=',11,14,2,dtime)
1
call mtools(0,sext)
if(kbdr.eq.67)then
c mefrin(iue,ieq), mefron(iue,ieq,u, maxA, maxAl, sub(A), device)
call mefrin(2,5)
call mefron(2,5,6,60,7,lokal,0)
endif
call grid(kbd)
if(kbd.eq.62) goto 10
if(kbd.ne.27) goto 1
call scwrit(16,2,28,23,' Do You want to Quit ? [Y/N]')
call skbdr(inkey)
if(inkey.ne.'Y
'.and.inkey.ne.'y
')goto 1
999
call sclear
end
subroutine lokal(ie,nl,nod,al,fl)
c Input: IE-index of element, NL-dimension, NOD-number of nodes
dimension al(7,7),fl(7),x(3),y(3),u(3),v(3)
common /prop/dtime
call get(ie,nod,x,y,u,v,beta)
C Local STIFFNESS MATRIX AL(7 x 7)
S=.5*abs(x(1)*(y(2)-y(3))+x(2)*(y(3)-y(1))+x(3)*(y(1)-y(2)))
al=0
fl=0
do i=1,3
i1=2*i-1
C New trick: IP1=i+1, IP2=i+2 in a cyclic list 1,2,3
ip1=mod(i,3)+1
ip2=mod(ip1,3)+1
C Last column and row are formed by X,Y (integrals of derivatives)
XMKPE.DOC
21
al(i1,7)=(y(ip1)-y(ip2))/2
al(i1+1,7)=(x(ip2)-x(ip1))/2
al(7,i1)=al(i1,7)
al(7,i1+1)=al(i1+1,7)
C Submatrix 6 x 6
do j=1,3
j1=2*j-1
if(i.eq.j)then
vv=s/3
else
vv=s/6
endif
al(i1,j1)=vv
al(i1+1,j1+1)=vv
enddo
enddo
fl(7)=beta*s
end
subroutine get(ie,nod,x,y,u,v,beta)
c
c data transfer (3-nodes)
c
common z(20000)
dimension x(3),y(3),u(3),v(3),iz(20000)
equivalence (z,iz)
call mlocr(2,ie,1,loc,it,nod,idif)
do i=1,3
indu=iabs(iz(loc+(i-1)*idif))
call mlocr(3,indu,1,locp,it,npu,idpu)
x(i)=z(locp)
y(i)=z(locp+idpu)
call mlocr(6,indu,1,locp,it,npu,idpu)
u(i)=z(locp)
v(i)=z(locp+1)
enddo
call mlocr(7,ie,1,locp,it,npu,idpu)
beta=z(locp)
end
However, this program fails from unknown reasons, giving results compared with correct
solution using program WAFF5-1.for
XMKPE10
WAFF5-1
C
C WAFF5-1 Finite Element Method
C
C Algorithms test - expansion
C
parameter (num=50,nem=100)
common /grid/x(num),y(num),nc(3,nem),beta(nem),xn(num),yn(num)
common am(10000),fm(100)
dimension xs(4),ys(4)
XMKPE.DOC
22
C Read grid data
open(1,file='waff5-1.dat')
open(2,file='waff5-1.out')
read(1,*)
read(1,*)nu,ne
read(1,*)(x(i),y(i),i=1,nu)
read(1,*)((nc(j,i),j=1,3),beta(i),i=1,ne)
neq=2*nu+ne
C Assembly of stiffness matrix and R.H.S. vector
call gassem(neq,ne,nu,nc,x,y,beta,am,fm)
C Solution of linear equations by Gauss elimination (routine IBM)
call gelg(fm,am,neq,1,1e-6,ier)
C Output Results
write(2,1)nu,(x(i),y(i),i=1,nu)
write(2,2)ne,((nc(j,i),j=1,3),beta(i),i=1,ne)
write(2,3)ier,(i,fm(2*i-1),fm(2*i),i=1,nu)
1
format(i3/(2e10.3))
2
format(i3/(3i5,e10.3))
3
format(' IERROR=',i3/(i3,2e10.3))
end
C
C
C
C
C
C
subroutine gassem(neq,ne,nu,nc,x,y,beta,am,fm)
dimension x(nu),y(nu),beta(ne),nc(3,ne),am(neq,neq),fm(neq),
/
al(7,7),fl(7),xl(3),yl(3),ieq(7)
AM - stiffness matrix of system
FM - R.H.S. vector of system
do i=1,neq
do j=1,neq
am(i,j)=0
enddo
fm(i)=0
enddo
Element loop (NC(1..3, 1..NE)-connectivity matrix)
do ie=1,ne
do i=1,3
iu=nc(i,ie)
xl(i)=x(iu)
yl(i)=y(iu)
ieq(2*i-1)=2*iu-1
ieq(2*i)=2*iu
enddo
ieq(7)=2*nu+ie
call kbeta(xl,yl,beta(ie),al,fl)
ASSEMBLY
do i=1,7
Add local R.H.S. vector FL(1..7) to the global vector FM(1..NEQ)
fm(ieq(i))=fm(ieq(i))+fl(i)
do j=1,7
Add local matrix (7 x 7) to the global matrix (NEQ x NEQ)
am(ieq(i),ieq(j))=am(ieq(i),ieq(j))+al(i,j)
enddo
enddo
enddo
end
subroutine kbeta(x,y,beta,al,fl)
dimension x(3),y(3),al(7,7),fl(7)
C Local STIFFNESS MATRIX AL(7 x 7)
det=x(1)*(y(2)-y(3))+x(2)*(y(3)-y(1))+x(3)*(y(1)-y(2))
al=0
fl=0
do i=1,3
i1=2*i-1
C New trick: IP1=i+1, IP2=i+2 in a cyclic list 1,2,3
ip1=mod(i,3)+1
ip2=mod(ip1,3)+1
C Last column and row are formed by X,Y (indegrals of derivatives)
XMKPE.DOC
23
al(i1,7)=(y(ip1)-y(ip2))/2
al(i1+1,7)=(x(ip2)-x(ip1))/2
al(7,i1)=al(i1,7)
al(7,i1+1)=al(i1+1,7)
C Submatrix 6 x 6
do j=1,3
j1=2*j-1
if(i.eq.j)then
v=det/6
else
v=det/12
endif
al(i1,j1)=v
al(i1+1,j1+1)=v
enddo
enddo
fl(7)=beta*det/2.
end
The discrepancy of results obtained by XMKPE10 is explained – the program is correct the
only problem was specification of too large EPS (smallest acceptable PIVOT). For the
problem shown in previous example EPS=1E-9 gives absolutely correct results.
Remark: Frontal routine MEFRON makes use of only DIAGONAL PIVOTING, however it
was not the problem – the program XMKPE5 with IBM subroutine GELG (full pivoting) has
been rewritten also to the diagonal pivoting and results were the same.
XMKPE.DOC
24
3.6. XMKPE11 – Pressure thermal forming (pressure distribution during baking)
If complicated at all, the computational procedure of the expansion is not so important as
the procedure for computing pressure distribution (pG), which has significant influence on
thermal processes inside elements (and therefore on the predicted temperatures). Assuming
that the thickness of gap between the surface of waffle and the heating plate is constant, this
distribution is described by the Poisson's equation

pG
p G
 vx ,
 , and   M
 m
v
  fG M
  fG M
vy
v
x
y
 2 pG  2 pG
(3.6.1)

  f G m v
x 2
y 2
where the source term m v is the mass flux of steam at the surface of the baked waffle (a scalar
 / S ). Poisson's equation - what could be easier
function calculated at an element level as M
v
for finite elements? However in this particular case it is not so, and this equation represents a
great problem in connection with the integral model used for element definition. According to
this model the pressure pG is in fact an internal variable and it is the pressure pA outside the
control volume (element), which controls the baking process. Moreover, Eq.(3.6.1) is of the
second order in derivatives x,y , and thus the pressure pG has to be approximated at least by
linear polynomial inside an element. Single nodal value located somewhere inside the element
is not enough. Therefore at least three nodal pressures pG have to be located at element
vertices. How to treat this discrepancy? Seemingly straightforward way is development of a
new integral model, not accounting the pressure drop in the gap, because this pressure drop is
included in the Poisson Eq.(3.6.1). In such a model, the friction factor fG as well as the
ambient pressure pA disappear being replaced by the explicitly prescribed pressure pG. It is
questionable if this approach would be successful, as the frictional resistance f G plays a
stabilisation role in the integral model (improves convergence of inner iterations). As a
compromise we decided to consider the mean value of nodal values pG as the ambient
pressure pA of an element. This mean value can be calculated simply as arithmetic mean of the
three nodal values or more generally as
1
pA   pG dl
(51)
Le
Remark: According to the integral model holds fG/(fCh)De2 and thus decreasing characteristic
dimension De0 of element leads to lim pG=pA, i.e., any averaging method gives the same
results for sufficiently small elements. Diameter De is important input parameter of the
integral model, specifying temporary volume of an element. It is calculated as
S
(52)
De  2 e .

If the pressures pG are localised in the same nodes as velocities, the same form of
approximation pG(t,x,y) and the same shape functions Nj(x,y) can be used, giving the
following finite element equivalent of Poisson's equation (50) - symmetric system of linear
equations:
N
N
N i N j N i N j
(53)
i pGi 
 ( x x  y y )dxdy  
 f C m ve N j dxdy
e 1 Se
e 1 Se
Exactly the same reasoning holds also for the last remaining field, temperatures Tw of
heating moulds. Fourier equation for this temperature field can be written as (see Eq.(39))
XMKPE.DOC
25
 hchhh
Tw
 2T  2T
S
S
  hhh ( 2w  2w )  ( e  h  h )Tw  q   eT  h  hTe
t
x
y
S
S
(54)
where hh(x,y) is thickness of heating plate, and Sh/S is the ratio of outer and inner surface at a
given place. Heat flux q corresponds to the intensity of electrical heating and is calculated as
q=hhQ, where Q [W/m2] is the volumetric heat source. Eq.(54) can rearranged to the weak
solution for finite elements in a similar way as the Poisson's equation for pressure, i.e.
substituting approximation Tw=NjTwj , multiplying (54) by shape function Ni (now the shape
function plays the role of a weight function) and integrating across the whole surface of the
heated waffle. Using Green's theorem the second spatial derivatives of the shape functions are
removed, giving
N M
T
S
 N N j N i N j
{ h ch hh  N i N j dxdy wj  Twj  [( e  h ) N i N j   h hh ( i

)]dxdy} 


t
S
x x
y y
e 1 j 1
Se
Se
N
  (q   eT 
e 1
Sh
T
 h Te )  N i dxdy   h hh  N i w dn
S
n
Se
(55)
The line integral in r.h.s. of Eq.(55) reminds the (hopefully) last problem: this term describes
lateral heat flux around the periphery of waffle, but inside the heating plate (inside the wall of
mould). While it was no problem with pressure (at this periphery the pressure is constant and
equals the atmospheric pressure) we cannot assume constant temperatures along this line; in
fact we cannot use this periphery
as the boundary of the region,
where the temperature are
computed. This region has to be
extended to the whole plate and
Twi,new=Nj(xi,new,yi,new)Twj
even then the line integral can
xi,yi,Twi
xi,new=xi+uxit , yi,new= yi+uyit
be
either
neglected
or
substituted by the line integral
of heat flux from the sides of
heater.
This
necessitates
time t
generation of different mesh for
time t+t
waffle and for plate; it should be
stressed that equations (55) are
valid only for a fixed mesh; when the waffle expands, the computational mesh must be
updated in each time step and temperatures Tw must be recalculated by interpolation, see Fig.5
Fig.5 Mesh expansion and wall temperature interpolation
XMKPE.DOC
26
Read data: geometry,
parameters fC,hG,,,bw
Generate mesh (nodal coordinates,
connectivity matrix)
Initial conditions: Tw, T0 (for
elements), uniform pressure pA
t=0,t,....,tmax
e=1,2,...,N
Element procedure inputs pA,Tw, T0
Outputs: T,p,Mv,e
time step by Intg.met.
Pressure distribution
FEM
distributionpGpGbybyFEM
Pressure
(53).
to(50).
according to
according
An outline of the overall computational
procedure is shown in Fig.6
In the case that the sample walls are very thick,
or if the lateral flow of suspension in the liquid
core is significant, a true three-dimensional
models should be used, discretising not only the
lateral but also the transversal coordinate. For
now on this way of modelling is oriented only
upon the simple planar geometry, with the aim to
obtain more information about the pressure
profile along the wall and estimation transversal
temperature profiles. This approach will be
demonstrated in the following paragraph 2.3.
Accuracy?
Modify mesh (nodal coordinates,
interpolate wall temperatures Tw)
Temperature distribution Tw by FEM
according to (55).
Write results: geometry, T,
Tw, pG, masses. Update To.
new time step
XMKPE.DOC
27