FINITE ELEMENT METHODS: Parallel-Sparse Statics and Eigen-Solutions
FINITE ELEMENT METHODS: Parallel-Sparse Statics and Eigen-Solutions
Due Thai Nguyen Old Dominion University Norfolk, Virginia
~ Springer
Prof. Due Thai Nguyen 135 Kaufman Old Dominion University Department of Civil & Environmental Engineering Multidisc. Parallel-Vector Comp Ctr Norfolk VA 23529 Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Library of Congress Control Number: 2005937075 ISBN 0-387-29330-2 e-ISBN 0-387-30851-2 ISBN 978-0-387-29330-1 Printed on acid-free paper. © 2006 Springer Science+Business Media, Inc. All rights reserved. This work may not be translated or copied in whole or in part without the written permission of the publisher (Springer Science+Business Media, Inc., 233 Spring Street, New York, NY 10013, USA), except for brief excerpts in connection with reviews or scholarly analysis. Use in connection with any form of information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now know or hereafter developed is forbidden. The use in this publication of trade names, trademarks, service marks and similar terms, even if the are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
Printed in the United States of America.
9 8 7 6 5 432 springer.com
To Dac K. Nguyen Thinh T. Thai Hang N. Nguyen Eric N. D. Nguyen and Don N. Nguyen
Contents 1. A Review of Basic Finite Element Procedures 1.1 1.2
;
Introduction Numerical Techniques for Solving Ordinary Differential Equations (ODE) 1.3 Identifying the "Geometric" versus "Natural" Boundary Conditions 1.4 The Weak Formulations 1.5 Flowcharts for Statics Finite Element Analysis 1.6 Flowcharts for Dynamics Finite Element Analysis 1.7 Uncoupling the Dynamical Equilibrium Equations 1.8 One-Dimensional Rod Finite Element Procedures 1.8.1 One-Dimensional Rod Element Stiffness Matrix 1.8.2 Distributed Loads and Equivalent Joint Loads 1.8.3 Finite Element Assembly Procedures 1.8.4 Imposing the Boundary Conditions 1.8.5 Alternative Derivations of System of Equations from Finite Element Equations 1.9 Truss Finite Element Equations 1.10 Beam (or Frame) Finite Element Equations 1.11 Tetrahedral Finite Element Shape Functions 1.12 Finite Element Weak Formulations for General 2-D Field Equations 1.13 The Isoparametric Formulation 1.14 Gauss Quadrature 1.15 Summary 1.16 Exercises
2. Simple MPIJFORTRAN Applications 2.1 2.2 2.3 2.4 2.5 2.6
1 1 1 6 6 9 13 14 17 18 21 22 24 25 27 29 31 35 .44 51 59 59
63
Introduction 63 63 Computing Value of "rt" by Integration Matrix-Matrix Multiplication 68 MPI Parallel I/O 72 Unrolling Techniques 75 Parallel Dense Equation Solvers 77 2.6.1 Basic Symmetrical Equation Solver 77 2.6.2 Parallel Data Storage Scheme 78 2.6.3 Data Generating Subroutine 80 2.6.4 Parallel Choleski Factorization 80 2.6.5 A Blocked and Cache-Based Optimized Matrix-Matrix Multiplication 81 2.6.5.1 Loop Indexes and Temporary Array Usage 81 2.6.5.2 Blocking and Strip Mining 82 2.6.5.3 Unrolling of Loops 82
V111
2.6.6 Parallel " Block" Factorization 2.6.7 "Block" Forward Eliminat ion Subro utine 2.6.8 "Block" Backward El iminatio n Subr outine 2.6.9 "Block" Erro r Chec king Subroutine 2.6. 10 Numerical E valuation
2.6.1 1 Conclusions 2.7
2.8 2.9
"
83 85 86 88 91
,
,
95
Dcvcloping/Dcbugging Parallel MP I App lication Code on Your Ow n Lap top Summary Exercises
3 . Direct Sparse Eq uatio n Solvers 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3. 10 3. 11 3.12
Intr oduction Sparse Storage Schemes Three Basic Steps and Re-Ordering Algor ithms Symbolic Facto rizatio n with Re-Ordering Column Number s Sparse Numerical Factorization Supe r (Master) Nodes (Degree s-o f-Freed om) Numerical Factoriz ation with Unrolling Strategies Forward/Back ward Solutions with Unrolling Strate gies Alternative Approach for Handling an Indefinite Matr ix Unsymm etrical Matrix Equa tion Solver Summary Exe rcises
105
"
4. Spa rse Assem bly Process 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 4. 12 4. 13 4.14 4.15 4.16
95 103 103
Introduct ion A Simple Fi nite Elem ent Model (Symmetrical Matr ices) F inite Element Sparse Assem bly Algorithms for Symmetrical Matrices Symbolic Spar se Assembly of Symmetrical Matrices " Numeri ca l Sparse Assembly o f Symmetrical Matrice s Step-by-S tep Algorithms for Symmetrical Sparse Assembly A Simp lc Finite Ele ment Model (Unsymmetrical Matrices) Re-Ordering Algorithms Imposing Diric hlet Boundary Cond itions Unsymm etrical Spar se Equations Data Formats Symbolic Spar se Assembly of Unsymmetric al Matrices Nume rical Sparse Assembly of Unsymmetrical Matrices Step-by-Step Algorithms for Unsymmetrical Spa rse Assem bly and Unsymmetri cal Sparse Equation Solver A Numerical Example Summary Exercises
105 105 ll0 118 132 134 137 137 154 165 180 181
183 183 183 188 189 l 92 200 2 19 224 229 254 259 260 260 265 265 266
ix 5. Generalized Eigen-Solvers....... . . ......................................................................... 269
. .
Introduction............... .............................................................................. 269 . ................................... 269 A Simple Generalized Eigen-Example................. . ....... . ........................ 271 Inverse and Forward Iteration Procedures........... . . ............................................................. 274 Shifted Eigen-Problems........... . ....... . ................................................ 276 Transformation Methods............. ................................................. 286 Sub-space Iteration Method ............... . ............................................. 290 Lanczns Eigen-Solution Algorithms........... . . ................................. 290 5.7.1 Derivation of Lanczos Algorithms................. . . . ..................... 295 5.7.2 Lanczos Eigen-Solution Error Analysis..................... . . .............................................. 302 5.7.3 Sturm Sequence Check......................... .........306 5.7.4 Proving the Lanczos Vectors Are M-Orthogonal.............. 308 5.7.5 "Classical" Gram-Schmidt Re-Orthogonalization.................................... 314 5.7.6 Detailed Step-by-step Lanczos Algorithms............................................ ..........316 5.7.7 Educational Software for Lanczos Algorithms................. 5.7.8 Efficient Software for Lanczos Eigen-Solver........... .........................336 .................................................. 339 Unsymmetrical Eigen-Solvers ......... 5.8 5.9 Balanced Matrix......................................................................................... 339 5.10 Reduction to Hessenberg Form...................... . . ........................................ 340 . . ....... . . ........................................................................... 341 5.1 1 QR Factoruat~on . . . ................................................. 341 5.12 Householder QR Transformation....... 348 5.13 "Modified" Gram-Schmidt Re-Orthogonalization......................................... 350 5.14 QR Iteration for Unsymmetrical Eigen-Solutions......................................... 5.15 QR Iteration with Shifts for Unsymmetrical Eigen-Solutions................... 353 ............................................................. 5.16 Panel Flutter Analysis............. 355 5.17 Block Lanczos Algorithms.................. . . ................................................. 365 . . ............................... 366 5.17.1 Details of "Block Lanczos" Algorithms.......... 5.17.2 A Numerical Example for "Block Lanczos" Algorithms.......... . . .......371 377 5.18 Summary..................................................................................................... 5.19 Exercises.................. . . ............................................................................. 378 5.1 5.2 5.3 5.4 5.5 5.6 5.7
. . . .
..............
. . . .
............. . .
. . .
6. Finite Element Domain Decomposition Procedures................. . . .......................... 379
. . . .......... .
Introduction....... .................................................................................... 379 A Simple Numerical Example Using Domain Decomposition (DD) Procedures .............................................................................. 382 Imposing Boundary Conditions on "Rectangular" Matrices K$!
...............390
How to Construct Sparse Assembly of "Rectangular" Matrix K$; .............392 Mixed Direct-Iterative Solvers for Domain Decomposition......................... 393 Preconditioned Matrix for PCG Algorithm with DD Formulation............... 397 Generalized Inverse....................... ......................................................... 404 FETI Domain Decomposition F o r m n l a t i ~ n ' ~ ........................................ ~~~." 409 Preconditioned Conjugate Projected Gradient (PCPG) of
. .
x the Dual Interface Problem 16 .41 6.10 6. 11 6.12 6.13
,.A I7
Automated Procedures for Computing Generalized Inverse
and Rigid Body Motions
422
Numerical Examples of a 2-D Tru ss by FETI Form ulation A Precond ition ing Te chnique for Indefinite Linear Sr stem 16 121 FETI-DP Domain Decompo sition Formul ation [6.6. 6.1
433 .459 46 3
6.14 Multi-Level Sub-Domains and Multi-Frontal Solver [6. u - 6.101 . S0 1utfun · Wit. h S uccessive . R·tght-IIand Sid 1 es 16.21,6.241 6. 15 1teranve
,
6.16 6.17
,..510 .5 10
Summa ry E xercises
Append ix A Singular Value Decom position (SVD) Refere nces Index
..488 490
.515 52 1 .527
Preface Finite element methods (FEM) and associated computer software have been widely accepted as one of the most effective, general tools for solving large-scale, practical engineering and science applications. It is no wonder there is a vast number of excellent textbooks in FEM (not including hundreds of journal articles related to FEM) written in the past decades! While existing FEM textbooks have thoroughly discussed different topics, such as linear/nonlinear, static/dynamic analysis, with varieties of I-DI2-D/3-D finite element libraries, for thermal, electrical, contact, and electromagnetic applications, most (if not all) current FEM textbooks have mainly focused on the developments of "finite element libraries," how to incorporate boundary conditions, and some general discussions about the assembly process, solving systems of "banded" (or "skyline") linear equations. For implicit finite element codes, it is a well-known fact that efficient equation and eigen-solvers play critical roles in solving large-scale, practical engineering/science problems. Sparse matrix technologies have evolved and become mature enough that all popular, commercialized FEM codes have inserted sparse solvers into their software. Furthermore, modern computer hardware usually has multiple processors; clusters of inexpensive personal computers (under WINDOWS, or LINUX environments) are available for parallel computing purposes to dramatically reduce the computational time required for solving large-scale problems. Most (if not all) existing FEM textbooks discuss the assembly process and the equation solver based on the "variable banded" (or "skyline") strategies. Furthermore, only limited numbers of FEM books have detailed discussions about Lanczos eigen-solvers or explanation about domain decomposition (DD) finite element formulation for parallel computing purposes. This book has been written to address the concerns mentioned above and is intended to serve as a textbook for graduate engineering, computer science, and mathematics students. A number of state-of-the-art FORTRAN software, however, have been developed and explained with great detail. Special efforts have been made by the author to present the material in such a way to minimize the mathematical background requirements for typical graduate engineering students. Thus, compromises between rigorous mathematics and simplicities are sometimes necessary. The materials from this book have evolved over the past several years through the author's research work and graduate courses (CEE715/815 = Finite Element I, CEE695 = Finite Element Parallel Computing, CEE711l811 = Finite Element II) at Old Dominion University (ODU). In Chapter I, a brief review of basic finite element
X 11
procedures for Linear/Statics/Dynamics analysis is given. One. two, and threedimensional finite element types are discussed. T he weak form ulation is emphasiz ed . Finite element general field equations are derived. isoparametric formulation is explained, and Gau ss Q uadrature formulas for effic ient integra tion arc d iscussed . In this chapter, only simple (non-efficient) finite clement assembly procedures are explained. Chapter 2 illustrates some salient features offered by Message Passing Interface (MPI) FORTRAN environments. Unrolling techniques, efficient usage of computer cache memory, and some basic MPUFORTRAN applications in matrix linear algebra operations arc also discussed in this chapter. Different versions of direct. "SPARSE" equation solvers' strategies are thoroughly discussed in Chapter 3. The "truly sparse" finite element "assembly process" is explained in Chapter 4. Different versions of the Lanczos algorithms for the solution of generalized eigenequations (in a sparse matrix environment) are derived in Chapter 5. Finally, the overall finite clement domain decomposition computer implementation, which can exploit "di rect" sparse matrix equation, etgen-sclve rs. sparse assembly, "iterative" solvers (for both "symmetrical" and "unsymmetrical" systems of linear equations), and parallel processing computation, are thoroughly explained and demonstrated in Chapter 6. Attempts have been made by the author to explain some difficult concepts/algorithms in simple language and through simple (hand-calculated) numerical examples. Many FORTRAN codes (in the forms of main program, and sub-routines) are given in Chapters 2 - 6. Several large-scale, practical engineering problems involved with several hundred thousand to over I million degree-offreedoms (dol) have been used to demonstrate the efficienc y of the algorithms discussed in this te xtbook. Th is textbook should be useful for graduate students, practicing engineers, and researchers who wish 10 thoroughly understand the detailed step-by-step algorithms used during the finite element (truely sparse) assembly, the "direct" and "iterative" sparse equation and eigen-solvers, and incorporating the DD formulation for efficient parallel computation. The book can be used in any of the following "stand-alone" courses: (a)
Chapter I can be expanded (with more numer ical examples) and portions of Chapter 3 (only cover the sparse formats, and some "key components" of the sparse sol ver) can he used as a first (introductive type) course in finite element analysis at the senior undergraduate (or 1st year graduate) level.
(b)
Chapters 1,3, 4, and 5 can be used as a "stand-alone" graduate course such as "Speci al Topics in FEM: Sparse Linear Statics and Eigen-Solutlons."
(e)
Chapters I, 2, 3, 4, and 6 can be used as a "stand-alone" graduate course, such as "Special Topics in FEM: Parallel Sparse Linear Stat ics Solutions."
(d)
Chapters 2, 3, and 5, and portions of Chapter 6, can be used as a "standalone" graduate course such as "High Performance Parallel Matrix Computation."
Xl11
The book also contains a limited number of exercises to further supplement and reinforce the presented concepts. The references for all chapters are listed at the end of the book. The author would like to invite the readers to point o ut any errors they find. He also welcomes any suggestions or comments from readers. Duc Thai Nguyen Norfolk, Virginia
Acknowledgements During the preparation of this book, I have received (directly and indirectly) help from many people. First, I would like to express my sincere gratitude to my colleagues at NASA Langley Research Center, Dr. Olaf O. Storaasli , Dr. Jaroslaw S. Sobieski, and Dr. Willie R. Watson, for their encouragement and support on the subject of this book during the past years. The close collaborative work with Professor Gene Hou and Dr. J. Qin, in particular , has a direct impact on the writing of several sections in this textbook . I am very grateful to Professors Pu Chen (China), S. D. Rajan (Arizona), B. D. Belegundu (Pennsylvania), 1. S. Arora (Iowa), Dr. Brad Maker (California), Dr. Esmond Ng (California), Dr. Ed. D' Azevedo (Tennessee), and Mr. Maurice Sancer (California) for their enthusiasm and support of several topics discussed in this book. My appreciation also goes to several of our current and former graduate students, such as Mrs. Shen Liu, Ms. N. Erbas, Mr. X. Guo, Dr. Yusong Hu, Mr. S. Tungkahotara, Mr. A.P. Honrao, and Dr. H. B. Runesha, who have worked with me for several years. Some of their research has been included in this book.
In addition, I would like to thank my colleagues at Old Dominion University (ODU) for their support, collaborative work, and friendship , among them, Professors Osman Akan, Chuh Mei, Hideaki Kaneko , Alex Pothen, Oktay Baysal , Bowen Loftin , Zia Razzaq, and Roland Mielke. The excellent computer facilities and consulting services provided by my ODU/OOCS colleagues (A. Tarafdar, Mike Sachon, Rusty Waterfield, Roland Harrison, and Tony D'Amato) over the past years are also deeply acknowledged. The successful publication and smooth production of this book are due to Miriam I. Tejeda and Sue Smith (ODU office support staff members) , and graduate students Mrs . Shen Liu, Ms. N. Erbas, Mr. S. Tungkahotara, and Mr. Emre Dilek. The timely support provided by Elaine Tham (editor), her colleagues, and staff members also gratefully acknowledged. Special thanks go to the following publishers for allowing us to reproduce certain material for discussion in our textbook: •
•
Natalie David (
[email protected]) for reproducing some materials from "Sparse Matrix Technology", by Sergio Pissanetzky (pages 238 - 239, 263 - 264, 270, 282) for discussion in Chapters 3 and 4 of our textbook (see Tables 3.2, 3.3, 3.8, and 4.2) . Michelle Johnson and Sabrina Paris (
[email protected]) for reproducing some materials from "Finite Element Procedures", by KJ. Bathe, 1st Edition, 1996 (pages 915 - 917, 924 - 927, 959) for discussion in Chapter 5 of our textbook (see examples on pages 293 - 297, 301 - 302; see sub-routine jacobiKJB and pages 344 - 348).
xV]
•
Adam H irschberg (AHirschberg@cambridge .org) for reprodu ci ng ma terials from "Numerical Recipes", by W , H. Press, ct.al. (pages 35 - 37, 366, 368, 374) for discussions in Chapter 5 of our textbook (see sub-routines LUBKSB , LUDC MP on pages 34 8 - 350; See table s 5.8, 5 .9, 5. 14).
Last but not least, I would like to thank my paren ts (Mr. Dae K. Ng uyen and Mrs . Thinh T. Thai ), my wife (Mrs. Hang N. Nguyen), and my so ns (Er ic N. D. Nguyen, and Don N. Nguy en) whose encouragement has heen ever present. Due T . Nguyen Nor folk, Vir ginia
Disclaimer of Warranty We make no warranties, expressed or implied, that the programs contained in this distribution are free of error, or that they will meet requirements for any particular application. They should not be relied on for solving a problem whose incorrect solution could result in injury to a person or loss of property. The author and publisher disclaim all liability for direct, indirect, or consequential damages resulting from use of the programs or other materials presented in this book.
1 A Review of Basic Finite Element Procedures 1.1 Introduction Most (if not all) physical phenomena can be expressed in some form of partial differential equations (PDE), with appropriated boundary and/or initial conditions. Since exact, analytical solutions for complicated physical phenomena are not possible, approximated numerical procedures (such as Finite Element Procedures), have been commonly used. The focus of this chapter is to briefly review the basic steps involved during the finite element analysis [1.1-1.l3]. This will facilitate several advanced numerical algorithms to be discussed in subsequent chapters.
1.2 Numerical Techniques for Solving Ordinary Differential Equations (ODE) To simplify the discussion, rather than using a PDE example, a simple ODE (structural engineering) problem will be analyzed and solved in the subsequent sections. Given the following ODE: 2y
EJd = rox(L-x) dx 2 2 with the following boundary conditions: y(@ x = 0) = 0 = y( @ x = L)
(l.l)
(1.2)
The above equations (1.1-1.2) represent a simply supported beam, subjected to a uniform load applied throughout the beam, as shown in Figure 1.1. While several numerical methods are available (such as Variational, Galerkin, Colloquation, Minimize Residual methods), the Galerkin method is selected here due to its generality and simplicity. To facilitate the derivation and discussion of the Galerkin method, the ODE given in Eq.(1.1) can be re-casted in the following general form (1.3) Ly=f Land fin Eq.(1.3) represent the "mathematical operator," and "forcing" function, respectively. Within the context of Eq.(l.l), the "mathematical operator" L, in this case, can be defined as: d2 L == E I - ( )
dx 2
(1.4)
2
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
~
A__
E=Young Modulus I=Moment of Inertia
I >
IE L
Figure 1.1 a Simply Supported Beam under Uniformly Applied Load Hence 2(y)
Ly =EI d and f == w x (L-x) dx 2 2
(1.5)
If we "pretend" the right-hand side "f" in Eq.(1.3) represents the "force," and the unknown function "y" represents the "beam deflection," then the virtual work can be computed as:
ow = Hf(f)*OY dv == Hf(L y)*oy dv v
(1.6)
v
In Eq.(1.6), oy represents the "virtual" displacement, which is consistent with (or satisfied by) the "geometric" boundary conditions (at the supports at joints A and B of Figure 1.1, for this example). In the Galerkin method, the exact solution y(x) will be replaced by the approximated solution y(x), which can be given as follows: N
y(x) =
Z>ii (x)
(1.7)
i=l
where a, are the unknown constant(s) and i(X) are selected functions such that all "geometric boundary conditions" (such as given in Eq. [1.2]) are satisfied. Substituting y(x) from Eq.(1.7) into Eq.(l.6), one obtains: Hf(f)OY dv;t Hf(Ly)oy dv v
(1.8)
v
However, we can adjust the values of a, (for y), such that Eq.(1.8) will be satisfied, hence
Due T. Nguyen
3
HJ(f)oy dv "" HJ(Ly) oy dv v
(1.9)
v
or (1.10)
HJ(Ly - f)oy dv = 0 v
Based upon the requirements placed on the virtual displacement the following selection: OY=G>i(X)
/Jy,
one may take (1.11)
Thus, Eq.(1.lO) becomes the "Galerkin" equations, and is given as:
HJ~ ~
dv=O
(1.12)
v Residual Weighting or error Function
Thus, Eq.( 1.12) states that the summation of the weighting residual is set to be zero. Substituting Eq.(1.7) into Eq.(1.12), one gets: N
JH[L(~>iG>i(X))-f]G>i dv=O v
(1.13)
i=1
Eq.(1.l3) will provide i=1,2, ... ,N equations, which can be solved simultaneously for obtaining a, unknowns. For the example provided in Figure 1.1, the "exact" solution y(x) can be easily obtained as: (1.14)
assuming a two-term approximated solution for y(x) is sought, then (from Eq. [1.7]): (1.15) or (1.16) or (1.17) where (1.18) Based on the given geometric boundary conditions, given by Eq.(1.2), the function G>I (x) can be chosen as:
4
Finite Element Methods: Parallel-Sparse Statics and Eigen-So1utions
(1.19) Substituting Eqs.(1.18 - 1.19) into Eq.(1.17), one has:
y = A I *sin( ~ ) + A 2 * x sin( ~ )
(1.20)
Substituting the given differential equation (1.1) into the approximated Galerkin Eq.(1.12), one obtains : L
roX(~-X)]*j (x)dx
f[Ery"
=0
(1.21)
x=o For i = 1, one obtains from Eq .(1.21): L
"rox(L-x) . nx ]*[,(x)=sm(-)]dx=O 2 L
J[Ery x=o
(1.22)
For i = 2 one obtains from Eq.(l.21): L
r.:"
J[Eq ~
-
an-(L - x)
2
]*[~2(X)
. 11X = xsm(-)]dx =0
(1.23)
L
Substituting Eq~(1.20) into Eqs.( 1.22 - 1.23), and performing the integrations using MATLAB, one obtains the following two equations: 4
[2E1Aj * re 5 + E1A2 * re 5 * L + 8oL 5
3
]
=0
(1.24)
5
[3E1AI * re + 3E1A2 * re * L + 2E1A 2 * re * L + 120Jl}] = 0 or, in the matrix notations: 5
(EI)*[21t 31t 5
5L
4
1t
31t
(1.25)
3L+21t 5L
]*{A,} _ {-8roL } A 2 - -12roL4
(1.26)
Using MATLAB, the solution of Eq.(1.26) can be given as: _ 4UJl} (-4) * (5)mL =- - =-'---'--'-'-4
AI
1!5 £1
(5)1!5 £1
-
5mL4
(~)Jr5 £1
-
5mL4
(1.27)
382.523 £1
4
(1.28) Thus, the approximated solution y(x) , from Eq.(l .20), becomes : 4
_() ( -5wL Y X = 382.523El
)*. L sm
(11X)
(1.29)
Due T. Nguyen
5
At x = L , the exact solution is given by Eq.(I.l4): 2
-5OJL4 y = 384£/
(1.30)
At x = L , the approximated solution is given by Eq.( 1.29): 2
_
- 5OJL4
Y = 382.523£/
(1.31)
Remarks (a) The selected function j (x ) are selected to satisfy all essential boundary conditions associated with a particular finite element only.
10
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
The unknown primary function (say, deflection function) f(x;) at any location within a finite element can be computed in terms of the element nodal "displacement" vector {r'} as: 0.60) In Eq.(1.60), n represents the number of "displacements" (or degree-offreedom=dof) per finite element, and N(xj) represents the known, selected shape function(s). For the most general 3-D problems, the shape functions [N(Xi)] are functions of XI> X2, and X3 (or X, y, and z). The left-hand side of Eq.(l.60) represents the three components of the displacement along the axis XI> X2, and X3. The strain displacement relationships can be obtained by taking the partial derivatives of displacement function Eq.(l .60), with respect to the independent variables Xi, as follows:
o
r
{e] = -[N(xj)] * {r } OXj
(1.61)
{s] = [B(xj)] * [r"]
(1.62)
or where
0
[B(xj)] == -[N(xj)] OXj
(1.63)
The internal virtual work can be equated with the external virtual work, therefore
[s £ T *0 dV = {£f'Y *{P,}
(1.64)
v In Eq.(1.64) , the superscript "T" represents the transpose of the virtual strain bE and virtual nodal displacement Sr', whereas a and p' represent the stress and nodal loads, respecti vely. The stress-strain relationship can be expressed as: {o] = [D]{£}
(1.65)
where in the above equation, [D] represents the material matrix. For a I-D structural problem, Eq.(l.65) reduces to the following simple Hooke's law scalar equation (1.66) where E represents the material Young Modulus. From Eq.(l.62), one obtains : {£}T = {r'}T[B]T
(1.67)
Hence (1.68)
Duc T. Nguyen
11
substituting Eqs.(l.65, 1.62, 1.68) into the virtual work equation (1.64), one obtains:
°
(1.69)
[BIT [DUBjdV' {(}- {P'I] =0
(1.70)
J{or') T [B) T *[D]{£ = B r'} dV -{or') T {p']
=
V
or
I&'fl' ,
[J
The virtual displacements {or') can be arbitrarily selected as long as they are consistent with (or satisfied by) the geometrical boundary constraints, hence in general {or')*O. Therefore, from Eq.(1.70), one requires: [k'] * {r'] - {p') =
to)
(1.71)
where the "element" local stiffness matrix [k'] in Eq.(l.71) is defined as: [k'] == J[B] T [D][B]dV
(1.72)
v Since the element local coordinate axis in general will NOT coincide with the system global coordinate axis, the following transformation need to be done (see Figure 1.3): yglobal
Xglobal
9
Figure 1.3 Local-Global Coordinate Transformation
12
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
, {x A} {x Acos(S) + YASin(S)} [COS(S) {r}= YA = YAcos(S)-xAsin(S) = -sin(S)
sin(S) ]{x A} cos(S) YA
(1.73)
or
,
{XA}
{r }= [AJ YA == [A]{r}
(1.74)
where "I
[11.] ==
[
cos(S) - sin(S)
Sin(S)] ; for 2-D problems cos(S)
(1.75)
Similarly, one has: {p'} = [A]{p}
(1.76)
Substituting Eqs.(l.74, 176) into Eq.(l.71), one has: [k'] *[A]{r} = [A]{p}
(1.77)
Pre-multiplying both sides of Eq.(1.77) by [A]T, one gets: [A]T[k'][A] * {r} = [A]T[A]{p}
(1.78)
Since [A]T[A]= [I], thus [AJT = [Ar l , hence Eq.(1.78) becomes: [A]T[k'][A] *{r} = {pI
(1.79)
[k]*{r}={p}
(1.80)
or where [k] = [A]T[k'][AJ == [k(c)] = element stiffness in global coordinate reference
(1.81)
The finite element stiffness equations, given by Eq.(1.80), can be assembled to form the following system stiffness equations: [K]*{R}={P} (1.82) where NEL [K] = L[k(C)] (1.83) c=1
and [k(C)] is defined in Eq.(1.81) {PI =
NEL {p(c)} ; and {p(C)} is the right-hand-side of Eq.(1.80)
L
c=1
{R} = system unknown displacement vector
Duc T. Nguyen
13
For structural engineering applications, the system matrix [K] is usually a sparse, symmetrical, and positive definite matrix (after imposing appropriated boundary conditions). At this stage, however [K] is still a singular matrix. After imposing the appropriated boundary conditions, [K] will be non-singular, and the unknown vector {R} in Eq.(1.82) can be solved. 1.6 Flowcharts for Dynamics Finite Element Analysis
The kinetic energy (= 112*mass*velocitl) can be computed as: K.E.
=~ J{f}T * If }* pdV
(1.84)
V
In Eq.(1.84) "pdV ," and
Ii} =: at represents the "mass" and "velocity,"
at
respectively. Substituting Eq.(1.60) into Eq.(1.84), one obtains: K.E. =..!..{r'}T J[N(xj)]T[N(xj)]PdV *{f'} 2 V The kinetic energy can also be expressed as: K.E. = ..!..{f'}T[m']{r'} 2
(1.85)
(1.86)
Comparing Eq.(1.85) with Eq.(1.86), the local element mass matrix [m'] can be identified as: [m']=: J[N(Xj)]T[N(xj)}pdV=:[m,(e)] (1.87) V
The global element mass matrix [m} can be obtained in a similar fashion as indicated in Eq.(1.81), hence (1.88) [m] = [A]T[m' (e)J[A] =: [m(e)} The system mass matrix can be assembled as: NEL
[M] = ~)m(e)}
(1.89)
e=1
where [m(e)] has already been defined in Eq.(1.88). The system dynamical equilibrium equations, therefore, can be given as: [M]{R} + [KJ{R} = {P(t)} (1.90) If a "proportional" damping matrix [C] is used, then [C]=ul[K]+u2[M] (1.91) where u. and U2 are constant coefficients, and Eq.(1.90) can be generalized to:
14
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
[M]{R} + [C]{R} + [K]{R} = {P(t)}
(1.92)
with the following initial conditions: @t=O,{R}={R(O)} and {R}={R(O)}
(1.93)
For undamped, free vibration, Eq.(l.92) will be simplified to: [M]{R} + [K]{R} = {OJ Let {R} = {y}sin( rot)
(1.94) (1.95)
where ro == natural frequency of the structure. Then {R} = {y}rocos(rot)
(1.96)
{R} = _{y}ro2 sin(rot) = -ro 2{R}
(1.97)
Substituting Eqs.(1.95, 1.97) into Eq.(1.94), one gets: -[M]{y}ro 2 +[K]{y} = {OJ
(1.98)
[K]{y} = ro2[M]{y} = A[M]{y}
(1.99)
or
Thus, Eq.(1.99) can be recognized as the Generalized Eigen-Value Problem. The eigen-values of Eq.(1.99) can be solved from: [K-AM]{y}={O} (1.100) In Eq.(1.100), A. and {y} represent the eigen-values and the corresponding eigenvectors, respectively.
1.7 Uncoupling the Dynamical Equilibrium Equations To facilitate the discussion, the following system stiffness and mass matrices are given (assuming proper boundary conditions are already included): 1] [K]=[!11 (1.101) [M] =
[~
?]
(1.102)
In order to have a "non-trivial" solution for Eq.(1.100), one requires that
"I
2 1, -1 I =0 DetK-/uVl =Det 1 --12A. 1-11.
I
The solution for Eq.(1.103) can be given as:
11.= 2+J2 2 Hence
(1.103)
Due T. Nguyen
15
(1.104) and
~
= 2+.fi
2 Substituting the I" eigen-value (=1.. 1) into Eq.(1.100), one obtains :
-,H 2-2J2H~ ?]}{;I:} {g}
([_2,
(1.105)
(1.106)
In Eq.(1.106), the superscripts of y represent the lSI eigen-vector (associated with the 1st eigen-value AI) while the subscripts of y represent the components of the l " eigen-vector. There are two unknowns in Eq.(1.106), namely y~1) and y~) however, there is only one linearly independent equation in (1.106). Hence, if we let
y~l) =1
(1.107)
then, one can solve for
y~) =.fi
(1.108)
The l SI eigen-vector cj>(I) (associated with the lSI eigen-value A.), therefore, is given as: cj>(I)={h-}
(1.109)
Similar procedures can be used to obtain the 2nd eigen-vector cj>(2) (associated with the 2"d eigen-value /..z), and can be obtained as: cj>(2)
={-h}
(1.110)
The eigen-vector cj>(I) , defined in Eq.(1.109), can be normalized with respect to the mass matrix [M], according to the following two steps: T
Step 1 Calculate cI = cj>(l) [M]cj>(I) = 4
(1.111)
Step 2 Compute the lSI normalized eigen-vector cj>~) as: (I) _ cj>(l) _{ 1/2 } cj>N .fi/2
F; -
(1.112)
Similarly, one obtains: (2) _{
cj>N -
1/2 }
-.fi/2
(1.113)
16
Finite Element Methods: Parallel-Sparse Static s and Eigen-Solutions
Thu s, the normalized eigen-matrix [«1>] can be assembled as:
I~J=~W~~) ]=l~ -~1
(1.114)
Now, let's define a new variable vector {A} as: {R} = []* {A}
(1.115)
Hence , Eq.(l .92) becomes (damping term is neglected): [M] * [] * {A} + [K]* [] * {A} = {P(t)}
(1.116)
Pre-multiplying both sides of Eq.(1.116) by []T , one obtains: [] T[M][«1>]{A} + []T[K][]{A} = []T{P(t)}
(1.117)
The above equation can be represented as: [M *]{A}+[K *]{A} = {p *(t)}
(1.118)
where [M *] == []T[M)[f(x)
(1.179f)
n
Let u == "u ~ 1J>~(x ) L..J J J j=1
(1.179g)
26
Finite Element Methods: Parallel -Sparse Statics and Eigen-Solution s
For the case n = 2 , <j)f (x) and <j)j (x) have already been identified as the shape functions [N(x)] shown in Eq.(1.I43), where i, j = 1,2. Substituting Eqs.(1.I 79f, 1.I79g) into Eq..( 1.17ge), one obtains:
0=
d JEA -(~ u~ r dx ~
xn
dtP ~
II
J]
J= 1
XA
II
)*-'-dx- ~ tPt( @ x ' ) *Q ' dx ~ J J ] =1
xn - JtPt * q(x )dx
(1.I 79h)
XA
It should be noted that the last two (boundary) terms in Eq.(1.17ge) have been replaced by the last (summati on) term in Eq.(1.I79h), so that an axially loaded finite element that has more than (or equal to) two nodes can be handled by Eq.(1.179h). Using the properties of the finite element shape (or interpolation) functions (see Eqs.[1.I43, 1.144]) , one obtains: n
n
L)f (@x j ) *Q j=LOij *Qj==Q f j=1
(1.I 79i)
j=1
Utilizing Eq.(1.I 79i), Eq.(1.I79h) can be expressed as:
o=
a aih e JEA -(L uj j) * dx ax ax
XB
n
XA
j=!
_'f'_i
Q~
XB
- J ? * q (x) dx
(1.179j)
XA
or
(1.I79k)
where i = 1, 2, ..., n (= number of dof per element)
and [k~. ] == IJ
d<j) ~ J)
d<j)e J(EA __ *__ dx dx ax
XB
element "stiffness" matrix
(1.1791)
== Jq(x ) * f dx - "Equivalent" nodal load vector
(1.I 79m)
i
-
XA
XB
XA
Due T. Nguyen
{Q?}
27
= "Internal" nodal load vector
(1.179n)
Equation (1.179k) can be further re-arranged as: (1.1790)
Remarks th
(1) Referring to Figure 1.5, a typical e finite element will have: • 2 equations (see Eq.[1.179k], assuming n = 2) • 4 unknowns (say, for the 2nd finite element), which
ui, ul,
Q~, and Q~ can be identified as (2) Thus, for the "entire" domain (which contains all 3 finite elements, as shown in Figure 1.5), one has: equations . •2 * 3 elements = 6 equations element • 12 unknowns, which can be identified as :
I QII and QI2"",U 3 3 Q33' Q34 3,U 4,
J Ul'U 2'
(3) The additional (6, in this example) equations can be obtained from: • System, geometrical boundary condition(s), such as:
=0
u\
• Displacement compatibility requirements at "common" nodes (between "adjacent" finite elements), such as: I
2
u2 =u2 2
3
U 3 =U 3
• Applied "nodal" loads, such as: I
2
2
3
Q2+Q2=O Q3 +Q3 = 0
Q~
= l) (see Figures 1.4 and 1.5)
1.9 Truss Finite Element Equations The formulation derived in Section 1.8 for the axially loaded rod element can be trivially expanded to analyze 2-D truss structures such as the one shown in Figure
28
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
1.6:
I
Figure 1.6 a Typical 2-D Truss Structure A typical truss member, such as member #{!] of Figure 1.6, is shown separately with its own local axis (x' and y') in Figure 1.7:
Yo
A
y'
x'
j=2
9
Figure 1.7 a Typical 2-D Truss Member with Its Nodal Displacements
Since a truss member can only carry axial force and have only "axial" displacements, such as UI and U3 in Figure 1.7, the "fictitious" local displacements U2 and U4 are indicated in the same figure. Thus, the local element stiffness matrix [k'] of the rod (see Eq.[1.148]) can be slightly modified to become the 4x4 local element stiffness matrix of a 2-D eth truss element.
[e(e)]
=
1 0 0 0 [ o 0
(AE) 0 L -1
(1.180)
Due T. Nguyen
29
The 4x4 global element stiffness matrix of a 2-D truss element can be computed from Eq.(1.81) as:
[k (e)] 4x4
I o-1 OJ
= [[A]
[O]]T 0 0 0 0 [[A] [0]]( AE) [0] [A] -1 0 1 0 [0] [A] L 000 0
r
(1.18])
The 2x2 submatrix [A] in the above equation has already been defined in Eq.(l.75) 1.10 Beam (or Frame) Finite Element Eqnations A typical beam element, its local/global coordinate axis, and its local displacements (or degree -of- freedom, dot) are shown in Figure 1.8. Axial dof is usually neglected and there are only 4 dof associated with a 2-D beam (or frame) element:
Yo x'
Figure 1.8 a Typical 2-D Beam Element without Axial dof
30
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
In the Euler-Bernoulli beam theory, it is assumed that a plane cross-section remains perpendicular to the beam axis even after deformation. The transverse deflection of the beam ro(x) is governed by the following 4 th order differential equation
forO~ x~
L
(1.182)
where f(x) is the transverse distributed loads acting on a beam and the material matrix [D)lxl is defined as: [D)lxl = EI (1.183) The transverse displacement field ro(x) within a 4 dof 2-D beam element can be given as:
(1.184)
Hence
(1.185)
The unknown constants a, through a, can be solved by invoking the following four geometric (or essential) boundary conditions: At x = 0, ro =ro) At x = 0,
(1.186)
ro, =dro\ dx x=Q
At x =L, At
x= 0,
=ro3 ro, =-drol
=8 2
(1.187) (1.188)
to
dx x=L
=8 4
(1.189)
Substituting Eqs.(1.186 - 1.189) into Eqs .(1.184 - 1.185), one gets:
WI} [ {
1,0,0,1 82 _ 0,1,0,0 2 3 w3 1, L, L , L 84 0,1,2L,3L 2
l{a
l
a2 } a3 a4
The above matrix equation can also be expressed in a compacted notation as:
(1.190)
Duc T. Nguyen
31
(1.191)
{U}4xl = [A]4x4 {a}4xl Hence
(1.192) Substituting Eq.(1.192) into Eq.(1.184), one obtains: ffi(x) = [1,x,x ,x3]lx4[A]4~4{U}4xl 2
(1.193)
The product of the first two terms of the right-hand side of Eq.(1.193) can be recognized as the beam element shape functions N(x), hence
«(x)
= [N(x)hx4 *{u}4x1
(1.194)
where the shape functions [N(x)] are given as:
1 0 0 0 1 0 [N(X»)lx4 =[1, x, x , x ] 1 L L2 [ o 1 2L 2
3
2
_{L -3Lx +2x [N(x)}3 L
3
2
3 '
x(L -2Lx+x 2 L
2
-x
)
(1.195)
2(-3L+2x)
'
L
3
2(-L+X)}
X '
L
2
(1.196)
The distributed load f(x)=fo KJin acting on the beam member can be converted into the equivalent joint loads by the following formula: L
{FeqUiv} = J(fo) * [N(x)f dx
(1.197)
o
or
10 *L 2
10 *L2 {FequiV}
=
12 10 *L 2 - 10 * L 2 12
(1.198)
1.11 Tetrahedral Finite Element Shape Functions The governing 3-D Poisson equation can be given as:
-~(CJ dro)_~(C2 dro)_~(C3 dro)=f inQ
dX dX
dy
dy dZ
dZ
(1.199)
32
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
with the following geometric boundary condition(s): 00= ~on
r1
and the natural boundary condition(s ):
dOl
dOl
dOl
c)-n x +c2 - n y +c3 - n z = qo on r 2 dX dy
(1.200)
dZ
where c, = Cj(x,y,z) and f = f(x,y,z) are given functions on the boundaries T, and respectively.
r 2,
The weak formulation can be derived by the familiar three-step procedures: Step 1 Setting the weighted residual of the given differential equation to be zero, thus
o= JW[-~(Cl dW)_~(C2 dW)_~(C3 n'
dx
ax
dY
dY
az
dW)_ f]dQ dZ
(1.201)
where dQ == dxdydz (1.202)
Step 2 Eq.(1.20l) can be integrated by parts once, to give:
dOl dOl dOl] W[-c) ax n -C 2 ay-n - C3 a;n J r" _J[-C) dOlax dW -C 2 aOl aw -C3 dOl dW + Wf}Q dX dy dy dZ dZ
0=
x
ne
z
y
(1.203)
.
Step 3 Let
(1.204)
Then, Eq.(1.203) can be re-written as:
(1.205)
The primary dependent function co can be assumed as:
(J) =
~
(J)jN ; (x , y , Z) == [N(x, y, Z)])>>I
*1:: (J)n
(1.206) nxl
Due T . Nguyen
33
In Eq.(l.206), n, (OJ, and Nj repre sent the number of dof per element , element nodal displacements , and element shape functions , respecti vely. For a 4-node tetrahedral element (see Figure 1.9) n = 4, the assumed field can be given as: (1.207 ) or
m( x , y, z)
~
[I, .r, y,
ZJ*{;~}
(1.208)
For an 8-node brick element (see Figure 1.9), n = 8, the assumed field can be given as:
y
x
z
(a) Tetrahedron Element
x
z
(b) Brick Element
Figure 1.9 Three-Dimensional Solid Elements The shape functions for the 4-node tetrahedral element can be obtained by the same familiar procedures. The geometric boundary conditions associated with an e1h element are given as:
(1.210)
Substituting Eq.(1.21O) into Eq.(1.208), one obtains :
34
Finite Element Methods: Parallel -Sparse Statics and Eigen-Solutions
(1.211)
In a more compacted notation, Eq.(I.2I 1) can be expressed as:
iiJ = [A]4 x4 {a} 4xl
(1.212)
From Eq.(1.212), one gets:
{a}
= [Ar 1 ro
(1.213)
Substituting Eq.(I.213) into Eq.(1.208), one obtains:
m(x, y, z)
~
[1, x, y, zlb'
*[AJ;;,
*g}
(1.214)
or
m(x , y, zH N (x , y, Z)]b.
*g~}
(1.215)
where the shape function s can be identified as: [N (x , y, z)h x4 =[ I, x, y,z] * [A]- l Let W = Nj(x, y, z), for i = 1,2,3,4 (tetrahedral)
(1.216) (1.217)
and substituting Eq.(1. 215) into Eq.(1.205), one obtains the following (finite) element equations:
(1.218) or
Due T. Nguyen
35
(1.219)
or
~~» ) * {ro~c)} [ k IJ 4 x4 J 4x l where (e)
_
[k .. ]=
(Ie
I)
{F/
J[
e ) }4xl
= {F(e)} 1
(1.220)
dNi dN dNi dN dNi} c 1dN - - - - + cz - - - - + C3 - - - - n j
dx
=
j
dX
j
dy dy
dz
dZ
IN;!dQ+ fNiqn dr ne
(1.221)
re
The first term on the right side of Eq.(1.22 l) repre sents the equi valent joint load s due to the distributed "body" force f, while the second term represe nts the equivalent joint loads due to the distributed "boundary" force q.,
1.12 Finite Element Weak Formulations for General 2-D Field Equations The two-dimensional time-depende nt field equation can be assumed in the following form:
a2u
a2u
a2u
C\ - 2 + C2 - 2 + C3 - - +
ax .
au ax
au ay
2
C4 - + C S -+C 6u + c 7u+ CS
ay axay au au = C -2 a2 u- + CIO -au +c llc tg(U) - +C I2ctg (X) 9 ax ax at at
(1.222) where c j,i =1-12 are constants; u =u (x ,y,t) It should be noted that the term s associated with constants for handling other special appli cations [1.14].
Cll
and
CIZ
are included
The weighted residual equati on can be established by the familiar procedure
(1.223)
36
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
The following relationships can be established through integrati on by parts:
a2
Hw~xdy
cl
ax
Q e
= Cl
a
au
II w-(-)dxdy ax ax aw au II axa ( wauax-J---]dxdy ax ax
Q e
=C1
(1.224)
[-
Qe
au au = C1 r 'j w-nxds - CI IIaw -.::..::....clxdy;
re
ax
Q e
ax ax
a2u II ay Q e a au = C2 w-(-)dxdy IIe ay ay Q aw au =C2 II [a- ( wau-J- --]dxdy ay ay ay ay Q e aw au J w-n au yds - C2 II -~xdy; = C2 'j r e ay Q e ay ay C2
w~xdy
(1.225)
a2 u dxdy n' axay a (-)dxdy+au C 3 Ifwa (-)dxdy au = -C 3 Ifw2 n' ax dy 2 n' dy ax 3 I·J[~ a ( wau) ---]dxdy+dw au C 3 I·J[~ a ( wau J---]dxdy aw au =CC3
Hw
2~~
au
dy
~dy
3,(
au ax
2~dy 3
~
IJ aw au
dy~ 3
IJdw au
C C C =C3,( - 'jw-nxds+'jw-n yds---~dy-- --~dy; 2 r ' dy 2 r' 2 n' dy 2 n' dy
ax
ax
(1.226) Substituting Eqs.(l .224 - 1.226) into Eq.(1.223), one gets:
Due T. Nguyen
37
H(-c Q'
aw au _c aw ~ _!:..l. aw ~ _!:..l. aw au _c wau _c wau ax ax ay ay 2 ax ay 2 ay ax ax ay 2 2 au au + c 6wu +C 7 WU +c at at au au + C wctg (u)-+ C wctg (x) -)dxdy ax ax I
2
4
g w - C9 W -
II
- 2
5
- C IQw -
12
(au
au)
J C3 +'jw[n c,-+ -x r' 2
ax
ay
+11 ,
(au c
)
ay
C3
au) ]ds=O ax
2-+---
2
(1.227) Let (1.228)
Then Eq.(1.227) becomes:
H(-e n'
aw au -e aw au _~ aw au _~ aw au -e w au J ax ax 2 ay ay 2 ax ay 2 ay ax 4 ax 2 au 2 au au - e 5 w - + e 6 wu + e 7 wu + e 8 w - e 9 w - - 2 - - e 10 w ay at at au au,.( + wetg(u)-+c wctg(x)-)dxdy + '1 wq ids = 0 ax ax r' ell
J2
(1.229) The dependent variable field u(x,y,t) is assumed to be in the following form: n
u(x,y,t)i o 101 = Ay,~ Y~ =-1 L 3
3
3 i=!
111 =
Yi
0.250)
3 i=J
Z), ~(± XiYi +9XY),I ZO= ~(± x; + 9X l oz = ~(± y; + 9 YZ) 12 i=! 12 i=1 12 i=!
(1.251)
From Eq.(1.24 7), one obtains:
S~I IJ
= _1_ (a;.A.. + A..f.l.. + y.f.l. .y~) S~2 = _1_ (a;.y . + A.·y · + y.y.y~) 4A I....J ....,....J ,....J ' IJ 4A I J ...., J 1 J
x
x
S~O = _1_[a;.a; . + (a;.A. . + a;.f.l..)x + (a;.y . + a;.y. )y~]+_1_[120f.l..f.l. · 1J 4A 1 J I....J J....I 1)) , 4A ....1....) 2
(1.253)
(1.254)
+ 111 (YiPj + YjPi) + I02YiYj] Using the special cases (triangular element local coordinates; see Fig. 1.10), one has:
42
[s"
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
pr"
&l ~22]~~[&
0
2a
[sOll~I>[=: 6 -I
0 I 2b 0 -1
0 0
~Il [sI21~-'-[& I 2 0
:I &J [s021~"[& =1-I [soo l~ ab[iI 0
ft =- HC8'11idxdy = -{;8 n
n
6 0
e
a:
24
I 2 I
!I T ]
(1.255)
0
i]
{I I IY
(1.256)
(1.257)
Similarly, using rectangular element (local coordinates), one has:
I] [Sll ]=~ [2 -2 -I I -I, -I I -2
6a
I
2
2 - 2 -I -2 2
-I 2 -2 -I I 6b -I -2 2 -2 -I I 2
[I-I -I1-II -I]II , [S Ol ]=!:- [-2-I I 1I -I] -I
~12 ]=~ -I -I I 4
[S22
I [ 2 ]=~ I
I
I -I -I
[-2 -I 12]
12
2 -2 2
2 -2 -I I 2 -2
[4
2 [S02]=!:.. -I -2 2 I [soo]=ab 2 4 12 -I - 2 2 I ' 36 I 2 2 I - 2 -I I 2
f{
=-
Hcg"'idxdy = -Cg ~ {I I
n
I 2 4 2
i]
I If
-2]
(1.258)
(1.259)
(1.260)
(1.261)
e
The following cases are considered for the purposes of comparing the above derived formulas with [l.l]: Case 1 Let's define (1.262)
Then, Eq.(1.222) will be simplified to J. N. Reddy's Eq.(8.l) [1.1] . Substituting Eq.(1.262) into Eqs.(l.234, 1.237), one obtains:
Due T. Nguyen
43
(1.263)
fr =- HCS"'idxdy = Hf"'idxdy Qe
(1.264)
Qe
Again, Eqs.(1.263 -1.264) are the same as J. N. Reddy's Eq.(8.14b) [l.l].
Case 2 Let's define cl =-alJ,c2 =-a22,c3 =c4 =cs =c6 =cll =c12 =0,
0
3
•
);
L/3
4
• 2U3
U4
>
il
);
L
~ 1.12 Evaluate the following integral: 4
I I} = (x 2 - 2x+-2e -3x )dx I x
J
(a) by using a 2 point Gauss Quadrature formula (b) by using a 3 point Gauss Quadrature formula
1.13 Re-do problem 1.12 for the following integral: 4
4 J J(X2y - 2 x y 2+6x y-8 )dydx 2
1 =
x=1 y= 1
)
x
2 Simple MPI I FORTRAN Applications 2.1 Introduction The numerical algorithms discussed throughout this textbook can be implemented by using Message Passing Interface (MPI) either in FORTRAN or C++ language. MPI/FORTRAN is essentially the same as the "regular" FORTRAN 77 and/or FORTRAN 90, with some additional, "special FORTRAN" statements for parallel computation, sending (or broadcasting), receiving and merging messages among different processors. Simple and most basic needs for these "special" FORTRAN statements can be explained and illustrated through two simple examples, which will be described in subsequent sections. 2.2 Computing Value of 7tby Integration The numerical value of function:
1t
("'3.1416) can be obtained by integrating the following 4
(2.1)
f(x)=-- , for x =[0,1] l+x 2 Since
Ja + 1bx 2.,[;ili dx =_I_tan-1[x.,[;ili) a hence 1
-l+x4 J o
2
dX= 4 [tan-I (x)
1=
1t
Integrating the function given in Eq.(2.1) can be approximated by computing the area under the wave f(x), as illustrated in Figure 2.1.
In Figure 2.1, assuming the domain of interests, x = 0 ~ 1, is divided into n = 8 segments. For example, segment 1 will correspond to x = 0 and 2/16, segment 4 corresponds to x = 6/16 and 8/16, etc. Thus, the integral size h = (1-0)/8 = 1/8. It is further assumed that the number of processors (= numprocs) to be used for parallel computation is 4 (= processors Po, Ph pz. and P3) . The values of "myid" in Table 2.1 (see loop 20) are given by 0, 1,2, and 3, respectively .
64
Finite Element Meth ods: Parallel-Sparse Statics and Eigen-Solutions
f(x) h .--..
//-
/------~
l i 1 - 1 ) i a d d 2 o i add+ c o n s t +l i 1 - 2) i a d d 3 " i a d d 2 +c o n s t + l i 1 - 3 ) c+ +++ + + ++ + + +++ + + + + +++ ++++++++ ++ + + + ++++ + ++ + +++ + + ++ ++ +++ ++ ++
if
(xx . e q . O. OdO . a n d. xx2 . e q . O. Od O . a n d. x x 3 . e q . O.OdO .and. x x 4 .eq. O. OdDI g o to 14 c · + + + + + + + + + + + + + + + + + + + + + ++ + + + + + ++ + + + + + + + + + + + + + + + + + + + + + + + + + +
d o 2 i o i s tart .iend x ( j u ( i ) ) oX (ju ( i ) ) -u n (i I ' xx S l i u (n +l ) ,ju(nc o e f 2 ) , u n (ncoef 2 ) .di(n): Struc t u r e o f t he f actor i z e d matrix wh i c h i s t he ou t p u t o f t h e nu me r i c a l fa c t o r iz ation b en) ri g h t - h a nd sid e v e c t o r ou t p u t x (n) v ect or of unkn owns (d i s p l a c e me n t vec t or)
f o r wa r d so l u t ion p h a s e NM=N-l DO 1 0 I =l, N 1 0 X ( I) =B (I) DO 4 0 K=l,NM I UA =IU(K ) IU B=IU(K+ l) - l XX=X(K ) DO 20 I= IU A, I UB 2 0 X(JU(I) =X(JU ( I) ) -UN(I) *XX
Due T. Nguyen
c
c
c
153
3 0 X(K)= XX'Dl (K) 40 CONTI NUE X(N) =X (N ) ' DI (N) write(6, ') 'f o r wa r d sol = ' ,( x ( i ) , i =1 , 4 ) ,x (n - 2 ) , x (n - l ) . x tn) wr i teI6 , ' ) ' f o rw a r d s o l = ' , (x (il , i =l, n ) back wa r d s o l u t i o n pha se K=NM 5 0 I UA=IU(K ) IUB=I U(K +l) -l XX =X (K ) DO 6 0 I= I UA, IU B 6 0 XX=XX- UN ( I) ' X(JU ( I » X(K) =XX 7 0 K=K- l I F (K .GT . O)GO TO 50 wri t e( 6 ,*) ' b a c kwa r d s ol = " (x ( i) , i =1 , 4 ) , x (n - 2 ) . x t n -L ) . x t n) wr it e(6 , '1 'ba ckwa r d s o l = ' ,(x (i) , i=l ,n l r et ur n e nd
c %%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% s u b r o u t i n e pie r r o t i me r eal ta r (2 1 rea l *8 time
c c c c c c c c c
(t i me)
p u r pos e : Th is r o u t i ne r e tu r n s t h e u s e r + s y s t e m executi on t i me
Th e a rgume n t t a r re tur n s u s er time in the f i r s t e leme n t a nd sys t e m t ime i n t h e s eco nd e l e me n t . Th e fun c ti o n v a lue is the s um o f u s er a nd sys tem ti me . Thi s value a ppr ox i ma t e s the prog r am 's e lapsed t i me o n a q u i e t sys tem. Unc ommen t
f o r y ou r c or responding p la t f o r m
c
c c c c
Note: On t h e SGI t h e r e s ol u ti on o f etime is
11HZ
Out pu t time : u s e r+ s y t em executime time
c c
SUN - So l a r i s time=e t im e(ta r)
c c c
HP - HPUX t i me =e t i me _ ( t a r ) t i me =e t im e _ ( t a r )
c c
COMPAQ - a lpha t im e =e t i me (t a rl
c
CRAY
c
t im e= t s e c n d ( 1
c
IB M t ime= O. Ol ' mcl o c k ( )
c c c
! f 90 ! f7 7
SGI o r ig i n t im e =etime(ta r ) r et ur n e nd
3.9 Alternative Approach for Handling an Indefinite Matrix [3.5) A system of sparse, symmetrical, INDEFINITE simultaneous linear equations have arisen naturally in several important engineering and science applications. Tremendous progress has been made in the past years for efficie nt large-scale
154
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
solutions of sparse, symmetrical, definite equations. However , for a sparse indefinite system of equations, only a few efficient, robust algorithms , and software are available (especially the FORTRAN versions in the public domain) . These existing indefinite sparse solvers have been discussed in recent papers [1.9, 3.2, 3.4 - 3.7]. Major difficulties involved in developing efficient sparse indefinite solvers include the need for pivoting (or 2x2 pivoting) [3.8], criteria for when and how to switch the row(s), effective strategies to predict and minimize the nonzero fill-in terms, etc. In this work, an alternative approach is proposed for solving a system of sparse, symmetrical , indefinite equations . The key idea here is to first transform the original indefinite system into a new (modified) system of symmetrical, "definite" equations. Well-documented sparse definite solvers [1.9, 3.9 - 3.10] can be conveniently used to obtain the "intermediate solution" (in the "modified" system). This "intermediate" solution is then transformed back into the "original" space to obtain the "original" unknown vector. To validate the formulas developed in our paper and evaluate the numerical performance of our proposed alternative approach, several NASA indefinite systems of equations have been solved (ranging from 51 to 15,637 indefinite equations) on inexpensive workstations. Our preliminary numerical results have indicated that this alterative approach may offer potential benefits in terms of accuracy, reducing incore memory requirements and even improving the computational speed over the traditional approach when the alternative approach is implemented in a parallel computer environment.
In this section, consider systems of indefinite equations in the form as shown in Eq.(3.99):
[A]x= J
(3.99)
where (3.100)
In Eq.(3.100), the symmetrically indefinite matrix [A] has the dimension nxn, and [K], [a], and (0) are sub-matrices. To simplify the discussion, it is assumed (for now) that the lower, right sub-matrix [0] has the dimension 1x1. Thus, matrix [A) has a zero on its (last) diagonal. Sub-matrix [K], shown in Eq.(3.100), is also symmetrical.
The key idea here is to transform Eq.(3.99) into a new system, such as:
Due T. Nguyen
155
[A~ * = f where the new coefficient matrix
(3.101)
lAJcan be computed as: (3.102)
Matrix
[AA), shown in Eq.(3 .102), should be selected
a.)
[AA]
with the following criteria:
should be sparse, symmetrical, and simple
b.) The resulting new matrix [A] will have better properties (such as positive definite) as compared to the original coefficient matrix [AJ
Thus, one selects matrix
[AA] as:
o
0
0 0
o
o
0 (3.103)
o
0 1
Eq.(3.103) can also be expressed as: (3.104) where
o d=
o o
(3.105)
1 Using Eq.(3.l 02), Eq.(3.99) can be re-written as: (3.106)
156
Finite Element Methods : Parallel-Sparse Statics and Eigen-So1utions
Substituting Eq.(3.104) into Eq.(3.106), one obtains:
1-
T
I- -
LA -did j JX = f
Pre-multiplying both sides of Eq.(3.107) by
(3.107)
["All, one has (3.108)
In Eq.(3.108), [I] is an nxn identity matrix, and x* == [At
l
x' is given as: *f
(3.109)
Eq.(3.108) can also be expressed as: lI-pjd; ~ =x*
(3.110)
r-H Pi == LAJ *d j
(3.111)
where
or (3.112) From Eq.(3.110), one obtains: (3.113) Pre-multiplying Eq.(3.113) by
di , one gets: - * = dTdT dTdT i x i x - i Pi i x
(3.114)
Since d;x * and d;x are scalar quantities , hence Eq.(3.114) can be re-written as: d[x*=(l-d[pj)d[x
(3.115)
or (3.116) From Eq.(3.113), one obtains: (3.117) Substituting Eq.(3.116) into Eq.(3.117), one has: d!x * • x =x +p _* _ :-1 __ 1 T l-d j Pi
(3.118)
Duc T. Nguyen
157
Remarks on Eq.(3.118)
lAJ
Both matrices [AJ and are assumed to be non-singular. Then, from Eqs.(3.107, 3.106, 3.102), one obtains the following relationship:
[1]- [AJI djd[ = product of two non-singular matrices
[XJ1and [A]
[I]-pjd[ = non-singular
Thus, in a more general case, the denominator of Eq.(3.ll8) will also be NONSINGULAR. The entire alternative formulation can be summarized in a convenient step-by-step procedure:
Step 0: Use Eq.(3.105) to form
d
j •
Then matrices [M] and and (3.102), respectively.
lAJ
can be computed according to Eqs.(3.104)
-* Step I: Use Eq.(3.101) to solve for x.
Step 2: Use Eq.(3.112) to compute
Pi.
Step 3: Use Eq.(3.118) to compute
x.
Generalized Alternative Formulation for Indefinite Systems
The alternative formulation presented in the previous section can now be generalized for cases where the original coefficient matrix [AJ has multiple zero values for its diagonal terms. In this case, the sub-matrix [6.A] will have the following form:
158
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
0 0 0 0 0 0 0 0 0 0
[M]= 0 0 0 0 0
(3.119)
0 0 0 1 0 ~ilh row 0 0 0 0 I ~ /h row Eq.(3.l19) can be expressed as:
[~A] = [~A d+ [M J=
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 0
+
0 0 0 0 0
(3.120)
0 0 0 0 0 0 0 0 0 1
or m
[M]= L[M j ]
(3.121)
i=1
In Eq.(3.121), m (ccn) represents the total number of zero diagonal terms of the original coefficient matrix [A]. Furthermore, Eq.(3.120) can be represented as:
(3.122) where
o o
0 0
[D]= 0 0
(3.123)
1 0
o
1
Following exactly the same derivations given in the previous section, the "generalized" version of Eqs.(3.112) and (3.118) can be given as: (3.124)
(3.125)
Remarks
Duc T. Nguyen
(a) If
159
lAJ is a symmetrical matrix (which it isl), then [At is also symmetrical. l
One starts with the following identity:
(3.126) Transposing both sides of Eq.(3.126), one obtains:
(3.127) Since both matrices
[A] and [I] are symmetrical, Eq.(3.127) becomes: (3.128)
or (3.129)
Post-multiplying both sides of Eq.(3.129) by
lA -I 1. one has: (3.130)
Thus,
[A -I} is also a symmetrical matrix.
(b) Matrix product [D]T[P] is also symmetrical.
From Eq.(3.124), one has:
[Dr [P] = [Dr [A-1JD]
(3.131)
Transposing both sides ofEq.(3.131), one obtains:
(3.132) Utilizing Eq.(3.130), Eq.(3.132) becomes:
(3.133) Comparing Eq.(3.131) and Eq.(3.133), one concludes:
160
Finite Element Methods: Parallel-Sparse Static s and Eigen-Solutions
(3.134) Thu s, the product of matrices DTp is also symmetrical. (c) The order of computations of Eq .(3.125) should be done as follows:
Ist Step: Compute
v= [DFx*
2 nd Step : Let
[Z] == Imx m -
3rd Step: Let
[Z]-l v== y
or
(3.135)
DT P
(3.136) (3.137)
[Z]y=v
(3.138)
The system of equations, shown in Eq.(3.138), in general is dense (but still is symmetrical) and can be solved for the unknown vector y. 4 th Step: d)
.x = x* +[Ply
(3.139)
Out-of core memory can be used to store matrix [Pl . Since the matrix [P], in general, could be large (especially true when m is large) , thus, a block of L columns (where L«m«n) for matrix [P] could be solved, and stored in the out-of-core fashion from Eq.(3.124). The specific value of L can be either specified by the user or can be automatically calculated by the computer program (based on the knowledge of available incore memory). Later on, a block of L columns can be retrieved into the core memory for the computation of in Eq .(3.125).
x
e)
Overhead computational costs for this alternative formulation is essentially occurred in the forward and backward solution phase to solve for matrix [Pl. The number of right-hand-side columns of matrix [D) is m. In the parallel computer environments, the overhead costs can be reduced to a "single" forward and backward solution since each processor will be assigned to solve for one column of the matrix [D).
f)
The computational (overhead) cost for vector y (see Eq.[3.138]) is insignificant since the dimension of matrix [Z] is small, and the righthand-side ofEq.(3.138) is a "single" vector.
g)
In practice, the value of max . Ai; (for i = 1,2,..., n) should be used in Eq .(3.119), instead of the value 1. Furthermore, the alternative formulation can be made even more stable by using Gerschgorin's theorem to determine the precise (diagonal) locations and values to be used for diagonal terms of matrix [M] in Eq.(3.119). Let Z, denote the
Duc T. Nguyen
161
circle in the complex plane with center ajj (= diagonal terms of matrix [A] whose eigen-values are sought) and radius rio Thus, the eigen-values of [AJ will fall into those circles : (3.140) where n
rj = Ilajjl forI=I,2,...,n
(3.141)
j=l ;j.. i
Hence (3.142)
From Eq.(3.142), one can estimate the number of NEGATIVE and/or POSITIVE eigen-values of matrix [AJ. For example, if ajj - rj > 0, then the eigen-values associated with the circle Z, is must be positive. Adding a positive number () to the diagonal term of [AJ will shift the value of the eigen-value associated with the circle Z, For example, adding () to make (3.]43) will ensure that the eigen-value associated with the circle Z, is positive. From Eq.(3.l43), one may add (3.144) or, to be even safer ()j = rj - ajj
>E
where
E
is a small positive value
(3.145)
to the diagonal term ajj so that all eigen-values will be positive (and therefore, the new matrix
IAI will be positive definite).
A simple example is given in the following paragraphs to clarify the above discussion. The matrix [AJ is given as:
(3.146)
From the data shown in Eq.(3.146), one computes :
162
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
all =4;fl =lando l =fl-all =-3} a22 =0;f2 =2and0 2 =f2 -a22 =2 a33 = -4;f3 = 2and 03 = f3 - a33 =
(3.147)
6
Let E =1, it is then suggested to add positive values 2 = 2, and 3 = 6 to the second and third diagonal terms of[A]. The new matrix
IAI is therefore defined as:
(3.148)
The three eigen-values associated with matrices [A] and
IAI
are AA = {-4.2146, -
0.0556,4.2702} and A. A = {4.618, 2.382, 1.000}, respectively. h) Major advantages of the generalized alternative formulation are • Pivoting strategies are NOT required, hence the algorithm should be more robust and better solution accuracy can be expected. • Incore memory requirements can be reduced and predicted before entering the numerical factorization phase. • Any positive definite sparse solvers can be integrated into this alternative formulation. i)
In actual computer coding, there is no need to "push" all zero diagonal terms of [A] to the bottom right of [A]. Furthermore, the sub-matrix [0], shown in Eq.(3.100), does NOT have to be completely zero. In other words, the off-diagonal terms of this sub-matrix [0] mayor may not be zero (only the diagonal terms of sub-matrix [0] are zero).
Numerical Applications
Based upon the proposed alternative formulation presented in previous sections, several benchmark indefinite system of equations (obtained from NASA Langley
Duc T. Nguyen
163
Research Center) have been used to validate the proposed algorithms. The sizes (= Neq = Number of equations) and the original number of non-zero, off-diagonal coefficients of matrix [A) (= Ncoff) are given in Table 3.12. In the partitioned form, Eq.(3.99) can also be expressed as (please refer to Eq.3.100):
(3.149)
For
structural mechanic
applications, the vector
x
u
may represent
the
x
displacements, whereas the vector A may represent the Lagrange multipliers associated with the interfaced problems. Solution accuracy of the proposed algorithms can be established by comparing the following quantities with Boeing's sparse indefinite equation solver:
1. Maximum absolute displacement (of
xu' shown in Eq.[3.149))
2. Summation of absolute displacements (of
3. Relative error norm (ReI Err =
xu' shown in Eq.[3.149))
IIAX-fll Ilfli ' shown in Eq.[3.99))
The above quantities are also included in Table 3.12. It should be emphasized that CPU time comparisons are NOT yet included in this study, due to the following reasons: (a) Boeing's sparse indefinite solver timing has been implemented earlier on the Cray-YMP supercomputer. However, the author' FORTRAN code has been recently tested on an Old Dominion University (ODU) Sun (= Norfolk) workstation since the author currently has no access to the CrayYMP nor Boeing's source code. (b) The re-ordering algorithms, such as Modified Minimum Degree (MMD) or Nested Disection (ND), have NOT yet been integrated into the current version of the author' FORTRAN code. (c) Parallel processing for J[p] = [D] = multiple RHS has not been done.
lA
Finite Element Methods: Parallel-Sparse Statics and Eige n-Solutions
164
Table 3.12 Comp arison of ODU and Boeing Indefinite Sparse Solvers
Neq
Neoff
U iI
IIXUil
Maxlx
2.265 *10.2
2.000*10.3
ReI Err
Time
(ODUNorfolk)
I
5 I(Boeing)
2 18
2
(2.265 *1024 7(Boei ng)
1440 (Boeing)
2009
22137
76111
286044
)
(7.0*10-
)
10
N/A
0.1525
2.63 *10-
0.1sec
(3.16)
(0.15 25)
(4.03*10-10)
N/A
29 .68
0.20289
4.27*10. 11
8.7sec
(0.20289)
(3.26* 10. 10)
N/A
113.7 1 (113 .71)
15367(Boeing)
( 1.999* 10.
O.Osee
14
3.16
(29. 68) 7767(Boeing)
)
3
4.68*10.6
512.35 (5 12.35)
0.1610576 (0.1610576)
5.31*10.
8
(6 .00*10.
42.7sec
8
)
10
N/A
0.2056 96
9.22*1 0-
5400sec
(0.205696)
(4.38 *10-11)
N/A
Conclusions
Alternati ve formulations and algorithms for solving sparse system of equations have been developed. The proposed numerical algorithms have been implemented and validated through several benchmark NASA applications. Preliminary results have indicated that the prop osed alternative algorithms are quite robust and are in excellent agreement with Boeing' s commercial sparse indefinite solver. Detailed analysis of the proposed sparse indefinite algorithms have suggested that: (a) The proposed algorithms are quite robust and accurate. (b) The additional (overhead) costs for the proposed algorithms mainly occur in the forward and backward solution phases (of the associated positive definite system). These overhead costs can be easily and drastically reduced by performing the forward and backward solution phases (of multiple-right-handside vectors) in a parallel computer environment. (c) In the proposed formul ation, one only deals with "po sitive-definite " sparse systems. Thus , complex and expensive pivoting strategies are NOT required. As a consequence of these desired features, several importa nt advantages can be realized, such as: • Incore memory requirements can be easily and efficiently predicted (before entering the sparse numerical factorization phase). • The amount of non-zero "fill-in" (and hence, the number of floatin g operations) can be reduced.
Due T. Nguyen
•
165
Any efficient sparse "positive definite" solvers can be conveniently integrated into the proposed formulations.
Efforts are underway to incorporate various reordering algorithms (such as MMD, ND, etc.) into the proposed algorithms and implement the entire procedure in the MPI parallel computer environments. Additional results will be reported in the near future. 3.10 Unsymmetrical Matrix Equation Solver Let's consider the following system of unsymmetrical linear equations: Ax=b
(3.150)
where the coefficient matrix A is unsymmetrical and the vectors x and b represent the unknown vector (nodal displacement) and the right-hand side (known nodal load) vector, respectively. In this section, a solver for unsymmetrical matrices, where the upper-and lower-triangular portions of the matrix are symmetrical in locations but unsymmetrical in values (see Figure 3.6), will be developed.
166
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
I'\. I
~
0
15
0
5
t
8
flo
5
~
5
I
~
7
~9
4
9
4
90
4
5
~
too
107
112
118
l2I 22
124
129
134
139
t45
119, 146 147 148
150
155
160
165
!71
146 "172 173
175
80
185
190
196
721'\. 197
199
04
09
14
7
'\2 2 ,2 2
1'\ I t ' \ 119
10
7 66
4 t2t 147
8
5 122 148 173 197 ,
7
27 28
243
21'\ 244
49 50
65
~,66 66 '\. 87 871'\.. 07
15
20
21 22
70 71
86
90 91
306
09 10
25
0 7 , 26 27 28
43
26'\. 344 ~5
I3w
27 49 70 90 09 27 ~" 28 50 7]
9]
76
61
to 28 45 61 "
77
I'\.
,
92
fw6 r-,
91
97 98
flO5
]0
19
-,
0
83 84
31
,
]I
18
22 23
30
33 34
fwl
fw2 443 144
"
~Eq.20
56
52 53
fo6O
161
ft6s
~Eq.23
75
--?Eq.24
fu;9 5
-->Eq.19
76
81 82
" ,
86
87
90 9t
93 94 95
96 I
I 90 118 145 !71 196 20 43 65 861306 25 43~6O 76
-tEq.31
Figure 3.6 Detailed Storage Scheme for an Unsymmetrical Matrix In order to take advantage of the algorithms discussed earlier in Sections 3.4 - 3.8 for the solution of symmetrical matrices, exploit the vector capability provided by supercomputers, take advantage of the cache provided by many workstations, and minimize the data movements into fast memory, it is necessary to arrange the data appropriately. A mixed row-wise and column-wise storage scheme is used. This storage scheme offers the advantage of applying the symbolic factorization and the super node evaluation only on one portion of the matrix, instead of the entire matrix. Compared to the symmetrical case, the re-ordering (fill-in minimization), the numerical factorization, the forwardlbackward substitution, and the matrix-vector multiplication sub-routines are different since the matrix is unsymmetrical in value.
Duc T. Nguyen
167
Sparse Storage of the Unsymmetrical Matrix
The unsymmetrical matrix A is stored in a mixed row-oriented and column-oriented fashion. The upper portion of the matrix is stored in a sparse, row-wise NASA format as has been explained in [3.11]. The lower portion of the matrix is stored in a sparse column-wise format. Since a column-wise representation of a matrix is a rowwise representation of its transpose, and the matrix is symmetrical in locations, the arrays IA (neq + 1), JA (ncoef), which are used to determine the nonzero locations of [A], will be the same for both the upper and lower portions. AN (ncoef) will contain the coefficients of the upper portion of the matrix and a new array, AN2 (ncoef), is introduced to store the coefficient values of the lower portion of the matrix. The diagonal values will be stored in the real array AD (neq). This storage scheme allows the use of the loop unrolling technique, described in [1.9], during the factorization for both the upper-and lower-triangular portions of the matrix. Figure 3.7 shows how the coefficient matrix A is stored.
••
••
••
#
••
#
............ .......
~~ ..~.
Figure 3.7 Storage Scheme for Unsymmetrical Matrix
To illustrate the usage of the adopted storage scheme, let's consider the matrix given in Eq.(3.15l).
168
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
A=
11.
O.
0
44.
0 8 0 9
0
O. O.
1.
O.
2.
O. 66. O.
3.
O. O. O.
4.
0
0
88
10
11
12 110
0
0
0
5. 14
(3.151)
7 112
The data in Eq.(3.150) will be represented as follows: IA (1:7 = neq + 1) = {l, 3, 4, 5, 6,7, 7} JA (1:6 = ncoef) = {4, 6, 5, 5, 5,.6} AD (1:6 = neq) = {11., 44., 66., 88., 110., 112.} AN (1:6 = ncoef) = {I., 2., 3., 4., 5., 7.} AN2(1:6 = ncoef) = {8., 9.,10.,11.,12., 14.} where neq is the size of the original stiffness matrix and ncoef is the number of nonzero, off diagonal terms of the upper-triangular stiffness matrix (equal to the nonzero, off diagonal terms of the lower-triangular stiffness matrix). Thus the total number of non-zero off diagonal terms for the entire matrix is 2 x ncoef.
Basic Unsymmetrical Equation Solver
One way to solve Eq.(3.150) is first to decompose A into the product of triangular matrices, either LV or LDU. Since the graphs of the upper-and lower-triangular matrices are the same, we chose the LDV factorization. Thus A=LDV
(3.152)
where V is an upper-triangular matrix with unit diagonal, D a diagonal matrix, and L a lower-triangular matrix with unit diagonal. After factorization, the numerical values of matrix L are different from those of matrix V.
Duc T. Nguyen
169
In order to better understand the general formula that we will derive for factorization of an unsymmetrical matrix, let's try to compute the factorized matrix [L), [D), and [U) from the following given 3x3 unsymmetrical matrix [A), assumed to be a full matrix, to simplify the discussion.
(3.153)
The unsymmetrical matrix A given in Eq.(3.153) can be factorized as indicated in Eq.(3 .152), or in the long form as follows:
(3.154)
The multiplication of matrices on the right-hand side of the equality gives:
where the nine unknowns (d ll , U1 2, Ul3, U23, hI> 131> d 22, 132> and d 33) from Eq.(3.154) and Eq.(3.155) can be found by simultaneously solving the following system of equations. all = d ll al2 = d ll Ul2 a21 = I2I d ll al3 = dlIUl3 a31 = 131dll a22= h1d ll u l2+d 22 a23 = 12JdIlUI3+d22U23 a32 = 131dlluJ2+132d22 a33 = 13Idllul3+132dnU23+d33
Thus from Eq.(3.l56), one obtains Eq .(3 .157 ):
(3.156 )
170
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
- a31 I3 1 -d ll
(3.157)
dzz= azz-h.dIlUl z a23 -12I d l l u 13 u23 =
d 22
- a32 -131 dll u12 I32d 22 d 33 = a3r ( 13Idllul3+13zdzzUZ3)
In solving for the unknowns in Eq.(3.157), the factorized matrices [L], [D], and [U] can be found in the following systematic pattern:
Step 1:
The I" diagonal value of [D] can be solved for d ll .
Step 2:
The 1st row of the upper-triangular matrix [U] can be solved for the solution of UI2 and UI3 .
Step 3:
The 1sf column of the lower-triangular matrix [L] can be solved for hi and 13 1,
Step 4:
The 2nd diagonal value of [D] can be solved for d zz.
Step 5:
The 2nd row of the upper-triangular matrix [U] can be solved for the solution of un
Step 6:
The 2nd column of the lower-triangular matrix [L] can be solved for 13z.
Step 7:
The 3rd diagonal value of [D] can be solved for d33.
By observing the above procedure, one can see that to factorize the term Uij of the upper-triangular matrix [U], one needs to know only the factorized row i of [L] and column j of [U]. Similarly, to factorize the term lij of the lower-triangular matrix [L], one needs to know only the factorized row j of [L] and column i of [U] as shown in Figure 3.8.
Due T. Nguyen
171
col i
colj
rowi
row j
Figure 3.8 Unsymmetrical Solver: Factorization of Uij and Iji
By generalizing to a matrix of dimension neq, the ith row elements of [UJ and the ith column elements of [L] can be obtained by the formulas in Eq.(3.158) and Eq.(3.159), assuming that the rows from I to i-I and column from I to i-l have already been factorized: r-i
a--IJ - "I-kd--UkL... 1 II J k-I
(j=i+l,neq)
(3.158)
(i=j+l,neq)
(3.159)
d.,II
j-I a.,J I- L "I-kd--Uk...JJJI Iji =
k-~__ JJ
and the diagonal values will be given by Eq.(3.160): i-I d ii = au - LlikdjjUki k=I
(3.160)
172
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Once the matrix is factorized, the unknown vector x is determined by the forward! backward substitution. Using Eq.(3.152), one can write Eq.(3.150) as follows: LDy=b
(3.161)
with y = Ux. The solution of Eq.(3.161) can be obtained as follows: i-I
Yi* = b, - ~ LJLikYk (i = l,...,neq) with y•= Dy
(3.162)
k=1
and to solve Ux
e
y
(3.163)
for x, neq
xi
= Yi -
IVikXk (i = neq, ...,l)
(3.164)
k=i+1
The factorization is computationally much more involved than the forwardlbackward substitution.
Efficient-Sparse LDU Unsymmetrical Solver
The developed sparse unsymmetrical solver is a collection of sub-routines that follow the same idea as the one given in Figure 3.8, with the sub-routines performing different tasks. Since the matrix is unsymmetrical in value, the re-ordering algorithm for the symmetric matrix is not suitable. On the other hand, by observing Figure 3.8 and the derivations in Eq.(3.152), the multipliers in the factorization of the upper portion of the matrix will be computed from the coefficients of the lower portion of the matrix and vice versa; thus, the numerical factorization will be different from the symmetrical case. The purpose of symbolic factorization is to find the locations of all non-zero (including "fill-in" terms), off-diagonal terms of the factorized matrix [Vl Since both upper and lower portions of the matrix have the same graph, the symbolic factorization is performed only on either the upper or lower portion of the matrix. The symbolic factorization required the structure lA, JA of the matrix in an unordered representation and generates the structure IV, JV of the factorized matrix in an unordered representation. However, the numerical factorization requires IV, JV to be ordered while lA, JA can be given in an unordered representation. A symbolic transposition routine, TRANSA, which does not construct the array of non-zero of the transpose structure, will be used twice to order IV, JV, after the symbolic factorization, since we are only interested in ordering JV. One of the major goals in this phase is to predict the required computer memory for subsequent numerical factorization for either the upper or lower portion of the matrix. For an
Due T. Nguyen
173
unsymmetrical case, the total memory required is twice the amount predicted by the symbolic factorization.
Ordering for Unsymmetrical Solver
Ordering algorithms, such as minimum-degree and nested dissection, have been developed for reducing fill-in during factorization of sparse symmetrical matrices. One cannot apply fill-in minimization, MMD [3.9J, on the upper and lower matrices separately. Shifting rows and columns of the upper portion of the matrix will require values from the lower portion of the matrix and vice versa. Let's consider the following example: 100
1
2
3
6
7
5
100
A= 9
100 11 15 100
12
13
10 14
17
18
19
100
20
4 8 (3.165)
16
Let us assume that the application of the Modified Minimum Degree (MMD) algorithm on the graph of the matrix results in the following permutation:
1
1
2
4
PERM 3
2
4
3
5
5
(3.166)
By switching rows and columns of the matrix given in Eq.(3.165), according to the permutation vector PERM, given in Eq.(3.166), the recorded matrix Ar becomes:
Ar
=
100
3
1
2
4
13
100
14
15
16
5
7
100
6
18
9
11
10
100
12
17
20
18
19
100
(3.167)
174
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
On the other hand, if one considers only the upper portion of the matrix (as for a symmetrical case), switching rows and columns of the matrix according to the permutation vector, PERM, will result in the following reordered matrix As given in Eq.(3.168).
Ap
=
lOO
3
3 1
I
2
4
lOO
7
11
16
7
lOO
6
8
2
11
6
100
12
4
16
8
12
lOO
(3.168)
One can see that the elements A(2,3) and A(2,4) came from the lower portion. Therefore, re-arranging the values of AN (or AN2) after the permutation vector PERM has been determined by the MMD routine will require certain elements of AN2 (or AN). The re-ordering subroutine for symmetric system has been modified to account for these changes and implemented without adding any additional working array. The portion of the skeleton Fortran code in Table 3.13 shows how to efficiently retrieve the appropriate elements from the lower (upper) portion of the matrix while constructing the re-ordered upper (lower) portion of the matrix. The permutation vector PERM and the structure IU and JU of the re-ordered matrix are assumed to be available already. The algorithm in Table 3.13 is different for a case of a symmetrical matrix because, if only the upper portion of a symmetrical matrix is stored in memory, the numerical values in row i at the left side of the diagonal value are identical to the values in column i above the diagonal value (see Figure 3.8). Consequently, the second DO loop 231 in Table 3.13 will not be needed because all data can be retrieved from the upper portion of the matrix and one can select the appropriate pointers no and BOO before the inner most DO loop. On the other hand, for an unsymmetrical matrix, one should scan separately the upper and lower portion of the matrix (AN = AN2) as shown in Table 3.13. Table 3.13 Portion of Skeleton Fortran Code for Re-ordering an Unsymmetrical Matrix DO 200 .i e L, N-l IO=perm(i) DO 220 j=IU(i), IU(i+l) JO=perm(JU(j) ) IF(IO.LT.JO) THEN IJO=IO IJOO=JO DO 230 jj=IA(IJO), IA(IJO+l)-l IF(JA(jj) .NE.IJOO) GO TO 230 UN( j ) =AN( j j ) UN2(j)=AN2(jj)
Due T. Nguyen
175
GO TO 22 0 230 CONTI NUE ELS E I JO=JO I J OO=I O DO 2 31 j j =I A(I JO ), I A (I J O+l ) - l IF( JA (jj).NE . I JOO) GO TO 2 31 UN ( j ) =AN2 ( j j ) UN2 ( j ) =AN ( j j ) GO TO 22 0 23 1 CONTI NUE ENDIF 22 0 CONTI NUE 2 0 0 CONT IN UE
Sparse Numerical Factorization with Loop Unrolling
By observing Figure 3.8 and the derivations in the previous section, in order to factorize an element uij of the upper-triangular matrix, one needs to know how to factorize row i of [L] and the columnj of [U]. Thus, the multiplier of the upper portion of the matrix will be computed from the coefficient of the lower portion of the matrix. Table 3.14 gives the pseudo Fortran skeleton code on how the multipliers are computed and how the factorization is carried out. The diagonal matrix [0] (see Eq.3.154) is also contained by the diagonal terms of the upper- triangular matrix [U] as can be seen from line 5 of Table 3.14. Table 3.14 Pseudo FORTRAN Skeleton Code for Sparse LOU Factorization 1.
c
Assuming r o w 1 h as b e en fac tor ized earl ier
2. 3.
Do 11 1 =2, NEQ Do 22 K=On ly t hose prev i ous rows wh i c h h a v e contr ibut ions to c urre n t row I 4. c Compu t e the mul tipli ers 5. XMULT=U (K, I )/ U (K,K ) rela t e d to the upper t r i a n g u l a r mat r i x XMULT2 = L(I,K) / U (K,K ) rel a t e d to th e l owe r t r i angul a r matrix 6 . Do 33 J = approp r i a t e d column numbers of row # K 7 . U ( I ,J ) = U(I,J) - XMULT2 * U(K ,J) L (J ,I ) = L(J,I) - XMULT * L(J , K) 8. 33 Con ti n u e 9 . U (K, I ) = XMULT L (I , K) = XMULT2 10 . 2 2 Con tinue 11 . 11 Cont inue
In the sparse implementation , after the symbolic factorization is completed on one portion of the matrix, the numerical factorization requires IU, JU (structure of [L] or [UJ) to be ordered and the required computer memory for the factorization is known. Similar to the symmetrical case, the numerical factorization for the unsymmetrical
176
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
case also requires to construct chain lists to keep track of the rows that will have contributions to the currently factorized row. Another advantage of the storage scheme that we have adopted is that the chain lists for the factorization of [L] (or [U]) will be the same as for the factorization of [U] (or [L]). The loop unrolling strategies that have been successfully introduced earlier can also be effectively incorporated into the developed unsymmetrical sparse solver in conjunction with the master degree of freedom strategy. In the actual code implementation, "DO loops" in Eqs.(3.158 - 3.160) will be re-arranged to make use of the loop unrolling technique. The loop unrolling is applied separately for the factorization of the upper portion and for the lower portion assuming the super-nodes have already been computed (the super-nodes of the upper portion are the same as the ones for the lower portion). The skeleton FORTRAN code in Table 3.14 should be modified as shown by the pseudo, skeleton FORTRAN code in Table 3.15 for a loop unrolling level 2. Forward and Backward Solution The forward and backward solutions were implemented following the formula in Eqs.(3.161 - 3.163), once the factorized matrices [L], [D], and [U] are computed. In the forward solution, (Eqs.[3.161 and 3.16]), the factorized matrices [L] and [D] are used, and in the backward substitution, the upper portion of the factorized matrix [U] is used. Table 3.15 Pseudo FORTRAN Skeleton Code for Sparse LDU Factorization with Unrolling Strategies C
c
C
Assuming row 1 has been factorized earlier Do 11 1=2,NEQ Do 22 K=Only those previous "master" rows which have contributions to current row I Compute the multiplier(s) NSLAVE DOF=MASTER (I) - 1 XMULT = U(K,1) I U(K,K) XMULm = U(K+m,1) I U(K+m,K+m) XMULT2 = L(1,K) I U(K,K) XMUL2 m = L(1,K+m) I U(K+m,K+m) m=I,2 SLAVE DOF Do 33 J = appropriated column numbers of "master" row #K U(1,J) U(1,J) - XMULT2 * U(K,J) - XMULT2 m * U(K+m,J) L(J,1) = L(j,1) - XMULT * L(J,K) - XMULm * L(J,K+m) 33 Continue U(K, I) = XMULT U(K+m,1) = XMULm L(1,K) = XMULT2 L(1,K+m) XMUL2m 22 Continue 11 Continue
Due T . Nguyen
177
Sparse Unsymmetric Matrix-Vector Multiplication
A matrix-vector multiplication sub-routine has been efficiently designed for which the unsymmetrical matrix is stored in a mixed row-wise and co lumn-wise storage scheme. The non-zeros from the upper- and lower-triangular matrix are stored in two distinctive arrays AN and AN2 with the same structure IA and lA. Let's consider a vector temp (1:neq) that will contain the result of the matrix-vector multiplication. After multiplying the diagonal values by the right -hand side, the multiplication of the upper and lower portion of the matrix are efficiently implemented as shown in Table 3.16 .
Table 3.16 Unsymmetrical Matrix-Vector Multiplication
10
Do 10 i=l,n iaa =i a ( i } i a b =i a ( i +l ) -1 Do k= ia a , iab kk =j a (k ) s um=su m+an( k)*rh s(kk} t emp (kk }=t emp (kk } +an2 (k}* rhs (i} ENDDO temp ( i }=sum Continue
The algorithm shown in Table 3.16 offers the advantage avoiding a conversion of a row-wise complete unordered storage that is normally used for general unsymmetric matrix into our special storage scheme (mixed-row and column-wise format).
The algorithm shown in Table 3.16 can be conveniently used to calculate the relative error norm, such as:
RELERR =
I\AX_- hll
(3.169)
b
Application of the Developed Sparse Unsymmetrical Solver
Three examples are considered to evaluate the performance of the developed unsymmetrical vector sparse LDU solver (that we will refer to as UNSYNUMFA). The author has considered pivoting strategies in earlier and separate works. However, these pivoting strategies have not yet been incorporated into the current unsymmetrical sparse solver. Two applications, the HSCT (16,152 degrees of freedoms) and the SRB (54,870 degrees of freedoms) finite element models for
178
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
which the static solution is known, are considered. In these first two examples, the coefficient (stiffness) matrices are known to be symmetrical. However, we still have used the developed unsymmetrical sparse solver to obtain the correct solutions! Another application, Pierrot HSCT (16,152 degrees of freedoms), is constructed by considering the structure of the HSCT FEM with the same coefficient values for the upper portion of the matrix and different values for the lower portion of the matrix to make the matrix completely unsymmetrical in value. To check the accuracy of the results, a relative error norm is computed, as shown in Eq.(3.l69), where matrix [A] is unsymmetrical. The sparse unsymmetrical matrixvector multiplication sub-routine developed in the previous section is used to compute the product [A]{x} (where {x} is the displacement vector) that is required for error norm computation. The numerical performance of the above three (finite element based) structural examples are presented in Tables 3.17 - 3.21. Table 3.17 HSCT FEM: Memory Requirement for UNSYNUMFA REORD
NCOEF
NCOEF2
Integer
Real
Total
Memorv
Memorv
Memory
No Reord.
999,010
7,400,484
4,296,626
8,480,224
12,776,850
UnsynM MD
999,010
6,034,566
3,613,667
7,114,306
10,727,973
Table 3.18 HSCT FEM: Summary of Results for UNSYNUMFA1I2/8 Using UnsyMMD and Different Level of Loop Unrolling on the IBM RS6000/590 Stretch Machine
Loop
Symfa
Numfa
FBE
Total
Max.
Summat
Relative
Unrolling time
time
time
time
abs.
abs.
Error
Level
(sec)
(sec)
(sec)
(sec)
disnl,
disnl.
Norm
1
0.480
50.010
0.310
53.350
0.477
301.291
l.34E-08
2
0.470
35.420
0.320
38.760
0.477
301.291
1.99E-08
8
0.480
28.730
0.320
32.700
0.477
301.291
1.36E-08
Due T. Nguyen
179
Table 3.19 HScr FEM: Comparison of Results for UNSYNUMFA with No UnsyMMD and Different Level of Loop Unrolling on the IBM RS60001590 Stretch Machine
Loop
Symfa
Numfa
FBE
Total
Max.
Summat
Relative
Unroll time ing (sec) Level
time
time
time
abs.
abs.
Error
(sec)
(sec)
(sec)
displ.
displ.
Norm
1
0.710
52.079
0.370
55.200
0.477
301.291
2.2E-09
2
0.680
35.650
0.380
38.730
0.477
301.291
2.0E-09
8
0.700
28.390
0.390
31.520
0.477
301.291
2.0E-09
Table 3.20 SRB FEM: Summary of Results for UNSYNUM FA Using UnsyMMD and Different Level of Loop Unrolling on the IBM RS60001590 Stretch Machine
Loop
Symfa Numfa
FBE
Total
Max.
Summat
Relative
Unroll time ing (sec) Level
time
time
time
abs.
abs.
Error
(sec)
(sec)
(sec)
displ.
displ.
Norm
1
1.93
210.500
2.820
229.560
2.061
301.291
8.1E-13
2
1.93
155.630
2.270
173.280
2.061
301.291
8.1E-13
8
1.93
133.150
1.300
150.230
2.061
301.291
8.1E-13
180
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Table 3.21 Pierrot FEM: Summary of Results for UNSYNUMFA Using UnsyMMD and Different Level of Loop Unrolling on the IBM RS6000/590 Stretch Machine
Loop
Symfa Numfa
FBE
Total
Max.
Summat
Relative
Unrollin time g (sec) Level
time
time
time
abs.
abs.
Error
(sec)
(sec)
(sec)
displ.
displ.
Norm
1
0.480
49.970
0.330
53.320
8.791
45.134
2.3E-07
2
0.470
35.340
0.320
38.650
8.791
45.134
1.8E-07
8
0.480
28.650
0.320
31.970
8.791
45.134
1.3E-07
3.11 Summary In this chapter, various topics related to direct sparse equation solvers for symmetrical/unsymmetrical, positive/negative/infinite system of equations have been explained. Sparse storage schemes, impacts of sparse re-ordering algorithms on the performance of the sparse solvers, sparse symbolic/numerical factorization, and forward and backward solution phases have been discussed. Unrolling strategies, which utilize "super-row" information, have also been incorporated into the factorization and forwardlbackward solution phases. Several medium- to large-scale, practical applications have been used to evaluate the performance of various proposed algorithms. These sparse solvers will also be used in subsequent chapters of this textbook.
Due T. Nguyen
181
3.12 Exercises 3.1 Given the following sparse matrix: Matrix A = 00
1
2
00
9
10
11
00
16 4 00
4
0
0
12
0
0
17
18
0
22
23
500
7
8
0
13
14
15
0
0
19
20
21
0
0
0
24
25
26
0
0
0
0
27
0
SYM
0
0
0
0
0
33
0
35
0
36
11 00
37 1200
(a) Repeat the above sparse matrix [AJ by using two integers and 2 real arrays
----
(= IA , JA, AD , AN ), as discussed in Eqs.(3.7 - 3.10). What is the value of
NCOEF1, as can be seen from Eq.(3.10)? (b) Without any actual numerical calculation, find the number and location of non-zero terms due to "fill-in" effects during the factorizati on phase. What is the value of NCOEF2, as discussed in the remarks about Eq.(3.35)? (c) Using the results of part (b), how do you re-define the arrays IA and JA [in part (a)] to include "fill-in" terms?
3.2 Assuming the matrix given in Problem 3.1 represents the factorized matrix, find the super-row information as discussed in Eq.(3.78).
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
182
3.3 Assuming each node in Figure 3.1 has 2 dof, construct the 2 integer arrays, as discussed in Eqs.(3.37, 3.38).
3.4 Using the same data, shown in Figure 3.1 and Eqs.(3.37, 3.38), and assuming the value of an integer array IPERM (see Eq.3.39) is given as:
IPERM
1
5
2
1
3 4
=
4
2
5
6
6
3
how will the matrix [U], shown in Eq.(3.41), be modified?
3.5 Given the indefinite matrix [A], shown in Eq.(3.l46), and the right-hand side vector b = {S,2,-2}T, using the procedures discussed in Eqs.(3.l3S-3.l39), find the solution vector
xof [A]x = b.
3.6 For the unsymmetrical matrix [A], shown in Eq.(3.16S), find the factorized matrix [A) = [L] [D] [U].
4 Sparse Assembly Process
4.1 Introduction
Systems of sparse, linear, symmetrical and/or unsymmetrical equations have occurred frequently in several engineering applications such as in nonlinear thermal finite analysis using discontinuous Galerkin method, acoustic finite element analysis, etc. A number of highly efficient sparse symmetrical equation solvers has been developed and reported in the literature. However, much less attention have been focused on the development of efficient, general symmetrical/unsymmetrical sparse assembly procedures. The objectives of this chapter, therefore, are (a) To discuss efficient algorithms for assembling a general, symmetrical/ unsymmetrical, sparse system of matrix equations that arise naturally from finite element analysis. (b) To summarize key steps involved in solving a general system of sparse, symmetrical/ unsymmetrical equations, and (c) To develop a simple template, in the form of sub-routines, where all key components of the procedure can be integrated to form a complete finite element analysis code. 4.2 A Simple Finite Element Model (Symmetrical Matrices)
To facilitate the discussion in this chapter, a simple finite element model of a 2-D truss structure, with 1 bay and 1 story, is shown in Figure 4.1. This structure has pin supports at nodes 3 and 4. Thus, zero prescribed Dirichlet boundary displacements are specified at nodes 3 and 4. Each node is assumed to have 2 degree-of-freedom (dot). The applied loads and the prescribed boundary dof at the nodes are given in Figure 4.1. There are 5 (2-D) truss members in this finite element model. Young modulus (= E), and cross-sectional area (= A), for each truss member is assumed to be E =lk/in.2 and A = 1 in. 2, respectively. The base and height for this 2-D truss structure is assumed to be 12", and 9", respectively. Since there are 4 nodes, with 2 dof per node, this finite element model has a total of 8 dof (N = 8).
184
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions F2= 2K F] = 1K
F4=4 K
1
F3 = 3 K
CD
1
2
0
G)
0)
CD Fs=O" y
3
4
41
Fs=O"
Figure 4.1 Simple 2-D Truss Finite Element Model With 1 Bay and I Story
1
2 K=
3 4 5
6 7 8
1
2
3
4
5
6
7
8
X
X
X
X
o.
o.
-0.0427
+0.032
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
(4.1)
Due T. Nguyen
IS5
lK 2K
Fi F2 F3 F4 F5 F6 F7 FS
~c
3K
4K 0'"
(4.2)
0'" 0'" 0'"
Using the "conventional" (not truly sparse) finite element assembly process discussed in an earlier chapter, the total (system) stiffness SxS matrix can be given in Eq.(4.l). At this stage, the exact values for various terms of the symmetrical stiffness matrix, shown in Eq.(4.1), are not important. Thus, these non-zero values of many terms are simply represented by the symbol x. The applied joint loads, including the prescribed Dirichlet boundary conditions (= 0 inch), are specified in Eq.(4.2). After incorporating the Dirichlet boundary conditions, the total stiffness matrix, given by Eq.(4.1), will be modified as: ] ]
2
3
4
-0.032
-0.0833
0.00
0.00
0.00
5
6
7
8
0.0833
+ 0.0427
O.l]ll
2
+ 0.0240
(4.3)
0.0833 3
+
0.032
0.0427
o.nn 4
+ 0.0240
5
1.0
6
7 8
1.0 S
Y
M
1.0 1.0
186
Finite Element Methods: Parallel-Sparse Statics and Eigen -Solution s
In Figure 4.1, there are five truss elements (with NDOFPE = 4 dof per element), thus the elernent-dof connectivity information can be described by the following two. integer arrays:
1
l-m dofpe
2
= locations for
3
Ie
connectivity infomation 5+ndofpe
4
(4.4)
NEL=5 6=NEL+l
je
1
1
2
2
3
3
4
4
5
1
6
2
7
5
8
6
•
•
•
•
• •
•
global dof associated
= with
each and every element (4.5)
•
17
3
18
4
19
5
NEL * ndofpe = 20
6
Eqs.(4.4) and (4.5) are the sparse representation of the following (element-dof con nectivity) matrix: 2345678 I x
x
x x
2 x x E= 3
4 x
5
x x
x
x
x
x
x x
x x
x
x x
(4.6)
Due T. Nguyen
187
The input Dirichlet boundary conditions for the finite element model, shown in Figure 4.1, are given as:
1
5
2
6
3
7
4 =# Dirichlet boundary dof
8
ibdof
(4.7)
The dof-element connectivity matrix [E]T can be obtained by transposing the matrix Eq.(4.6):
1 2
3 4
1 x x x x
2 x x
3
4 x x
x x
5 6 7 8
5
x x x x
x x x x
(4.8)
x x
Eq.(4.8) can be described by the following two integer arrays:
iet
1
1
2
4
3
7
4
10
5
13
6
15
7
17
8
19
N +1=9
21
(4.9)
188
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solution s
jet
1
1
2
2
3
4
4
1
5
2
6
4
7
1
8
3
9
5
10
1
11
3
12
5
13
2
14
5
15
2
16
5
17
3
18
4
19
3
20 = NEL * NDOFPE
4
(4.10)
4.3 Finite Element Sparse Assembly Algorithms for Symmetrical Matrices Having incorporated the appropri ate Dirichlet boundary conditions, the total stiffness matrix (shown in Eq.[4.3]) can be represented (in the sparse format) as follows:
1 2
1 4
3
6 7 7 7 7 7 7
4
ia
5 6 7 8 9=N+ l
(4.11)
Due T. Nguyen
189
Ja
1
2
2
3
3
4
4
3
5
4
6= ncoefl
ad
an
4
1
0.126
2
0.135
3
0.126
4
0.135
5
1.000
6
1.000
7
1.000
8=N
1.000
1
-0.032
2
-0.083
3 4
(4.12)
=
(4.13 )
0.000 0.000
5
0.000
6 = ncoefl
0.032
(4.14)
4.4 Symbolic Sparse Assembly of Symmetrical Matrices
Assuming the element-dof connectivity matrix [E] (see Eq.[4.6]), the dof-elernent connectivity matrix [E]T(see Eq.[4.8]), and the locations of the Dirichlet boundar y conditions vector {ibdof} (see Eq.[4.7]) are known. The non-zero patterns of matrices [E] and [E]T can be described by the integer arrays {ie }, {je} and {iet}, {jet} as indicated in Eqs.(4.4, 4.5), and Eqs.(4.9, 4.10), respectively. To facilitate subsequent discussion, information about the location of Dirichlet boundary conditions (see the integer array {ibdof}, shown in Eq.[4.7]) can be "slightly modified" and "copied" into the followin g integer array {ia}:
190
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
ta
1
0
2
0
3
0
4
0
5
N =8 N=8
6 7 8=N
(4.15)
N=8 N=8
It should be clear from Figure 4.1 that the prescribed Dirichlet boundary conditions
occurred at node 3 (or dof 5, 6) and node 4 (or dof 7, 8). This information is reflected in Eq.(4.15) since the following definitions are used for array {ia} shown in Eq.(4.15): .
la(-) =
{N , at those dof(such as dof #5,6,7,8) that correspond to Dirichlet boundary conditions 0, elsewhere (such as dof #1,2,3,4)
(4.16) The purpose of a "sparse symbolic assembly" algorithm can be summarized by the following problem: Given N (= total number dof = 8, for the example shown in Figure 4.1), the connectivity information (such as arrays {ie}, {je}, {iet}, and {jet}, as indicated in Eqs.(4.4, 4.5,4.9,4.10), and the Dirichlet boundary condition information (see array {ia}, shown in Eq.[4.15]) find the locations of non-zero, off-diagonal terms of the upper-triangular portion of the total stiffness matrix (shown in Eq.[4.3]). In other words, the main objective of the "sparse symbolic assembly" phase is to find two integer arrays [ia} , and {ja}, such as shown in Eqs.(4.11, 4.12), for the example illustrated in Figure 4.1. The "key ideas" for the "sparse symbolic assembly" algorithm are summarized in Table 4.1. A complete FORTRAN code (with detailed explanations) for a sparse, symmetrical symbolic assembly process is presented in Table 4.2. Using the example shown in Figure 4.1, and executing the FORTRAN code shown in Table 4.2, then the following information can be obtained: raj After processing row 1 of the total stiffness matrix [Kbc ] (see Eq.[4.3]), we have:
Duc T. Nguyen
191
1
1
2
1
3
1
iA __ 4
After processing row 1 (see Eq.[4.3])
__1-__
_
5 6
N=8 N=8
7
N=8
8=N
N=8
Initialized values
JP = 2l J = {2} 3 JA JP= ( JP=3 4 JP=JP+ 1 =4 [bJ After processing row 2 of the total stiffness matrix [KbcJ (see Eq.[4.3J), we have:
IA
1
1
2
4
3
2
4 5
After processing row 2 (see Eq.4.3)
2 -
8=N
6
8
7
8
8=N
8
Initialized values
JA(JP = 4J = {3} JP=5 4 JP= JP + 1 = 6 [cJ After exiting subroutine symbass, we will obtain the final output arrays {ia} and {ja} as shown in Eq.(4.11), and Eq.(4.12), respectively. The number of non-zero, off-diagonal terms of the upper-triangular matrix [KbcJ, shown in Eq.(4.3), can be computed as: (4.17) NCOEF1 = IA (N+1) - 1 = 7 - 1 = 6
192
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
4.5 Numerical Sparse Assembly of Symmetrical Matrices To facilitate the discussion in this section, the following variables and arrays are defined (refer to the example, shown in Figure 4.1). Input: IA,JA (see Eqs.[4.11, 4.12]) Descriptions of non-zero, off-diagonal terms' locations of matrix [Kbc ] (see Eq.[4.3])
o o o - - {I, corresponds to Dirichlet b.c.location(s) o IDffi= = 0, elsewhere 1
(4.18)
I
1 1 AE, BE = Elements stiffness matrix and element load vector (if necessary), respectively
(4.19)
LM = Global dof numbers, associated with an element
(4.20)
1 1
Example: LM
2
1
= 3 ; LM 4
2
2 5
6
NN = Size of Element Matrix (= 4, for 2-D truss element, see Figure 4.1) B = values of applied nodal loads and/or values of prescribed Dirichlet boundary conditions
(4.21)
Remarks [1] The 4x4 element stiffness matrix (for 2-D truss element) should be computed and stored as a I-D array (column - by - column fashion), such as: AE (i,j) ==AE (locate) (4.22) where locate = i + (j -1)*(NN = 4) i,j=1 ~ 4 For example: AE (3,2) == AE (7)
(4.23) (4.24) (4.25)
Duc T . Nguyen
193
[2] For the example data shown in Figure 4.1 , the vector
B
1 2 3 4 5 6 7
8=N
13 should be initialized to:
}K
2K 3K 4K
0 .. 0 .. 0 .. 0 ..
(4.26)
-Output : AN, AD =Values of off-diagonal and diagonal terms of [Kbc] , respectively
(see Eqs.[4.l4, 4.13]) B = Right-Hand-Side (RHS) load vector (see Eq.[4.26]) Notes: AD (N) should be initialized to 0 before calling this routine N = 8 == NDOF (4.27) Working Space: IP (N), should be initialized to 0 before calling this routine (for more efficient implementation) The "key ideas" for the "sparse numerical assembl y" algorithm are summarized in Table 4.3. A complete FORTRAN code (with detailed explanation) for sparse, symmetrical numerical assembly process is presented in Table 4.4. Important remarks about Table 4.4 are given in Table 4.5. Table 4.1 Key Ideas for Sparse Symbolic Assembly Algorithms
Input : IE, JE
Element -Node Connectivity Information (see Eqs. 4.4, 4.5 and Figure 4.1)
IET, JET Node-Element Connectivity Information (see Eqs. 4.9, 4.10) N
Number of Nodes (or dot) in a finite element (FE) model
{ N, correspond to Dirichlet boundary conditions (be) location (see Eq.4.15) IA(N ) = 0, elsewhere
194
Finite Element Methods: Parallel -Sparse Statics and Eigen-Solutions
Output
-
1
(see EgA.! I) . . IA(N + I), NCOEFI Description of Non - Zero location of stiffness matrix [A] JA(NCOEFl) is unordered (see EgA.l 2) Key Ideas
Do 30 1= I---7NM 1 (= N- I) for each I'h row of[ Kbc] (see Eq.4.3) If (l d' row corre spond to Dirichlet b.c.) Go to 30
Do 20 IP = consider all cle ments attached to lib row (or dot) Do 10 KP = consider all nodes (or dot) which belong to a particular element ( in loop 20) K = JE (K P) = dof #
x
x
x
1=1" row
SYM.
*S!siQ assembl ing Lower Tria ngle of [K",j , due to SYM. *Do NOT want to include the dof which already acco unted for (from other elements) ---7 Let IA(K) = I *Record the column #K (on the ~ row) which has non- zero term s-e JA(JP)
=K
*Increase the co unter 1)' by I (for computing NCOEFI= numb er of non- zero, off-diago nal terms of upper- triangular portion of the matrix) 10 Continue 20 Continu e
130lAm =JP~ IA(N) = 11' IA(N+ I ) =Jp
Duc T. Nguyen
195
Table 4.2 Complete FORTRAN Code for Sparse, Symmetrical, Symbolic Assembly Process s u br o ut i ne s y mba s s( i e, j e , i e t, je t, n, i a, j a ) imp lic i t real *8 (a - h ,0 - z) dimensi o n i e ( * ) , j e (*) , i e t (* ) , j e t (*) , i a (*) , j a (*)
c + ++ ++ ++ + ++ + ++ + +++++ ++ + +++ + + + + + +++ +++++++++ + ++ + ++ + + + + + +++ + + + ++++ + + + + +
c c c c
PLEAS E d irect y ou r q ues tions t o Dr. Nguy en (n g uy en @cee .odu .edu ) Purposes : symmet r ical , s p a rse symbolic as s emb ly This code i s st o r e d un der fi le name *symb* . f , i n s ub- d i r e c t o ry cd -/c e e/newfem/ comp l e te*/part2 . f
c+ +++ + ++ + + + + + + + + + + + ++ ++ + +++ + ++ + +++++ + + + + + + + + + + + + ++++ ++++ +++ + + + + + + + + + +
c
c c
c c
c c
I nput: ie(nel +l) =l o c a ti o n s (o r pointers) of t h e f irst n on - z e r o . of ea ch r o w (o f el ement -do f con n e c t i v i t y i nfo . ) j e (nel *ndof p e )= gl obal dof co lumn n umber f o r n on-ze ro . terms o f e a ch r o w (of el ement-dof conn e c t ivity info. ) . i e t (ndo f +l) =l o c a t i o n s (p o i n t ers) o f t h e f i r s t non -zero . . o f each r ow (of d o f - e l e me nt connec tiv ity i n fo. ) jet (nel*nd of p e)=l o cations (p o i n t e r s) o f t h e firs t non .
z e ro
c c
. .
of each r ow (o f dof - element conn e c t iv i t y in f o . ) i a( nd o f ) = ndof in the pos itions co r respond to Dirich le t
b .c . c. . . . . . 0 el sewhere c .... Ou t p u t :ia( ndo f +l )= s t a r t i ng locat i o n s o f the f i r s t non -z e ro c...... off -diagon a l t e r ms f or each r ow o f struct ural s tiff ness c. .. . . . ma t r i x c. . . . .. j a (n c o e ff ) =co l u mn numbers (u n o rd e r ed) co r r esp o n d to c .. . . . . each nonze r o , off -d i agonal term o f ea ch r ow of st r u ct u r a l c . sti ff ness ma trix
c +++ ++ ++ ++ ++ + + +++ + + +++ ++ + + + + + +++++ + ++++++ ++ ++ ++ + ++++ ++ ++ ++++++++ + + + + +
wr i t e(6,*) wr i te(6 , * ) write(6,*)
'***** * *** ** * ******************** ******* ********' '**** ****** * *********************** * ** ** ********'
write(6,*)
c+ + +++++ + +++ + + + +++ + ++++ ++++ +++ +++++++++ ++++++ + + + +++ ++ + + + + + + + + + + + + + + + +
jp=1 !OOI nml=n- l !0 0 2 d o 30 i =l , nml ! 0 03 l a s t row ( = eq ) will be ski pped jpi= jp !0 04 d e l a y e d cou nt er f or i a (-) array if ( ia(i) . e q . n ) g o to 3 0 ! 005 sk ip r o w wh i c h c orres p o n d to ! Dir ichlet b .c . ieta =i e t (i ) ! 00 6 b e gi n index ( t o f i n d how man y element s ) iet b =i e t (i +l )-l ! 00 7 end i ndex ( t o fin d how many e l e me n t s ) d o 20 i p=ie ta,i e tb ! 00 8 loop cover i n g ALL e lement s a tt a ch e d
196
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
to j=jet(ip)
! row i !009 actual "element number" attached to row
i
iea=ie(j)
ieb=ie(j+l)-l
!010 begin index (to find how many nodes attached to element j)
!011 end index (to find how many nodes
attached
10 20 30 non-
to element j) do 10 kp=iea,ieb !012 loop covering ALL nodes attached to element j k=je(kp) !013 actual "node, or column number" attached to element j if (k .le. i) go to 10 !014 skip, if it involves with !LOWER triangular portion if ( ia (k) .ge. i ) go to 10 ! 015 skip, if same node !already been accounted by !earlier elements ja{jp)=k !016 record "column number" associated with non-zero off-diag. term jp=jp+l !017 increase "counter" for column number array ja(-) ia(k)=i !018 record node (or column number) k already contributed to row i continue !019 continue !020 ia(i)=jpi !021 record "starting location" of
c ia{n)=jp
!022
zero off-diag. terms associated with row i record "starting location" of
non-
ia(n+l)=jp
!023
zero term of LAST ROW record "starting location" of non-zero term of LAST ROW + 1
c c c c
ncoef1=ia (n+l)-l write (6, *) 'ia{-) array write(6, *) 'ja(-) array return end
" (ia(i) ,i=l,n+l) ", (ja ( i }. i=l,ncoefl)
Duc T. Nguyen
197
1
2 Note: Before calling this routine, initialize I
3
=0
(4.28)
Ndof Do 40 L = 1, NN(= Element local row dof#) • Get I = global row dof # (correspond to L) = LM(L) • If (I is Dirichlet b.c.) Go To 40 (~ skip) • Assemble diagonal terms {AD} of [Koc } from [AE} • Assemble the l'" row of {B), if we have load acting on element • KK = 0 ~ Indicator that entire row I of [AE} has no contribution to [Koc } For example, en/ire row I of[AE] is in lower triangle offA] Do 20 LL=I, NN (= element local column dof#) • Find the location K of [AEJr..u. in the I-D array of [AE} • If (LL=L) Go To 20 ~ skip, since diagonal term of [AE} already taken care before loop 20 • Get J = LM(LL) = global column dof# • If (J is Dirichlet b.c.) Go To 10 ~ skip, but modify the RHS vector B first • If (J.LTJ) Go To 20 ~ skip lower triangle • lP(J) = K~ record col. # J(associate with row #1) & the correspond Kth location of [AE} = [AE]L,LL • KK = I => Indicator, that row L of [AE} does have contribution to row I of [Koc} Go To 20 10
B(l) = B(l) -B(J)* AE(K)
20
Continue If (KK = 0) Go To 40
~
~
modify RHS B, for Dirich b. c. only
if row L of [AE] has no contribution
Do 30 J = IA(l) , lA(l+1) -1
~
pointer to col.# of row of [Koc]
leol. # = JA(J) K = lP(leol.#) If (K = 0) Go To 30
~
skip (the current element has nothing to do with leol# of [Koc]
AN(J) = AN(J) + AE(K)
~
contribution of element stiffness (= AE) to total stiffness (= AN)
30
IP(lcol. #) = 0 ~ initialize again, before considering next row Continue
40 Continue
198
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Table 4.4 Complete FORTRAN Code for Sparse, Symmetrical Numerical Assembly Process
c%%%%%%%%%%%% %%%%%%%%% %%%%%%%%%%%%% %%% %%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%
c c
Ta b l e 4 .4
Comp let e FORTRAN Co de f or Spa r s e , Symmetr i c al Numeri c al Assemb l y Pro cess
sub rou ti n e n uma ss l ia , ja , i d i r ,ae , b e , l m, n do f pe , an ,ad ,b , i p ) implici t real " Sl a-h , o -z) d i me n sion i a t e ) ,ja l ") ,i d ir(+) . ue t r ) ,be l") , lm(") , an t " ) d i men s i o n a d ( ") , b ( " ) , i p ( " ) C + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
c
PLEASE direct you r que s ti ons t o Dr. Nguyen (nguyen @cee . odu.edu) Purp o s e s : symme t r i c al , s p a rs e nume r i c a l assemb l y Thi s code i s stor e d under file nam e " s y mb". f, in s ub d i r e ct ory
c c. .
c .. .. .. c + + ++ + + + + + + + + + + + + + + + + + + + + + + + ++ + + ++ + + + + + + + + + + + + + + + + + + + + + + + ++ + ++ + + + + + + +
c c c c c c c c c c c c c c c c c c
.. . .. .. .. .. .. .. . .. .. . . . ..
I n pu t: ia(ndof+l) =st ar ting l ocati ons o f the first n on - z er o o f f - d i a g o n a l t e rms f o r each row o f stru c tu r a l s ti f f n e s s ma t r ix
j a (n c o e ff )= c ol umn n umbe r s ( un o r d e r e d ) correspond t o e a ch n on z e r o , of f - d i a gon a l term o f eac h row of s t ru c t u r a l st iffne s s matrix idir(ndo f) = I in t h e po sitions c orrespond t o Di ri c hl e t b . c . o e l s e wh e r e ae(ndof p e"" 2) , b e (ndo f p e) = element (s t i f f n e s s) matr i x , a nd e lemen t (l oa d ) v e c t or lm (n dofpe ) = g lob a l dof as soc i a t e d wi t h a f i n i t e e lement n d o f p e = n umber o f dof per element b l nd o f) = b e fore u s ing t h i s r outine , values o f b l -) s hou l d be i nit i al iz e d t o : Ci , v al ues o f prescr i bed Dirichlet b c a t p r op e r l oca ti ons o r v a l ues of a p pl ied noda l l o a d s Ou t p u t :
a n ( nc oe ff l)= v a lues o f n o nzero, of f -di a g o na l t erms o f st ructura l s t i f f n ess matr ix ad(ndof) = va l ues o f f diagona l t erms o f st ruc tu r a l s t i f f n e s s .... matr ix .... blndof l = ri g h t - ha n d - s i d e ( load ) vec tor o f s yst em o f l i n e a r .. .. equation s Tempora r y Ar r ay s : . . .. ip(ndof) = ini tiali zed to 0 .. .. then IP( -) i s used and rese t t o 0
c. . . . .. c . ... . .
c. . c c c c c
.. .. .. ..
c%% %%% %%%%%%%%%%%%%%%%%%%%%%% %%% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
d o 40 L=l ,ndofpe i e Lm (L) if ( i dir(i ) . n e . 0 ) go t o 401 k =L- n d o f p e
!OOI !0 02 !003 ! 00 4
a d li) =a d li ) +a e ( k +L " ndo f pe ) b l i )= b (i )+ b e (L ) kk=O
!005 assemble K-di a g ! 0 0 6 a s s emb l e e leme nt r h s l oa d v ect or ! 0 0 7 f l a g , to s k ip cont r i but ion of ent i re g lobal row i if a l l g loba l c o l # j < i, or i f en t i re row i be l on gs t o LOWER t r i a ng l e ! OOS local "c o l umn " d o f ! 0 09 f i n d loc a tion of e l e me n t
loca l " r ow" d of g lobal " r ow " d o f skip , i f DIR ICHLET b .c . t o fi nd l o c a t i o n o f e lemen t k -
d iag
c c
c d o 20 LL=l , nd of pe k =k +ndo fp e
Due T. Nguyen
stiffness k i f ( LL . e q . L) go to 2 0
199
!01 0 skip, di a g. te rm already taken
c a re j =l m (LL ) if ( idir( j) . n e. 0 ) g o to 1 0 i f (j . 1t . i) go to 2 0 ip(j)= k (assoc iated
c c k k= l
l Ol l ! 01 2 ! 01 3 ! Ol 4
g loba l co lumn dof sk ip , i f DI RIC HLET b .c. s ki p, i f LOWER p ort i on r eco r d global c o l u mn # j
with globa l r ow #i) corr espon d t o k-t h te rm o f e l ement st if f ness k !015 FLAG, i ndi c a t e r ow L o f [k ) d o
have
c
con tr i bu t ion to globa l r ow I of
[ K)
10 20
go t o 20 b(i ) =b( i) -b(j ) *a elk l cont i nu e i f (k k .eq. 0) go to 4 0 i a a= i a ( i ) i a b =i a ( i +l ) - 1 do 30 j=iaa, i a b
c k= i p ( j a ( j ) )
! 01 6 ! 01 7 modify r h s load v e c t or due to DIR I CHLET b .c. !018 !019 skip indi c a t o r Is e e li ne 007) !020 start i n d ex !02l end ind e x ! 022 loop c ove r i n g a l l co l n u mbe r s as s o c i a t e d with g loba l r ow i ! 0 2 3 i p I co l # ) a lready def i n ed on
line
c if ( k . e q . 0) g o to 3 0
c
0 14 o r i n i t i a l ize d to ZERO i ni t i al l y ! 0 2 4 s k ip, bec ause eventhoug h r ow L o f [k) d o ha v e cont r i b ution t o globa l r ow I
of [ K ).
c
some te r ms of row L (of
[k l)
wh i ch ass o c ia t ed wit h DIRICHLET b .c . col umn s
c sh ould a n lj) =a nl j ) +ae l k) i p( j a( j ) ) =0
c 30 401 40
c c c c c c c c
con t i nu e g o to 4 0 ad ( i ) =1 . 0
be SKIPPED ! 025 assemb le [ K) f r o m [k ) !026 reset t o ZERO f or co l c o nsidering t h e ne xt row L !02 7
be f o re
res e t t he di ag onal o f K(i ,i)=1 .0 , d u e t o b .c .
con ti nu e ! 02 8 p rint deb ugging r e s u lt s rrdo f e Lz n coe f f 1 =i a l n d o f+l) - 1 write ( 6 . * ) 'a t the e n d of rout i ne nurna s s ' wri t e ( 6 . * ) ' i a( - ) array ', ( i a (i) , i=1.ndof+ l ) wri t e I 6 . * ) ' j a ( - ) array " I ja ( i ) , i= 1. n c o e ff 1 ) wr i t e t G, * ) ' a d ( - ) array ' , (a d (i ), i =1.ndof ) wr i t e t s . * ) "an Li ) arra y . , (a n (i I . i =1 . n c o e f ill r e t ur n e nd
c %%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
200
Finite Element Methods : Parallel -Sparse Statics and Eigen-Solutions
Table 4.5 Im ortant Remarks about Table 4.4 The elements (terms) of [AE] can't be directly assembled into [A], For example : right after line 15 (of Table 4.4), because LM and JA (= column #) are not ordered !!! 01 . 02 .
Do 4 0 L=l . NN I =LM(L)
1 3 . If (J . LT. I) Go To 2 0 14 . IP(J)=K 1 5 . KK=1 15 .1 AN(J) =AN(J)+AE(K 1 6 . Go To 20 1 7 . 10 B ( I) =B (I) -B(J)*AE( K) 18 . 20 continue
22 . Do 39 J=IA(I).
25.
Here. J
== l o c a t i on
po i n t t o get c o l umn #=;.c orrec t
4.6 Step-by-Step Algorithms for Symmetrical Sparse Assembly The complete FORTRAN code, which consists of the main program and its subroutines, for finite element sparse assembly is given in Tables 4.6, 4.7, 4.2, and 4.4. Outlines for this entire code are summarized in the following step-by-step algorithms : Step 1: [a] Input joint coordinates (see sub-routine jointc, Table 4.6) [b] Input joint loads (see sub-routine jointload, Table 4.6) [c] Input element connectivity (see sub-routine eIcoOl, Table 4.6) for 2-D truss element, there are 4 dofpe, hence ndofpe = 4 [d] Input Dirichlet boundary conditions (see sub-routine boundary , Table 4.6) Step 2: "Symbolic" sparse assembly (a) Call transa2 tnel, ndof, ie, je, iet, jet), see Table 4.7 (b) Call symbass (ie, je, iet, jet, ndof, ia, ja), see Table 4.2
Due T. Nguyen
201
The dimensions for output arrays: iet(ndof+ 1), jet(nel*ndofpe) Step 3: "Numerical" Sparse Assembly Do 4 iel = 1, nel [a] Get the global dof (and stored in array 1m) associated with element # iel [b] Get element information (see call elinfo, Table 4.6), such as joint coordinates, material properties, etc. [cJ Get element stiffness matrix ae (and element equivalent joint load, be, if applicable) in global coordinate reference (see call elstif, Table 4.6)
-----------
[d] Call numass (ia, ja,iboundc,ae,be,lm,ndofpe,an,ad,b, ip), see Table 4.4 where ip (ndof+l) = temporary working array
I
o
2
o o o
3 iboundc
4 5
=
1 = Dirichlet b.c.
6
1 = Dirichlet b.c.
7
1 =Dirichlet b.c.
8
1 = Dirichlet b.c.
... b should be initialized as b
4
Continue
1
lK
2
2K
3
3K
4
4K
5
0'"
6 7
0'"
8
0'"
0'"
=0
(initially)
(4.29)
(4.30)
(4.31)
202
Finite Element Method s: Parallel-Sparse Statics and Eigen-Solutions
Remarks
(1)
After completing the "sparse" assembly (including the imposed Dirichlet boundary conditions), the matrix [KbcJ and right-hand-side (load) vector can be "directly" generat ed and stored by the followin g arrays:
i\c
{ia}, see Eq.(4.l l) {ja}, see Eq.(4.12) {ad}, see Eq.(4.l 3) {an}, see Eq.(4.14) {B}, see Eq.(4.26)
If non-zero (say = 1.00") prescribed displacements are specified at each Dirichlet (support) boundary DOF, then the modified RHS load vector {B} (see Eq.[4.26]) will become:
(2)
F]
F2 F3
Fbc
=
F4
1.0107 K ~lK -(K IS =O)(Zs =I")-(K I6 =0)(Z6 = 1"') - (K J7 = - 0.0427)(Z7 = I"') 2.1031 K - (K IS = 0.032)(ZS = I"') 3.0747 K 4.1671 K
FS
1.00"
F6
1.00"
F7
1.00"
FS
1.00"
(4.32)
(3) The following example (2 Bay-I Story) can be used to further validate the above step-by-step sparse assembly procedure. E
= lKJin .2
A
= Iin.2
Height = 9" Base = 12"
Due T. Nguyen
203
h =I
F II =0
FlO
=0 "
Figure 4.2 2-Bay, l -Story Truss Structure A 2-D truss structure with the applied loads, Dirichlet support boundary conditions, element connectivitie s, material properties, and the geometrical dimensions are all given in Figure 4.2. The non-zero terms for the total stiffness matrix (before imposing the Dirichlet boundary conditions) are indicated by Eq.(4.33). The applied joint load vector (including the prescribed boundary displacements) is given by Eq.(4.34). The total (= system) stiffness matrix, after imposing boundary conditions, is shown in Eq.(4.35 ).
[K] =
1 2 3 4 5
1 x
2
3
4
x
x
x
x
x x
x x x
x x x
6
x
x
7
8
x
x
x x x
x x x
x
x
6
7 8 9 10 11 12
5
x S
y
M
9 x
10 x
x x
x
x x x
x x x x
x x
x
11
12
x x x x
x x
x
x
x x
x x x
X
(4.33)
204
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Fbc =
[KbcJ =
1 1 x 2 3 4 5 6 7 8 9 10 11
12
2 1st X
3 20 0 4 th X
F} F2 F3 F4 Fs F6 F7 Fs F9 FlO Fll F 12
4 5 3ro 5th 6th 7th X 9th
x
lK
ZK K 4K
3
SK K
6
(4.34)
0" 0" 0" 0" 0" 0"
6
7
8
9
10
11
12
8th 10th 11th X (4.35)
1.0 1.0 1.0 1.0 1.0 1.0
(4) Different finite element types can also be easily incorporated into the presented sparse assembly algorithms. As an example, the 1-Bay, l-Story truss structure with five truss elements (shown in Figure 4.1) is now added with two triangular elements as illustrated in Figure 4.3.
Due T. Nguyen
i
205
=1
i=2
k=2
j = 3 (= NBAYS+2) k = 4 (= NBAYS+3)
j = 3 (= NBAYS +2)
Figure 4.3 Tw o Triangular Elements Added to Figure 4.1
The "artificial" or "faked" element stiffness matrix for the triangular finite element can be given as:
123456 1234567 2345678 [ k (e)
l X6 =[
k j, j ]
(4.36)
= ~ ~ ~ ~ ~ ~ 1~ 567891011 6 7 8 9 10 11 12
where i, j = 1,2,...6 and [ki , j] = i + j
(4.37)
The input element connectivity arrays for this mixed finite element model (for NBA YS = I = NSTORY) becomes:
1
1
2
5
3
9
4
5 = NELTYPE(l)
ie
6 7
= NELTYPE(l)+ NELTYPE(2)
[~NELTYPE(i)]+1
8=
=
13 17 21 27
33
(4.38)
206
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Je
1 2 3 4
1 2 3 4
17 18 19 20 = NELTYPE(l) * 4
3 4 5 6
21 22 23 24 25 26 27 28 29 30 31 32 = ncoefl
=
1 2 5 6 3 4 3 4 5 6 7 8
(4.39)
Duc T. Nguyen
207
since NELTYPE(l ) = 5 truss elements with ndofpe = 4 (= number of dof per element) NELTYPE(2)
= 2 triangular elements with ndofpe = 6 NELTYPES
ncoefl
= ie(8)-1 = 33-1 = 32 =
LNDOFPE j *NELTYPE(i) i :; ]
where NLETYPE (l ), and NELTYPE(2) represents the number of finite element type 1 (= 2-D truss element), and type 2 (= 2-D triangular element), respectively. The general flowchart for symmetrical sparse assembly process for mixed finite element model is outlined in Figure 4.4.
calI sparseassem 1 (please see the attached subroutine in Table 4.6)
User Main Program, or User Driver Subroutine
Do 1 i =l, NELTYPES ISAY=20) nel=NELTYPE ( i ) I f l n e l . EQ. Ol Go To 1 ndo fpe= 4 Ifl i . EQ .21 ndofpe =6 If l i . EQ . 3 1 ndofpe= 12 I f li. EQ . 20 1 ndo f p e =24 Do 2 j =l. n e l Ca ll use r 's s u b ro u ti n e s ( s ) t o get: ( k ee ) ). wh ere : (k lel) =e lement s t i f f n ess matr i x
be,LM
be = el e me n t load v e ctor
LM =glob a l d of a s soc i ated with an element
1
b a l l sparsea s s e m2 lPl e a se see the at ta ched Table 4.6 11 2 c o ntin u e 1 continue
Figure 4.4 Outlines for Symmetrical Sparse Assembly Process with Mixed Finite Element Types Using the computer program, shown in Tables (4.6, 4.7, 4.2, and 4.4), the input and output data (arrays lA, lA, AD, AN, and B) are shown in Table 4.8 for the mixed finite element model shown in Figures 4.1 and 4.3.
208
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Table 4.6 Inputs and Outputs for Mixed (2-D Truss and Triangular) Finite Element Sparse Assembly Process c c c
Table 4.6
c
version: June 1, 2002 ----»
Main Program and Its Subroutines For Symmetrical Finite Element Sparse Assembly part1.f
c****************************************************************
c PLEASE do "NOT" distribute this code to any persons, or any c organizations without explicit written agreement from c D r . Duc T. NGUYEN (Tel~ 757--683-3761.
[email protected]) c This file is stored under -/cee/*commer*/part1.f c****************************************************************
c PURPOSES: (a) Simple demonstration to users on EFFICIENT SPARSE ASSEMBLY c c (b) Simple 2-D "artificial" truss, 2-d triangular elements c...... /material/load data is "automatically" generated c...... Small examples (5 "real" truss & 2 "faked" triangular elements c has been successfully/correctly assembled. c (c) For "testing" users c-----> Part 1 "source codes" of main program/"several" routines c-----> Part 2 ~ "object codes" of routines: TRANSA2, SYMBASS, NUMASS
c c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
implicit real*8(a-h,o-z) common/junk1/height,base,ireal,nbays,nstory c
$ $ $
dimension b(10001, ibdof(lOOOI, ia(1000), ir(10000001, elk(24,24), be(24), ae(576), lm(24), ad(10001, x(10001, y(1000), z(1000), ja(1000000), an(10000001, neltype(20)
c c+++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + + + + + + + + +
c
input general information ~ User just needs to change this input nstory~l User just needs to change this input bcdispl~O.O User inputs zero prescribed displ. at each bc dof bcd i sp l e L. 0 prescribed disp1. at each bc dof nbays~l
c
c height~9.0 base~12.0 ndofpemax~24 ndofpn~2
ne Lt ype s e z 0
mtoti=1000000 c nboundc~(nbays+1)*ndofpn nel1~nstory*(4*nbays+1)
nodes~(nbays+I)*(nstory+11 ndof~nodes*ndofpn
c
202
do 202 i~l,neltypes neltype (i) ~O neltype (1) ~nel1 neltypel21~2
# of 2-d truss elements # of 2-d triangular elements
c
writeI6,*) 'Date: June 1, 2002' writel6,*1 write(6,*) 'nbays, nstory, # real truss/faked triangular el. write(6,*) nbays, nstory, neltype(1), neltype(2)
c call jointc(x,y,z,nodes) call jointload(ndof,b) c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ nelcum~O
~
total # elements (all element types)
ndofpenel=O
c do 203
i~l,neltypes
Due T . Nguyen
209
if ( nel type(i) . ne . 0 ) t h en i f ( i .eq . 1) n d ofpe~4 if (i . e q. 2 ) nd o f pe ~ 6 ne lc u m ~n e lc um +ne ltype ( i )
ndofpenel ~ndofp en e l + n do f pe* n e l typ el i )
e n d if cont i nue
203
c i e beg ~ 1
jebeg=iebeg+(nel cum+l) ibc beg ~ j ebeg + ( n do f pe ne l) ietbeg~ibcbeg+ ndof j e t b eg ~ i e t be g + ( n d o f+ l ) i pbeg ~ j e t beg + ( ndo f p e n e l ) l a s t ~ i pb eg + n d o f
if (mto ti .I t . l a s t ) t he n write(6 . * ) ' e r r o r : n o t e nou g h memory f o r rntoti ! ! ! ' end if call e lcoOl( i r l j e b e g ) ,ne l l , i r l i e b e g ) , n e lty p e s , n e l t y p e ) c+ + + + + + + + + + + + + + + + + + + + + + + + + + + ++++++ + ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
c c c .. .
i npu t (ie}
c. . . . . .
(or "ar t i f i c i a l l y" g e n e r a t e d ) connect i v i t y inf orma t ion location s f o r t h e c onnec t i v i t y informa t i o n 1, l+l* n d o f p e , 1+2 *ndof pe , 1 +3 *n d o f pe , et c . 1, 5, 9, 13 , 1 7, et c .
c
c C oo . . .
c
wri te I 6 , *) ' i e ~ l i r (i e b e g - l +i ) , i ~ l ,n el c u m + l ) {je} ~ g loba l d of ass oc i a t e d wit h EACH and eve ry e l e me n t . ~ 13 , 1 4 , 1 . 2, 13 , 14. 7. 8 . etc ... wri t e ( 6 .* ) ' j e ( i r( j ebeg -l+i ) , i ~ l . nd o f pen e l ) in itia l ize t h e b o u nd a r y con d i tion f lag . and rh s l o a d v e c t or d o 1 .i e L, n d of i r ( i bc b eg - l + i ) ~ O
1
c c C oo . . .
c
2
cont i nue input (or "artif i ci a ll y · g enera ted) b oundary d of {ibd of} ~ the gl ob a l do f a s soc i a t e d wit h DIRI CLET b o undary c o n d i t i on s . 13 , 1 4 . 1 5 . 16 cal l bounda ry l n o d e s , nbay s , i bdof ) wri teI6 , * ) , ibd o f = " l ibdofl i ) , i =l . n b o u n d c l mod ify the b o und a ry c ond it i on f lag d o 2 i=l . nbo undc j = i bdo f ( i ) i r(i bcbeg-1 +j)=1 ! will b e us ed later in spar se n ume r ica l a s s e mbl y b (j ) =b cdi sp l ! p r e s c ribe d dir ichlet b c con t i n u e
c + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
c a l l sparseasseml (n el c u m, n d of . n d o f p e n e l. mt ot i. i r, i flag .
$ ae ,be, lm, ia ,ja , ad ,an, b,nd ofpe) c+ + ++ ++ + + + + + + + + + + + + + + + + + + + ++ + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
d o 10 6 i=l , n e l t y p e s i f I nelty p e ( i ) . e q . 0 ) g o t o 106 i f Ii .eq. 1) t h e n ne Le ne Lt yp c ( i )
ndofpe =4 elseif (i .eq. 2)
t hen
n e l. en e Ltyp c ( i )
c c
c 76
n do f p e = 6 endi f l o o p f o r a ll element s do 4 i e l = l ,ne l g e t the g loba l d of a ssoc iat ed wi t h each e lement if (i . e q. 1 ) then i e n d =i e l *n d o f p e i s ta r t =i e nd - n d o f p e do 7 6 j=l ,ndofpe I m ( j ) = j e ( is ta r t + j l I m(j)~ir ( jebeg - l + i s t a r t + j )
76
c on t i n u e
c ca ll e l infoliel ,x, y , z ,i rl j e b e g ) , y o u n g m, a r e a a , x l, c x, c Y , c 2 , l m)
210
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
m=ndofpema x ca l l e l s ti f (iel,you n gm , a r eaa,x l , cx , cy , e l k , ndofpe ,m,nel ) if(i e l . e q . 1 .or , i el .eq . ne l ) t h en writ e( 6, * } • e lem # " i e l, ' 11:** pa ssed e ls t if f *** e ndif I
c g o t o 67 8 elseif Ii . e q . 2 ) t h e n . g e t Im ( - ), elk ( -, - ) , a nd b e l - ) = (0) f o r 2 - d t r i angul ar e l ement
c t y pe
c -- - -- -- - -- - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - c "a rtificial" 2 - d t r i a n g u l a r element s s t r uc t ura l da ta c
c 86
h a r d coded e leme n t con nec t iv it i e s , e lk( - , -), a n d be ( - ) d o 8 6 j =l , n d o f p e I m ( j ) = j e ( i s t a r t +j ) 1 0 c a t e= j e b e g -l+ n e l t y p e ( 1) *4 + ( i e l -l) *n d o f p e + j Im (j)=ir(locate)
c be ( j) =O.
c 88
do 88 k=l, n d o f p e e l k ( j , k ) = j +k c on t i nu e
c 86 c on t i nue c -- -- --- - -- - -- - - - - - -- -- - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - go to 678 e ndi f c c o n v e r t e lement s t i f f ness fr om 2 - D a rray in t o I - D a r ray 67 8 c o n t i nu e d o 78 j=l,ndofpe d o 7 7 jj= l ,ndofpe l o cate=jj +(j -l)*ndo fp e a e (loca t e ) =e lk ( jj , j ) 77 c on t inue 78 cont inu e spa rs e "numeri ca l " a s s e mbly c cal l sparsea s sem2 (ne lcum, n do f , n d o f p e n e l , mto t i , i r , i f l a g, ae ,be , l m, i a,j a , a d ,an,b , n d o fp e l i f ( i el . e q . 1 . or . ie l . e q . n el l t h e n wr ite( 6 , * ) ' e l em # " i el, ,*** pa ssed numas s *** , endif
c .. .. .. 4 106
c on t i n u e c o n ti n u e
diff e r ent e l e me n t
t ype l o o p
c .. .. . . ncoef 1 =i a (ndof+ l ) -i a( l) write(6 ,*) ' n d o f, n c o e f 1 = ' , n d o f , n c o e f l write(6 , * ) ' i a (n d o f +11 = ' , ( i a l i l ,i= l ,ndof +l) write( 6 , * ) 'j a (n c o e fl ) = ' , ( j a l i J , i =l, nc o e fl ) wri te( 6 , * ) "a d t ndo f ) e ' , l a d l i l , i =1,ndo fl wri te ( 6 , *) 'an( n c o e fl l = " (an t i ) , i =1,ncoefl ) wr i te ( 6 , * ) 'bl n d of ) = ' , (b ( i ), i =1 , n d o f ) s top end c %%%%%%%%%%% %%%%%%%%%%%%%%%%% %% %%%% %%%%%% %%%%%%%%% subrout i n e joint c( x ,y ,z, n od e sl imp l ic i t real *8(a -h, o - z) c * ** ** *pur pos e s: i npu t j oi nt c oo rd i na t e s d i me n s ion x ( l) , y ( l ) , z (1 ) common / j u n k l/ he ig ht , b a se, i r e a l ,nbays , ns t o ry c - - - - - - - - - - --- - - - - - -- - - ---- - - - - - ---- - - - -- - - - - - - - - -c "artifici a l" s tru ctu r al d at a s j o i n t =O d o 11 i =l,ns t ory+ 1 y cor= (n s t o ry +1 - i ) *h e ight x c o r =- base do 1 2 j =1 , n b a y s +l j o int= j oi nt+l z (j o i n t l-O .
Due T. Nguyen
211
x cor =xcor+bas e x ( jo i n t) ~xco r y ( j o i n t ) ~y c o r
12 11
c
con t i nu e c ontinu e
.
wr i te (6 . * ) ' j o i n t coord i na t e s ' do 2 1 i ~ l , nod e s wr ite(6 , * ) i, xl i) , y ( i ) , z ( i) 21 con ti n u e r et u r n end c %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% %%%%%%%%%%%%%%%%%% %%%%%%% s ub ro u t i n e e l c o Ol l j e ,ne l , i e, n e l t y pes , n e l ty pe ) i mpli cit rea l *8l a - h , o - z ) c * * ** **pur po s e : inp ut e l e me n t c onne c t i v i t y c * ** * **e x p l a i n : d im ension j e l *) , i e ( * ) , n e l t y p e ( * ) c ommo n / j u n k l / h e i g ht , ba se ,i r e a l , n b a y s , n s t o ry
c do 102 i l ~ l ,neltype s if ( neltype( i i ) .n e . if (ii .eq. 1 ) t h en
a )
t hen
ndofp e~ 4
c - - - - - - - - - - - - - - - - - - - - -- - -- -- - - - - - - - - - - -- - - - - - - - - - - - - - - - c c
" a rt ificial" 2- d t rus s e leme n t s structural da t a l f ir s t) h o r izo n tal members memhor~nbays * ns t ory
i e l n u m=O is ta r t ~- n ba ys
d o 11
i ~ l , n s t ory
is t a r t ~ i s t a r t + lnbay s + 1 )
d o 1 2 j =1, nbay s i e l num=i el nuffi +l c+++ + + ++ + + + + + + + + + + ++++ ++ ++ + + + + + + + nod e i ~ i s t a r t + j - l no d e j ~ i s t a r t + j ie ls t art ~( ie 1n um - l )*4
je ( i e 1 sta rt+1) ~ n o d e i* 2 - 1 je (ie ls t ar t +2 ) ~ nod e i *2 j e ( ie l s t art + 3 ) ~ n o d e j * 2 -1 j e ( i el s t a r t + 4 ) ~ n o d e j * 2
C t + + + + + + + + + + + + + + + + + +++ + + +++ + + + + + +
12 11
c
con t i n u e c o n t i nu e (s e c o n d ) ve r ti c al me mbe r s memve r~n s tory * l nbay s + l)
i e l nu m ~ O
d o 2 1 i=l,nb ay s+l do 2 2 j ~ l , n s t o ry ie l nurn:: : i e l nurn+l i e l= i e l num+me mhor node i =i + l n b a ys+l)*(j - l) n odej~n o d e i + (nbays+ l)
c++ + ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + ielstart ~(iel - l)* 4 j e ( i e 1 s t a r t +1 ) ~ node i * 2 -1
j e ( i e l s t a r t +2 )= n o d e i *2 j e ( i e l s t a r t + 3 ) ~ n o de j * 2 -1 j e l i e 1 s ta r t + 4 ) ~ node j * 2
c + + + + + + + + + + + + + + + + + + + + ++ + + + + + ++ + + +
22 21
c
c on t i nue con t i n u e (t hird ) d iag o n a l memb er s memhv =rnemho r tmemv er i e l n um ~ O
i n c r= nb ay s *n s tory d o 3 1 i~ l,nbays do 32 j ~ l , n s to ry
ie l num-i e l num+l
212
Finite ElementMethods: Parallel-Sparse Statics and Eigen-Solution s
i el =i e l num+rnemhv diagonal me mbers o f t y pe " \ \ \ \ \ \ \ \" node i o i + (n bays +l) * ( j - 1 )
c
nodej~no d e i +(nba ys+ 2)
Ctt + +++ + +++ + + + + + + + + + + + + + + + + + + + + + +
ielsta r t o(iel -1) *4 je(ie ls ta r t +l)o node i *2 - 1 j e ( i e l s t a r t + 2 )~ n o d e i * 2
j e ( i e l s t a r t +3 ) on o d e j *2 - 1 j e ( i e l s t a r t +4 ) on o d e j *2 c++++ + + + + ++ + + ++ ++ ++ + ++ + + + + ++ + + + ++
d i ago na l member s o f t ype " 1111111 1" node ij ( i e l +inc r . l )o node ij ( ie l . 1 ) +1 n o de i j ( i e l +incr. 2 ) on o de ij( i e l. 2) - 1 ie l s t ar t o (i el - 1 ) *4 i wh a t o j e ( i e l s t a r t +2 ) / 2 j wha t o j e ( i e l star t +4) / 2 nodei : : i wha t tl node jo j wh at - 1
c c c
c ielst ar t o ( iel +inc r - 1)* 4 C t + ++ + + + + + + + + + + + + + + + + + + + + + + + +++++
je (iel s t a r t+1 ) on odei*2 - 1 j e(ie l s ta rt+2) onode i* 2 j e ( i e l s t a r t +3 ) onode j *2 -1 j e ( i e l s t a r t +4 )o nod ej *2 C .t+ + + + ++ + + + + + + + + + + + ++ +++++ + +++++
32 31
c
con t i n u e con ti n ue
. writ eI 6 . * ) ' el e me n t c o n n e c t i v i t y n o d ei &j' d o 61 i ~ l . n e l i st art ol i - 1 ) *4 wr i t e t e , *) i j e Li s t ar t s L ) . j e l i s t a r t +2) .j e(i star t +3) . j e ( i s t a r t +4 ) c on t i n u e i
61
C t+ + + + + + ie (l)~ l
71
do 7 1 i ol.nel ie l i +1) o i e( i l +ndofpe cont i nue g o to 1 0 2
c - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - -- -- - - - - - - - - - - - - - - - c c
"ar t ifi cia l " 2- d t r i a ngu l a r e leme n t s s t r u ct ura l d at a ha r d c ode d e lemen t connectiviti e s elsei f (i i . e q . 2 ) t h e n n d o fpe o 6 i e( n e l t y p e(l )+ l ) ~ 4 *n e l t y p e( 1 )+1 ie l n e ltype ( 1) +2 ) ~ 4*n e l t y p e (1 ) + 7 ie( ne ltype( 1 ) +3 ) ~4 *n e l type( 1) + 13 j et 4 *n e ltype( 1) +1 ) ~1 jet 4*ne lt y p e ( 1 ) +2 1~2 je t 4*ne ltype ( 1 ) +3 ) ~( n b a y s +2) *2 - 1 je t 4*neltypel l ) +4 ) ~( n b ay s+ 2) *2 je t 4*neltype( 1 ) +5 ) ~ 3 je t 4*nel typ e (1 ) +6 ) ~4 j e t 4*ne l t y p e (1 ) +7 ) ~ 3 j e t 4 *neltyp e ll )+ 8 ) ~4 j et 4*nel t y pe (1)+ 9 ) ~(n b a y s+ 2 ) *2 - 1 j e t 4 * n e l typ e ( 1 ) + 10 ) ~(n bay s + 2) * 2 je l 4 *ne l type ( 1 ) +11 ) =lnb a y s +3) *2 - l je l 4 *ne l t y pe( 1 ) +1 2 ) = (nb a y s+ 3 ) *2
c--- - -- ------ - -- -- -- -- -- ---- - -- ··-- --- - --- - -- -- -- ---- - -- 1 02
end if endif con tinu e
c 999
r etu rn e nd c %% %%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% subrou tine b o u n d a r Y l n od e s . n b a ys . i bdo f )
Due T. Nguyen
dimension ibd o f( ' ) l a s t b n= n odes i f irstbn =lastbn -nbay s i count:: O d o 35 nodebc =ifir stbn, l a stbn icount:::icount+l i bdo f l i c ou n t l =n o d e b c ' 2 - l
c 35
i c o un t :::: i c o unt +l i bdo f (i c oun t) =nod e bc '2 c o n t i n ue r e t urn
e nd c%% %%% %% %%%%%%%%%%%%% %%%% %% %%%% %%%%% %%%%%%%%%%%%%%%%% sub rou t i ne e l stif( i the l , y o u n gm .ar e aa. x l.cx , c y . e l k.n d o fp e .m .nel) impl i cit r e al ' 8 ( a - h , o - z ) c * * ** **pu r po s e : t o g en er a t e e leme nt st if f ness matri x c * * * * * *e x p l a i n : dimens ion e lk (m, m)
c - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - c=y o u n g m*a r e a a / xl
c
e l e me n t stiff n e s s ma t r i x f or 2 - D " truss" e l k ( l . l l =c *c x · c x el k ( 2 . 2 1=c · c y · c y el k ( 1 . 2 1=c *c x ' c y e l k ( 3 . 31 =e l k l l . l ) el k I2 .31 =- e l k l l .21 e l k( l .3 1=- e l k ( 1. l l e l k( 4 .4 1=e lk ( 2 .2 ) el k (3. 41 =e lk( l .2 ) e l k (2. 41 = - e l k ( 2 .2) e l k ( l . 4) =- e l k (1 . 2)
c .... ..
2 1
do 1 i=l. ndof p e do 2 j =i,ndo f pe elk(j ,il =e l k(i . j ) c ontinue con t inu e
c .. . ... c c C
c c c c3 4 c33 c
if(ith e l .eq. 1 .o r. i th el .eq . ne ll t h e n wr ite (6 , ') ' e 1. st i ff ( k ] fo r member " . i thel write(6. · ) 'youngm , are a a ,xl ,c . cx ,cy ,cz = wri te (6 , ' ) youngm,areaa,x l .c ,cx ,cy .cz do 3 3 i =l , n dof pe wr ite (6 , 34) (e lk (i, j ) , j =l. ndo f pe ) f orma t( 2x ,6e1 3. 6 ) cont i nu e e ndi f
c - - - - - - - - - - -- - - - - -- - - - - - - -
re turn end c%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% s u b r ou t i n e elin f o l i t h e l, x , y , z . j e, youngm,are a a , x l, c x , c y , c z , l m) i mpl i c i t real*8I a - h, o - z ) c ** ** * *pur p o s e : to obt a i n all n e c e s s ary i n f o r ma t i on fo r e lemen t st if f n e s s c ** ** ** gene r a t i o n c ** ** * *exp l a i n : d i men s ion x (l ) .y t l ) , z l l ) , j e t ') , lm( ' )
c------------------------------ --------------------------------------youngm=l . OO area a = l .OO
c .. .. .. c c
n ode i=n o de i j (it hel ,l ) n o d e j =n o d e i j ( i t hel, 2 ) ie lstar t = ( i t he l - l) '4 nodei =je(iels tar t +2 )/ 2 node j= je( ielstart+41/ 2
c l m ( l ) =j e ( i e l s t a r t +l l Im (2) -je(i e lst art+ 2 J
213
214
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Im(3)~je(ielstart+3) Im(4)~je(ielstart+4)
c ~ ..... deltax~x(nodej)-x(nodei)
deltay=y(nodej)-y{nodei) deltaz~zlnodej)-z(nodei) xl~deltax**2+deltay**2+deltaz**2 x
I
e
d a q r
t
(x l
)
cx- de l t ax zx I cy~deltay/xl cz~deltaz/xl
c c c
.
writel6, *) 'youngm,areaa,xl,cx,cy,CZ, ithel ',youngm $,areaa,xl,cx,cy,cz,ithel return end c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine jointloadlndof,b) implicit real*8(a-h,o-z) dimension bl*) c generate "artificial" horizontal force in the x-direction c at dof #1 of 2-D truss structure do 1 i~l.ndof bl i) ~i continue
return end c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c
NO
SOURCE
CODE
FROM
HERE
DOWN
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
subroutine sparseassemllnel,ndof.ndofpene1,mtoti,ir,iflag, $ ae,be,lm,ia,ja,ad,an,b,ndofpe) implicit real*8(a-h,o-z) c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c c c c c
Purposes: Symbolic sparse assembly Ifor symmetrical matrix) according to ODU sparse formats Author(s), Dated Version: Prof. Duc T. NGUYEN, June 1'2002
c
Input Parameters:
c c c c c c c c c
c c c c
c c c
nel
total Icumulative) number of finite elements (including all different element types ndof = total # degree-of-freedom (dof), including all Dirichlet b.c . ndofpenel ~ summation of (ndofpe type 1 * nel typel + ndofpe type2 * nel type2 + etc ... ) mtoti ~ available INTEGER words of memory ir(mtoti) ir(iebeg~l, , jebeg-l) same as ie(-) array ir(jebeg , , ibcbeg-l) same as je(-) array ir(ibcbeg, , ietbeg-l) Dirichlet b.c. ~ either 0 or 1 ~
iflag(40) unused for now ae{ndofpernax**2) ~ unused for now belndofpemax) = unused for now Imlndofpemax) = unused for now b(ndof) = unused for now ndofpe ~ # dof per element (correspond to a specific finite element
type
c c c c c c c c
c (sym. )
c c
c
Output Parameters: ir(mtoti) ir(ietbeg, , jetbeg-l) same as ie(-) transpose array ~ ir (j etbeg, , ipbeg-l) same as j e (-) transpose array = ir(ipbeg, , last-I) same as ip(-) array ia(ndof+l) starting location of FIRST' non-zero, off-diag. term for each row of the assembled sparse (symmetrical) matrix ja(ncoefl)
column numbers associated with non-zero terms on each row
where ncoefl
~
matrix ad(ndof) ~ unused for now an(ncoefl) = unused for now
ia(ndof+l)-l of the assembled sparse
Due T. Nguyen
c
b ln d o f)
c
Te mpo r ary
c
215
~
un u s e d fo r n ow (wo r k i ng)
i r (mtot i)
~
Pa r a me t e r s :
irliebe g ~ l ,
. . . • jeb eg - l, .. . , mt o t i )
c c ++++++++ + + + + + + + + + + + + ++ ++ ++ + +++ +t+ + + + + + + ++ + + + + + + + + + ++ + + ++ + +++ +t +++t+ + + + + + + + t
di me n si on ir( * ) , i fla g ( *} , a e (* ) , b e (* I ,l m( * ), i a ( *) , j a (* ) , a d( * } , a n ( * l , b ( * )
c i e be g ~ l
j eb e g ~i e beg + ( ne l +l l i bc beg ~ j e beg + l n d o f p e n e l) i e t beg ~ i bc beg +n do f j et beg ~ ie tbeg+ ( n d of + 1 ) i p beg ~ j e t b e g + (ndofp e ne l )
l a st~ ip beg+ nd of
i f (mt o ti . I t . l a s t ) t he n wr ite ( 6 , * )
' erro r : no t e noug h memory f or mt o t i
!!!'
end i f
c c
c opy bou ndary fl ag f or l a t e r u s a g e i n Du c' s s p a r s e s y mb o l i c as s e mb l y do 3 id,ndof i f ( i r (ibcbeg - l +i I . e q . 0 ia ( i ) ~ O i f ( ir(ibcbeg -l +i l . e q . 1 ia ( i )~ n d o f con t i nue
c wri t e( 6, * ) 'ju s t b e fo r e c a l l t r a n s a 2 : ie ( - ) ~ wr ite(6 , *) ( irl i ebe g - 1 +i ) , i =l. n el +l ) wr i teI6 , * ) 'j u s t be for e c a ll t r a n s a 2 : je ( - ) ~ wr ite 16 , * I (i r I j e b e g - 1+i) , i =l , ndo f p e ne l ) c a l l t r a nsa 2 1ne l , nd o f , i r ( i ebeg) , i r l j e be g ) , i r( i et b e g ) ,i r ( jetbeg » wr i t e I6 , * ) ' jus t a f ter call t r ansa2 : i e t( - ) ~ wri te ( 6 , * ) ( i rli e t b e g - 1+ i ) , i =l, nd of+ l ) wr i t e (6 , *) ' j u s t after cal l t r a n s a 2 : jet ( - )~ write ( 6 , *) ( i r ( j e t b e g - 1 +i ) , i =l , ndo f p e n e l ) wr it e ( 6 , *) ' *"'11" p as s e d t ransa2 ** *. spars e " s y mbo l i c" a ssembl y c a l l symba ss (ir (i ebeg ) , i r ( j e b e g l , i r( i e t b e g ) , i r ( j e t b e g l S , n d ot. i a , j a )
c c c c c c c c
c
nc o e f l ~ i a(n d o f + 1 ) - 1
wri t e (6 , ...l . .... .. pa s s ed s ymbass wr iteI 6 , * ) ' a f t e r s ymbass: ia ~ ' , ( ia( i) ,i~l,nd o f+ 1 writ eI 6 ,* ) 'a f ter s y mba s s: ja = ', ( j a ( i) , i ~ l , n co e f 1 wr i te ( 6 ,* ) ' af t e r s y mbas s: ncoef 1 = ' ,ncoef1 i nitia l ize be f ore nume ri c a l spa r se assembli ng do 9 5 j~ l,n c o e f1
c c c
c 95
c
)
)
a n l j) ~O .
i n i t ia l ize
do 6 i =l , ndof ad ( i l ~ O .
i r ( i pb e g - l +i l =O conti n u e
c r e t urn
end c@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
s ubr ou t i n e spars e a s s em2( n el, n d of,ndofp enel ,mt o t i, i r , i f1 a g, S ae , b e , l m, i a , j a , a d ,an , b , ndof pe l imp l ic it rea l* 8 Ia - h , o - z l C+ + ++ + + + + + + + + + + + + + + + + + + + + + + + +++ + + + ++ + + + + + + + + + + + + + + + + + + + + ++ + + + ++ ++ + + + ++ + + + + + +
c c c
c c
c c c c c c
Pu r p o s e s : Nume ri c al spars e a s sembl y (f o r symme t r ica l mat r i x ) a c cording t o ODU s pa rse for mat s Au t h or (s ) , Da ted Ve r s i on : Pr o f . Duc T . NGUYEN, June 1 ' 200 2 I np ut Pa ramete r s : ne l = t ot a l lcumu l a t iv e) n umber o f f in i te e leme n t s ( i nc l ud i ng al l di ffe r ent e lement t ypes n d of ~ t ota l # d e g r e e- o f -f reedom (d of ), includ ing a ll Dirich l et b . c . ndo f p ene l ~ summa t i on of (ndof p e type l * ne l type l + ndof p e typ e 2 * n el type2 + e t c .. . )
2 16
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
c c c c
mto t i ~ a v a i l a b l e I NTEGER words of memory .i r trnt o t i ) ir( i ebeg ~l , , j ebe g - l) same as i e ( - ) ar ray i r (j e beg , ibcbeg - l) same a s j e (- ) array ir( i b cbeg, , ietbeg- l) Di r ich l et b . c. ~ e i the r
o
or I
c c c c
i r (i etbeg , j e t b e g -l) same as ie( -) trans pos e array ir ( je tbe g , ipbeg - l } same a s j e ( - ) tran s pos e array ir(ipbeg, , last- I} s a me a s ip( - ) ar ray iflag(40) un us ed fo r n ow ae(ndofpemax ** 2) ~ e lemen t s ti f f n e s s matri x. sto r ed as l - d a rray (column- wise ) whe re nd o f p e ma x ~ ma x i mu m #d of p e r e leme n t ( fo r a l l e l. types ) be (ndo f pemax) equi valen t j o int loa d v ec tor ( i . e : di s t ri b u ted, pre s su re l o a d a c ting o n a n e lemen t) 1m (ndo fpe ma x) g loba l do f # assoc i a ted with ea c h elemen t b(ndof) ~ rhs vector; con t a i n s t he a pp l ied j oi nt loads "AND " kn own
c
c c c c c c c c val u e
c c
ndo f p e
~
o f DI RICHLE T b .c . # d o f p e r elemen t (c o r r e spond t o a specifi c f i n i t e el e me n t
t ype
c
i a (ndo f-r l )
c
c c
ja (ncoefl 1
s t a r ti n g l o c a t i o n of F I RST n on - z e r o. of f -diag . t erm f or ea c h row o f t he a s s e mbled spa r s e (s y mme t ri c al) matr i x co lumn number s as s o c i a t e d wi th no n - z e r o t e r ms on e a c h row where n c o e fl ~ ia (nd o f +l ) - l of the a s sembled s p a r s e
(s ym.l
c
matrix
c c
Out p u t Paramet er s : a d (ndo f ) ~ va lu e s o f di agona l t e rm s o f the as s embled s p a r se (sym )
c
mat rix
c
an (n c o e fl )
v a l ues o f o f f - d i a g o n a l , n on- z e r o t erms of the s p a r s e
(sym )
c
matrix
c b(ndo f) DIRI CHLET
c c c
"mo d i f i e d"
r hs v ect o r to inc lude "effec t s " o f kn own
b .c . o f DIRI CHLET b .c. Temporary (working) Pa r a me t er s: i r (mt o t i l ~ ir( i ebe g~ l , . . . . jebeg -l .
c
. . . . mt o t i )
c c++ ++ + ++~ ++ + + + + + + ++++++++ +++ + + ++++ +++++ ++ + + + + + +++ ++++ + + + + + + + + + + + + + + + + + + + + + + +
c $
di me n s i o n i r(') , ifl ag ( *) , a e( ') , b e ( ') ,lm ( ' ) , i a (*) . j a (. ) , a d ( . ) , a n ( * ) , b ( .)
c ie be g ~ l
j eb e g~ i e beg +( ne l +l } i bc b e g ~ j e b eg + (n dofp en e l l ie tb e g ~ i bc be g + n dof j etbe g ~ i e t be g+ ( n do f + l } ipbe g ~ j e t be g + (nd ofp e n e l ) la st~i pb e g + ndof
if (mt oti .It . l a s t) t h e n write(6 . * ) 'er r o r : not e n o ug h me mo ry f o r mt o t i end if
! ! !'
c c a l l num ass( i a.j a.i r( i b cbe g l , a e ,be , lm . n d ofpe . an . a d . b , i r( i pbe g l )
c re t urn end c@@@@@@@@ @@@ @@ @@@@@@ @@@@@ @@@@@@@@@@@@@@@@@@@@@@ @@@@ @@@@@@@@@ @@ c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Duc T . Nguyen
217
Table 4.7 Tran sposing a Sparse Matrix Table 4.7
C
Transpos ing a Sp arse Matr ix
C@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ c fi le = p art 2. o (onl y ob j e c t cod e s ) . subr outine t ransa2(n ,m . i a ,j a .iat ,jat ) dime ns ion ial * ) , j a ( * ) ,i a t (*) . j a t ( * )
c
10
20
30 40
C
50 60
MH=M +l NH=N+1 DO 1 0 1= 2 ,MH l AT( I) =O IAB = IA (NH) - 1 DO 2 0 I=I . I AB J =J A ( I ) +2 IF (J .LE .MH) IAT(J ) =I AT( J)+ 1 CONT I NUE I AT(I) =1 I AT ( 2 ) =1 I F (M. EQ. l ) GO TO 4 0 DO 3 0 I =3.MH IAT ( I ) =I AT II ) +IAT ( I -l) DO 60 I =l, N lAA =IA ( I ) I AB=I A ( 1 +1)-1 IF (IAB . LT .IAA1 GO TO 60 DO 5 0 JP=I AA, I AB J =JA(JP )+ 1 K=I AT (J ) JAT( K) =I ANT(K) =AN(JP ) I AT (J) =K+ l CONTI NUE return e nd
Table 4.8 Inputs and Outputs for Mixed (2-D Tru ss and Triangular) Sparse Assembly Process Date : June 1, 2002 nbay s, nstory, # real truss/faked triangular el. = 115 2 joint coordinates I O. 9.0000000000000 O. 2 12.0000000000000 9.0000000000000 O. 3 O. O. O. 4 12.0000000000000 O. O. elem ent connectivity node i&j I 12 3 4 2 12 5 6 3 347 8 4 127 8 5 345 6
218
ie
=
je =
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
1 5 9 13 17 21 27 33 I 2 34 125 6 3 4 7 8 I 2 7 8 34 5 6 I 2 5 6
34345678 ibdof = 5 6 7 8 * * * passed transa2 * * * ************************ ************************ * * * passed symbass * * * elem # 1* * * passed elstiff * * * elem # 1* * * passed numass * * * elem # 5* * * passed elstiff * * * elem # 5* * * passed numass * * * elem # 1* * * passed numass * * * elem # 2* * * passed numass * * * ndof, ncoefl = 8 6 ia(ndof + 1) = ja(ncoefl) = ad(ndof) =
14 6 7 7 7 7 7 7 2 34 34 4 2.1260000000000 4.1351111111111 2.1260000000000
16.1351111111111 1.0000000000000 1.0000000000000 1.0000000000000 1.0000000000000
an(ncoefl) =
2.9680000000000 5.9166666666667 7.0000000000000
7.0000000000000 8.0000000000000 14.0320000000000
b(ndof) =
i .0000000000000 2.0000000000000 3.0000000000000
4.0000000000000 O. O. O. O. real user sys
0.0 0.0 0.0
Duc T. Nguyen
219
4.7 A Simple Finite Element Model (Unsymmetrical Matrices) In this section, three different algorithms for general and efficient sparse assembly of a system of finite-element-based , unsymmetrical equations are presented. These three unsymmetrical sparse assembly algorithms will be incorporated into different unsymmetrical sparse solvers such as the ones developed by I. Duff's group [3.2, 3.6, 3.7], by D. Nguyen's team [1.9], and by SOl library subroutines [3.1). METIS re-ordering algorithms [3.3], for minimizing the fill-in terms , symbolic factorization, numerical factorizations, master degree-of-freedom, are also discussed. Simple examples are used to facilitate the discussions, and medium-to large-scale examples are used to evaluate the numerical performance of different algorithms. To facilitate the discussions, a simple/academic finite element model that consists of four rectangular elements, with I degree-of-freedom (dot) per node, and its loading condition (R), is shown in Figure 4.5. There are 4 dof per element (ndofpe = 4).
G>
CD 3
G)
@
Figure 4.5 a Simple, Unconstrained Finite Element Model The global dof, associated with each of the eth rectangular element (see Figure 4.5), are given by the following "elernent-dof" connectivity matrix [E], as follows: 2 [E]=
1 2
3 4
x x x
3 x x x x
4
5
6 x
x
7
8
9
x
(4.40)
x x
x x
x
x
In Eq.(4.40), the number of rows and columns will correspond to the number of (finite) elements, (NEL = 4) and number of dof, (NDOF = 9) respectively. Using the sparse storage scheme, matrix [E] in Eq.(4.40) can be described by the following two integer arrays:
220
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
IE
IE
1
1
2
5
3
9
4
13
5= NEL+l
17
(4.41)
1
3
2
8
3
1
4
6
5
7
6
3
7
2
8
4
9
5
10
2
11
3
12
6
13 14
9
15
8
16= NEL*ndofpe
(4.42)
7
3
Thus, Eq.(4.41) gives the starting location of the first non-zero term for each row of matrix [E) while Eq.(4.42) contains the global dof associated with each e th (= 1,2,3, 4) rectangular element. The transpose of the matrix [E) can be given as:
Due T. Nguyen
1
221
3
x
x
x
x
x
x
5
x
x x
7 8
(4.43 )
x
x
4
6
4
x
2 3
2
x
x
x x
9
which can be described by the following two integer arrays:
IE
1
1
2
2
3
4
4
8
5
9
6
10
7
12
8
14
9 10= NDOF+l
16
17 .
(4.44)
222
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solution s
1
JET
2
2
3
3
4
1
5
2
6
3
7
4 8
9
2 3
10
1
11
3
12
2
13
4 14
1
15
4
16
(4.45)
4
The "exact" numerical values for the 4x 4 (rectangular) element stiffness matrix [ELK] are "unimportant" at this stage of the discussion, and therefore is assumed to be given by the following formula: (4.46) ELK(i,j) =(i + j) * iel and for i =1= j, then ELK(j,i) = -ELK(i,j)
(4.47)
In Eqs.(4.46 and 4.47), i.j = 1, 2,3,4 and iel = rectangular element number (= I, 2, 3 or 4) Thus, according to Eqs.(4.46, 4.47), element stiffness matrix for rectangular elements Q) is given as: [ELK
8 10] 8 10 12 l=[_23 ~ ~ 5]6 *(ie1=2) =[-64 6 -4 -5
6
7 -5 - 6 - 7 8
- 8 - 10 12 14 - 10 - 12 -14 16
(4.48)
Duc T. Nguyen
223
Hence, the "simulated" elements stiffness matrix, given by Eq.(4.48), is unsymmetrical in value, but it is still symmetrical in location! Following the usual finite element procedures, the system of linear, unsymmetrical equations can be assembled as: [KHZ} = {R} (4.49) where 1 1
~
2 [K]=
2
3
4
5
6
-4
~
5
-9
18
-8
12
-12
26
-26
-25
-24
F
F
-10
F
F
15
F
F
F
~
F
-6
F
16
12
-16
~
-20
-12
20
4
-14
-12
5
9
12
~
-18
-26
-15
8
26
6
-7
7
8 9
5
9
14
~
4
8 -5
7
-5
3
7
~
10
25
6
24
~
(4.50)
~
4 44 10
-20
{R}= 42 -40
(4.51)
84 28 48 The hand-calculator solution for Eqs.(4.49 - 4.51) is: {ZIT={1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}
(4.52)
which have been independently confirmed by the developed computer program, shown in Table 4.9. Remarks
For the upper-triangluar portion of Eq.(4.50), there are nine fill-in terms, denoted by the symbols F (fill-in terms are NOT shown for the lower-triangular portion, although they also exist!).
224
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
4.8 Re-Ordering Algorithms
In order to minimize the number of fill-in terms during the symbolic and numerical factorization phases, re-ordering algorithms such as MMO , NO, and METIS [3.4, 4.1 ,3.3] can be used . In this work , METIS re-ordering algorithm is selected due to its low memory and low number of fill-in requirements. For the example shown in Figure 4.5, one needs to prepare the following two adjacency (integer) input arrays for METIS
lAD]
1, 4, 9, 17, 23, 28, 33, 38, 41
={ 20,
JADJ = []J],
p, 3, 4, 5, 6~
~ ~,8, 1,5,
2j,
(4.53)
~,1, 6, 7, 2, 4, 5, 9~
I[U,
13,2,4,9,81,
13,1,6,7,
(4.54)
9j,
~ NOOE(orOOF) =
1,
2, 3, 4,
~
6, 7,
8,
(4.55)
{
Equation (4.55) represents the node (or dot) number of the finite element model. Eq.(4.54) represents the node (or dot) numbers connected to the ith node , and Eq.(4.53) contains the starting locations associated with the array lAOJ. The output of METIS, for example, will be given by the following two integer arrays :
2
5 1
3
6
4
9
IPERM 5
4
6
7 8
1
7 8 9
(4.56)
3 2
or IPERM (old numbering dof system) = {new numb ering dof system} (4.57)
Duc T . Nguyen
225
and
INVP
1
2
2
9
3
8
4
5
5
1
6
3
7
6
8
7
9
4
(4.58)
or INVP(new numbering dof system)={ old numbering dof system} (4.59)
Using the array IPERM(-), shown in Eq.(4.56), the system matrix [K], shown in Eq.(4.50), can be re-arran ged as:
1 1
[K metis]=
~
2
4
~
3
-20
~
5
~
-5
5 -5
7
-18
8
8
9
-14
-24
12
6
7
8
9
5
18
-8
14
24
20
9
6
5
-9
2
4
3
~
25
6
-16
12
15
F
-4
7
F
26
-26
12
F
F
-25
-12
4
~
-6
-15
-7
-26
16
-12
~
26
~
-12
-10
(4.60)
F
10
~
Similarly, the system right-h and-side load vector {R}, shown in Eq.(4.51), can be rearranged as:
226
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
44 48
28
42 [Rmetis]=
4
(4.61)
10
-40 84
-20 Remarks
For the upper-triangular portion of Eq.(4.60), there will be five fill-in terms, denoted by the symbol F, upon completing the numerical factorization phase.
Using Eq.(4.56) for the array IPERM(-), Eqs.(4.40-4.45) will become Eqs.(4.624.67): 1 [E rnetis]=
2
I
4
x
2
x
3
x
4
3
5
6
7
x
x
X
x x x
x
x
x
1
1
2
5
IE metis 3
9
4
13
5
17
8
9
x
x
(4.62)
X x
(4.63)
227
Due T. Nguyen
1
6
2
3
3
5
4
7
5
8
6
6
7
1
8 JEmetis =
1 1
9
=
9 4
10
1
11
6
12
7
13
8
14
2
15
3
16
6
2
3
x
X
2 [ETmetis]=
3
(4.64)
4
x x
x
4
X
5
x
6
x
7
x
x
X
x
X
8
x
9
x
x
(4.65)
228
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
1
1
2
3
3
4
4
6
5 IETmetis
7
=
6
8
(4.66)
7
12
8
14
9
16
10
17
1
2
2
3 3
4
4
1
5
4
3
6 7
1 8
[JETmeti s ] =
9
1
=
2
10
3
11
4
12
1
13
3
16
14
2
15
4 2
(4.67)
Due T. Nguyen
229
4.9 Imposing Dirichlet Boundary Conditions
Assuming the following Dirichlet boundary conditions are imposed at dof 2, 4, 5 (see Figure 4.5):
(4.68)
and the corresponding right-hand-side load (and prescribed Dirichlet boundary conditions) vector {R} becomes:
{J~{~.::}
(4.69)
Then Eqs.(4.60 - 4.61) will become:
1
1
[Kmetis, be)
=
r-.
2
2
~
3
-20
3
6
~ -5
-24
7 8 9
12
5
20
4 5
4
6
24
r-,
5
r-,
6
-4
7 26
4
~
-6
-7
-26 26
8
9
-12
25
-25
16
7
~
-16
(4.70)
-26
~
r-,
230
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
0.2' 48 K
28 K
0.5'''
{R metis .bc } =
4K 12.2 K -28.9 K
(4.71)
7804 K 004' It should be mentioned that fill-in terms associated with Eq.(4.70) are NOT shown
here.
The hand-calculator solution of [K mctis, be] *{Zmctis, be} = {Rmctis, be }
(4.72)
can be given as: {Zmetis, belT= {0.2, 0.975, 0.996, 0.5, 1.575, 1.265,0.656, 1.490, 0.4 1 (4.73)
which have been independently confirmed by the developed computer program shown in Table 4.9. Table 4.9 Unsymmetrical Sparse Assembly c
Table 4.9 Unsymmetrical Sparse Assembly
c c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine part Iunsym implicit real *8(a-h,0-z)
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c c c c c c c c
purpose : d.t. nguyen's general , unsymmetrical sparse assembly version : November 12, 2002 author : Prof. Due T. Nguyen (Email=
[email protected]) notes: these files (part1unsym.f, part2unsym.t) are stored under sub-directory -/ceelnewfem/*complete*sparse*/ Please do "NOT" distribute this source code to anyone without explicit written agreement by Prof. D.T. Nguyen
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dimen sion ie(looO)je(4000),iet(l000)jet(4000) dimension ia(l OOO)ja(40(0),iakeep(l 000) dimension iakeept(l OOO)jat(4000),ibc(l 000) dimension elk(4,4),ae(l6),be(4),Im(4) dimension b(l Ooo),an(4ooo),ip( 1000),ant(4000) dimension iakepp(l ooo),jj(40oo),aa( 4000) dimension index( 1ooO),itempo 1(I OOO),tempo I(1000)
Due T. Nguyen
dimension dimension dimension dimension dimension
ipermt l OOO),invp(l000) ikeep(l OOO,5),iw(1000,8),w(l 000) ! required by ma28 ad(l 000),an2(4000),x(l OOO),iut(lOOO),jut(4000) ! Duc-Pierrot idir(I000),isupd(l000),iu(1000),ju(4000) ! Duc-Pierrot di(l000),un(4000),iup(l000),un2(4000),di2(l000) ! Duc-Pierrot
c write(6,*) **************************' write(6,*)' version: November 12,2002 ' write(6,*) I ************************** I I
c read(5,*) nel,ndof,ndofpe,method,nbc,metis,iunsolver c ..... .input finite element mesh (connectivities) call femesh(nel,ndofpe,ie,je) ! from Willie write(6, *) 'nel,ndof,ndofpe,method,nbc,metis,iunsolver= ' write(6, *) nel,ndof,ndofpe,method,nbc,metis,iunsolver write(6, *) 'method = I = sorting column # by sparse TRANSPOSE' write(6, *) , 2 = sorting column # by SORTING' write(6,*) 'iunsolver = I = Duff's unsymmetrical sparse algo' write(6,*)' = 2 = Duc-Pierrot"s unsym sparse solver' write(6, *) , = 3 = SGI library unsym sparse solver' write(6,*) 'ie= ',(ie(i),i=l,nel+l) write(6, *) Je= ',(je(i),i=l,nel*ndofpe) c ..... .input "system" rhs load vector(s) call rhsJoad(ndof,b) ! from Willie c applying boundary conditions call boundaryc(ndof,ibc,nbc,b) from Willie
c call transa2(nel,ndof,ie,je,iet,jet) write(6, *) 'iet= ',(iet(i),i= I ,ndof+1) write(6, *) 'jet= ',(jet(i),i=1 ,nel*ndofpe) c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c use METIS or not ?? do 11 i= I .ndof ipermtijei invp(i)=i II continue if (metis .eq. I) then call adjacency(ie,je,iet,jet,ndof,ia,ja,iakeep) write(6,*) 'iakeep(-)= ',(iakeep(i),i=l,ndof+1) jcount=iakeep(ndof+ I )-1 write(6, *) 'ja( -)= ',(ja(i),i=l,jcount) call metisreord(ndof,iakeep,ja,ipeffil,invp) write(6,*) 'ipermt-)= ',(ipeffil(i),i= I .ndof) c arrays je(-), and iet( -), jet(-) need be re-defined (due to lPERM) icount=nel*ndofpe do 12 i- I .icount itempo I (j)=je(j) 12 continue c call newje(itempo I .iperm.icount.je) write(6,*) 'ie= ',(ie(i),i= I ,nel+ I) write(6,*) 'je(-)= ',(je(i),i=I,nel*ndofpe) call transa2(nel,ndof,ie,je,iet,jet) write(6, *) 'iet= ',(iet(i),i=l,ndof+ I) write(6, *) 'jet= ',(jet(i),i=l,nel*ndofpe) c rhs load vector {b}, & Dirichlet be need be re-defined (due to lPERM) do 16j=l,ndof iakepp(j)=ibc(j) 16 tempol(j)=b(j)
231
232
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
do 17 j= I ,ndof newe ipermtj) b(new)= tem po l (j) ibc (new)=iakepp(j) 17 co ntinue endif c++++++++++++++++++++ ++++++++ +++ ++++ +++ +++++++++++++++++ +++ c nguyen' s unsymmetric symbo lic sparse asse mbly do 42 i= l, ndof+ 1 ia(i)=O 42 iakee p(i)= O do 43 i= 1,4000 ! at this moment , di mension of ja (-) is unkn own ? 43 ja(i)=O if (iunso lver .ne. 2) then ca ll symbass(ie,j e,iel,je t,ndof,ia,ja,iake ep,ibc) c ncoefl =iakeep(ndof+ I )-iak eep( I) write(6, *) 'iakeep(ndof+ l)= ',(iakeep(i),i= I ,ndof+ I) wrile(6,*) 'ja(ncoefl)= ',(ja(i),i= I ,ncoe fl) c ......nguy en's unsymmetric numeri cal sparse asse mbly ca ll unsymasem(ibc,ncoefl ,an,ip,ndof,nel,elk ,be ,ndofpe, $Im,j e,ae,iakeep,ja,b,nbc) c write(6, *) 'rh s load = ',(b(i),i=I ,ndof) c elseif (iuns olver .eq. 2) then c unsym sparse ass embly by Duc-Pierrot's forma ls do 77 i= I ,ndof ia( i)=ibc( i) 77 continue ca ll symbassym(ie,je,iel,jel,ndof,iaja) write(6, *) 'duc-pierrot ia(-)= ',(ia(i),i= I,ndof+ I) ncoefl =ia(ndof+ 1)- 1 wrile(6, *) 'duc-pierrot ja( -)= ',(ja(i),i= I ,ncoefl )
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c do 93 i= I ,ncoefl an2(i) =0 . 93 an(i)= O.
c 92
do 92 i= l, ndo f ip(i)= O
C
c
icou nl=O do 94 i= l,nel ca ll elunsym(i,elk,ndofpe,be,lm,je,ae) ! from Willie write(6,*) 'el# = ',i,' UNSYM . row-wise elk(4,4)= ' write(6,8) «elk(ir,jc),jc=1 ,4),ir=I,4) 8 forma t(2x,4(e 13.6,1 x) write(6 ,*) 'el# = ',i,' UNSYM . col-wise elk(4,4)= ' do 88 jce l ,4 istart=(jc- I )*ndo fpe+ I iend=jc *ndo fpe write(6 ,8) (aet irj.ire istan .iend) 88 continue
C
ca ll numassun s(iaj a,ibc ,ae,be,lm,ndofpe,an, ad ,b,ip ,an2,itempo I)
c 94 c c
continue call transag ain(ndof,ndof,iaja,iakee p,ja l,an,a nt) call 1ransag ain(ndof, ndof,ia,ja,iakcepjal,an2,aa)
Due T. Nguyen
c
write(6,*) 'before symfact ia(-)= ',(ia(i),i=l,ndof+l) write(6,*) 'before symfact ja( -)= ',(ja(i),i=1 ,ncoefl) call symfact(ndof,ia,ja,iu,ju,ip,ncoef2) write(6,*) 'duc-pierrot iu( -)= ',(iu(i),i= I ,ndof+ I) write(6, *) 'duc-pierrot ju(-)= ',(ju(i),i=1 ,ncoef2) call transa(ndof,ndof,iu,ju,iut,jut) ! TWICE, but no real numbers write(6,*) 'after transa TWICE iu(-)= ',(iu(i),i=l,ndof+l) write(6, *) 'aftertransa TWICE ju( -)= ',(ju(i),i= I ,ncoef2) call supnode(n,iu,ju,isupern)
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c write(6, *) 'an(ncoefl) = ',(an(i),i=1 ,ncoefl) write(6,*) 'an2(ncoefl) = ',(an2(i),i=l,ncoefl) write(6, *) 'ad(ndof)= ',(ad(i),i= I ,ndof) endif c ordering column numbers (of each row) in ascending orders if (method .eq. 2) then c ....... using "sorting" ideas! if (iunsolver .ne. 2) then call sorting(ndof,iu,itempol,ju,tempol,index,b,an) 'here an=upper+lower elseif (iunsolver .eq. 2) then call sortingan2(ndof,iu,itempo I ,ju,tempo I ,index, ! here aneupper $ b,an,an2,x) , an2=lower endif c ....... using "sparse transposing" ideas! elseif (method .eq. I) then if (iunsolver .ne. 2) then call transa2m(ndof,ndof,iakeep,ja,iakepp,jat,an,ant)' here aneupper-rlower elseif (iunsolver .eq. 2) then call transa2m(ndof,ndof,iakeep,ja,iakepp,jat,an2,aa)! here an2=lower endif endif write(6,*) 'an(ncoefl) = ',(an(i),i=l,ncoefl) write(6,*) 'an2(ncoefl) = ',(an2(i),i=l,ncoefl) write(6, *) 'ad(ndof)= ',(ad(i),i=1 ,ndof) c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ if (iunsolver .eq. I) then c...... get unsym. matrix [A} in MA28's (row,column) formats call rownuma28(iakeep,ndof,iakepp) nz=iakeep(ndof+ I )-1 Iicn=4*nz lirne licn u=O. write(6,*) 'ndof,nz,licn,lirn,u = ',ndof,nz,licn,lirn,u write(6,*) 'irn(-)= ',(iakepp(i),i=l,nz) write(6, *) 'icn( -)= ',(ja(i),i=l ,nz) write(6,*)' b(-)= ',( b(i),i=l,ndof) c ......no need tonumbers in increasing order before using ma28 ? c call transa2m(ndof,ndof,iakeep,ja,itempo I ,jat,an,ant) c call transa2m(ndof,ndof,itempol ,jat,iakeep,ja,ant,an) c write(6,*) 'irn(-)= ',(iakepp(i),i=l,nz) c write(6,*) 'icn(-)= ',(ja(i),i=l,nz) c ...... LU factorization write(6,*)' an(-)= ',( an(i),i=l,nz) call ma28ad(ndof,nz,an,licn,iakepp,lirn,ja,u,ikeep,iw, $w,iflag) write( 6, *) 'passed ma28ad' c ......forward-backward solution phases nrhs=1 mtypee l
233
234
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
do 62 i= I,lIrhS call ma28cd(ndof,all,licn,ja.ikeep.b,w.mtype) writetfi,*) 'passed ma28cd' 62 continue c print solutions writeto ,*) 'unknown» '.(b(i). i= l .ndof) elseif (iunsolver .eq. 2) then c get unsym. matrix [A) in Duc-Pierrot's ODU-NASA unsym. formats do 80 i=l .ndof isupd(i)= 1 80 continue write(6.*) 'just before call unsynumfaJ' call unsynumfa l (ndof.iaja.ad.an.iu.ju.di.un.ip.iup, $ isupd,an2,un2,di2) writeto ,*) 'just before call unsyfbe' call unsyfbemdof.iu.ju.di.un.b.x.unz) write(6.*) 'j ust after call unsyfbe' writctfi,*) 'unknown x(-)= '.(x(i).i= I.nd of)
c elseif (iunsolver .eq. 3) then c......get unsym. matrix [A) in SGl's column-wise formats c call SGllibrary routine for unsym. sparse solver. c based on input arrays previously generated: c iakeppt -j. jan -), ant(-) writeto,") 'SGl : iakepp (-)= '.(iakepp(i),i=l .ndof+l ) write(6,*) 'SGl: jat (-)= '.(jat(i).i= Lncoef'l ) write(6.*) 'SGl : ante-)= ',(ant(i).i= I.ncoef l ) endif c+++++++++++++++++++++ ++++++++ ++++++++++++++++++++ ++++++++++++++++++++
c estop return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine supnodetn.ista rtr.kindx.isupern) c implicit real*8(a-h,o-z) c ......purposes: identify the rows which have same non-zero pau em s c...... (i.e. same column numbers lined up) for "unrolling" dimension istartr(l ),kindx(l ),isupern(l ) c......initialize super node integer array do 1 i= l ,n 1 isupern(i)=1 c......meaning of variable "iamok" = 0 (= NOT having same non-zero pau erns) c...... = 1 (= DOES have same non-zero patterns) c do 2 i=2.n- l d02 i=2.n c iamok=O iamok= 1 c check to see if i-th row has the same # nonzeroes as (i-I )-th row c also.check to see if the (i- I)-th row have a non-zero right above c...... the diagonal of the i-th row c .if the i-th row does NOT have the same "GENERAL" non-zero patterns. c then, skip loop 2 immediately (no need 10 check any furthers !) kptrsi=istartr(i+1)-istartr(i) kptrsimI=istartr(i)-istartr(i-I ) c if(kptrs(i).ne.kptrs(i-I )-1) go to 2 if(kptrsi.ne.kptrsim1-1) go to 2 iieis tartrti -I) if(kindx(ii).ne.i) go to 2 c......now. check to see if the i-th row and the (i- I )-th row have the
Due T . Nguyen
235
c c
same "DETAILED" non-zero patterns write(6,*) 'check point I' iii=istartr(i) jje ii ili=i ii-I c do 3 j= I,kptrs(i) do 3 j= I,kptrsi jj=jj+1 ili=ili+ I if(kindx(jj).ne.kindx(jjj» then iamok=O c write(6,*) 'check point 2' go to 222 else iamok=1 c write(6, *) 'check point 3' endif 3 continue c if(kindx(ii).eq.n) iamoke l c.....j f all"DETAILED" non-zero patterns also match, then we have "supernode" 222 if(iamok .eq.l) then isupern(i)=O c write(6,*) 'check point 4' endif 2 continue c finally, establish how many rows a supernode has (based on the I's, c and the O's of the array isupem( -) obtained thus far) icount=O do II i=2,n c.......counting the number of zeroes encountered in array isupem (-) if(isupern(i) .eq.O)then icount=icount+ I c write(6,*) 'check point 5' else ithrow=i-I -icount isupern(ithrow)=icount+ I icount=O c write(6,*) 'check point 6' endif II continue c......now, take care of the last super node ithrow=n-icount isupern(ithrow)=icount+ I return end
C%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine symfact(n,ia,ja,iu,ju,ip,ncoef2) implicit real*8(a-h,0-z) dimension ia(*),ja(*),iu(*),ju( *),ip(*) C......Purposes : Symbolic factorization c input : ia(n+l),ja(ncoefl ) structure of given matrix A in RR(U)U. c...... ia(n+ I) starting location of l -st non-zero term c n order of matrix A and of matrix U. c...... ncoef'l = ia(n+ I)-I c output : iu(n+ l) j u(ncoef2) structure ofresulting matrix U in RR(U)U. c working space: ip(n) of dimension N. Chained lists of rows c associated with each column. c The array IU is also used as the multiple c switch array. NM=N-l c
236
Finite Element Method s: Parallel-Sparse Statics and Eigen-Solutions
NH=N+I DO IOI =I ,N IU(I)=O 10 IP(I)=O JP=I DO 90 I=I ,NM JPI=JP JPP=N+JP-I MIN=NH IAA=IA(I) IAB=IA(I+1)-1 c write(6,*) 'SYMFACT: i.nm.jpi.jp.n.jpp .min.iaa.iab = ' c write(6,*) i.nm.jpi.jp.n.jpp.min.iaa.iab IF(lAB.LT.IAA)GO TO 30 DO 20 J=IAA,IAB JJ=JA(J) JU(JP)=JJ c write(6,*) 'SYMFACT:insid eloop20: jjj,jp,ju(jp),min =' c write(6,*) j,jj,jp,ju(jp),min JP=JP+ I c write(6,*) 'SYMFACT:insideloop20: j,jjjpj u(jp),min =' c write(6,*) j,jjjp,ju(jp),min c IF(JJ.LT.MIN)MIN=JJ IF(JJ.LT.MIN) then min=jj c write(6,*) 'SYMFACT:inside]oop20: min =' c write(6,*) min endif c 20 IU(JJ)=I IU(JJ)=I c write(6,*) 'SYMFACT:insideloop20:jj,iu(jj),i = ' c write(6,*) jj,iu(jj),i 20 continue 30 LAST=IP(I) c write(6,*) 'SYMFACT: i,ip(i),last = ' c wrile(6,*) i,ip(i),last IF(LAST.EQ.O)GO TO 60 L=LAST 40 L=IP(L) LH=L+I IUA=IU(L) IUB=IU(LH)-I c write(6,*) 'SYMFACT: last,l,ip(l),lh,iu(l),iua,iu(lh),iub =' c write(6,*) last,I,ip(l),lh,iu(l),iua,iu(lh),iub c IF(LH.EQ.I)IUB=JPI-I IF(LH.EQ.I) then iubej pi-I c write(6,*) 'SYMFACT: Ih.ijpi.iub =' c write(6,*) Ih,i,jpi,iub endif IU(I)=I c write(6,*) 'SYMFACT: i,iu(i) = ' c write(6,*) i,iu(i) DO 50 J=IUA,IUB JJ=JU(J) c write(6,*) 'SYMFACT:insideloop50: j,iua,iub,ju(j)jj ,iu(jj),i = ' c write(6,*) j,iua,iubju(j)jj,iu(jj),i IF(lU(JJ).EQ.I)GO TO 50 JU(JP)=JJ c write(6,*) 'SYMFACT:insideloop50: jp,ju(jp)= '
Due T. Nguyen
237
c
write(6 ,*) jpju(jp) I P=l P+1 IU(11)=1 c write(6 ,*) 'SYM FACT :inside loop50: j p,jj ,iu(jj) ,i= ' c write(6,*) jp.jj .iutjj j.i c IF(l l.LT.MIN)MIN=ll IF(ll .LT.MIN) then c wrile(6 ,*) 'SYM FACT:inside]oop50 : jj. min = 'jj,min mine jj c wrile(6,*) 'SYMFACT:insid eloop50: jj ,min = ',jj,min endif 50 CONTINUE c write(6,*) 'SYM FACT : jp.jpp.l.last.min.nh = ' c wrile(6, *) j p.jpp.l.last.rnin.nh IF(1P.EQ.lPP)GO TO 70 IF(L.NE .LAST)GO TO 40 60 IF(MIN .EQ .NH)GO TO 90 70 L=IP (MIN) c writc(6,*) 'SYMFACT: min,ip(min),1 = ' c write(6, *) min,ip(min),1 IF(L.EQ .O)GO TO 80 IP(I)=IP(L) c write(6,*) 'SYMFACT: I,ip(l), i,ip(i) =' c wri tc(6, *) I,ip(l),i,ip(i ) IP(L)=I c wri te(6,*) 'SYMFACT: I,ip(l),i,ip(i) = ' c wrile(6,*) l,ip(I),i,ip(i) GO TO 90 80 IP(MIN )=I IP(I)=I c write(6, *) 'SYM FACT : min,ip(min),i,ip(i) =' c writc(6, *) min,ip (min),i,ip(i) 90 IV (I)=l PI IU(N)=l P IU(NH)=lP c wri te(6, *) 'SY MFACT: i,iu(i),j pi,n,iu(n),jp,nh,iu(nh) = ' c writc(6,*) i,iu(i)jpi,n,iu(n),jp,nh,iu(nh) ncoef2=iu (n+ I )-I write(6,*) 'inside symfact: ncoef2= " ncoef2
return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine rownuma28(ia,ndof,irow) dim ension ia(*),irow(*)
c
2 I
do I i=I,ndof istart=ia(i) iend=ia(i+ 1)-1 do 2 jeistart.iend irow(j)=i continue continue
return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine elunsym(iel,elk,ndofpe,be,lm,je,ae) ! from Will ie implicit real*8(a-h,o-z) dimen sion elk(ndofpe ,ndofpe) dimen sion be(*),lm(*)je(*),ae(*) c......purp ose: generate "FA KED" unsym . elemenl stiffness
238
2 1 c
Finite Element Meth ods: Parallel-Sparse Statics and Eigen-Solution s
do 1 i- l .ndofpe do 2 j- i.ndotpe elk(i.j)=(i+j)*iel if (i .ne. j) then elk(j,i)=-elk(i,j) endif continue continue
jcou nt=O do 13 k=1,ndofpe be(k)=O. icount=icount+1 lm(k)=je (icount) 13 continue c do 28 ic= 1,ndofpe do 29 ir=1,ndofpe jco unt=jcount+1 ae(jcount)=elk(ir,ic) 29 continue 28 continue return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine ferneshtn el.ndofpe.ie.je) dimension ie(*)j e(*) rcad(S.*) (ie(i),i= 1,nel+ I ) readtfi,") (je(i),i= ],nel*ndofpe) return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine rhsload(ndof,b) implicit real*8(a-h,0-z) dimension b(*)
c-------------------c do 22 i=1,ndof c22 b(i)=i c-------------------c such that unknown displ. vector = ( 1.0. 1.0, ...• 1.0} b(l)=4.0 b(2)=44 .0 b(3)= 10.0 b(4)=-20.0 b(S)=42.0 b(6)=-40.0 b(7)=84.0 b(8)=28.0 b(9)=48.0
c------------------return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine boundaryctnd of.ibc.nbc.b) implicit real*8(a-h,0-z) dimension ibc(*),b(*) c......assuming no boundary conditions ----» answers are correct do 1 i=1,ndof 1 ibc(i)=O c......applied boundary conditi ons ----» answers are» ALSO " correct! !
Due T. Nguyen
239
if (nbc .ne. 0) then ibc(2)=ndof ibc(4)=ndof ibc(5)=ndof b(2)=O.2 b(4)=OA b(5)=O.5 endif return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
c c c c
subroutine unsyma sem(ibc,ncoefl ,an,ip,ndof,nel,elk,be,ndofpe, $ Im,je,ae,iakeep,ja,b,nbc) implicit real*8(a-h,o -z) dimension ibc(*),an(*),ip(*),elk(ndofpc,ndofpe),be(*), $ Im(*),je(*),ae(*),iakeep( *)ja(*),b(*) if (nbc .ne. 0) then applied boundary conditions ----» answers are "ALSO" correct !! ibc(2)= I ! should be consistent, such as ibc(2)=ndof ibc(4) =1 ! hence, we should NOT need these 3 stmts ibc(5)= 1 cndif
c 43
do 43 i=1,ncoefl an(i)=O.
c 42
do 42 i= I ,ndof ip(i)=O
c icount=O do 12 ie I.n el call cluns ym(i,elk ,ndofpe,be,lmje,ae)
! from Willie
c call unnuma ss(iakeepja,ibc,ae,be,lm,ndofpe ,an,b,ip) c write(6 ,*) 'el# = 'J,' UNSYM . elk(4 ,4)= ' write(6,8) «elk(ir,jc),jc= I A ),ir= 1,4) 8 format( 2x,4(eJ3.6,1x) 12 continue return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine sorting(ndof,iakeep ,itempo 1j a,tempo 1.index.b.an) implicit real*8(a-h,o-z) dimension iakeep(*),itempol (*)ja(*),tcmpo I(*),index(*),b(*) dimension an(*) writer6,*) '-------------------------------' write(6,*) 'use method = 2 = sorting' writer6,*) '-------------------------------' do 34 irowe l ,ndof jbeg=iakeep(irow) jend=iakeep(irow+1)-1 ncol=iakeep (irow+ I)-iakeep(irow) do 35 icol=1,ncol itempol (icol)=ja(jbeg+icol-I) tempo I (icol)=an(jbeg+icol- I) 35 cont inue call indexi(ncol,itempo I.index) call sorti(ncol,itempol .index.jatjbeg) call sortr(ncol, ternpo l .index.antjbeg)
240
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
34 continu e c output row-by-row do 48 irow= I ,ndof jb eg=iakeep(irow) jend=iakee p(irow+ 1)- J write(6,*) 'irow,jbeg ,jend = ',irow,jbegj end write{6,*) 'an row-wise = ',(an(j)j=jb egjend) write{6,*) 'rhs load = ',b(irow) 48 continue return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine sortingan2{ndof,iakee p,itempo I ,ja,tempo I.index, $ b,an,an2,x) implicit real*8{a-h,o-z) dimen sion iakeep( *),itemp o I(*)j a(*),tempo I (*),index(*),b(*) dimension an(*),an2( *),x(*) write(6,*) '-------------------------------' write(6, *) 'use method = 2 = sorting' write(6,*) •------------------------.••.•. •• do 34 irow= I ,ndof jbegeiakeepurow) jend= iakeep{irow+ I )-1 ncol=iakeep (irow+ I )-iakeep{irow) do 35 icol=l ,ncoI itemp ol (icol)=ja{jbeg+icol- I) tempol{i col)= an(jbeg+icol-I) x{icol)=a n2(jbeg+icol- I) 35 continue call index i{ncol,itempo I ,index) call sortitncol.itempo I.index.jatjbeg) call sortr{ncol, tempo I.index.antjbeg) call sortr{ncol, x.index.anztjbeg) 34 continue c......output row-by-row do 48 irow= I ,ndof jb eg=iakeep(iro w) jend=iakeep(irow+ I )-1 write{6,*) 'irow,jbegjend = ',irow,j beg,jend write{6,*) 'an row-wise = ',(an(j)j =jbeg,jend) write{6,*) 'an2 col-wi se = ',(an2(j),j=jb eg,jend ) write{6,*) 'rhs load = ',b{irow) 48 co ntinue return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine transpose(ndof,iakeepja,iakeeptjat,an,ant,b,aa) implicit real*8{a-h,o-z) dimen sion iakeep{*),ja{*),iakeept{*),jat(*),an{*),ant{*),b(*) dimension aa{*) write(6,*) '-------------------------------' write{6,*) 'use method = I = transa' write{6,*) '---------------------.. _.._----'
c call transa2m{ndof,ndof,iakeep j a,iakeept ,jal,an,ant ) call transa2m{ndof,ndof,iakeept,jat,iakepp,jj,ant,aa ) c......output row-by-row do 32 irow= I ,ndof jbegei akeept irow)
Due T. Nguyen
jen d=iakeep(irow + I )-1 write(6, *) 'iro wjbegjend = ',irowjbeg,je nd write(6,*) 'an row -wise = ',(aa(j)j =j beg,j end) write(6,*) 'rhs load = ',b(irow) 32 co ntinue return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine newje (jeold ,iperm ,icounl ,je) dimension jeold(*),iperm( *),je( *)
c do I i= I ,icount iold=j eold (i) new= iperm (iold ) je(i)=new
continue
c return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub routine transa(n,m,ia,ja,ial ,jat) implicit real*8(a-h,0-z) d imension ia(*),ja( *),ial( *),jat(*) c++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++ c _. PLEASE direct your qu estion s to Dr. Nguyen (ng uyen@cee .od u.ed u) c purposes: Afler symbolic factori zation .ja is j ust a merge lists c...... WITHOUT orde ring (i.e . the non zero column numbers of a c...... partic ular row are 12, 27, 14,46, 22, 133). Up on c...... completion , this routine will rearrange lhe non zero co lum n c...... numb ers WITH ordering , 10 be ready for num erical factoriza tion c...... phase (i.e . 12, 14, 22, 27 , 46, 133) c input : ia j a,an given matri x in RR (C) U. c n numb er of rows of the matrix. c m numb er of co lum ns of the matrix. c output: iat.jat.ant transposed matri x in RR(C)O. c+++++++++++++++++++++++++ +++ +++++++++++++++++++ ++++ +++ +++++++++ ++++++ c dimension ia(6), ja (7), iat(6), ja l(7) c dim ension ia(neq+ I ), ja(ncoefl ), iauneq- I), jat(ncoefl ) c neq=5 c ncoef'l e ? c nrows=5 c
c
ncolseo x 2 0 4 5 ---> input unordered col # 2,5,4 x 3 4 0 ---> input unor dered col # 4,3 x 0 5 ---> input col # 5 x 5 ---> input col # 5
c...... c...... c...... c......
c...... c c c c c c
c c
c c c
c c
ia(l )= 1 ia(2)=4 ia(3)=6 ia(4)= 7 ia(5)=8 ia(6)=8 ja (1)=2 ja(2)=5 ja(3 )=4 ja(4)=4 ja( 5)=3 ja(6)=5
x
241
242
c
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
ja(7)=5
c c c c c c
call transatnrow s.ncols.ia.ja.iat.jat) write(6,*) 'after reordered, ia(-)= ',(ia(i),i= l, neq+ l ) write(6,*) 'after reordered,ja(-)= ',(ja(i),i=l ,ncoefJ ) stop end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c MH=M+I NH=N+I DO 101=2,MH 10IAT(I)=0 IAB=IA(NH)-I DO 20 1= I ,lAB J=JA(I)+2 IF(J.LE.MH)IAT(J)=IAT(J)+ 1 20 CONTINUE IAT(I)=I IAT(2)=1 IF(M.EQ.I )GO TO 40 DO 30 1=3,MH 30 IAT(I) =lA T(I)+ lAT(l-I) 40 DO 60 I=l,N IAA=IA(l) IAB=IA(I+I)-I IF(lAB .LT.IAA )GO TO 60 DO 50 JP=IAA ,IAB J=JA(JP)+I K=lAT(J) JAT(K )=I c ANT(K )=AN(JP) 50IAT(J)=K+I 60 CONTINUE call tmnsa2(n,m,iat,jat,ia,ja) return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine tmnsagain(n,m,ia,ja,iat,jat,an,ant) implicit real*8(a-h,o-z) dimension ia(*),ja(*),iat(*),jat(*),an(*),ant(*)
c MH=M+I NH=N+I DO 10 I=2,MH 10 IAT(l)=O IAB=IA(NH)-I DO 20 I=I,IAB J=JA(I)+2 IF(J.LE.MH)lAT(J)=lAT(J)+ I 20 CONTINUE IAT(I)=I IAT(2)=I IF(M.EQ.l)GO TO 40 D030I=3,MH 30IAT(I)=lAT(I)+lAT(l-I) 40 DO 60 I=I,N IAA=IA(I) IAB=lA(l+ 1)-1 IF(lAB .LT.lAA)GO TO 60
Due T. Nguyen
243
DO 50 JP =IA A,lAB J=J A(JP )+ I K=IAT (J) JAT(K )=I ANT( K)=AN(JP) 50 IAT (J)= K+ I 60cONT lNUE calltransa2m (n,m ,iat,jat,ia,ja ,ant ,an) return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c c
Tabl e 4 .9 Unsymmetrical Sp arse Assembly (continued)
c c@ @@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@ c+ ++++++ ++++++++++++++++++ ++++++ ++++++++++++++++++++++ +++ +++++++ e purpose : d.l. nguyen's general, un symmetrical sparse assembly e version : November 12,2001 c author: Prof. Due T. Nguyen (Email=
[email protected]) c notes: these files (part lunsym .f, part2un sym.f) are stored c under sub-directory - /eeel newfem/* co mplete*sparse*/
c c Please do "NOT" di stribute this so urce code to anyone c with out explicit written agreem ent by Prof. D.T. Nguyen c++++++++++++++++++++++++++ +++ ++++++++++++++++++++++++++ ++++++++ c@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@ subroutine transa2( n,m,iaja,iat,jat) dim ension ia(*),ja (*),iat (*),jat (*)
e MH=M+I NH=N+I DO 101=2,MH 10IAT(I)=0 IAB=IA(NH )-I DO 20 1= I ,lAB J=J A(I)+2 IF(J.LE.MH)IAT (J)=IAT (J)+ I 20 CONTINUE IAT(l )=1 IAT(2 )=1 IF(M .EQ .l )GO TO 40 DO 30 1=3,MH 30 IAT (I)= IAT(I)+IAT (I-1) 40 DO 60 l=l ,N IAA=IA(I) IAB=IA(I+ I )-1 IF(lAB.LT.IAA)GO TO 60 DO 50 JP=IAA,lAB J=JA(JP)+I K=IA T(J) JAT(K )=I c ANT(K )=AN(JP) 50IAT(J)=K+I 60cO NT lN UE return end
e%%%%%%%%%%%%%% subroutine transa2m(n,m ,ia j a,iat,jat,an ,ant ) impl icit real*8(a -h,o-z) dimension ia(*)ja(*),iat(*),jat(*)
244
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solution s
dimension an(*),ant(*) c MH=M+l NH=N+l DO 10 1=2,MH 10IAT(I)=0 IAB=IA(NH)- I DO 20 1= I,lAB J=JA(I)+2 If(J.LE.MH)IAT(J)=IAT(J)+ I 20 CONTINUE IAT(l )=1 IAT(2)=1 IF(M.EQ. l )GO TO 40 D0 301 =3,MH 30 IAT(I)=IAT(I)+IAT(l-I) 40 DO 60 1=I ,N IAA=IA(I) IAB=IA(I+ I)-1 IF(lAB .LT.lAA)GO TO 60 DO 50 JP=IAA,IAB J=JA(JP)+I K=IAT(J) JAT(K)=I ANT(K)=AN(JP) 50 IAT(J)= K+ I 60 CONTINUE return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine symbass(ie,je,ietjet,n,iaja,iakeep,ibc) implicit real*8(a-h,o-z) c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c purpose: nguyen's general, unsym. symbolic sparse assembly c note: these files (part Iunsym.f, pan2unsym.1) are stored c under sub-directory - /ceelnewfem/*complete*/ c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dimension ie(*)je(*),iet(*),jet(*),ia(*),ja(*) dimension iakeep(*),ibc( *) c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++ c PLEASE direct your questions to Dr. Nguyen (
[email protected]) c Purposes: UN-symmetrical, sparse symbolic assembly c.. This code is stored under file name *symb*.f, in sub-director y c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c......lnput: ie(nel+1)=Iocations (or pointers) of the first non-zero c...... of each row (of element-dof connectivity info.) c...... je(nel*ndofpe)=global dof column number for non-zero c...... terms of each row (of element-dof connectivity info.) c...... iet(ndof+ I)=Iocations (pointers) of the first non-zero c...... of each row (of dof-element connectivity info.) c...... jet(nel*ndofpe)=locations (pointers) of the first non-zero c...... of each row (of dot-el ement connectivity info .) c...... ia(ndol)= ndof in the positions correspond to Dirichlet b.c. c...... 0 elsewhere c......OUtpul:ia(ndof+1)=starting locations of the first non-zero c...... off-diagonal terms for each row of structural stiffness c...... matrix c...... ja(ncoefl)=column numbers (unordered) correspond to c...... each nonzero, off-diagonal term of each row of structural c...... stiffness matrix
Due T. Nguyen
245
c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ write(6,*)' , write(6, *) , c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ jp=1 !001 nm I =n-I !002 do 30 i=1.n !003 last row (=eq) will NOT be skipped jpi=jp !004 delayed counter for ia(-) array c if ( ia(i) .eq. n ) then !005 skip row which correspond to Dirichlet b.c. if ( ibc(i) .eq. n ) then ja(jp)=i jp=jp+1 ia(i)=i iakeep(i )=jpi go to 30 endif ieta=iet(i) !006 begin index (to find how many elements) ietb=iet(i+ 1)-1 !007 end index (to find how many elements) do 20 ipeieta.ietb !008 loop covering ALL elements attached to row i j=jet(ip) !009 actual "element number" attached to row i iea=ie(j) !010 begin index (to find how many nodes attached to element j) ieb=ie(j+ I)-I !011 end index (to find how many nodes attached to element j) !0l2 loop covering ALL nodes attached to element j do 10 kpeiea.ieb k=je(kp) !013 actual "node, or column number" attached to elementj if (k .Ie. i) go to 10 !014 skip, if it involves with LOWER triangular portion c if (ia(k) .ge. i) go to 10 !015 skip, if same node already been accounted by earlier elements if ( ibc(k) .eq. n ) go to 1O! skip this column (correspond to be) ja(jp)=k '016 record "column number" associated with non-zero off-diag. term c write(6,*) 'jp,ja(jp)= ',jp,ja(jp) jp=jp+ I !017 increase "counter" for column number array ja(-) ia(k)=i !018 record node (or column number) k already contributed to row i c write(6, *) 'k,ia(k)= ',k,ia(k) 10 continue !019 20 continue !020 c30 ia(i)=jpi !021 record "starting location" of non-zero off-diag. 30 iakeep(i)=jpi !021 record "starting location" of non-zero off-diag. c terms associated with row i c ia(n)=jp !022 record "starting location" of non-zero term of LAST ROW !023 record "starting location" of non-zero term of LAST ROW + 1 c ia(n+I)=jp iakeep(n+ 1)=jp !023 record "starting location" of non-zero term of LAST ROW + I c c ncoefl =ia(n+ 1)-1 c write(6,*) 'ia(-) array = ',(ia(i),i=l,n+1) c write(6, *) 'ja(-) array = ',(ja(i),i=I,ncoefl) c return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine numass(iaja,idir,ae,be,lm,ndofpe,an,ad,b,ip) implicit real*8(a-h,0-z) dimension ia(*),ja(*),idir(*),ae(*),be(*),lm(*),an(*) dimension ad(*),b(*),ip(*) c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c PLEASE direct your questions to Dr. Nguyen (
[email protected]) c Purposes: symmetrical, sparse numerical assembly c...... This code is stored under file name *symb* J, in sub-directory c . c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c lnput: ia(ndof+ 1)=starting locations of the first non-zero c...... off-diagonal terms for each row of structural stiffness
246
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
c
.
c c c
. . .
c
.
c c c c
. . . .
c
.
c c
. .
matrix ja(ncoeff)=column numbers (unordered) correspond to each nonzero, off-diagona l term of each row of structural stiffness matrix idir(ndof)= I in the positions correspond to Dirichlet b.c. oelsewhere ae(ndofpe**2),be(ndofpe)= element (stiffness) matrix, and element (load) vector Im(ndofpe)= global dof associated with a fin ite element ndofpe= number of dof per element b(ndof)= before using this routine, values of b(-) should be initialized to: Ci, values of prescribed Dirichlet be at proper locations or values of applied nodal loads
c . c . c c Output: an(ncoeffl )= values of nonzero, off-diagonal terms of c...... structural stiffness matrix c...... ad(ndof)= values off diagonal terms of structural stiffness c...... matrix c...... b(ndof)= right-hand -side (load) vector of system of linear c...... equations c......Temporary Arrays: c...... ip(ndof)= initialized to 0 c...... then IP(-) is used and reset to 0
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% d040 L=1,ndofpe !OOl local "row" dof i=lm(L) !002 global"row" dof if ( idir(i) .ne. 0 ) go to 40 1 !003 skip, if DIRICHL ET b.c. k=L-ndofpe !004 to find location of element k-diag ad(i)=ad(i)+ae(k+L*ndofpe) !005 assemble K-diag b(i)=b(i)+be(L) !006 assemble element rhs load vector kk=O !007 flag, to skip contribution of entire global row i if all globa l col # c j < i, or if entire row i belongs c to LOWER triangle c do 20 LL= I ,ndofpe !008 local "column" dof k ek-mdofpe !009 find location of element stiffness k if (LL .eq . L) go to 20 !0 1O skip, diag. term already taken care j=lm(LL) !Ol l global column dof if ( idir(j) .ne. 0) go to 10 !012 skip, if DIRICHLET b.c. !013 skip, if LOWER portion if (j .It. i) go to 20 ip(j)=k !014 record global column # j (associated with global row # i) correspond to k-th term c c of element stiffness k !015 FLAG, indicate row L of [k] do have kk=1 contributi on to global row I of [K] c go to 20 !016 !017 modify rhs load vector due to DIRICIILET b.c. 10 b(i)=b(i)-b(j)*ae(k) 20 continue !018 if (kk .eq. 0) go to 40 !019 skip indicator (see line 007) iaa=ia(i) !020 start index !021 end index iab=ia(i+ I)-1 !022 loop covering all col numbers associated do 30 je iaa.iab with global row i c !023 ip ( col # ) already defined on line 014 k=ip(ja(j) ) c or initialized to ZERO initially !024 skip, because eventhough row L of [k] do if (k .eq. 0) go to 30 have contribution to global row I of [K ], c some terms of row L (of [kJ) which associate d c with DlRICII LET b .c. columns should be SKIPPED c
247
Due T. Nguyen
an(j)=an(j)+ae(k) ip(ja(j) )=0
c 30
!025 assemble [K] from [k] !026 reset to ZERO for col # j before considering the next row L !027
continue go to 40 40 I ad(i)=1.0 ! reset the diagonal of K(i,i)=1.0, due to b.c. 40 continue !028 c print debugging results c ndof=12 c ncoeffl =ia(ndof+ I )-1 c write(6,*) 'at the end of routine numass' c write(6,*) 'ia(-) array = ',(ia(i),i=I ,ndof+l ) c write(6,*) Ja(-) array = ',(ja(i),i=I,ncoeffl ) c write(6,*) 'ad(-) array = ',(ad(i),i=I ,ndof) c write(6,*) 'anti) array = ',(an(i),i=I,nc oeffl ) return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine unnumass(ia,ja,idi r,ae,bc,lm,ndofpe,an,b,ip) implicit real*8(a-h,0-z) dimension ia(*),ja(*),idir(*),ae(*),be(*),lm(*),an(*) c dimension ad(*),b(*),ip(*) dimension b(*),ip(*) c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c PLEASE direct your questions to Dr. Nguyen (
[email protected]) c Purposes: UN-symmetrical, sparse numerical assembly c...... This code is stored under file name *symb* J, in sub-directory
c . c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c......lnput: ia(ndof+I)=starting locations of the first non-zero c...... off-diagonal terms for each row of structural stiffness c...... matrix c...... ja(ncoeff)=column numbers (unordered) correspond to c...... each nonzero, off-diagonal term of each row of structural c...... stiffness matrix c...... idir(ndof)= I in the positions correspond to Dirichlet b.c. c...... 0 elsewhere c...... ae(ndofpe**2),be(ndofpe)= element (stiffness) matrix, c...... and element (load) vector c...... Im(ndofpe)= global dof associated with a finite element c...... ndofpe= number of dof per element c...... b(ndof)= before using this routine, values of b(-) should c...... be initialized to: c...... Ci, values of prescribed Dirichlet be at proper locations c...... or values of applied nodal loads c c Output: an(ncoeffl)= values of nonzero, off-diagonal terms of c...... structural stiffness matrix c...... ad(ndof)= values off diagonal terms of structural stiffness c...... matrix c...... b(ndof)= right-hand-side (load) vector of system of linear c...... equations c......Temporary Arrays: c...... ip(ndof)= initialized to 0 c...... then lP(-) is used and reset to 0 c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% do 40 L= I,ndofpe !OOJ local "row" dof i=lm(L) !002 global"row" dof if ( idir(i) .ne. 0 ) go to 401 !003 skip, if DIRICHLET b.c. k=L-ndofpe !004 to find location of element k-diag
248
Finite Element Method s: Parallel-Sparse Statics and Eigen-Solutions
c
ad(i) =ad(i)+ae(k+L*ndofpe) !005 asse mble K-d iag will be don e later b(i)=b(i)+be( L) !006 asse mble eleme nt rhs load vec tor !007 flag, to skip contr ibution of entire c kk=O write(6 ,*) 'L,i,k = ',L,i,k e ! global row i if all globa l col # c e ! j < i, or if entire row i belon gs ! to LOW ER triangl e c do 20 LL=I ,ndofpe !008 1ocal "column" dof kek-mdofpe !009 find location of eleme nt stiffness k if (LL .eq. L) go to 20 !0 10 skip, diag . term already tak en care c j= lm(LL) !OII global co lumn dof if ( idir(j) .ne. 0) go to 10 !012 skip, if DIRICHLET b.c. if G .It. i) go to 20 !013 skip, if LOWER portion c ipG)=k !OI4 reco rd globa l column # j (assoc iated with global row # i) correspond to k-th term c of elem ent stiffness k c kk= I !015 FLAG, ind icate row L of [kJ do have c write(6, *) 'LL,k,j,iPG) = ' c write(6, *) LL,k,j,ipG) c c ! contribution to global row I of [KJ go to 20 !OI6 b(i)=b(i)-bG)*ae(k) !017 modify rhs load vector due to DIRICH LET b.c . 10 write (6,*) 'ij,k,bG),b(i ),ae(k) =' c write(6,"') ij ,k,bG),b(i),ae(k ) c co ntinue !OI 8 20 !019 skip indicator (see line 007 ) c if (kk .eq . 0) go to 40 iaa= ia(i) !02 0 start index iab=ia(i+ I)- 1 !02 1 end ind ex do 30 j =iaa ,iab !022 loop cove ring all col numbers assoc iated with globa l row i c k=ip(jaG) ) !02 3 ip ( col # ) already defined on line 0 14 write(6 ,*) 'j,jaG),k = ' c write(6,*) j ,jaG),k c or initialized to ZERO initially c if (k .eq. 0) go to 30 !024 skip, because eventhough row L of [kJ do have co ntribution to global row I of [KJ, c some terms of row L (o f [k)) which associ ated c with DIRICHLET b.c. co lumns should be SKIPPED c anG)=anG)+ae(k) !025 asse mble [KJ from [k] !026 reset to ZE RO for col # j before considering ip( jatj) )=0 write(6,*) 'j,k,ae (k),an G),jaG), = ' c write(6 , *) j,k ,ae(k),anG)jaG) c ! the next row L c !027 30 continue go to 40 c find the location of diagonal term , c which corresponds to Dirichlet b.c . 401 locate=ia(i) an(loca te)= 1.0 ! reset diagonal term K(i,i)= J .0, due to b.c. 40 continue !028 c......print debu gging results ncoeffl =ia(ndof+ 1)-1 c write(6,*) 'at the end of routin e unnumass' c write(6,*) 'ia(-) array = ',(ia(i ),i=l ,ndof+l ) c write(6,"') 'ja(-) arra y = ',Ga(i),i= l ,ncoe ffl) write(6,*) 'an(i) arra y = ',(an(i),i= I ,ncoe ffl) c write(6 ,*) 'rhs b = ',(b(i) ,i= l ,ndof) c return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Due T. Nguyen
11
12 2 13
3
4
SUBROUTINE indexi(n,irr,indx) INTEGER n,indx(n),M,NSTACK,irr(n) PARAMETER (M=7,NSTACK=50) INTEGER i,indxt,ir,itemp,jjstack,k,l,istack(NSTACK) do 11 j=l,n indx(j)=j continue jstack=O 1=1 ir=n if(ir-l.lt.M)then do 13 j=l+ Lir indxt=indx(j) iii=irr(indxt) do 12 i=j-l,I,-1 if(irr(indx(i».le.iii)goto 2 indx(i+ 1)=indx(i) continue i=O indx(i+l)=indxt continue if(jstack.eq.O)retum ir=istack(jstack) I=istack(jstack-1) jstackejstack-2 else k=(I+ir)12 itemp=indx(k) indx(k)=indx(l+ 1) indx(l+ 1)=itemp if(irr(indx(l+ 1)j.gt.irnindxrir) )then itemp=indx(l+ 1) indx(l+ 1)=indx(ir) indx(ir)=itemp endif if(irr(indx (I». gt.irr( indx( ir) )then itemp=indx(l) indx(l)=indx(ir) indx(ir)=itemp endif if(irr(indx(l+ 1)).gt.irr(indx(l)»then itemp=indx(l+ 1) indx(l+ 1)=indx(l) indx(l)=itemp endif i=l+l jeir indxt=indx(l) iii=irr(indxt) continue i=i+l if(irr(indx(i».lt.iii)goto 3 continue j=j-l if(irr(indx(j».gt.iii)golo 4 if(j.lt.i)goto 5 itempeindxti) indx(i)=indx(j) indx(j)=itemp goto 3
249
250
5
Finite Element Method s: Parallel-Sparse Statics and Eigen-Solution s
indx(l)=indxG) indxG)=indxt jstackejstack +2 if(jstack .gI.NSTAC K)pause 'NSTACK too small in indexx' if(ir-i+ I .ge.j-I)then istacktjstackje ir istacktjsrack-I )=i ir=j- I else istack tjstackjej- I istack(jstack- I)=1 I=i endif endif goto I END
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine sorti(n,in,index,iout) dimension in(*),index(*),iout(*) do I i= l, n locateeindexti) iout(i)=in(locate) continue return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine sortrtn.ai n.index.out) implicit real*8(a-h,0-z) dimension ain(*),index(*),ouH*) do I i= l, n locateeindexti) out(i)=ain(locate ) continue return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine adjacency(ieje,ietj et,n,iaj a,iakeep ) c+++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++ c purpose: obtain ing adjacency arrays for METISIMMD etc... reorderin g c note: could be applied to either "node" number , or "dof" number ! c stored under sub-directory - /ceel newfem/*complete*/adjac encyJ c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dimension ie(*),je(*),iet(*),jet(*),ia(*),ja(*) dimension iakeep(*) c++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c......Jnput: ie(nel+ I )=Iocations (or pointers) of the first non-zero c...... of each row (including LOWER & UPPER TRIANGULAR, excluding DIAGONAL TERMS, c...... of element-dof [or node] connectivity info.) c...... je( nel*ndofpe)=global dof column number for non-zero c...... terms of each row (of elemcnt-dof [or node] connectivity info.) c iet(ndof+ I )=Iocations (pointers) of the first non-zero c . of each row (of dof [or nodej -clement connecti vity info.) c .. jet(nel*ndofpe)=locations (pointers) of the first non-zero c . of each row (of dof-elem ent connectivity info. ) c . c c......notes: ndof may represent total # dof, or total # nodes
c c c
this subroutine is "almost identical" to Due T. Nguyen's routine for UNSYM. SPARSE "SYMBOLIC ASSEMBLY", where we ju st simply SKIPING the
Due T. Nguyen
251
c diagonal term (since METlS/MM D/ND does NOT count DIAGONAL terms in the 2 adjacency arrays). Also, this routine will NOT require to c consider Dirichlet boundary conditions! c c c Output:ia(ndof+ I) =starting locations of the first non-zero c...... terms for each row of structural stiffness matrix c...... ja(ncoeff)=column numbers (unordered) correspond to c...... each nonzero term of each row of structural c...... stiffness matrix c+++++++++++++++++++++++++++++++++++ +++++++++++++++++++++ ++++++++++++ jp=1 !OOI do 30 i= I,n !003 last row (=eq) will NOT be skipped jpi=jp !004 delayed counter for ia(-) array ietaeeietti) !006 begin index (to find how many elements) ielb=iel(i+ I)-1 !007 end index (10 find how many elements) do 20 ip=ieta,ietb !008 loop covering ALL elements attached to row i j=jet( ip) !009 actual "element number" attached to row i iea=ie(j) !OlObegin index (to find how many nodes attached to element j) ieb=ie(j+ I)-1 !Oll end index (10 find how many nodes attached to element j) do 10 kpeiea.ieb !O12 loop covering ALL nodes attached to element j k=je(kp) '013 actual "node, or column number" attached to clement j
c···---··---------------------------------------··· ···...----------------------------if (k .eq. i) go to 10
!0 14 SKIP, if il involves with DIAGONAL terms
c------------------------------------------------------------------------------------if ( ia(k) .ge. i ) go to lO !O15 skip, if same node already been accounted by earlier elements ja(jp)=k !0 16 record "column number" associated with non-zero off-diag. term c write(6,*) 'jp j a(jp)= 'jpja(jp) j p=jp+ I !017 increase "counter" for column number array jat o) ia(k)=i !018 record node (or column number) k already contributed to row i c write(6,*) 'k,ia(k)= ',k,ia(k) 10 continue !O19 20 continue !020 30 iakeep(i)=jpi !02 1 record "starting location" of non-zero terms assoc iated with row i iakeep(n+ I)=jp !023 record "starting location" of non-zero term of LAST ROW + I c ncoef'l=iakeep(n+ I)- 1 write(6,*) 'iakeep(-) array = ',(iakecp(i),i= I,n+ l ) write(6,*) 'j ato) array = ',(ja(i),i=I ,ncoefl )
c return end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine symbassym(ie,je, iet,jet,n,ia,ja) dimension ie(*),je(*),iet( *),jel(*),ia(*),ja(*) c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c PLEASE direcl your question s to Dr. Nguyen (
[email protected]) c Purposes: symmetrical, sparse symbolic assembly c...... This code is stored under file name *symb*.f, in sub-directory c...... c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c......lnput : ie(nel+ I)=locations (or pointers) of the first non-zero c...... of each row (of element-dof connectivity info.) c...... je (nel*ndofpe)=global dof column number for non-zero c...... terms of each row (of element-dof connectivity info.) c...... iet(ndof+I) =locations (pointers) of the first non-zero c...... of each row (of dof-element connectivity info.) c...... je t(nel*ndofpe)=locations (pointers) of the first non-zero c...... of each row (of dot-element connectivity info.) c...... ia(ndof)= ndof in the positions correspond to Dirichlet b.c. c...... 0 elsewhere
252
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
e OUtput:ia(ndof+ I)=starting locations of the first non -zero c...... off-diagonal terms for each row of structural stiffness c...... matrix c...... ja( neoeff) =eolumn numbers (unordered) correspond to c...... each nonzero, off-diagonal term of each row of structural c...... stiffness matrix e+++++++++++++++++++++++++++++ ++++++ +++++++++++++++++++++++++++++++++ j p= 1 !OO I nrnl en- I '002 !OO3 last row (= eq ) will be skipped do 30 i=l ,nml j pi=jp l004 delayed counter for ia(-) array if ( ia(i) .eq. n ) go to 30 !005 skip row which correspond to Dirichlet b.e . ieta=iet(i) !006 begin index (to find how many elements) ietb=iet(i+ I )-1 !OO7 end index (to find how many elements) do 20 ipe ieta.ietb !008 loop covering ALL elements attached to row i j=jet(ip) !009 actual "element number" attached to row i iea=ie(j) !OlObegin index (to find how many nodes attached to element j) ieb=ie(j+ I )-1 !O I I end index (to find how many nodes attached to element j) !O12 loop covering ALL nodes attached to element j do lO kpeiea.ieb !O I3 actual "node, or column number" attached to element j k=je(kp) if (k .Ie. i) go to 10 !014 Skip, if it involves with LOWER triangular portion if ( ia(k) .ge. i) go to lO !015 skip, if same node already been accounted by earlier elements ja(j p)=k !016 record "column number" associated with non-zero off-diag. term jp=jp+1 !017 increase "counter" for column number array jato) ia(k)=i !0 18 record node (or column number) k already contributed to row i 10 continue !0 19 20 continue l020 30 ia(i)=jpi !021 record "starling location" of non-zero off-diag . terms associated with row i ia(n)=jp !022 record "starting location" of non-zero term of LAST ROW ia(n+ I )=jp !023 record "starting location " of non-zero term of LAST ROW + I c ncoefJ =ia(n+ I)- 1 c write(6,*) 'iat-) array = ',(ia(i),i=1,n+ I) c write(6,*) 'jato) array = ',(ja(i) ,i= l ,ncocfl)
c retum end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine numassuns(iaj a,idir,ae,be,lm,ndofpe,an,ad ,b,ip $ ,an2,itempo l) implicit real*8(a-h,0-z) dimension ia(*),ja(*),idir(*),ae(*),be(*),lm(*),an( *),an2( *) dimension ad(*),b(*),ip( *),itempo 1(*) c+++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++ e PLEASE direct your questions to Dr. Nguyen (
[email protected]) e Purposes: UNsymmetrical, sparse numerical assembly c...... This code is stored under file name *symb *.f', in sub-directory
c
.
c+++++++++++++++++++++++++++ ++++++++++++++++++++++++++++ ++++++ +++++++ c......lnput: ia(ndof+I )=starting locations of the first non-zero c...... off-diago nal terms for each row of structural stiffness c...... matrix c...... ja( neoeff)=column numbers (unordered) correspond to c...... each nonzero, off-diagonal term of each row of structural c...... stiffness matrix c...... idir(ndof)= I in the positions correspond to Dirich let b.c. c...... 0 elsewhere c...... ae(ndofpe**2),be(ndofpe)= element (stiffness) matrix, e...... and element (load) vector
Due T. Nguyen
c c
. .
253
Im(ndofpe)= global dof associated with a finite element ndofpe= number of dof per element b(ndof)= before using this routine, values of b(-) should be initialized to: Ci, values of prescribed Dirichlet be at proper locations or values of applied nodal loads
c . c . c .. c . c c Output : an(ncoeffl)= values of nonzero, off-diagonaltenns of c...... structural stiffness matrix (upper triangular portion ) c...... an2(ncoeffl)= values of nonzero, off-diagonal terms of c...... structural stiffness matri x (lower triangular portion ) c...... ad(ndof)= values off diagonaltenns of structural stiffnes s c...... matrix c...... b(ndof)= right-hand -side (load) vector of system of linear c...... equations c Temporary Arrays: c...... ip(ndof)= initialized to 0 c...... then IP(-) is used and reset to 0
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% do 40 L=I ,ndofpe tOO I local "row" dof i=lm(L) !002 global"row" dof if ( idir(i) .ne. 0 ) go to 401 !003 skip, if DIRICHLET b.c. k=L-ndofpe !004 to find location of element k-diag c k2=(L-1 )*ndofpe+ L k2=(L-1 )*ndofpe write(6,*) 'local row #L,k,k2= ',L,k,k2 ad(i)=ad(i)+ae(k+L*ndofpe) !005 assemble K-diag b(i)=b(i)+be(L) 1006assemble clement rhs load vector kk=O 1007 flag, to skip contribution of entire global row i if all global col # j < i, or if entire row i belongs to LOWER triangle do 20 LL= I,ndofpe !008 local "column " dof kek-md ofpe !009 find location of element stiffness k k2=k 2+ I ! find location of el stiff (lower) write(6 ,*) 'local col #LL,k,k2 = ',LL,k,k2 if (LL .eq. L) go to 20 !01Oskip, diag. term already taken care c 1 find location of el stiff (lower) k2=k2+ I j=lm(LL) !Ol l global column dof if (idir(j) .ne. 0 ) go to 10 1012 skip, if DIRICHLET b.c. if (j .u. i) go to 20 !O13 skip, if LOWER portio n ip(j)=k !014 record global colum n # j (associated with itempoI(j)=k2 global row # i) correspond to k-th term of clement stiffness k kk=1 !015 FLAG, indicate row L of [k) do have contrib ution to global row I of [K) go to zu !016 10 b(i)=b(i)-b(j)*ae(k) !017 modify rhs load vector due to DIRICHLET b.c . 20 continue !018 if (kk .eq. 0) go to 40 1019 skip indicator (see line 007) iaa=ia(i) 1020 start index iab=ia(i+ I)-1 !021 end index do 30 jeiaa.iab 1022 loop covering all col numbers associ ated with global row i k=ip(ja(j ) ) !023 ip (col # ) already defined on line 014 k2=itempo I( ja(j ) ) or initialized to ZERO initially if (k .eq. 0) go to 30 !024 skip, because eventhough row L of [k) do c ! have contributi on to global row I of [K},
254
Finite Element Methods: Parallel -Sparse Statics and Eigen-Solutions
! some terms of row L (of [k]) which associated ! with DIRICH LET b.c. columns should be SKIPPED write(6, *) 'j,k,k2= ',j,k,k2 write(6,*) 'an(j),ae(k),an2(j),ae(k2)= ' write(6,*) an(j),ae(k),an2(j),ae(k2) an(j)=an(j)+ae(k) !025 assemble [K} from [k} an2(j)=an2(j)+ae(k2) !025 assemble [K} from [k} write(6,*) 'an(j),ae(k),an2(j),ae(k2)= ' write(6,*) an(j),ae(k),an2(j),ae(k2) ip( ja(j) )=0 !026 reset to ZE RO for col # j before considering the next row L 30 continue !027 go to 40 401 ad(i)=1.0 ! reset the diagonal of K(i,i)=1.0, due to b.c. 40 continue !028 c......print debugging results c ndof=12 c ncoeffl =ia(ndof+ 1)-1 c write(6,*) 'at the end of routine numass' c write(6,*) 'ia(-) array = ',(ia(i),i=I ,ndof+l) c write(6,*) 'ja(-) array = ',(ja(i),i=l ,ncoeffl) c write(6, *) 'ad(-) array = ',(ad(i),i= l,nd of) c write(6,*) 'an(i) array = ',(an(i),i= l ,ncoeffl ) return end
c c
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4.10 Unsymmetrial Sparse Equations Data Formats In this section, the system stiffness matrix given by Eq.(4 .70) is used as an illustrative example for I. Duff s [3.2, 3.6, 3.7, 4.2, 4.3], RuneshalNguyen's [3.11], and SGI's [3.1] input data format requirements. [A] I. Duffs Unsymmetrical Sparse Matrix Storage Scheme[3.2.3.6, 3.7,4.2,4.31
The matrix equation , shown in Eq.(4.70), can be described by the following storage schemes:
Due T. Nguyen
255
1 2
2
3
2
4
2
5
2
6
3
7
3
8
3
9
3
10
3
11
3
12
4
13
5
14
5
15
5
IAROWMA28 16
=
5
(4.74)
17
6
18 19
6
20
6
21
6
22
6
23
6
24
7 7
25
7
26
7
27
8
28
8
29
8
30
8
31
9
256
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
{JACOLma28 (l,2,3,...31)}T=@, 13,5,6,7l
~
~,3,5,6,7,8~
~,3,5,6,7,8~
~, (4.75)
13,5,6,7~
!2,3,6,8l ~} {ANma28(l,2,3, ...,31)}T= @, 116.,20., 24., -12.~ t20., 28., 5., 25., 6., -16.1
(4.76)
[], t5., 6., -4., 7. l ~24., -25., 4., 60., 26., -26.1
~6., -7., -26., 32.1 ' 112.,16.,26., 12.1 ' []} Remarks It is required that column number, shown in Eq.(4.76), be ordered by increasing
number.
[B] Nguyen-Runesha's Unsymmetrical Sparse Matrix Storage Scheme[3.1]]
The matrix equation, shown in Eq.(4.70), can be described by the following mixed row-wise (for the upper - triangular portion), and column-wise (for the lower triangular portion) storage schemes. Here, we assume the matrix Eq.(4.70) is still symmetrical in non-zero locations.
IA N- R
1
1
2
1
3
4
4
8
5
6 7
=
8
9 10
8
12
9 1O=NDOF+1
12 12
(4.77)
Due T. Nguyen
257
1
3
2
6
3
8
4
5
5
6
=
JA N- R 6
7
7
8
8
6
9
7
10
7
11
8
1
20.
2
24.
3
- 12.
4
5.
5
25.
AN N_ R 6
=
(4.7 8)
6.
7
- 16.
8
-4.
9
7.
10
26.
11
-26.
(4.79)
258
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
1
-20.
2
-24.
3
12.
4
-5.
5
-25.
AN2 N _ R 6
=
-6.
7
16.
8
(4.80)
4. -7.
9 10
-26.
11
26. 1
1.
2
16.
3
28.
4
1.
AD 5
=
6.
6
60.
7
32.
8
12.
9
1.
(4.81)
Remarks
The column numbers, shown in Eq.(4.78), need NOT be ordered.
[C] SGI's Unsymmetrical Sparse Matrix Storage Scheme[3.1]
The matrix equation, shown in Eq.(4.70), can be described by the following column - wise storage schemes:
Due T. Nguyen
259
IA SGI
1
1
2
2
3
6
4
12
5
13
6
17
7
23
8
27
9
31
10= NDOF+ 1
32
{JAsGl (l,2,3,4,...,31)}T = {[!], ~, ~,3,5,6,7,8~
f!I,
(4.82)
p,5,6,7~
(4.83)
12,3,4,5,6,7,81 ,p,5,6,7~ 12,3,6,81,~} {AN sGi (l,2,3,4,...,31)}T = {l!], 116.0, -20.0, -24.0, 12.g,
120.,28., -5., -25., -6., 16.1, l!],
(4.84)
b., 6., 4., -7·1,
124.,25., -4., 60., -26.,26.1, ~., 7., 26., 32.1,
tl2·, -16., -26.,12·1, II]} Remarks
The column numbers, given by Eq.(4.83), need NOT be ordered. 4.11 Symbolic Sparse Assembly of Unsymmetrical Matrices It should be very helpful to understand the symbolic sparse assembly for
"symmetrical" matrices first, as shown in Table 4.1, since only minor changes in the symmetrical case are required to make it work in the unsymmetrical case. The following minor changes in Table 4.1 are required for handling the unsymmetrical case: (a) Do 30 I = 1, N (last row will NOT be skipped) (b) Introduce a new integer array IAKEEP (N + 1) that plays the role of array IA(-), for example: IAKEEP(I) = JPI (see sub-routine symbass in Table 4.9).
260
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
(c) Remove the IF statement (in Table 4.1) that skips the lower-triangle portion . As a consequence of this, the original array IA(-) will contain some additional unwanted terms. (d) The output from "unsymmetrical " sparse assembly will be stored by IAKEEP(-) and JA(-), instead of IA(-) and JA(-) as in the symmetrical case! A complete FORTRAN code for unsymmetrical symbolic sparse assembly is shown in a sub-routine symbass of Table 4.9.
4.12 Numerical Sparse Assembly of Unsymmetrical Matrices The numerical sparse assembly for an "unsymmetrical" case is quite similar to the "symmetrical" case. The only minor change required is both upper- and lowertriangular portions of the element stiffness matrices, see Eq.(4.46 - 4.48), are used during the unsymmetrical assembly process. A complete FORTRAN code for unsymmetrical numerical sparse assembly is shown in subroutine unnumass of Table 4.9. 4.13 Step-by-Step Algorithms for Unsymmetrical Sparse Assembly and Unsymmetrical Sparse Equation Solver Step 1: Input General Control Information such as NEL, NDOF, NDOFPE, METHOD, NBC, METIS, IUNSOLVER where NEL =total number of elements in the finite element model NDOF = total number of degree-of-freedom (dof) in the finite element model (including the Dirchlet boundary conditions) NDOFPE = number of dof per element METHOD = {I, if sorting column numbers by transposing a matrix twice 2, if sorting column numbers by using numerical recipe's sub-routines} NBC = number of boundary (Dirichlet) conditions METIS = {I , if METIS re-ordering algorithm is used 0, if METIS re-ordering algorithm is NOT used} IUNSOLVER = { 1, if MA28 unsymmetrical sparse solver is used
[see 4.3)
2, if Nguyen-Runesha's sparse server is used
[see 3.11]
3, if SGI sparse solver is used}
[see 3.1)
Due T. Nguyen
261
Step 2: Input Element-DOF Connectivity Information call femesh (nel, ndofpe, ie ,
}e) where arrays ie(-) and je( -) have already been explained in Eqs.(4.4l -
4.42).
Step 3: Input System Right-Band-Side (RBS) Load Vector Call rhsload (ndof, b) where the array b(-) plays the same role as array {R} in Eq.(4 .51)
2
4 44
3
10
4
-20
1
b 5
42
6
-40
7
84
8
28
9
48
(4.85)
Step 4: Input Dirichlet Boundary Conditions Call boundaryc (ndof, ibc--->, nbc, b---» where the integer array ibc (NDOF) contains the boundary flags such as the one shown in Eq.(4.68)
2J= {OdOf} ndof [5 ndof
ibc 4
Here nbc
(4.86)
= number of boundary conditions = 3
The values of Eq.(4.85) should be modified to incorporate Dirichlet boundary conditions such as:
262
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
1
4K
2 3
0.2" K 10
4
0.4"
b 5
0.5"
6 7
-40 K
8
84 K K
28
9
81K
(4.87)
Step 5: Find the transpose of matrix [E), and express the answers in the form of two integer arrays lET (-) and JET (-), as explained in Eqs.(4.44 - 4.45) call transa2 (nel, ndof, ie...., je...., iet...., jet....)
Step 6: Compute the two adjacency arrays IADJ (-) and JADJ (-) as explained in Eqs.(4.53 - 4.54) . call adjacency ( ie, je , iet, jet, ndof, ia, ja, iakeep ) where ia (NDOF+ l ) is a temporary working array, and iakeep (-) and ja (-) arrays play the same roles as IADJ (-) and JADJ (-).
Step 7: Use METIS [3.3) re-ordering algorithms to minimize fill-in terms call
----
metisreord (ndof, iakeep, ja, iperm, invp ) where the output integer arrays IPERM (-) and INVP (-) have already been explained in Eqs.(4.56 - 4.59).
Step 8: Re-compute the input connectivity array je( -), shown IPERM (-) information
III
Step 2, using
call newje (itempol, iperm , icount , je ) where itermpol (NDOF) is a temporary , integer array, and icount = nel*ndofpe is the dimension for array je (-).
Step 9: Re-do Step 5
Due T. Nguyen
263
Step 10: Only apply for MA28, or SGI unsymmetrical solvers [A] Perform the unsymmetrical sparse symbolic assembly call symbass (ie, je, iet, jet, ndof, ia, ja, iakeep, ibc ) The input arrays iakeep (NDOF+l), andja (ncoefl) where ncoefl = iakeep (ndof + 1) - iakeep (1) will playa similar role as Eqs.(4.74 - 4.75), or Eqs.(4.82 - 4.83) for MA28, or SGI formats, respectively. [B) Perform the unsymmetrical sparse numerical assembly callunsymasem(ibc, ncoefl, lUi, ij), ndof, nel, elk, be, ndofpe, lm, ]e,
;;e, iakeep, ja, b, nbc)
where ibc (ndof) = containing flags for (Dirichlet) boundary condition code ( = ndof or 0) ncoefl = iakeep (ndof + 1) -1 = number of non-zero terms for the coefficient matrix (including upper + lower + diagonal terms for iunsovlver 1= 2, and including only upper terms for iunsolver = 2) an (ncoefl)
=numerical values of non-zero terms of the coefficient matrix
ip (ndot) = integer, temporary working arrays ndof = total number of degree-of-freedom (dot) nel = total number of elements elk (ndofpe, ndofpe) = element stiffness matrix be (ndofpe) = element (nodal) load vector ndofpe = number of dof per element lm (ndofpe)
= global dof associated with an element
je (ndofpe*nel) = connectivity information (= global dof associated with each and every element) ae (ndofpe*ndofpe) = element stiffness matrix (stored in I-D array, column-wise) iakeep (ndof + 1) = starting location of the I" non-zero term for each row of the coefficient matrix (including upper + diagonal + lower terms) ja(ncoefl) = column numbers (unordered) associated with non-zero terms for each row of the coefficient matrix b (ndof) =right-hand-side nodal load vector nbc = number of boundary conditions Step 11: Only apply for Nguyen-Runesha's unsymmetrical sparse solver [3.11] [A] Perform ONLY the "upper" triangular sparse symbolic assembly, since we assume the unsymmetrical matrix is still symmetrical in non-zero locations!
264
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
call symbassym (ie, je, iet, jet, ndof, ia, ja ) where the output arrays ia(-) and ja(-) play similar roles as indicated in Eqs.(4.77 4.78), which IPERM (-) information has already been assumed to be incorporated. [B] Obtain the "faked" element stiffness matrix, ELK C,_), and element load vector, be(-)
call elunsym (i, elk, ndofpe, be, lm, je, ae) [C] Perform the "upper and lower" triangular sparse numerical assembly call numassuns
~, ja,~,;, t;, I;, ndofpe,;;,;;d, b, iP,;;2, itempoI)
[D] Perform symbolic factorization
(ndof,;;,ja,~,ju,iP,ncoef2)
call symfact
[E] Transpose twice the arrays iu(-) and ju(-) so that the column numbers associated with each non-zero term for each row will be ordered (in increasing number) call transa
(ndof,ndof,~,ju,h.rt,jut)
[F] Only apply if "unrolling" strategies for factorization will be used. call supnode (ndof , ~, ju ,i sup em) Step 12: Only apply if (method = 2) ordering column numbers (of each row) by using "Numerical Recipe's Sorting" routines [A] if MA28 or SOl (iunsolver = 1, or 3) unsymmetrical solver is used, then call sorting
(ndof,~,itempll,ju,tempoI,i~,b,;;,;;2,;)
[B) If Nguyen-Runesha' s (iunsolver =2) unsymmetrical sparse solver is used: call transa2m
~dof, ndof ,iakeep, ;,iakepp, j;rt,;;2,;;;)
Step 14: Unsymmetrical Equation Solver's Solutions [A] ifMA28 (iunsolver = 1) solver is used: (A.I) Converting the coefficient matrix into MA28's formats call rownuma28
~akepp, ndof , iakepp)
(A .2) Performing LU factorization
call ma28ad (ndof , nz,~, lien, iakepp , lim,;, u, ikeep, iw, w, iflag) (A.3) Performing ForwardlBackward Solution
call ma28cd (ndof,;;,licn,
ja,ike~, b, w,mtype)
Due T. Nguyen
265
[B] If Nguyen-Runesha's (iunsolver = 2) solver is used: (B.1) Performing LU factorization (without unrolling strategies) call unsynumfa1 (ndof .ia.ja.ad.an.iu.ju.di, un.ip.iup.isup d.anz, un2,di2) (B.2) Performing forwardlbackward solutions call unsyfbe
(ndof,~,ju,di,~,b,;,~)
[C] if SGI's Unsymmetrical Sparse Solver (iunsolver = 3) is used: [C.l] Converting the coefficient matrix into SGI formats [C.2] Performing SGI unsymmetrical sparse factorization [C.3] Performing SGI unsymmetrical sparse forwardlbackward solution.
4.14 A Numerical Example
In this section, a small-scale (academic) example is provided for the following objectives: (a) To validate the developed computer program and the associated subroutines (for option to do sparse assembly process only) (b) To help the user to know how to prepare the input date filets) [A] Descriptions of the Illustrated Example: Please refer to Section 4.7. [B] Typical Input Date File (= test. dat) Please refer to Section 4.13. 4,9,4, 1,1,1, 3 1, 5, 9, 13, 17
.Input general control information .input or generate ie(-) array
13.8,1,61, [7,3,2, 4j,~, 2, 3, 6~t7, 9, 8, 31
(see Step 1) (see Step 2, and Eq.[4.41J)
.input or generate jet-) array . (see Step 2, and Eq.[4.42J)
Remarks
Different options/capabilities provided by the developed software can be specified by changing a few input values in the general control information (see Table 4.9 and Section 4.13). 4.15 Summary
In this chapter, numerical strategies and the computer software implementation for both symmetrical and unsymmetrical sparse assembly algorithms and solvers have been described. Detailed step-by-step procedures, in the form of the developed "template," have been presented. A simple numerical example is given to validate the proposed algorithms and their developed computer software.
266
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Finally, detailed input data file has been explained so that the users will have sufficient background and experience to incorporate the developed procedures into his/her large-scale application code s.
4.16 Exercises 4.1
For the above finite element model, which consists of three rectangular and one triangular elements, assuming each node has only one degree-of-freedom (dot), and the prescribed Dirichlet boundary conditions at nodes 6 - 8 are given as:
assuming the symmetrical element stiffness matrix for the typical rectangular, or triangular elements, are given as: [k <e)] = k. . = {(i + j) * 4, for i = j I .) i + j, for i ::1= j
(a) Find the integer array s tie}, {je}, {iet}, and {jet} (b) Compute the arrays {ia}, {ja}, {ad}, {an}, and [b} , which represent the total stiffness matrix and load vector, respectively (before imposing the Dirichlet boundary conditions) (c) Re-do part (b), after imposing boundary conditions 4.2 Re-do problem 4.1 for the case of unsymmetrical element stiffness matrix, where (i + j) * 4, for i = j [k <e)] = ki,j = {
i + j,for j > i - (i
+ j), for j < i
and Nguyen-Runesha' s unsymmetrical sparse storage scheme is used (see Section 4.10) . 4.3 Re-do problem 4.2 , but use SGI unsymmetrical sparse storage scheme (see
Duc T. Nguyen
267
Section 4.10). 4.4 Re-do problem 4.2, but use l. Duffs unsymmetrical sparse storage scheme (see Section 4.10)
5 Generalized Eigen-Solvers 5.1 Introduction Eigen-value problems arise naturally in many engineering applications such as free structural vibrations , structural dynamics, earthquake engineering, control-structure interactions, etc. Solution algorithms for both "standard" and "generalized" eigen-value problems are well documented in the literature [5.1 - 5.1 0]. The focus of this chapter is to explain some efficient algorithms, which take full advantages of sparse technologies, to find the solution of the following generalized eigen-problem: (5.1) where [K] ==nXn stiffness matrix [M] ==nXn mass matrix <jli == eigen-vectors A. i == eigen-values
If the mass matrix [M] is equal to an identity matrix, then the generalized eigenequation (5.1) will become the following standard eigen-problern: (5.2)
5.2 A Simple Generalized Eigen-Example Considering the following numerical data: [K]=[
5-2]
-2
2
(5.3)
[M]=r~ ;1
(5.4)
K<jl-A.M<jl=O
(5.5)
From Eq.(5.1), one has:
270
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
[K -A.M] = 0
(5.6)
(5.7)
The homogeneous system of Eq.(5.7) will have non-trivial solution if we set: det
5 - 5A. 4
- 2 - 0
-2
(5.8)
2-!:5
The corresponding two roots (= eigen-values) of the determinant Eq.(5.8) are given as:
A = Al = 2
(5.9)
1..=1.. 2=12
(5.10)
Substituting Eq.(5 .9) into Eq.(5.6) , one obtains:
2]{~1)} {O }
= 2.5 [ -2 1.6 «l>~ ) 0
(5.11)
Observing the Eq.(5.1I), one recognizes that the two equations are NOT independent, and therefore, there is only one (= n-l= 2-1) independent equation. Since there are two
unknown~ (=
tPl(I ) and
tPil ») and only one independent equation,
there is an infinite number of solutions to Eq.(5.11). A solution can be found by selecting, for example (5.12) Then the other unknown «l>:J) can be found from Eq.( 5.11) as: (1) I -
i5
(5.13)
Similarly, substituting Eq.(5.1O) into Eq.(5.6), and selecting ~2) = 2
(5.14)
Then, :2) can be solved as: .1. (2 )
'1'1
-_3. -
Thus, the eigen -matrix [ J can be formed as:
5
(5.15)
Due T. Nguyen
271
(5.16)
Following are two properties of the eigen-matrix normalized eigen-vectors: [
[}, for the appropriated choice of
Y[MI} =[1]= Identity matrix [Y[KI}=[A~
AOJ
(5.17) (5.18)
5.3 Inverse and Forward Iteration Procedures An eigen-value and its associated eigen-vector of Eq.(5.1) can be found by the following "inverse iteration" procedure, which is shown in Table 5.1:
Table 5.1 Inverse Iteration Procedure
Step 1: Guess eigen-pair solution (5.19) (5.20) Step 2: Substitute Eqs.(5.19-5.20) into Eq.(5.1), hence
[KXx]}:;t (1)[MXxJl
(5.21)
The new, better guess {x 2} can be found from:
[KXX 2}= [MXxj}
(5.22)
Step 3: If convergence is not yet achieved, for example
II~-~II>E then {x]} and {x2}in Eq.(5.22) will be replaced by {xz}and respectively.
(5.23)
{X3}'
The "forward iteration" procedure is very similar to the inverse iteration. The only difference is the new, better guess {x 2} can be found from the following (instead of Eq.[5.22J): (5.24) It is, however, preferable to solve for a new, better vector {x 2} from Eq.(5.22) rather
than from Eq.(5.24), since the former is involved with stiffness matrix, which is
272
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
usually positive definite, and therefore, the solution for {x 2} can be found more easily! The inverse iteration procedures can often be incorporated with the usage of an orthonormality condition, as illustrated in Table 5.2. The following assumptions are made: (a) The stiffness matrix [K] in Eq.(5.1) is positive definite. (b) The mass matrix [M] in Eq.(5.l) can be a diagonal mass, with or without zeros on the diagonal. Matrix [M] can also be sparse and/or banded. (c) If the stiffness matrix [K] is only positive semi-definite, a "shift" should be used prior to the iterations.
Table 5.2 Inverse Iterations with Orthornormality Conditions
Step 1: Guess eigen-pair solution
Step 2: For k = 1,2,3 ... until converge, solve for x i-r from the following equation [KRxk+l}=[MRxd (5.25) In order to satisfy the mass orthonormality condition (5.26)
{Xr+l}*[M]*{x k+d = 1 We need to orthonormalize the vector {x r-i} obtained from solving Eq.(5.25), as following: {xk+l } --
{Xk+l} T
(5.27)
~ I
(Xk+1MX"k+l) 2
The following example is used to illustrate the details involved in the algorithms shown in Table 5.2. Example: The stiffness and mass matrices [K] and [M] are given as:
[K]=r~lo ~l ~1 ~1 o
-1
2
-1
0
-1
1
(5.28)
Duc T. Nguyen
273
(5.29)
Initial guesses:
{x1Y Improved guessed vector
={I,
I, I, I}and A=I
{x2} is solved from: [KRx2}= [M]{x]}
(5.30)
(5.31)
Thus (5.32) Compute: (5.33)
Impose the mass orthonormality condition to obtain the new vector {x 2} :
3
1
6
.J136
7 8
{x 2 } =- - *
(5.34)
The above steps are repeated again, to obtain:
[KKx 3 }= [M]{x 2 }
(5.35)
Solve for
20
{x3 }=(_ 1
.J136
J*
40
(5.36)
48
56 }_ 6336 {-x3 }TM{x3 - - 136
20
{x 3
}=(
J* .J6336 1
40
(5.37)
0.251 0.503
48
0.603
56
0.704
(5.38)
274
Finite Element Methods: Parallel -Sparse Statics and Eigen-Solutions
The corresponding "exact" eigen-vector is:
0.250 (1)
0.500
=
(5.39)
0.606 0.707
[K~ (I) }=A.I[M]~ (I)}
(5.40)
It should be empha sized here that it is difficult to assure the convergence to a specific (and arbitrary selected) eigen-value and the corresponding eigen-vector.
2
-1 0 0
-1
0
0.250
0
0
0.250
- 1 0 0.500 =A 1 -1 2 -1 0.602 0 -1 1 0.707 2
0.500
2 0
0.602
(5.41)
0.707
From Eq.(5.41), one has: (5.42)
A. I = 0.148 5.4 Shifted Eigen-Problems
The following example will demonstrate "shifting" procedures can be used to obtain eigen-solutions in the case where the stiffness matrix [K] is singular.
Example: The stiffness and mass matrices [K] and [M] are given as:
[3 -3].[M] =[2 1]
'[K] =
- 3
3'
1 2
(5.43)
The "shifted" stiffness matrix lKJ can be computed as: lKJ=[K]-p[M]
(5.44)
where p is the shifted value. The "new" eigen-problem is defined as:
lK!\j1} = ~[MR\j1}
(5.45A)
Substituting Eq.(5.44) into Eq.(5.45) to get: (K - pMW = ~M\j1
(5.45B)
or (5.46)
Due T. Nguyen
275
Comparing the "new" eigen-problem of Eq.(5.46) with the "original" eigen-problem shown in Eq.(5.I), one has: (5.47) A=P+1l and (5.48) Thus, the eigen-vectors of Eq.(5.1) and Eq.(5.46) are the same, and the eigen-values of Eqs.(5.I, 5.46) are different only by the shifted value p. For the numerical data shown in Eq.(5.43), one has:
3 -3] ,J2 [-3 3 {<j>}='ll
(5.49)
or (5.50) For non-trival solution, we require the determinant of the coefficient matrix (= K - AM ) in Eq.(5.50) to be vanished, thus: detlK - AMI = 0 = 31.2 -181. = 0
(5.51)
or
A = A] = 0
(5.52)
1.=1. 2 = 6
(5.53)
Substituting Eq.(5.52) into Eq.(5.50), one obtains the first eigen-vector:
J~I») = {II J6} 1<j>~)
1/16
(5.54)
Substituting Eq.(5.53) into Eq.(5.50), one obtains the second eigen-vector:
J~2») = { 1<j>~2)
11J2 } -1/ J2
(5.55)
Now, using the shifted value p =-2 into Eq.(5.45B), one obtains:
[7 -I]{\j1}= [2 1]{\j1} -I
7
11 1 2
(5.56)
The two eigen-values from Eq.(5.56) can be obtained as: 11 = IlJ = 2, hence AJ = p + II I = - 2 + 2 = 0
(5.57)
11 = 112 = 8 , hence 1.2 = P + 112 = -2 + 8 = 6
(5.58)
Substituting the eigen-values 11 from Eqs.(5.57 - 5.58) into Eq.(5.56), one obtains the following eigen-vectors:
276
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
(5.59)
(5.60)
5.5 Transformation Methods The eigen-vectors {(i)} obtained from solving the generalized eigen-equation (5.1) have the following properties :
[P[KI]
l \1
[l'[MIJl Where the eigen-matrix
[(J>]
~1
(5.61)
(5.62)
is defined as:
[(J>] = l(l)
( 2)
••••••
(n)J
(5.63)
The basic idea in the transformation methods is to reduce (or transform) the matrices [K] and [M] into diagonal forms by using successive pre- and post- multiplication by
JT,
and [Pk ] , respectively. These ideas are based on the properties matrices [Pk given in Eqs.(5.61-5.62). The main ideas behind the transformation method can be summarized in Table 5.3.
Duc T. Nguyen
277
Table 5.3 Transformation Methods Let K I = K and M I = M
(5.64)
Then (5.65) (5.66)
(5.67) Similarly : (5.68)
M 2 =PITM1P1 M3 =
pIM P = pI (PITMIPI)P2 2 2
(5.69)
(5.70)
Comparing Eqs.(5.67, 5.70) and Eqs .(5.6l, 5.62), one clearly sees that if matrices P, are properly selected , then [Kk+tl
~[A]
and [Mk+tl
~[
I ] as k~ oc
in which case; with I being the last iteration , then the eigen-marix [J can be symbolically represented as: (5.71) In practice, it is NOT necessary that [Kk+tl converges to the diagonal eigen-values matrix [A], and [Mk+tl converges to the identity matrix [I]. Rather, it is only required that both [Kk+tl and [Mk+tl will converge to diagonal matrices , then diagonal k (/+1)
[AJ=
(5.72)
r
diagonal M ~l + I)
and
[J= (PI Pz ... PJ ) *
1
~diagonal M~/+I)
[A] Jacobi Method for the Stand ard Eigen-Problems
In this section, the following standard eigen-problem
(5.73)
278
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
(5.74) will be solved by the Jacobi method. Eq.(5.74) is a special case of the generalized eigen-equation (5.1) where [M] is set to be the identi ty matrix.
From Eqs.(5.70 , 5.62), and realizing [M) = [I], one has: M k +\ = PJ[I]J\ = [I)
or (5.75) Thus , the transformation methods (such as Jacobi method) require the selected matrix [Pd to have the properties as indicated in Eq.(5.75 ). The matrix [Pd, therefore, should have the following form:
~
- sine
cos e
i 1hrow
Pk =
(5.76)
... ... ... sin e
... ...
'"
cos e
...
~
j lhrow
Where e is selected such that the element (i, j) of [Kk+Jl at (k+ l)th iteration will become zero (since the main obje ctive of the Jacobi method is to transform the origin al matrix [K) into a diagonal matrix where all the off-diago nal terms K i , j will become zeros) . Considering the following triple produ cts: K k+1 = pJKkPK , or
(5.77)
Due T. Nguyen
279
a b b
g
c
h
I
m n
0
m n
p
q
r
q
S
0
r
t
d
e j f k cos B
e f j k
c h
sine
d
cos B
f k
I
m n
0
m n
p
q
r
q
s
t
0
r
t
u
c
b
g
h
c
h
e j f k
(5.78) e
a b
d
-sine
u d
cos B
-sin e
sin e
cos O
Assuming that i = 2 th and j = 5 th locations, and observing Eq.(5. 78), one clear ly sees that [Kk+d and [KJ are only different at locatio ns (2, 2), (2, 5), (5, 2), and (5, 5), and all remaining terms of matrices [Kk+d and [KJ are unchanged. Thus, at the (k+l)lh iteration, one only needs to consider the follow ing portions of the triple product: K
. [ K(k) K(k ) ] . _ p,TK P - [ cos B smo] ii ij -smo] k+1 - k k k - -sin 0 cos B K~~ ) K~~) sin 0 cos B
[COSO
JI
(579) .
JJ
where
The objective to select the matrix P, (at the k" iteration) is to make sure that in the next iteration (or the [k+l]th iteration), the off-diagonal terms of [Kk+d will be driven to zeros. Hence , setting the off-diagonal term s K
t: =Kj~+l)
= 0, and equating
with the corre sponding right-hand-side terms of Eq.(5.78), one can solve for the unknown 0 , from either of the following formulas: 2K~~)
tan(20) =
11
K ~.k)-K ~~)' II
.u
for K ~.k) II
or O=~ forK ~.k) =K ~~) 4' 11 lJ
;t:
K ~~)
(5.80)
JJ
(5.81)
280
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
If "I" is the last iteration, then
(5.82)
convergence to a tolerance conditions are met:
~
has been achieved , provided that the following
(a) Diagonal terms do NOT change much, or
K ~!+l) - K~!) I I'---------'-:s;1O~ II
11
_)0
i=1,2,···,n
K~!+l)
(5.83)
II
(b) Off-diagonal terms approach zeros, or 1
l
K(~~:;;(:+I) ]2 :s; II
10-1;
i <j
(5.84)
JJ
The step-by-step Jacobi method for the solution of the standard eigen-value problem can be given as follows : ~: At the sth sweep, a threshold for a near zero tolerance value is defined as
10- 25 . Step 2: For all Ki,j terms (with i<j, and i, j = 1,2, ..., n = size of matrix [KJ), compute the coupling factor according to the left-hand side of Eq.(5.84), and apply the transformation (see Eq.[5 .79]) if the factor is larger than the current threshold. Step 3: Use Eq.(5.83) to check for convergence. If convergence is achieved, then the process is stopped; otherwise, return to Step 1 for another sweep.
Example
[Kl= [5~
-4
Given
-4
I
~ 1=[K']
6 -4 ,- 4 6 -4 I
- 4
5
For sweep 1 we have as a threshold 10,2. Therefore we obtain the following results. For i = I , j = 2, applying Eq.(5 .80), one gets:
Due T. Nguyen
281 case =0.7497 ; sin e = 0.6618
and thus, from Eq (5.76), one has:
0,7497 0.6618
PJ =
o o
[
T
[
o
9.531 0 - 1.898 -3.661 0.6618
For i
010
o
1.169 PI KPI =
-0.6618 0 01 0.7497 0 0
0.7497
0
1
-1 .898 0,6618] -3.661 0.7497 =[K 6
-4
-4
5
] 2
= l ,j = 3: cos e = 0.9398 ; sin e = 0.3416
[
0'9~98 ~ -0.~416 ~~1
P2 = 0.34 16
T
T
2
I
P P KP P
I 2
= [
o
0
0.9398
0
0
0.7792 -1.2506 0 -0.74441 -1.2506 9.5314 -3.4402 0.7497 [ ] = K 0 -3.4402 6.6891 -3.9853 3 -0.7444
0.7497
- 3.9853
0,7046 - 0.6618 -0.2561 0.6220 0.7497 -0.2261 PP I 2 - 0.3~16 o 0.9398 [
o
For
j
o
= 1, j =4: cos
e = 0.9857 ; sin e = 0.1687
5.
0~11
282
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
0.9857 0 0 -0.1687] o I 0 0 P 30 0 I 0 [ 0.1687 0 0 0.9857 0.6518 T
T
T
3
2
1
PPPKPPP= 1 2
3
[
-I.I06 9.531 -0.6725 -3.440
o
0.9~99]
-I.I06 -0.6725
0.9499
-3.440 6.690
-3.928
-3.928
5.127
= [K
] 4
0.6945 -0.6618 -0.2561 0.6131 PP P J 2 3 0.3367 [ 0.1687
0.7497
o o
-0.1189] -0.2261 -0.1050 0.9398
-0.0576
o
0.9857
For i = 2, j = 3: cos O = 0.8312; sin e = -0.5560
0 0 0] 0.8312 0.5560 0 0 -0.5560 0.8312 0
I P = 0 4
[
o
0
0
I
-I.I74
o
-2.737
-2.737
5.127
0.6945 - 0.4077 -0.5808 0.6131 0.7488 PP P P = 1 2 3 4 0.3367 _ 0.5226 [ 0.1682 0
2.~74
4.388
]=[K ]
0.2289
-0.1189] -0.1050
0.7812
-0.0576
o
0.9857
To complete the first sweep, we kero element (3,4)1, using cos O = 0.7335; sin e = -0.6797
5
Due T. Nguyen
283
1 0 P6 = 0
o [ o
1
o o
0 0.7335 06U 0 -0.6797 0.7335
J
and hence the approximation obtained for A and are
i.e.,
A=
-0.5098
0.9926
12.96
-0.7124
-0 6560j -0.6601
-0.9926 -0.7124
6.7596
0
-0.6560 -0.6602
0
1.6272
[06518 0.5098
and
i.e.,
0.6945 -0.4233 -0.4488 0.6131
==
[
0.6628
0.3367 -0.5090 0.1687
0.3498
0.4152
-0.3702j -0.1113
0.4835
0.6275
-0.6264
0.6759
And after the third sweep we have
13.09
6.854
j 1.910
-0.3717 -0.6015 -06015j [03717 0.6015 0.3717 -0.3717 == 0.6015 0.6015 -0.6015 0.3717 0.3717 0.3717
0.3717
-0.6015
0.6015
284
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
The approximation for A is diagonal to the precision given and we can use
A]
=0.1459;
1
=
0.3717] 0.6015 0.6015 0.3717
~=1.91O;
2
l l l
=
- 0.60151 -0.3717 0.3717 0.6015
~
=6.854;
3
=
- 0.60151 0.3717 0.3717 -0.6015 717 - 0.6015 0.3 1
4
= -0.6015 0.3717
[B] Generalized Jacobi Method for Generalized Eigen-Problems For the generalized eigen-problem as described by Eq.(5.1), we wish to diagonalize both the stiffness and mass matrices [K], and [M], respectively. Thus, the transformation matrix [Pk ] will be selected as: 1
1
(5.85)
The new, updated matrices [K] and [M] in the next iteration can be computed from the current iteration as follows: (5.86)
Due T. Nguyen
285
or
[
K ~~ +I ) II
(5.87)
K~~+I) JI
_
-
or
[
K~~+I) II
o
0] [x _
K(k+I)jj
[
K~~) + OIK~~) II JI K~~) + 02K~~) JI
II
e2 {K(.k)+OK(~)}+{K~~)+OK(k)}] II I JI IJ I JJ
x
(5.89)
x
The off-diagonal terms on both sides of Eq.(5.89) are equated to each other, thus K(k+l) = 0 = 02K(k) + {I + 0I02}K(k) + 0IK(k)
(5.90)
M~k+l) =0 = 02M(~) + {I +OI02}M(k) +OIM\~)
(5.92)
IJ
II
JJ
IJ
Similarly, one has:
Q
The two unknowns simultaneously [5.5]:
01 and 02
JJ
Q
II
can be found by solving Eqs.(5.90,5.92)
(5.93) where (5.94) (5.95) (5.96)
{
(k)}2 ~ +a]=eigen-vectors (see Eq.5.1)
00
Remarks (a) Inverse iteration method is employed in Eq.(5.103) (b) Generalized Jacobi iteration method can be used to solve the reduced eigenequation (5.106). (c) The initial guess eigen-vector [XJl should contain independent columns. The simplest guess for [XJl is: (5.108) where
o o e(i) =
1
o o
--7 i throw
= unit vector
(5.109)
o nxl Example
The numerical data for the stiffness and mass matrix [K] and [M] are given as:
288
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
(S.IIO)
Assuming the initial guess for eigen-vectors is given by
[x,l=
[x 2 ] can
[~
r]
(S.III)
be solved from Eq.(5.103): (S.1I2)
Reduced stiffness and mass matrices can be found from Eqs.(5.104 - 5.105):
I)[S 3]
- T- ( [K R] 2 = X 2 KX 2 = "4
3 S
(S.I13)
(S.114) Solution of the reduced eigen-problem: [ K~ ]
[Q2l =[A 2l [M~ ] [Q2l
can be solved "iteratively" (by using Generalized Jacobi method), or can also be solved "directly," and "exactly" since the system is involved with only 2x2 matrices.
Thus [A2] =
[~ ~] =eigen-values of the reduced system
(S.IIS)
1
[Q2]=
-If 21 -2 rJ2
= eigen-vectors of the reduced system
The new, improved eigen-vectors can be obtained from Eq.(S.107):
(S.116)
Due T. Nguyen
289
L.
12 [X 2 ]=[X2 ] [Q2]= ~
-1
0
(5.117)
1
12 In this particular example, we obtained the "exact" eigen-values (see Eq.[5.115]), and "exact" eigen-vectors (see Eq.[5.117]) in one iteration (of the sub-space iteration loop)! This quick convergence is due to the fact that the starting iteration vectors [Xd (see Eq.[5.l11]) span the sub-space defined as the "exact" eigen-vectors $(1 ) and $(2) •
Proof (for the above paragraph)
The first two "exact" eigen-vectors from a 3x3 system given by Eq.(5.11O) are:
(5.118)
(5.119)
and
(5.120)
where
290
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
In other words, the exact first two eigen-vectors
(1 )
and
(2)
can be expressed as
linear combinations of the columns of the starting iteration vectors [XIl. Thus, sub space iteration algorithm converges in just one iteration.
5.7 Lanczos Eigen-Solution Algorithms For a large -scale system, if one has interest in obtaining the "first few" eigen-pair solutions for the generalized eigen-equation (5.1), then sub-space iteration algorithms can be employed. However, if the number of requested eigen-pair solutions increase, then the computational cost involved in sub -space iteration algorithms will increase very quickly. Thus, in this case, Lanczos eigen-solution algorithms are highly recommended (due to their highly computational efficiency).
5.7.1 Derivation of Lanczos Algorithms
The main steps involved in the Lanczos eigen-solution algorithms can be summarized in Table 5.4 . Table 5.4 Basic Lanczos Algorithms for Eigen-Solution of Generalized EigenEquation K = AM Step I : Input data Given the stiffness matrix [K]nxn, and mass matrix [M]nxn Let m == the number of requested eigen-values, and the corresponding eigen-vectors Let r == (2 or 3) * m
(5.121)
Step 2: Factorized the sparse stiffness matrix
[K]
=[L] [D] [L]T
(5.122)
Step 3: Select an arbitrary vector {x}, and normalize this vector with respect to the mass matrix [M], by the following operations
b=~x T Mx {x(I )
(5.123)
}= first Lancozos vector = {x}
(5.124)
b
(5.125 )
Let b)= 0 Step 4: Compute subsequent Lanczos vectors [x'"] where i = 2, 3,4, ... , r (a) Performing forward and backward solution to solve for vector { X l i )
}:
Duc T . Nguyen
291
[K J{x(i) }= [M]{x (i-I) }
(5.126)
(b) Compute the scalars a j -l
= ~(j) Y[MRx(i-l)}
(5.127)
~
already calculated in step 4(a) (c) Orthogonalize the Lanczos vector with respect to the mass matrix [M]
~ (i) }= ~(i ) }_ ai - 1{x (i - I) }_ b _
{x
i 1
(i-2) }
(5.128 )
(d) Normalize the Lanczos vector with respect to [M]
b 1.
=~x(i)TMx(i)
(5.129)
Get subsequent Lanczos vectors (5.130)
Step 5: Form the symmetrical, tri-diagonal matrix [T]rxr al bz
0
0 b3
0 0 az b3 a3 b 4 bz
0 0 0
0 0 0
[Tr ]=
(5.131)
Step 6: Compute the standard eigen-solution of the reduced , tri-diagonal system (5.132) 1
where A=-
(5.133)
Il Step 7: Recover the original eigen-vectors ell (5.134)
where
[X]=~ (I),
x(2) ,
, x(r)J=Lanczosvectors
(5.135 )
292
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Few Remarks about LaIt'zos Algorithms in Table S.4
(I) The relationship between the original, generalized eigen-equation Klj> = AMlj> , and the reduced, standard, tri-diagonal eigen-equation Trlj>* = Illj>* can be established as follows:
Pre-multiplying both sides of Eq.(S.I) by MK 1, one has MK -1(Klj» = AMK-1(Mlj»
(S.136)
or .!-Mlj>=MK-1Mlj>
(S.137)
A
Substitute Eq.(S.134) into Eq.(S.137), to get: (S.138)
(i)M(Xlj>*) = MK-1M(Xlj>*) Pre-multiply both sides of Bq.(S. 138) by X T to get:
(S.139)
Since the Lanczos vectors [X] is orthononnalize with respect to the mass [M] matrix, hence (S.140)
Using Eq.(S.140), Eq.(S.139) becomes: (XTMK-1MX)lj>* = (i}*
(S.141)
Comparing Eq.(S.141) with Eq.(S.132), one concludes:
[Tr ] == [Xf [M] [K-1 ] [M] [X]
(S.142)
and (5.133, repeated) (2) In practice, we never form the tri-diagonal matrix [1',] according to Eq(S.142) . Rather, [1',] is formed by Eq.(5.131). To prove that Eq.(S.131) can be obtained by the transformation of Eq.(5.142), one starts with Eq.(S.126): xli) = K- 1Mx(i-1) (5.143)
Due T. Nguyen
293
Also, from Eq.(5.128), one obtains: x ci) = a. X(H ) + b. x(i-2) + x ci) ,-I ,-I
(5.144)
Using Eq.(5.130), Eq.(5.144) becomes: x (i) = a.,-I X(H ) + b..-1 x(i-2) + b.x'" I
(5.145)
Comparing Eqs. (5.143,5.145), one obtains: x (i) = K-1Mx(H ) = a.1- IX(H) + b.1- ,x(i-2) + b.x(i) J
(5. 146)
Using the above relation for i = 2, 3,4, .. ., r (and recalled b , = 0), one obtains: x (2) =ajx(l ) +b 2x (2) (5.147) (5.148) (5.149)
x(r) = a
r-I
x(r-I) + b
r-I
x(r-2) + b x(r) r
(5.150)
Eqs.(5.147 - 5.150) can also be represen ted as: QI
b2
b2
Q2
0 b3
b3
Q3
o
• . . , x ( r)
0 0 b4
o o o
0 0 0
Lxr
br _ 1
Qr - l
br
b
r Qr
rxr
0 x(r) I (r) 0 x2
0 0
(5.151)
+ br
0 ... ... Thus, Eq.(5 .146) can be expressed as: K-1MX(j) = X(j)[Tr ]+ bJ(j+1)
...
0
lxl ~(j) ~n
x(r) n nxr
(5.152)
where
J (j) 1T fa 0, "F bxn = 1',
0, ' -
(5.153)
at the i" location
294
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
Pre-multiplying both sides of Eq.(5.152) by XU) M, and using the Morthonormality of Lanczos vectors XU), one has: X(j)TMK-1MX (j) =
~)[Tr]+ bjX~+I)e(j)T [Identity]
(5.154)
[Zerol (5.142, repeated)
Eqs.(5.150 - 5.152) have clearly indicated the tri-diagonal matrix [Tfl can also be assembled from Eq.(5.13l), rather than from Eq.(5.142) . (3) When the size of [Tf] becomes nxn, x(n) calculated from Eq.(5.128) becomes{O} since the complete space is spanned by [X]nxn and no vector M-orthogonal to all vectors in [Xl nxnexists! (4) Either QL or Jacobi algorithms can be used to solve the standard, tri-diagonal eigen-problem shown in Eq.(5.132). However, QL algorithms seem to perform better in this step! (5) For a large-scale finite element model (where n ~ 106 dot), the memory requirements to store (2 or 3) *(m = # requested eigen-pair) Lanczos vectors could be very significant. (6) Handling an Indefinite Matrix
For some applications, such as linearized buckling analysis, or when a diagonal (lumped) mass matrix has zero diagonal terms, then the generalized eigen-equation can be expressed as: (5.154A) where
[A] = real, symmetric, positive definite, linear tangent stiffness matrix [B] = real, symmetric (does NOT have to be positive definite), linearized geometric stiffness matrix
To avoid numerical difficulties, (such as the square root operations defined in Eqs.[5.123, 5.129]) associated with Lanczos algorithm for Eq.(5.154A), it is fairly common [5.11] to solve the following modified eigen-equation that deals with two positive definite matrices: (5.154B)
Duc T. Nguyen
295
where
[A]=A+B
(5.154C)
-1J
1" = - A·I J - ( -A .
(5.154D)
I
The equivalence between Eq.(5.l54A) and Eq.(5.154B) can be easily established by substituting Eqs.(5.154C and 5.154D) into Eq.(5.154B) :
(5.154E) Multiplying both sides of the above equation by ( -Ai), one obtains: (5.154F) The above equation is exactly identical to Eq.(5.154A)!
5.7.2 Lanczos Eigen-Solution Error Analysis
From Eq.(5.137), one has:
MK -IM<j>:::~M<j> A
(5.137, repeated)
Assuming [M] is a positive definite matrix, then [M] can be decomposed according to the Cholesky factorization:
[M)::: [L][LY == [UY[U]
(5.155)
where [L)T == [U]::: upper-triangul ar matrix. If lumped mass formulation is used, then [M] is a diagonal matrix, which may have some zero diagonal elements. In this case, one first needs to perform "static condensation" to remove those massless degree-offreedoms. Substituting Eq.(5.155) into Eq.(5.137), one gets: (U.:")K-1(LLT)<j>::: ~ (LLT)<j>
A
(5.156)
Define (5.157) Then Eq.(5.156 ) becomes : (5.158)
296
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Using the definition given by Eq.(5 .133), the above equation becomes: U} K - I L'JI = JlL'JI
(5.159 )
Pre-multiplying Eq .(5.159) by L-J , one obtains: (LTK-1L)\jI = (Jl)'JI
(5.160)
Eq .(5.160) can be recognized as the standard eigen-problem where the coefficient matrix is eK1L. The "residual" vector obtained from the standard eigen-problern (see Eq .[5.160]) is given as: (5.161) Substituting Eq.(5.157) into Eq.(5.161), one gets:
(5.162) Using Eq.(5.134), Eq.(5 .162) becomes: Ilr O)1I = !ILf K-1LLTX$*(i) - JliLTX$ *(i)11
(5.163)
T IIr(j )11 = liLT (K-1LL X - JliX)$ *O)11
(5.164)
Pre-multiplying both sides of Eq.(5.132) by [X], one obtains: [X][Tr}P*(j) = Jli[X]$*(i)
(5.165)
Comparing both sides of Eq .(5 .165) , one concludes: Jli [X] = [X][T r]
(5.166)
Substituting Eq.(5.166) into Eq .(5.164), one obtains: Ilr(j)1I =
IILf (K -1LLTX -
XTr)$*(i)11
(5.167)
or (5.168) Using Eq.(5 .152), Eq.(5.168) can be re-written as: T
Ilr(i)II=IIL (bj x(j+l) e(j) T)$*(i)II The Lanczos vectors [X];: l~ (I ) }
~ (2) }
• .• ,
{x( r) ~ are orthonormalized with
respect to the mass matrix [M] , hence (5.169)
Due T. Nguyen
Substituting Eq.(5.155) into
297
Etji(~~'69), one has:
X T (LLT)X =[1]
or (XTL)(LTX)=[I] or (LTX)T(LTX) =[1]
(5.170)
From Eq .(5.170), one concludes: (5.171) Using Eq.(5.171), Eq.(5 .168) can be re-written as:
IlrO)11 = he(j)Tq>*(i)II
(5.171A)
Referring to the definition given in Eq.(5.l53), Eq.(5.171A) becomes:
Ilr (i) II = lib j$.j,i II
(5.172)
wherefj,i is the j" element of the vector $·(i)ofEq.(5.132). It can be proved that [5.5J (5.173) where): is the calculated eigen-value, and Ai is the exact ith eigen-value. Therefore (5.174) Since we do not know the exact eigen-values Ai' the error bound equation(5.l74) will not tell us if the calculated eigen-value x is close to which exact eigen-value. A Sturm sequence check, therefore, needs be applied for this purpose.
Derivation of Eguation(5.173) For the "standard" eigen-problem, [M] = [1], and the generalized eigen-equation (5.1) becomes: (5.175) K$ = A[M = 1]$ = A$ Let I and ~ be the computed eigen-value, and the corresponding eigen -vector of Eq.(5.l75). The residual (or error) vector can be expressed as:
r=K~-A$ Since [M] = [I], Eqs .(5.61 - 5.62) become:
(5.176)
298
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
(5.177)
(5.178) where (5.179) Pre-multiply and post-multiply both sides of Eq.(5.177) by , and T, respectively (and also using Eq.[5.178]), then Eq.(5.177) becomes: (5.180) K = [A] T Substituting Eq.(5.180) into Eq.(5.176), one obtains: r = A T~ -"X: ~
(5.181)
or
or r = (A - "X:I) T~
(5.182)
Pre-multiply both sides of Eq.(5.182) by T to obtain: Tr = (A _ "X:I) T~ or (A - "X:I)-I Tr = T~
Pre-multiply both sides of Eq.(5.183) by to obtain: (A - "X:1)-ITr = ~
(5.183)
(5.184)
Taking the norm on both sides of Eq.(5.184), one has:
(5.185) Thus (5.186) The calculated eigen-vector
Hence, Eq.(5.186) becomes:
can be normalized, so that
Due T. Nguyen
299
(5.187) Also, since Hence Eq.(5.187) becomes: (5.188) Also, since (5.189) Therefore (5.190) Example: Consider the standard eigen-problem Klj> = Alj> , where [K]=[2 -1
-1] 2
The eigen-values of the above matrix are roots of the following characteristic equation: det
I
2- A -1 =0=4+A2 -4A-1 -1 2-A 1
or
hence
A = 4±.Ji6=U= 4±J4 2 2 Thus A= Al = 1 A=A 2=3 The two "normalized" eigen-vectors (/1) and f/J, (2) which correspond to the two eigen-values Al =1 and A2 =3, respectively, can be computed as:
300
Finite Element Methods: Parallel-Sparse Static s and Eigen-Solutions
assuming the calculated XI = 1.1and (jl(I) = {0.6} are approximations to 0.8
x,
and lIz
(5.213)
5.7.3 Sturm Sequence Check
The Sturm sequence check can be briefly described as follows : Step 1: Given the stiffness matrix [K]nxn and the shifted value p Step 2: Compute the stiffness matrix
lK to as follows :
K = K-pI Step 3: Factorize [K) as follows:
(5.214)
Due T. Nguyen
303
K == [L)[D][L]T
(5.215)
where [L] and [D] are the lower triangular, and diagonal matrice s, respectively.
Step 4: Count the number of "NEGATIVE" elements in [D], (say == m::;; n). Then, we conclude that there are "m" eigen-values of [K] whose values are less than p.
Example: Using the data from the previous example, assuming we have no ideas that the computed eigen-value Xis an approximation of 1.. 2 , hence (5.216) or
IIAi -1.111::;; 0.286
(5.217)
1.1- 0.286::;; Ai ::;; 1.1 + 0.286
(5.218)
Thus
0.814::;;
x, s 1.386
(5.219)
Let us use the lower bound 0.8, and upper bound 1.4:
(a) Consider lower bound case: K == K-O.8I == [1.2 A
-I
-I]
1.2
==[L][D][L]T
(5.220)
(5.221)
Conclusion: there is no eigen-values (of K == A*( j) 1+)
i
(5.24S)
(Aj)computed (3) Assuming SO (out of the m = 100 requested eigen-pair) have already been converged, we define : NEVNC =~umber of gigen-Yalues ~ot honverged Thus NEVNC = m-SO = 100-SO = 20 (4) The next time to solve the tri-diagonal eigen-system will be approximately at (2*NEVNC) iterations later (assuming i + 2*NEVNC ~ r, where r = maximum number of Lanczos steps). (5) Go back to Step 4(a), until all requested "m" eigen-values are converged. (6) If we wish to obtain, 100 eigen-values greater than certain threshold value (say p > 5 ), then a shift should be applied, such as: K=K-pM (7) Recover the original eigen-vectors
5.7.7 Educational Software for Lanczos Algorithms
Based upon the detailed step-by-step Lanczos algorithms presented in Table 5.6, an educational (non-sparse) version of Lanczos eigen-solver has been coded in FORTRAN and is listed in Table 5.7.
Due T. Nguyen
317
Many statements have been inserted in Table 5.7. Together with Table 5.6, the readers should be able to read and understand the presented Lanczos eigen-solver without too much difficulty. A far more efficient "sparse" Lanczos eigen-solver can be easily constructed simply by replacing the numerical recipe' s dense solver [5.12J embedded inside Table 5.7 with the sparse solver as described in Chapter 3 of this book. Table 5.7 Educational Lanczos Eigen-Solver (Version 3) c
Table 5.7: Education al Lanczos Eigen-Sol ver (Version 3) implicit real*8(a-h,0-z)
c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ c educational version of D.T. Nguyen's Lanczos code c DTN's original version> Feb. 1, 2000 ----» Sept. 17'2001 c...... (JQ debuged few errors/improvements) c++++++This code is stored under the file name education_lanc zos_3.f c++++++in sub-directory - /cee/educational*2001/ c education _lanczos_3.f
c c
c c c c
c c c c c c c c
c c c
c c c c c
c c e c
c c c c c
notes: (a) The main program is followed by all subroutines (in alphabet order) (b) JQ has made the following changes in DTNguyen's educational Lanczos [01] The order of computation for sub-matrices [T] should be: 1'(1,1),1'(1,2),1'(2,1), then 1'« 2,2), 1'(2,3),1'(3,2) etc... instead of 1'(1,1), then 1'(1,2), 1'(2,1), 1'(2,2), then 1'(2,3), 1'(3,2), 1'(3,3) [02] Error norm check should use the original [K] [03] Suppo se after say 20 Lanczos steps, it is time to solve the reduced , tri-diagonal [T] eigen-values. Just before this step, we need to save/copy the original [1'] (upto this point), since matrix [T] will be destroyed/overwritten/updated during this eigen-solution, and therefore if not all evalues converged yet, then we kneed to proceed for more Lanczos steps, by continuing to build up (or expand) the previous, original [1'], and "NOT" by expandin g the previous "destroyed/overwritten" [1'] [04] JQ used the same "approx, error estimation" for evalues as the one JQ did in the SPARSEPACK, or in ooc sparse Lanczos, which is different than the formula used by DTNgu yen's educational Lanczos version [OS] JQ used routine TQ2, instead of using DTNguyen's Jacobi to solve the redu ced [T] evalues problem, because: TQ2 is more efficient to solve the "STANDARD" eval ues problem JACOBI requires "positive" definite matrix [06] JQ added the option for finding n-evalues above the threshold value (this option should be useful, especially for electromagnetic problems, where users do NOT want to
318
Finite Element Methods: Parallel-Sparse Static s and Eigen-Solutions
c
find a lot of "near zero" evalues, which are useless! c c The value ofISHIFf need be activated ( = user's specified input) c for this option . Thi s option is also useful for "singul ar", or c "near singular" stiffness matrices. c [07] Each time that we generate a "new" Lanczos vector, we have also c had generated the associated constants "a" and "b", which are c used to construct the [T] matrix. After "re-orthogonalize" c the current Lanczo s vector with all previous Lanczos vector s, JQ c used the "new" const ant "b" in constructing the [T] matrix c [08] in re-ortho . routin e, JQ is faster because ofvector*vector operations c in re-ortho . routine , DTN is slower because of matrix*vector operations c (c) Upon completing all changes mentioned in item (b), DTNguyen has c already "successfully" tested different options in this educational c version of Lanczos (but not 100% thoroughly tested) c......Latest test = July 20, 2004
c c c
c c c c c c c c c
c c c c c
c c
Could also obtained CORRECT Lanczos solution for Subby's tiny CST structural problem: [K] = 1.53*D+06
-308378 1.1596D+06
[Diag. M] = 0.026
o o
o
-245739 0 1.53D+06
0
0.052 0 o 0.052
ABUQUS 's eigen-values =Subby' s code =(2.02D+07, 2.84D+07, 6.2D+07) [09] In this educat ional Lanczos (2-nd) version, if the problem size n_dof is too small (n_dof less than certain threshold value, say n_dof < 20 or 30), we will implement Lanczos procedures (not JACOBI procedure s) to find "ALL" eigenvalues!
c [10] Yes, we can requ est "ALL" eigen-values (from I to n_eigen -values) by Lanczos procedures.
c c c c c c c c c
c c c c
[11] Due T. Nguyen provided additional option, where user defines the the "full" stiffness and mass matrice s. [12] This educational Lanczos (3-rd) version will "re-orthogon alize" the current Lanczo s vector with "ALL previous Lanczos vectors". "Selective" re-orthogonalized wrt only those "few previous Lanczos vectors" (which failed the re-orthogonal checks ) will NOT be robust , and might give WRONG solutions to some cases. However , in this current implementation (including the ooc_ sparse_lanczos) we do NOT want to re-ortho gonal every Lanczos vector with all the other vectors either (since it will be highly inefficie nt). Thus, in this version (and includ ing the ooc_sparse_lanczos), we do NOT care about the array lossorth(-)
c
c c
[13] Due's implementation of "estimated " convergence check fonnular will take more Lanczos iteration s to converge, as compared to JQ's formu lar
Due T. Nguyen
319
c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ real*8 xk(l 000, I000), xm( I000, I 000), xx(lOOO), tempo] (l000), $ tempo2(l000), b(lOOO), x(lOOO,lOOO), a(lOOO), xj(lOOO), $ xitutar(lOOO), z(l 000, 1000), evalamda(lOOO), $ phi(lOOO,lOOO), omega(lOOO), xkorig(lOOO,lOOO) real*8 xmi(lOOO,IOOO), tridiam(l 000, 1000) reaJ*8 W(lOOO),wl(l 000),w2(1000),w4(1000),epsl ,eps2 integer lossorth(l OOO),indx(lOOO) c npe l 000 ! only for dimension purposes nsweeps=35 c read master control information write(6, *) 'Re-vised Version, or latest test Date: 07-20-2004' write(6,*)'LanFlag,ishift,irepeat,n,neig,lumpk,lumpm,ntimes $ .jacobonly.epsl ,eps2' write(6,*) 'LanFlag = 0 = DTNguyen"s (original) slower version' write(6,*) 'because matrix vector operations in reorthog routine' write(6,*) 'LanFlag = I = JQ"s faster version' write(6,*) 'because vector vector operations in reorthog routine' c########################################################################
open(unit=7,file="K.INFO",status="old",form= "formatted ") read (7 , *) LanFlag,ishift,irepeat,n,neig,lumpk,lumpm, I ntimes,jacobonly.epsl ,eps2,iauto_data write(6, *) 'LanFlag,ishift,irepeat,n,neig,lumpk,lumpm, I ntimes,jacobonly,epsl ,eps2,iauto_data = ' write(6,*) LanFlag,ishift,irepeat,n,neig,lumpk,lumpm, I ntimes,jacobonly.eps l ,eps2,iauto_data if ( n .gt. 999 ) then write(*, *)'Error: n cannot be larger than 999 !' stop end if c++++++ n = actual size of stiffness matrix c++++++ neig = number of requested eigen-pair solutions c++++++ lumpk = I (if diagonal stiffness is used), else general c stiffness is used c++++++ lumpm = I (if diagonal mass is used), else general mass is used c++++++ ntimes = factor to compute lanmax (Ianmax = ntimes * neig). c++++++ = 3 or 4 is a recommended value for ntimes c++++++ lanmax = max. number of Lanczos vectors generated c++++++ jacobonly = I (if "ALL" eigen-values/vectors are computed using CJACOBl method) c++++++ = 0 (if a "few" lowest eigen-values/vectors are computed Cby Lanczos method) c++++++ eps l , eps2 = small positive error tolerance used for convergence c check, or c++++++ orthogonalized check c ,. iauto_data = l (if [K] & [M] data are automatically generated) c iauto_data = 0 (if [K] & [M] data are specified by the user's input file K.INFO) c#########################################################################
c......Option for user's input data file (=K.INFO) to define [K) & [M) matrices if (iauto_data .eq. 0) then ! read (7 , *) «xk(i,j),j= I ,n),i=1 ,n) ! read STIFFNESS matrix, row-wise read(7,*) «xm(i,j),j=l,n),i=l,n) ! read MASS matrix, row-wise
320
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
c do 318 i=l,n do 319 j=l,n xk(i,j)=xk(i,j)-ishift*xm(i,j) 319 continue 318 continue c do 321 i=l,n do 322j=l,n xkorig(i,j)=xk(i,j) 322 continue 321 continue c step I: automatically generate stiffness and mass matrices else ! do 1 i=l,n do2j=l,n xk(i,j)=O.OdO 2 xm(i,j)=O.OdO 1 continue
c c 6
c c
8 7
c 3
c c
if (Iumpm .eq. 1) then do 6 i=l,n xm(i,i)=I.O xm(i,i)=1.0dO continue else do 7 i=l,n do 8j=i,n xm(i,j)=(-1.0)**(i+j)/(i+j) if (i .eq. j) xm(i,i)=i xm(i,j) = O.OOOOOl/(i+j) if ( i .eq. j ) xm(i,j) = 1.0DO xm(j,i)=xm(i,j) continue continue endif jjj = ishiftl 1 !1000 write(*, *)'JJJ ,irepeat= ',jjj,irepeat if (Iumpk .eq. 1) then do 3 i=l,n xk(i,i)=lO.OdO * i - ishift * xm(i,i) xk(i,i)=-i xkorig(i,i)=xk(i,i) continue else do 4 i=l,n do 5 j=i,n xk(i,j)=(i+j)*(-1.0)**(i+j) if (i .eq. j) xk(i,i)=(i+i)*i*lOOO.O xk(i,j) = 0.001 *(i+j) - ishift * xm(i,j) if( i .eq.j) then xk(i,j) = I.ODO * i - ishift * xm(i,j)
Due T. Nguyen
5 4
if ( i .gt.jjj .and . i .Ie. jjj+ircpeat ) xk(i,j) = I.ODO * ( I +jjj) - ishift * xm (i,j) end if xk(j,i) =xk(i,j) xkorig(i .j)=xk(i,j) xkorigjj.ije xktj. i) co ntinue continue end if endif
c if (jaco bonly .eq. I ) then c c c c
do we have to re-arrange eigcn-so lutions in "INCREASING" order from "lowest" to "highest" eigen -val ues/eigen-vectors ?? call jacobikjb (xk,xm.z,evalamda .n,temp02,eps2,nsweeps,np)
c writetfi, *) 'KJBathe Jacobi evalues =' write(6 .*) (evalamdauj.ie l ,n) call errnorm(neig.evalamda.n,xx,z.x m,temp02.np.xkorig ,xitutar) c......print resul ts go to 345 endif c......step II : factorize stiffness matrix call 1udcmp (xk.n.np.indx. d) ! overwrite xk(-,-) write(6,*) 'check point #01 : passed fact orized ' c do 61 i=l .n c writeto, ") 'factori zed K= ',(xk(i,j),j=l ,n) c6 1 co ntinue c......step III: choose an arbitrary vector I xx ], an y better starting vector ?? do 9 i= l ,n c xx(i)=xkorig( i,l) ! this choice will give xitutar = 10J for cert ain data xx(i) =1 9 co ntinue
c call matvec2 (xrn.xx. tempo l .n.np) write(6, *) 'tempo 1(-)= ',(tempo 1(i),i= I.n) call dotprod (xx,tempol .bb,n ) bb=dsqrt(bb) c write(6, *) 'bb= ',bb c......get I-st Lanczos vector do II i= l,n xx(i)=xx(i)/bb x(i, I )=xx(i ) II cont inue c write(6, *) 'got I- st Lanczos vector xx(-)= ',(xx(i),i=1 .n) write(6,*) 'chec k point #02: go t I-st lanczos vector' c......step IV: solve for add itional Lanczos vectors, with Bi=O.O, c...... and i = 2,3 , ... , r = lanmax c......part (a): find XB ARi vector c
c lanmax=neig*ntimes
321
322
25 24 c? c? c? c? c? c C
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
if (Ianmax .ge. n) lanma x=n ! can we have lanmax=n, YES ! do 24 i=I ,lanmax do 25 jei.lanmax tridiamO,j)=O.OdO tridiam(j ,i)=O.OdO continue continue b(l)=O.OdO markeig=2 *neig m=2 *neig if (markeig .ge. n) markei g=n ! can we ha ve markeig=n , YES! if (m .ge. n) m=n write(6 ,*) 'lanmax, markeig,m= 'J anm ax.markeig.m
Lanflag = 0 = 0 for Due 's procedure; = 1 for JQ's way IF ( LanFlag .eq. 0) THEN c------ Due's procedure: c......step V: obtain eigen solutions in the expanded ( = original) system ELSE C------ JQ' s procedure (after Gramschmidt re_orthogonalization, use "NEW bi": c -----------------------------------------c Due's code JQ's Code
e ------------------------------------------e e c c e e c e
4a . Part of 4e. 4b. Part of 4e. 4d . 4c .
call lubk sb do loop 3055 : x = x - b*x(i-l) call dorprod(...alf,..) do loop 3060: x = x - alf*x(i-2) bet2 = ..... call REORTH( ...) Loop 3110 for prepare next iteration ---------------------------------- -----------markeig = 2* neig
if ( markeig .gt. LANMAX ) markeig = LANMAX call matvee2(xm,xx,w2,Il,np) ! w2(-) = rhs of Eq.(9.239) do 3000 i = l ,n w l (i)=O.OdO 3000 wei) = O.ODO bet = bb ! computed earlier, scaled factor to normalize 1-st L_vector do 3050 JJ = 1, LANMAX ! ---------- step 4 (for subsequent Lanczos vectors) c (why NOT JJ = 2, LANMAX ??) do 10011 = Ln tempo 1(i) = w2(i) ! rhs of Eq.(9.239) ! rhs ofEq .(9.239) 1001 w4(i) = w2(i)
e----------------------------------------------------------------------------------------calilubksb(xk,n,np,indx ,tempo I)
3055
! tempo 1(-) = xbar_i (see step 4a)
! compute parts of step 4e ( = 3-rd term of rhs ) do 3055 1 = l ,n w4(i) = tempo 1(i) - bet *w(i) ! for first time (loop JJ= I) , w(-)=0. call dotprod(w2,w4,alf,n) ! compute a_i- l, Eq.(9 .240) , see step 4b
Due T . Nguyen
3060 c
323
do 3060 i = l ,n ! compute step 4c ( = 2-nd term of rhs ) w4(i) = w4(i) - alf*wl (i) ! array wl (-) has been initialized to ZERO ! we should have 2·nd term of rhs, even initially ??
c----------------------------------------········-----------------------.---------call matvec2(xm, w4,w2,n,np) call dotprod(w2 ,w4,bet2,n) bet2 = dsqrt(bet2) call REORTH(n ,np,w2,w4,X,JJ,BETI,epsI ) call matvec2(xm,w4 ,w2,n,np) call dotprod(w2,w4,bet2 ,n) bet2 = dsqrt(bet2) dbet2 = I. OdO/bet2 do 3110 i = I ,n w(i) = wI (i) w I (i) = w4(i) * dbet2 X(i,JJ+I) = wl(i) w2(i) = w2(i) * dbet2 3110 continue a(jj) = alf b(jj) = bet2 bet = bet2 IF (jj .eq. markeig ) THEN c write(6,*) 'JQ tridiagonal matrix dimension» ',JJ do 3066 j= I,JJ tridiam(j,I ) = a(j) tridiam(j ,2) = b(j) 3066 continue
c c c c
do we have to re-arrange eigen-solutions in "INCREASING" order from "lowest" to "highest" eigen-values/eigen-vectors ??
write(6,*)'nnnn,jj = ',nnnnJj c call jacobikj b(tridiam,xmi,z,evalamda,JJ,tempo2, eps2,nsweeps,np) c call eigsrt(evalamda,z,n,np) ! sorting eigen-pairs, from large to Csmall do jjj = l,jj do iii = I,jj z(iii,jjj) = O.OdO enddo z(jjj,jjj) = 1.0dO enddo call tq(npJj ,a,b,z,I.OE-15,L) ! Better version for TRIDIAGONAL Ceigen-solver call eigsrt(a,z,n,np) ! sorting eigen-pairs, from large to small nconv=O do 3028 j= I , JJ
change into do 28 j= I, rnJ2 ??
.
324
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
zij:=z(jj,j) errorj:=dabs(bet2*zijl atj) tempo 1(j) = O.OdO do jjj := 1,jj ternpo ltjjj) « tempo l (jjj) + abstztjjj.j) enddo tempol (j):= tempol(j) * 0.005dO* errorj c:=:=:=:===:=:=:=:=:==:==:=:=:=:=:=:=:==:=:=:=:=:=:==:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= if (tempo l (j) .Ie. eps2) then ! JQ used this formula for error check ! DTN used Eq.(9.248) for error check c if (errorj .Ie. eps2) then c ! Due & JQ wants to know if Eq.(9.248) is better or worse ?? c:=:=:=:=:=:=:=:=:=:=:=:=:=:==-=:==:=:=:=:=:=:=:=:=:=:=:=:=:==:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:==:=:=:=:=:=:=:=:== C write(6,*) 'J , errorj := ',j,errorj,nconv,lossorth (nconv) nconv:=nconv+l lossorthmconv)ej ! re-use array lossorth(-) for other purpose c write(6,*) 'J , errorj := ',j,errorj,nconv,lossorth(nconv),w(j) endif 3028 continue nevnyceneig-nconv markeigemarkeig-s2*nevnyc if (markeig .gt. lanmax) markeigel anm ax c if (nconv .ge. neig .OR. JJ .EQ. LANMAX) then c if ( nconv .It. neig ) then write(*,*)'Exceeded Maximum iterations: ',LANMAX write(*,*)'Only: ',nconv,' eigenpaires might be accurate.' end if do 3068 jjje l .neig omegaijjj) « l.OO/a(jjj) ee := l.OdO/a(jjj) + ishift write(6,*) 'converged eigen # ',jjj, 'omegas := ',ee 3068 continue ntsize e jj go to 678 prepare for successful exit c else do iii := l,jj a(iii):= tridiam(iii ,l) b(iii):= tridiam(iii,2) enddo endif write(6,*)'******* **** Neq markeig > ', markeig END IF 3050 CONTINUE END IF 678 continue c do 32 j:=l,neig do 33 ii:=1,ntsize xx(ii):=z(ii,j) 33 continue do 3033 II := ntsize+1,n
Due 1'. Nguyen
325
xx(ii) = O.OdO 3033 continue call matvec2 (x,xx,tempo2,n,np) do 34 iie Ln phi(ii,j)=temp02(ii) 34 continue 32 continue c step VI: compute the "exact, actual" error norm for eigen-solutions call errnorm(neig,omega,n,xx,phi ,xm,temp02,np,xkorig,xitutar)
c 345 continue stop end C================================================== subroutine REORTH(n,np,w2,w4,X,JJ,BET2,eps1) REAL *8 HH( 1000),W2(*),W4(*),X(np, *) real*8 wnorm,epsl wnorm=O.OdO c c do i=I,n c wnorm = wnorm + W2(i) *W2(i) c enddo c wnorm = dsqrt(wnorm) c if ( dabs(wnorm) .gt. 0.999 ) then c wnorm = 1.0dO c end if do 11 K = I,JJ HH(K) = O.ODO do 21 1= l .n HH(K) = HH(K) + W2(I) * X(l ,K) 21 CONTINUE 11 CONTINUE c we may want to do selective reortho ., by c checking ifhh(k) < epsl = 10-16 c to decide whether or not skipping loop 41 icount=O D041 K= I ,JJ c if ( dsqrt(HH(K»/wnorm .gt. epsl ) then c write( *,*)'HH(K),wnorm=',HH(K),wnorm,epsl icount = icount + 1 DO 31 1= I,N W4(I) = W4(i) - HH(K) * X(I,K) 31 CONTINUE c end if 41 CONTINUE write( *,*)'Reorth. done! ',icount ,' out of ',JJ,' vectors!' RETURN END
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine dotprod (a.b.answer,n) implicit real*8 (a-h.o-z) real *8 a(*),b(*) answer-O.ODO do I i=I ,n
326
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
answer:=answer+a(i)*b(i) continue retu rn end
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine eigsrt(d,v.n.np) implicit real*8(a-h ,o-z)
c c purpose: sorting eigen-solution vectors (fro m largest to smallest) c...... d(-) = eigen-values c...... v(-,-) = eigen- vectors
c INTEGER n.np REAL *8 d(np ),v(np,np ) c REAL *8 d(lOO),v(lOO,lOO) INTEGER i,j,k REAL *8p do 13 i=l,n-l k=i p=d( i) c...... find the largest eigen -values do II j=i+ I ,n if(d(j) .ge. p)then k=j p=d(j ) endif II continue
c if(k.ne.i) then d(k)=d (i) d(i) =p do 12j=l ,n p=v(j,i) v(j,i)=v(j,k) v(j,k)=p 12 continue endif 13 continue return END
c%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%% subroutine ermorm(neig,omega,n,xx ,phi,xm,tempo2,np,xk,xitut ar) implicit real*8(a-h,o-z) c......purpose: error norm check for eigcn-solution real*8 omega(*),xx(*),phi( np,*),xm(np,*),temp02(*) $,xk(np,*),xitutar(*) do 42 j= I ,neig evalue=o mega(j) ! do we have to rearrange eigen- solution s in CINCREASING order ?? do 43 ii= l, n xx(ii) =phi(ii,j) 43 continue call matvec2 (xm,xx,tempo2,n ,np)
Due T. Nguyen
327
call matvec2 (xk.xx.xitutar.n.np) do 44 ii= l,n temp02(ii)=xitutar(ii)-evalue*temp 02(ii) 44 cont inue c......find absolute erro r norm call dotprod (ternpoz.tempoz .abserr,n) abse rr=dsqrt(abserr) c find relative error norm call dotprod (xitutar, xitutar,value,n) value=dsqrt(value) relerr=abserr/value c ee = l. O/omega(j) write (6 , *) 'EIG .#, abserr, relerr = ',j ,abserr ,relerr 42 continue return end
c%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine grschmid (n,x ,qk,qj,k,xm,rkk ,np,temp02,lossorth) impli cit real*8(a-h,0-z) real *8 x(np,*), qk( *), qj (*), xm(np ,*), tempozt ")
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c c c c c c c c c c c c c c
purposes: Grahmscmidt re-orth ogonalization process to make sure that current i-th = k-th Lanczos vector will be orthogon al with previous Lanczos vectors Reference: Michael Heath' s book "Sci entific Computing", pp. 97 However , DTN guyen modified pp . 97, by deleting "outer-mos t loop k", since DTN guyen does NOT wan t every Lanczos vectors perpendicular to every oth er pre viou s Lanczos vectors notes: x(np,*) = "all" Lanczos vectors upto now qk (*) = temporary vector , to store "one" current Lanczos vector qj (*) = previous loss orthogo nal vector s (overwritten one-by-on e) k = current i-th Lanczos step temp ozt ") = temporary vector, to store [MASS] * {current i-th Lanczos vector}
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ intege r lossorth(*)
c do 1 i= l ,n qk( i)=x(i,k) continue
c do 2 j= l, k-l
c
c 3 c
mel ossorthtj) write(*, *)'reorthogo nalized: m = ',m do 3 i= l, n qj (i)=x(i,j) qj (i)=x(i,m) continue call matvec2 (xm,qk,tempo2 ,n,np) call dotp rod (qj.tempoz.rjk,n)
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
328
c 4
do 4 i=1,n qk(i)=qk (i)-rjk*qj(i) continue
c 2
continue
c call matvec2 (xm.qk.tempoz .n.np) call dotprod (qk, tempoz, rkk, n) rkk=d sqn(rkk)
c
6
do 6 i=1,n qk(i)=qk (i)/rkk continue return end
c%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c
subroutine jacobikjb (A,B,X,E1GV,N,D,rtol,nsmax,nmax) modified by runesha Nov 27, 1995
c c
c c
PROGRAM TO SOLVE THE GENERALIZED EIGENPROBLEM USING THE GENERALIZED JACOBI ITERATION
c
c c c
c c c c c c
c c c
c c c c c
c c c c
c
c
* *
-- INPUT VARIABLES -A(N,N) =Stiffness matrix (assumed positive definite) B(N,N) =Mass matrix (assume d positive definite ) X(N,N) =Vector storing eigen-vecto rs on solution exit . EIGV(N) =Vector storing eigen-val ues on solution exit D(N) =Workin g vector N =order of matrices A and B RTOL =Convergence tolerance(usually set to 10.**-12 . NSMAX =Maximu m number of swee ps allowed (usually set to ]5 ) -- OUTPUT -A(N,N) B(N ,N) X(N,N) EIGV(N)
=Diagon alized stiffnes s matrix =Diagonalized mass matrix =Eigenvectors stored columnwise =Eigen-values
Parameter (RTOL=10.**-12,NSMAX= 15,IFPR=0,IOUT=6) Parameter (RTOL=O.OOOOOOOOOOOl ,NSMAX=15,IFPR=0,IOUT= 6) IMPLICIT REAL *8 (A-H,O-Z) DIMENSION A(nmax,I ),B(nmax,I ),X(nma x,I ),EIGV(l ),D( ] ) DIME NS]ON A(I 00,] ),B( 100,1),X(100,1),EIGV(l),D(1) ABS(X)=DABS (X) SQRT(X)=DSQRT(X)
Due T. Nguyen
c c c c c c c c c
This program is used in single precision arithmetic on cdc equipment and double precision arithmetic on ibm or univac machines. activate,deac tivate or adjust above card for single or double precision arithmetic
INITIALIZE EIGEN- VALUE AND E1GEN-VECTOR MATRICES
DO IOI=I ,N IF (A(I,I).GT.O..AND. B(I,I).GT.O.) GO TO 4 WRITE (*,2020) cnguyen (Feb. 2, 2000) STOP 4 D(I)=A(I,I)/B(I,I) 10 E1GV(I)=D(l) D030 I=I,N DO 20 J=I,N 20 X(l,J)=O.dO 30 x n.n- r. c.....IF (N.EQ.l) RETURN IF (N.EQ.l) then write(6,*) 'tridiag. matrix dimension is 1x1 !l??' STOP endif c c INITIAALIZE SWEEP COUNTER AND BEGIN ITERATION c NSWEEP=O NR=N-l 40 NSWEEP=NSWEEP+1 c IF (lFPR .EQ.1) WRITE (*,2000)NSWEEP
c c CHECK IF PRESENT OFF-DIAGONAL ELEMENT IS LARG E ENOUGH TO REQUIR E c ZEROING c EPS=(.OI**NSWEEP)**2 DO 210 J=I,NR JJ=J+I DO 210 K=JJ,N EPTOLA=(A(J,K)*A(J,K»/(A(J,J)*A(K,K» EPTOLB=(B(J,K)*B(J,K»/(B(J,J)*B(K,K» IF EPTOLA.LT.EPS).AND.(EPTOLB.LT.EPS» GO TO 210 AKK=A(K ,K)*B(J,K)-B(K ,K)*A(J,K) AJJ=A (J,J)*B(J,K)-B(J,J)*A(J,K) AB=A(J,J)*B(K,K)-A(K,K)*B(J,J) CHECK= (AB *AB+4. *AKK *AJJ)/4. IF (CHECK)50,60,60 50 WRITE (*,2020) check=-check nguyen cnguyen STOP 60 SQCH=DSQRT(CHECK ) D1=ABI2 .+SQCH
«
329
330
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
D2=AB/2.-SQCH DEN=Dl IF(DABS(D2).GT.DABS(DJ» DEN=D2 IF(DEN)80,70,80 70CA=0. CG=-A(J,K)/A(K,K) GO TO 90 80 CA=AKKIDEN CG=-AJJ/DEN
c c PERFORM THEGENERAL ROTATION TO ZERO THE PRESENT OFF DIAGGONAL ELEMENT c 90IF(N-2)100,I90,100 100 JPJ=J+I JMI=J-I KPI=K+J KMl=K-l IF(JMJ-l)130,I1O,I1O 110 DO 120 I=J,JMl AJ=A(I,J) BJ=B(I,J) AK=A(I,K) BK=B(I,K) A(I,J)=AJ+CG*AK B(I,J)=BJ+CG*BK A(I,K)=AK+CA *AJ 120 B(I,K)=BK+CA*BJ 130IF(KPI-N)140,140,160 140 DO 150 I=KPl,N AJ=A(J,I) BJ=B(J,I) AK=A(K,I) BK=B(K,I) A(J,I)=AJ+CG*AK B(J,I)=BJ+CG*BK A(K,I)=AK+CA *AJ 150 B(K,I)=BK+CA*BJ 160 IF (JPI-KMl)170,J70,190 170 DO 180 I=JPl,KMl AJ=A(J,I) BJ=B(J,I) AK=A(I,K) BK=B(I,K) A(J,I)=AJ+CG*AK B(J,I)=BJ+CG*BK A(I,K)=AK+CA *AJ 180 B(I,K)=BK+CA*BJ 190 AK=A(K,K) BK=B(K,K) A(K,K)=AK+2. *CA*A(J,K)+CA *CA*A(J,J) B(K,K)=BK+2.*CA*B(J,K)+CA*CA*B(J,J) A(J,J)=A(J,J)+2.*CG*A(J,K)+CG*CG*AK
Due T. Nguyen
B(J,J)=B(J ,J)+2.*CG *B(J,K)+CG *CG *BK A(J,K)=O.dO B(J,K)=O.dO
c c c
UPDATE THE EIGEN-VECTOR MATRIX AFfER EACH ROTATION DO 200 1=I,N XJ=X(I ,J) XK=X(I ,K) X(I,J)=XJ+CG*XK 200 X(I ,K)=XK+CA *XJ 210 CONTINUE
c c C
UPDATE THE EIGEN-VALUE AFfER EACH SWE EP
DO 220 I=I,N IF (A(I,I).GT.O..AND.B(I,I).GT.O.)GO TO 220 WRITE(*,2020) cnguyen STOP 220 EIGV(I )=A(I,I )IB(I,I) c IF (IFPR .EQ.O)GO TO 230 c WRlTE(lOUT,2030) c WRlTE(lOUT,20IO) (EIGV(I),I=I ,N) c c CHECK FOR CONVERGENCE c 230 DO 240 1=I,N TOL=RTOL*D(I) DIF=DABS(EIGV(I)-D(I)) IF(D1F.GT.TOL) GO TO 280 240 CONTINUE
c c c c
CHECK ALL OFF-DIAGONAL ELEMENTA TO SEE IF ANOTHER SWEEP IS REQUIRED EPS=RTOL**2 DO 250 J= I ,NR JJ=J+l DO 250 K=JJ,N EPSA=(A(J,K)*A(J ,K))/(A(J,J)+A(K,K)) EPSB=(B(J,K)*B(J,K))/(B(J,J)+B(K,K)) IF «EPSA.LT.EPS) .AND . (EPSB.LT.EPS ))GO TO 250 GO TO 280 250 CONTINUE
c c c c
FILL OUT BOTTOM TRIANGLE OF RESULTANT MATRICES AND SCALE EIGEN-VECTORS 255 DO 260 1=I,N DO 260 J=I,N A(J,I)=A(I,J) 260 B(J,I)=B(I,J)
331
332
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
DO 270J=I ,N if (b(j,j) .It. 0.0) b(jj)=-b(j ,j) BB=DSQRT(B(J,J» DO 270 K=I ,N 270 X(K,J)=X (K,J)/BB
*
*
! nguyen
write(*,*) 'THE EIGEN -VECTORS ARE :' write(*,*) «x(i,j),j=1,n),i= I,n) return
c c c c
UPDATE D MATRIX AMD START NEW SWEEP,IF ALLOWED
280 DO 290 I=I,N 290 D(I)=EIGV(I) IF(NSWEEP.LT.NSMAX)GO TO 40 GO TO 255 2000 FORMAT(27HOSWEEP NUMBER IN *JACOBI* = ,14) 2010 FORMAT(l HO,6E20.12) 2020 FORMAT(55HO***ERROR SOLUTION STOP , MATRICES NOT POSITIVE DEFINITE) , 2030 FORMAT(36HOCURRENT EIGEN-VALUES IN *JACOBI* ARE,/) END
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine lubksb(a,n,np,indx,b) c......Following are FORTRAN subroutines obtained from NUMERICAL RECIPE implicit real*8(a-h,o-z) INTEGER n,np,indx(n) REAL *8 a(np ,I),b(*) cREAL*8 a( 100,IOO),b(l00) INTEGER i,iij,1I REAL *8 sum ii=O do 12 i=l,n lI=indx(i) sum=b(lI) b(II)=b(i) if (ii.ne.O)then do II j=ii,i-I sum=sum-a(i,j)*b(j) II continue else if (sum.ne.O.) then ii=i endif b(i)=sum 12 continue do 14 i=n,I,-1 sum=b(i) do 13 j=i+ l ,n sum=sum-a(i,j)*b(j) 13 continue
Due T. Nguyen
14
333
b(i)=sumla(i,i) continue return END
c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c
c c
II
12
13 14
15
16
17
subroutine ludcmpta. n.np.indx.d) Following are FORTRAN subroutines obtained from NUM ERICAL RECIPE impl icit real *8(a-h ,o-z) INTEGER n,np,ind x(np),NMAX REAL *8 d,a(np,np),TINY REAL *8 d,a(lOO,IOO),TINY PARAM ETER (NMAX=500,TINY=1.0e-20) PARAM ETER (NMA X=IOO,TINY=I .Od-20) INTEGER i,imax ,j,k REAL *8 aamax.dum.sum .vvmp) d=1. do 12i=l,n aamax=O.ODO do II j=l,n if (dabs(a(i,j» .gl.aamax) aamax=dabs(a(i,j» continue if (aamax.eq.O.) pause 'singular matrix in ludcmp' vv(i)= I .ODO/aamax continue do 19 j=l ,n do 14 i=l j -1 sum=a(i ,j ) do 13 k=l ,i-1 sum=sum-a(i,k)*a(k,j) continue a(i,j)=sum continue aamax=O.ODO do 16 i=j ,n sum=a(i,j) do 15 k= I ,j- I sum=sum-a(i,k)*a( k,j) continue a(i,j)=sum dum=vv(i)*dabs(sum) if (dum.ge.aamax) then imaxei aamax=dum endif continue if (j.ne.im ax)then do 17 k=l ,n dum= a(imax,k) a(imax,k)=a(j,k) a(j,k)=dum continue d=-d vv(imax) =vv(j)
334
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
endif indx(j)=i max if(aU,j)·eq·O.)aU,j)=TINY if(j.ne.n)then dum = ]. ODO/aU,j) do 18 i=j+ ], n a(i,j) =a(i,j)*dum continue 18 endif ]9 continue return END
c%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%% %%%%%%%%%%% c
subrou tine matve c2(phi,avec,vec,n ,nma x) impl icit real*8(a-h,0-z) purpose: to multiply matri x [phi] * {avec} = {vee] real *8 phi(nmax, ]),avee(l),vec(l )
c----------------------------c......initialize do 5 i=l ,n 5 vec(i)=O.ODO c--------------------- ---do I icol= I .n do 2 irow= ] .n vec(i row)=vec( iro w)+phi(irow .icol )*avec( icol) 2 continue ] con tinue c------------------- --------------------c write(6,*) 'passed mat vec.f return end
e%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine tq(N I,N,B,C,Q,eps,L) implicit real *8(a-h ,0-z) C* ****** ******** ******** ******** **** **** *** ********* ************ ********* C Thi s is a subro utine to solve eige nproblem of triangi al matrice s By CQR method C C B-- diaginal terms of Trian ginal matrix T, return the eigenvalue of T C C-- offdiginalk terms of T C [T]= C b(l) c(l) C eO ) b(2) e(2) C e(2) b(3) e(3) C C c(n-2) b(n- ]) em- I) C em- I) b en) C C C Q-- identity matrix , return eige n-vector c ************************************************************************ dimension B(n] ),C(n I),Q(n] .n1) C
Due T. Nguyen
C
10
C(N)=O.O D=O.O F=O.O DO 50 J=l ,N IT=O H=EPS *(ABS(B (J»+ABS(C(J») IF(H .GT.D) D=H M=J-l M=M+l IF(M.LE.N)THEN IF(ABS (C(M» .GT.D) GOTO 10 ENDIF
C 15
18
20
IF(M.NEJ)THEN IF(lT.EQ.60) THEN L=O WRlTE(6,18) FORMAT(lX,'FAIL') RETURN ENDIF IT=IT+) G=B(J) P=(B(J+) )-G)/(2 .0*C(J» R=SQRT(P*P+1.0) IF(P.GE.O.O)THEN B(J)=C(J )/(P+R) ELSE B(J)=C(J)/(P-R) ENDIF H=G-B(J ) DO 20 I=J+ 1,N B(I)=B(l)-H continue
F=F+H P=B(M) E=1.0 S=O.O DO 40 I=M-),J,-) G=E*C(I) H=E*P IF(ABS(P).GE.ABS(C(I» ) THEN E=C(I)/P R=SQRT(E*E+ ) .0) cu-i )=S*P*R S=EIR E=1.01R ELSE E=P/C (l) R=SQRT(E*E+1.0) C(l+) )=S*C(I)*R S=1.0/R E=EIR
335
336
30 40
C 50
60
70 80
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
ENDlF P=E*B(I)-S*G B(I+ I)=H+S*(E*G+S *B(I» D030K=I ,N H=Q(K,I+I ) Q(K,I+ I )=S*Q(K,I)+E*H Q(K,I)=E*Q(K,I)-S*H CONTINU E CONTINUE C(J)=S*P B(J)=E*P IF(ABS(C(J» .GT.D) GOTO 15 ENDlF B(J)=B(J)+F CONTINUE DO 80 I=l,N K=I P=B(I) IF((l+ I ).LE.N) THEN J=I J=J+l IF(J.LE.N) THEN IF(B(J).LE.P) THEN K=J P=B(J) GOT060 ENDlF ENDlF ENDlF IF(K.NE.I) THEN B(K)=B(I) B(I)=P D070J=I ,N P=Q(J,I) Q(J,I)=Q(J,K) Q(J,K)=P CONTINUE ENDlF CONTINUE L=I RETURN END
c%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5.7.8 Efficient Software for Lanczos Eigen-Solver
A brief description of the highly efficient sparse eigen-solver is given following section. User Manual for Sparse Lanczos Eigen-Solver
In
the
Due T. Nguyen
337
COMPLEX NUMBERS ofSPARSEPACK97 (This file is stored under -/cee/SPARSEPACK97-98 /complex_version_incore_SPARSEPACK97) (under file name complex_SPARSEPACKusermanual) [01] To solve the generalized eigen-problem in the form [A] * {x} = (Lamda) * [B] * {x} where [A] =
complex numbers, symmetrical (positive) "STIFFNESS" matrix
[B] =
complex numbers, symmetrical "MASS" matrix Note: [B] can be either "diagonal" (lumped) mass, or have the same non-zero patterns as [A] (consistent) mass matrix Lamda = eigen-values {x} = corresponding eigen- vectors
[02] How to prepare the input data (assuming matrices [A] and [B] are known) ?? 11.0 0.0 0.0 41.0 44.0 0.0 0.0 66.0 0.0 Assuming [A] = SYM 88.0
Here, N NCOEF
0.0 63.0 74.0 85.0 110.0
52.0 0.0 0.0 0.0 97.0 112.0
= size of matrix [A] = 6 = total number of non-zero off-diagonal terms of the upper
portion of matrix [A] = 6 22.0 0.0 0.0 77.0 0.0 66.0 Assuming [B] = SYM
(a)
-41.0 0.0 0.0 88.0
0.0 -3.0 74.0 85.0 100.0
12.0 0.0 0.0 0.0 27.0 12.0 K.INFO file, should contain two lines with the following information : Descriptions of Your Problem: format(a60), not exceeding 60 characters nreord, neig, lump, n, n2, ncoef, itime, ishift, iblock, mread where:
338
Finite Element Methods: Parallel-Sparse Static s and Eigen-Solutions
nreord = 3 (use MMD reorder algorithm), 0 ("NOT" use re-order algorithm) neig = number of requested eigen-values/vectors (above threshold -shift) lump = 1 (lumped , diagonal mass matrix [B], 0 (consi stent mass matrix [BD n = size of matrix [A(n,n)] = same definition as given above n2
=n
ncoef = same definition as given above itime = 0 (save memory), 1 (save time) ishift = 0 (default , noshift), NONZERO (perform a shift of value ISHIFf) iblock = -1 (sub-space iteration algorithm), 0 (regular Lanczos algorithm) rnread = negative integer (default, read ascii K* files) positive integer (read fort* files) (b)
K.PTRS file, to store # non-zero terms per row (EXCLUDING diagonal terms) of the STIFFNESS [A] matrix ("integer" numbers, should have N values) 2, 1, 1, 1, 1, 0
(c)
Kll.INDXS file, to store column numbers associated with the non-zero , off-diagonal terms (in a row-by-row fashion) of the STIFFNESS [A] matrix ("integer" numbers, should have NCOEF values) 4, 6, 5, 5, 5, 6
(d)
K.DIAG file, to store numerical values of DIAGONAL terms of matrix [A] (could be REAL or COMPLEX numbers, should have N values) (11.0,0.0), (44.0,0.0), (66.0,0.0), (88.0,0.0), (100.0,0.0), (12.0,0.0)
(e)
Kl1.COEFS file, to store numerical values of the non-zero, offdiagonal term s (in a row-by-row fashion) of the STIFFNESS [A] matrix (could be REAL or COMPLEX numbers, should have NCOEF values) (41.0 ,0.0), (52.0,0.0), (63.0 ,0.0), (74.0,0 .0), (85.0,0.0), (27.0,0.0)
For the complete listing of the FORTRAN source codes, instructions on how to incorporate the highly efficient sparse Lanczos eigen-solver package into any existing application software (on any computer platforms), and the complete
Duc T. Nguyen
339
consulting service in conjunction with this sparse Lanczos eigen-solver, the readers should contact: Prof. Due T. Nguyen Director, Multidisciplinary Parallel-Vector Computation Center Old Dominion University Room 1319, ECS Building Norfolk, VA 23520 (USA) Tel (757) 683-3761 Fax (757) 683-5354 E-mail
[email protected] 5.8 Unsymmetrical Eigen-Solvers The algorithms for symmetric matrices are highly satisfactory in practice. By contrast, it is impossible to design equally satisfactory algorithms for the nonsymmetric cases, which are needed in Controls-Structures Interaction (CSI), acoustic, and panel flutter applications. There are two reasons for this. First, the eigen-values of a nonsymmetric matrix can be very sensitive to small changes in the matrix elements. Second, the matrix itself can be defective so that there is no complete set of eigen-vectors . There are several basic building blocks in the QR algorithm, which is generally regarded as the most effective algorithm, for solving all eigen-values of a real, unsymmetric matrix. These basic components of the QR algorithm are reviewed in Sections 5.7.10-5.7.17. Several sub-routines mentioned in Sections 5.7.10-5.7.17 can be downloaded from the cited "Numerical Recipes" Web site and Text Books [5.12].
5.9 Balanced Matrix The idea of balancing is to use similarity transformations to make corresponding rows and columns of the matrix have comparable norms, thus reducing the overall norm of the matrix while leaving the eigen-values unchanged. The time taken by the balanced procedure is insignificant as compared to the total time required to find the eigen-values. For this reason, it is strongly recommended that a nonsymmetric matrix be balanced before attempting to solve for eigensolutions. The numerical recipe's subroutine balance is partially listed in Table 5.8. Table 5.8 Numerical Recipe's Subroutine BALANC c c c c c c
Th i s subroutine i s e x t ra c ted f rom NUMERICAL RECIPES (FORTRAN version , 199 0 , I SBN # 0 - 521 -38330- 7 ) , Authors = Pr e s s, Fl a nnery , Te uko ls ky and Ve t t e r l i ng p ages 3 66-3 67 Gi ven an N by N matri x [AJ stored in a n ar ray o f
340
c c c c c c
c
c
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
physical dimensions NP by NP. This routine replaces it by a balanced matrix with identical eigen-values. A symmetric matrix is already balanced and is unaffected by this procedure. The parameter RADIX should be the machine's floating point radix SUBROUTINE balanc(a,n,np) implicit real*8(a-h,o-z) INTEGER n,np REAL a(np,np),RADIX,SQRDX PARAMETER (RADIX=2.,SQRDX=RADIX**2) INTEGER i,j,last REAL c,f,g,r,s
nguyen
nguyen
5.10 Reduction to Hessenberg Form The strategy for finding the eigen-solution of an unsymmetric matrix is similar to that of the symmetric case. First we reduce the matrix to a simple Hessenberg form, and then we perform an iterative procedure on the Hessenberg matrix. An upper Hessenberg matrix has zeros everywhere below the diagonal except for the first subdiagonal. For example, in the 6x6 case, the non-zero elements are:
x
X
X
X
X
X
X
X
X
X
X
X
0
X
X
X
X
X
0
0
X
X
X
X
0
0
0
X
X
X
0 0 0 0 X X Thus, a procedure analogous to Gaussian elimination can be used to convert a general unsymmetric matrix to an upper Hessenberg matrix. The detailed coding of the Hessenberg reduction procedure is listed in Numerical Recipe's sub-routine ELMHES, which is partially listed in Table 5.9. Once the un symmetric matrix has already been converted into the Hessenberg form, the QR algorithm itself can be applied on the Hessenberg matrix to find all the real and complex eigen-values. For completeness, the QR algorithm will be described in the following sections. Table 5.9 Numerical Recipe's SubroutineELMHES c c c c c c c c c c
This subroutine is extracted from NUMERICAL RECIPES (FORTRAN version, 1990, ISBN # 0-521-38330-7), Authors = Press, Flannery, Teukolsky and Vetter1ing pages 368-369 Reduction to Hessenberg form by the elimination method. The real, nonsymmetric N by N matrix [Aj, stored in an array of physical dimensions NP by NP is replaced by an upper Hessenberg matrix with identical eigen-va1ues. Recommended, but not required is that this routine be
Duc T . Nguyen
c c c c
341
preceded by subro u ti n e BALANC . On ou tput, t he Hes senbe rg matr i x i s i n e lemen ts A ( I , J ), with I . le. J +l . El e me n t s with I . g t. J +l ar e to be t hough t o f a s ze ro , b ut are return ed wit h random v a l u es
c
c c
SUBROUTINE el mh e s (a , n , np ) impli cit real *8 (a -h ,o -z ) IN TEGER n , np REAL a (n p , n p ) d imension a (np ,np ) INTEGER i , j , m REAL x , y
n guyen
n g uy e n n g uy en
5.11 QR Factorization Assuming a matrix [A] with the dimension mxn, where m z n, we are looking for an mxm orthogonal matrix [Q], such that A=
Q[~]
(5.249)
where [R] is an upper-triangular matrix, with the dimension nxn.
5.12 Householder QR Transformation A Householder transformation 1-1 is a matrix, which can be given by the following formula: (5.250)
v
where is a non-zero vector: From Eq.(5 . 250), one has:
The product of [H]*[H]T= [H)T [1-1] can be computed as: [H][H]T
=[I-(~)*v*vT][I-(~)*v*vT] T f v v
v v
2 T 4 T T 2 T = I-(--) *v*v + *vv *vv -(--)*v*v T vTv (v V) 2 vTv
[I-I][HY = [I]:::::> [H]T =
rnr'
Thus, the matrix [1-1) is symmetrical (because HT= H) and orthogonal (because H"' = I-JT). Given a vector
a, we would like to select the vector vsuch that
342
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
[H]a =
"(
1
0
0
0
0 =
="(
-ye (1)
(5.251)
0
0
Substituting the formula for [HJ into the above equation, one obtains: [HJa =ye(l) = [I-(_2_)*vv TJa vTv or
2*
T
[HJa = a-(~)*v = ye(l) vTv
(5.252)
From Eq.(5. 252), one can solve for vector v: _
_ A(I ) v= ( a-ye
T
v) -2v Ta
*( V
(5.253)
T
The "scalar" factor (~) is unimportant since it will be cancelled out when 2vTa matrix [HJ is computed. Hence -
A(l) v =a-ye
(5.254)
Remarks
#[IJ To avoid possibilities for numerical overflow or underflow for the case components of a are very small or very large, the vector a should be normalized (by dividing a with its largest magnitude). Such a scale factor will not change the resulting transformation matrix [HJ. #[2J To preserve the norm, one should have y= ±llallz' and the (+), or (-) sign should be selected to avoid cancellation. #[3J The FORTRAN code to implement the Householder transformation is given in Table 5.10. #[4J There is no need to explicitly form [HJ since [HJ a can be obtained from v and a directly. #[5J The Householder transformation can be generalized to produce zero terms below the diagonals of columns of a given rectangular matrix [AJ as illustrated by the following symbolic explanation .
Due T. Nguyen
343
rl1
rl2
0
0 H1(A) = 0 0 0
a(2)
r13
* * * * *
o H 2(H1A)
=
2y(2)y(2)T (I T )(HjA) y(2) y(2)
=
0 0
o o
H 3(H 2H jA)
where
y(2)
=
T 2y(3)y(3) (1T )(H 2H1A) y(3) y(3)
can be computed from Eq.(5. 254): y(2) = a(2) -op)e(l)
with
a (2)
o * = * * *
* Similarly: and
=
r11
r12
r13
0
r22
r23
0
0
r33
0
0
0
0
0
0
0
0
0
344
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
o o
* * * * Table 5.10 Householder Transformation C%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% implicit real*8 (a-h,o-z) dimension a(100), v(100), e(100),Ha(100) dimension f1oatk(100,60), rhs(100) stored under cd -/cee/*odu*clas*/householder*.f
c c c
c c c
. .
input data: size of rectangular (or square) float (stiffness) matrix [floatkJ m by n, where m .ge. n, and vector {rhs} m by I mp=IOO
c read(5,*) m,n write(6,*) 'm rows, n columns
',m,n
c
1
do I j=l,n read(5,*) (floatk(i,j),i=l,m) write(6,*) 'column # ',j write(6,*) 'vector = ',(floatk(i,j),i=l,m) continue
c read(5,*) (rhs(i),i=l,m) write(6,*) 'rhs vector = ',(rhs(i),i=l,m)
c do 2 j=1, n ithzero=j
c 12
do 12 i=l,m a(i)=O.OdO
c
4
do 4 i=ithzero,m a(i)=floatk(i,j) continue
c if (j .eq. n) then wri te (6, *) '++ +++++++++++ +++ + +++++++ + ' write(6,*) 'new float(i,3) = ',(a(i),i=l,m) write(6,*) 1+++++++++++++++++++++++++' endif
c 2
call householder(mp,m,n,a,ithzero,v,e,Ha,floatk,rhs) continue
c stop
Due T. Nguyen
345
end c%%%%%%%%%%%%%%%%%%%%%%% %%%% %%%%%%%%%% %%%%%%% %%%%%% %% %%%%%%% subrou t i n e h o useho lder (mp , m, n ,a ,i t hz e ro , v , e ,H a ,floatk ,rhs ) i mp l i c i t r ea l * 8 (a - h , o - z ) dimens i o n a ( * ) , v (* ) , e ( *) , Ha ( * ) , floa tk (mp , *) , r h s ( * ) stored und e r cd -/cee/ *odu *c la s */ h o u s e hold e r *. f
c c c
g e n e r a t i n g t h e u n i t vec t o r
I e}
c d o 2 i = I ,m e ( i ) =O. Od O e ( i t hz ero ) =1 . 0d O
2
c c
comp u t e the L2 nor m of v e c tor
{a }
c s u m=O. Od O do 1 i =l,m s um=s u m+a ( i ) *a ( i ) c on t i nu e sum= d sqr t ( sum )
1
c c
se le c t
the sign, to a v o i d c a nc e l l a t i o n d u r i n g {v }
{a } - gamma
* ( e l} c if
( a ( it hz ero ) . g t. O.O dO .T t . O. OdO g a mma= s i g n g a mma*sum i f ( a ( ithz e ro )
s i gng a mma=-1 .0dO s i gnga mma=+1 .0dO
c d o 4 i=1, m v (i )=a ( i ) - g amma *e ( i) cont i nu e
4
c c c
Co nf i r m the c alculated v e c t o r {v } b y comp u ti n g : [H l * {a } = {a } - ( 2 .0dO * {v t r an s pos e} * {a } / {v tran s p o s e } *
(v} )
*
(v }
C
wr i t e(6, *) wr ite(6,*) write(6 ,*)
, --- --- - -- - - - - - -- - ----
c c d o 12 j = I , n eff ic ient do 12 j =ith z e r o , n e ff i c i e n t
correc t a nswe r b ut muc h less s ame , corr e c t a nswe r but much more
c 14
do 14 i =l , m a(i)=fl o a t k( i , j ) c ontinue
c ca l l dotprod(v, a, m, s c al a r l) ca l l d otprod(v, v, m, scal a r 2) sca lar =2. 0d O*sc a l a r l /sc a lar2
c
6
do 6 i=l, m Ha( i)=a(i) - s c al a r* v( i ) c ont inu e wr ite (6 , * ) ' Ha (i ) = ',( Ha( i) ,i =I , m)
c d o 15 i = l ,m fl oatk (i , j ) =Ha ( i)
Finite ElementMethods: Parallel-Sparse Statics and Eigen-Solutions
346
con t i nue
15
c 12 c
24
c o n t inu e now, also do househo l der t r a n s f o r ma t i o n rhs vector do 24 i =l , m a ( i ) =r h s ( i ) c ont inue
c ca l l dot prod (v , a ,m, sca la r l) ca l l do tprod (v ,v ,m, sca la r 2 ) sca l a r =2 . 0d O*sca la r l/sca la r 2
c c 26
d o 2 6 i =l ,m Ha ( i ) =a ( i )- s c a la r *v ( i ) c on t i nu e
c 25
do 25 i =l,m rhs(i) =Ha( i) continu e wr i t e(6,*) ' r h s( i )
' , ( r h s(i), i =l,m)
c c
ou t p u t s
c wr i t e( 6 ,*) ' n o r m (wi th approp r i a t ed si g n ) g a mma ',gamma wr i t e ( 6 ,*) ' v( i ) = ' , (v ( i) , i = l , m) r e tu r n e nd c %%%%%%%%% %%%%%% %% %%%% %%%%%%%%%%%% %%%% %%% %% %% %%%%%%%%%%%%%%%%%%% sub r o u t i n e d o tpr o d (a , b , n , s ca l a r ) imp l i c i t r e al * 8 (a - h, o - z ) d i me ns ion a ( * ) ,b ( *)
c
1
s calar =O. Od O d o 1 i =l ,n s ca l ar =sca lar +a ( i ) *b ( i ) c ont inu e
c r e tu r n e nd c %%%%%% %%%%%%%% %%%%%%% %%% %% %% %%%%%% %%%% %%%%%%%%% %%% %%%%%%% %%%%%%
Example 1
Given the vector
~ ~}
a { ,
find a Householder transformation, such that [H]a
~~
{ }
Due T. Nguyen
347
Solution
Example 2 [5.131 Using the Householder QR factorization to solve the quadratic polynomial data fitting problem: [Als x3 *{xhxI = {b}sxI
where
1 -1.0 1.00
1.0
1 -0.5 0.25
0.5
[A]= 1
0.0
1
0.5
0.00 and x = 0.0 0.25 0.5
1
1.0
1.00
2.0
The computerized results for the above problem are shown below:
348
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Example i 5 .! 3] Result m rows, n columns = 5 3 column # 1 vector = 1.0 1.0 1.0 1.0 1.0 column# 2 vector= -1.0 -0.5 0.5 0.0 1.0 column # 3 vector = 1.0 0.25 0.0 0.25 1.0 rhs vector = 1.0 0.5 0.0 0.5 2.0 Ha(i) = -2.236074998 0.0 0.0 0.0 0.0 Ha(i) = 2.220450 -16 -0.19098 0.30902 0.80902 1.30902 Ha(i) = -1.11803 -0.40451 -0.65451 -0.40451 0.34592 rhs(i) = -1.78885 -0.36180 -0.86180 -0.36180 1.13820 norm (with appropriated sign) = gamma = - 2.23607 v(i) = 3.23607 1.0 1.0 1.0 1.0 Ha(i)= 2.220450-161.581145.551120-17 1.110220-16 2.220450-16 Ha(i) = -1.11803 0.0 -0.72505 -0.58918 4.669240-02 rhs(i)= -1.788850.63246 -1.03518 -0.81571 0.40377 norm (with appropriated sign) = gamma = 1.58114 v(i) = 0.0 -1.77212 0.30902 0.80902 1.30902
+++++++++++++++++++++++ new float(l, 3) = 0.0 0.0 -0.72505 -0.58912 4.669240-02 +++++++++++++++++++++++ Ha(i)= -1.118030.00.93541 -2.220450-16 1.387780-17 rhs(i) = -1.78885 0.63246 1.33631 2.576(1) 0.33708 norm (with appropriated sign) = gamma = 0.93541 v(i) = 0.00.0 -1.66046 -0.58918 4.669240-02 5.13 "Modified" Gram-Schmidt Re-orthogonalization In real-life numerical calculation, the computed vectors q(k) by the "classical" GramSchmidt procedure do not tum out to be orthogonal. The idea presented in Eq.(5.231) is unstable. With a little modification, the so-called "modified" GramSchmidt procedure will be more stable and efficient as explained in the following step-by-step algorithms.
~ Compute (5.255)
Duc T. Nguyen
349
~ Project the vector a(k),l (instead of the original vector ark»~ onto q(2), and subtract that projection to obtain: T
a(k),2 = ark),] _ {q(2) a(k),l )q(2)
(5.256)
Remarks [1]
Substituting Eq.(5 .255) into Eq.(5.256), one gets: a(k),2 = ark) _ q(l)\ (k)q(l) _ q(2)T{a(k) _ q(l)\ (k)q(l)}q(2) or a(k),2 = a(k) _q(I)Ta(k)q(l) _ q(2)Ta(k)q(2)
T T +t(2) (j(k)q(l)q(2)
LgJ scalar =0 so
[2)
Eqs .(5.255 - 5.256) in the "modified" Gram-Schmidt are, therefore, e~uivalent to the "cla ssical" Gram-Schmidt (= to project the original vector a ) onto both q(l) and q(2» .
[3)
In the "classical" Gram-Schmidt, the current vector q (k) is orthogonalized with all previous vectors q(l), q(2), ..., q(k-I). However, in the "modified" Gram-Schmidt, the current vector, say q(l), is orthogonalized with subsequent vectors a(k),) = q(2) , a(k),2 =: q(3) , etc.
[4]
Memory usage in the "modified" classical Gram-Schmidt is more efficient than the "classical" version because the computed vector a(k),) , a(k),2, etc. will overwrite the original columns 2,3... of vectors a(2), a(3)..., respectively. This is not possible for the "classical" Gram-Schmidt since the original vectors ark) are also needed in the inner loop! In the "modified" Gram-Schmidt, the scalars rij which are used to form matrix [R] (from [A) = [Q)[R]), are obtained row-wise while the "classical" Gram-Schmidt generates the scalars rij in column-wise fashion.
[5]
A more detailed step-by-step procedure for the "modified" Gram-Schmidt is described in Table 5.11. Computer implementation and its outputs are given in Tabl es 5.12 and 5.13, respectively.
350
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Table 5.11 "Modified" GramSchmidt Algorithms Step I: Given the mass matrix [M] with the dimension n by n, and an arbitrary number of vectors a(kl. Step 2: For k = I, n lT (a) rkk = Ila(k Ma(klll (b)
q(kl = a(k)/
/rkk
(c)
Forj=k+l,n
(d)
rkj =q(k)T[M]a(j)
(e)
a(j) = aU) -rkjq(k)
(f) (g)
End End
The unknown vector
x, corresponding to the least square problem
[Als x3 *{xhx! = {b}sx! ' can be solved from: where
l
rll
[R] = upper-triangular matrix =
2.236 -5.55*10-17 [R] =
[
Y3Xl
0
1.581
o
0
~
1.~18l 0.935
J
= [QT hxs *{b_}Sxl = {1.789} 0.632 1.336
Thus
0.086} X = 00400 { 1.429 5.14 QR Iteration for Unsymmetrical Eigen-Solutions The eigen-solutions for a given (unsymmetrical) matrix [A] can be obtained by repeatedly using QR factorization, such as: Initialize [Ao] = [A] (5.257)
Due T. Nguyen
351
Then, where k represents the iteration number, one generates the following sequences of operations: (5.258) [Ad = [Qkl * [Rd [Ak+ll = [Rkl * [Qkl
(5.259)
Thus
~ From a known matrix [Aol = [Al, one obtains [Qol and [Rol Compute the updated matrix [All = [Rol [Qol Obtains [QIl and [RIl from [All Compute the updated matrix [Azl
= [RIl [QIl
The above steps are repeated until the updated matrix is (or nearly) diagonal. The diagonal terms of [Ak+Il will closely approximate the eigen-values of [Al, and the product of orthogonal matrices Qk will closely approximate the eigen-vectors of [A]. Example Use the QR iteration to find the approximated eigen-solutions of a given matrix
2 [A]=[-1
-1] 1
Let [A o l = [Al
2 = [ -1
(5.260)
-I) 1
Apply the QR factorization to obtain: [Qol = . [Rol = . Compute the reverse product [All = [Rol [Qol= ... Table 5.12 FORTRAN Coding for "Modified" GramSchmidt Algorithm c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c subroutine dummy02 c***************************************************** * * * * * * * * * * * * * *
c c c c c c c c c c
Coded by: Date: Purpose:
. . . . . Notes:
.
Duc T. Nguyen October 14, 1999 Given L vectors [A] in the space R~n, use the "modified" Gramschmidt (as explained on page 98, of HEATH's Scientific Computing book) to generate the set L orthogonal vectors [Q], where [Q] will overwrite [A] to save computer memory The answers obtained from this code has been successfully verified with page 99 of Heath's book
352
c
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Stored a t :
cd -/cee /* o du*cl as*/mod ified* .f
c **** ** *** *** ******************* ************ ***** *** ******** ********
i mpl i c it real *8 (a -h, o - z) dimens ion a(1 00,20) max r ow=l OO max c o l =2 0 read(5 ,*) n , l write (6 , *) ' n, l = ' , n, l ! r e a d col umn - wise r e a d ( 5 , * ) « a(i ,j ) ,i=l ,n) ,j=l,L) do 1 .i r ow e L j n write (6 ,*) ' g i v e n v ectors = ' , ( a(i r ow, j ), j = l , L ) wr i te r owwi s e 1
c on t i n ue ca l l modgs chmi d t( a ,n, l , ma x r o w ,ma x c ol) do 2 irow= l, n wr i te( 6 ,*) ' o r t h o g o vectors = " (a ( i row, j) , j=l ,L )
wi s e 2
c o nt i n u e s t op end c%%% %%%%%%%%%%%%%%%%%%%%%%%% %%%% %%%%%% c samp l e of inpu t da ta file c 5 3 c 1 . 0 1 . 0 1. 0 1 .0 1 .0 c - 1 . 0 -0 .5 0.0 0.5 1.0 c 1.0 0. 25 0.0 0 . 25 1 . 0 c %%%%%%%%%%%%%%%%%%%%%%%%%% %%% %%%%%%%% subrou t i ne modgschm i dt (a , n ,L ,maxrow,ma x c o l) implicit real*8 (a -h ,o -z ) dimension a (ma x r o w, ma x c ol)
c
2
do 1 kcol =l,L rkk =O. O d o 2 irow=l , n rkk =r k k +a ( i r ow, kco l ) ** 2 con tinue rkk =dsqrt(rkk ) writ e (6, * ) "r kk e ' ,rkk
c 3
do 3 irow=l ,n a ( irow,kcol )=a (irow, kcol )/rkk cont inue wr ite ( 6 , * ) ' v e c t o r Qk= ' , (a( i r ow, kc ol ) , irow=l,n)
c
5
d o 4 j =k c ol+ 1 ,L rkj= O. O do 5 i=l,n rkj =rk j +a (i ,kc ol) *a( i , j) c on t i n u e wr i te (6,*) ' rk j = ' ,rk j
c 6 4
do 6 i=l, n a( i , j ) =a ( i ,j )-rkj* a (i ,kcol ) cont inue wr i te (6 , *) ' v e c t o r Qk= ' , ( a ( i r o w, j) , i r ow=1 , n ) cont inue
c 1
c onti nue r e t urn e nd c%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%% %%% %%%%%%%%%
Duc 1'. Nguyen
353
Table 5.13 Outputs for "Modified" GramSchmidt Algorithm
n,l = 5 3 given vectors = 1.0 -1.0 1.0 given vectors = 1.0 -0.5 0.25 given vectors = 1.0 0.0 0.0 given vectors = 1.0 0.5 0.25 given vectors = 1.0 1.0 1.0 rkk = 2.23607 vector Qk = 0.44721 0.44721 0.44721 0.44721 0.44721 rkj = -5.55112D -17 vector Qk = -1.0 -0.5 2.48253D -17 0.5 1.0 rkj = 1.11803 vector Qk = 0.5 -0.25 -0.5 -0.25 0.5 rkk = 1.58114 vector Qk = -0.63246 -0.31623 1.57009D -17 0.31623 0.63246 rkj = 0.0 vector Qk = 0.5 -0.25 -0.5 -0.25 0.5 rkk = 0.93541 vector Qk = 0.53452 -0.26726 -0.53452 -0.26726 -0.53452 orthogo orthogo orthogo orthogo orthogo
vectors =[0.44721 -0.63246 vectors = 0.44721 -0.31623 vectors = 0.44721 1.57009D -17 vectors = 0.44721 . 0.31623 0.63246 vectors = 0.44721
0.53452 ] -0.26726 -0.53452 = [Q) 5x3 -0.26726 0.53452
5.15 QR Iteration with Shifts for Unsymmetrical Eigen-Solutions The convergence rate for QR eigen-iterations can be improved by applying a shift to Eqs.(5.258 - 5.259), as follows: [Ak]-adI)=[Qk)[Rd (5.261) (5.262) Two choices for computing the shifted value a k are suggested [5.13, page 123): (a)
a k = lower-right corner of [Ak)
(b)
A better choice for a k can be obtained by computing the eigen-values of the 2x2 submatrix in the lower-right corner of [Ad .
Example: For the same data shown in Eq.(5.260), one computes: Ao-(ao=I)I= Thus
[2 -1] [1 0] [I -1] -1
1
-
0
1
=
-I
0
354
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
[Qol = . [Ro] = . Then
[AJl = [Ro][Qo]+ (o, = 1)[ I] or
[Atl
= ...
Now
[Atl -(
(J\
=
)1 = .
Thus
[Q\] = . [RIl = . Table 5.14 Numerical Recipe's Subroutine HQR C
c c c c c c c c c c c
c c
This s u b r ou ti ne i s extrac t e d f r om NUMER I CAL RECIPES (FORTRAN ve r s i o n, 1 99 0 , ISBN # 0-521- 3 83 3 0 - 7 ), Au t hor s = Press , Flannery , Teukol s ky and Vet t erling page s 374-37 6 Find a l l eigenv a l u e s of a n N by N upper Hessen berg mat r ix [A] , that is st o red in a n NP by NP a r ray. On i npu t [A] c a n be exactl y a s ou tput from rou ti ne ELMHES , on outpu t i t is d e s troy e d . The r eal & imagi na r y par t s of the e igenvalues are returned i n WR & WI, re s p e c t ive l y . SUBROUTI NE h qr (a , n ,np , wr , wi ) implici t rea l *8 (a - h, o- z ) INTEGER n ,np REAL a (np ,np) ,w i( n p ) , wr (np ) dimens ion a (np ,np) ,w i (np) ,wr (np ) I NTEGER i , i t s , j, k, l, m, n n REAL an orm, p ,q ,r ,s , t ,u ,v , w,x , y ,z
nguyen nguyen ng uy e n ng uy e n
Table 5.15 Main Program for Unsymm etrical Eigen-Solver c%%%%%%% %% %%%%%%%%%%%%%%%%%%%%%%%%% %%%
implicit real*8( a - h , o - z) dimen s i o n a (500,500), wi (5 00), wr(500)
c======= ================= ======================= ======= c c c c c
Th is main prog r a m/ s ub r o u t i n e will compu t e all a l l ei g e n - valu es (on l y ) of an UNSYMMETRI CAL (re al ) mat ri x . The ou t put eigenval u e s ( f r om Numeri cal Rec ipe ) a r e stored i n arrays {wr (- » REAL part o f ei genvalu es and {wi( -) } = IMAGINARY par t o f e i g e nva l u e s
c The s e nume r i c al r e c i p e ' s s u b rou ti n e s (and Dr. Nguy en 's ma in c p rog ram ) a re sto r ed at c c c d - /cee / *odu *c las*/ recipe_unsym_ eva lues .f c c c=== ========= =================== === =========== ======= == c April 17 , 2002 : Duc T . Nguyen mad e mino r changes i n c t h r e e Re c i p e' s r outines to have DOUBLE c
Due T. Nguyen
c c c c c c c c c
355
PRECISIONS
Also, "correct" eigen-values have been obtained for the following examples:
c c c+++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + + + + + + + + + + + +
c c c c
[A]
2.0
-6.0
8.0
1.0
=
C I-st eval = (1.5, +6.91) = 1.5 + 6.91 i c 2-nd eval = (1.5, -6.91) = 1.5 - 6.91 i c====================================================== c np=500 c n=2 c do 1 i=1,n do 2 j=l,n 2 a(i,j}=O. 1 continue c c a(1,1)=1.0 c a(2,2)=2.0 c a(1,2)=-4. c a(2,1)= 5. a(1,1)=2.0dO a(l,2)=-6.0dO a(2,1)=8.0dO a(2,2)=1.0dO c call balanc(a,n,np} balancing a given matrix [A] call elmhes(a,n,np) transforming to upper Hessenberg matrix call hqr(a,n,np,wr,wi} QR iterations for eigen-pair solutions c write(6,*) 'real parts of eva I.» ',(wr(i),i=l,n) write(6,*) 'imag parts of cva l e ',(wi(i),i=l,n) c stop end
5.16 Panel Flutter Analysis Panel flutter is the self-excited or self-sustained oscillation of an external panel of a flight vehicle when exposed to supersonic or hypersonic air flow. There is a critical value of the non-dimensional dynamic pressure parameter, Acr (or flow velocity), above which the panel motion becomes unstable and grows
356
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
exponentially with time. Below this critical dynamic pressure , any disturbance to the panel results in motion that decays exponentially with time. The aero-dynamic equations of motion can be given as:
Mw-r-Gw-i-Kw =0
(5.263)
where M is the n by n system mass matrix G is the n by n system aerodynamic damping matrix K contains both the system stiffness and aerodynamic influence matrices (dimension is n by n matrix) w, lV, ware the displacement, velocity, and acceleration vector, respectively. Eq.(5. 263) can also be expressed as:
[~
~]{:} + [~I ~]{:}= {O}
(5.264)
If the vector {:} is sought in the form of
(5.265) where
{cI> I} and {cI> 2} are complex eigen-vectors that are arranged as a single column vector. n = a + im is the complex eigen-value C is a non-zero constant displacement amplitude Then, taking the derivative with respect to time of Eq.(5.265), one obtains: {:} =
cn{::
}e
QI
(5.266)
Substituting Eqs.(5.265 - 5.266) into Eq.(5.264), one gets: (5.267)
Pre-multiplying both sides of Eq.(5.267) by
[~I ~rl, one obtains :
n[G K]-l[M 0]{cI>1}+{cI>1}={0} -I 0 0 I cI>2 cI>2 or
Duc T. Nguyen
357
Q[~I
Krl- M o
o]{ $1 }_{ $] } ={o} -I $2 $2
0
Let
Krl-M ~I]
[G
[A] = -I
0
0
(5.268)
(5.269)
and {x}={::}
(5.270)
Then, Eq.(5.268) becomes: Q[A]{x}-{x}= {o}
(5.271)
or I
[A]{x}=-{x} Q Let 1 11=Q
(5.272)
Then, Eq.(5.271) becomes: [A]{x}=I1{x}
(5.273)
Thus, Eq.(5.273) represents the "standard" eigen-value problem where the coefficient matrix [A] is unsymmetrical. In nonlinear panel flutter analysis, the above standard eigen-value equations have to be solved repeatedly during the iteration. Fortunately, only a few of the lowest eigenpairs are required for the solution during each iteration. This feature makes it possible to develop an efficient eigen-solver for either large-amplitude vibration or the nonlinear flutter analysis. Define (5.274) and
[C]=[-M
o
0]
-I
(5.275)
Then Eq.(5.269) becomes: (5.276) and the original solution can be obtained as:
358
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
(5.277)
(5.278)
Since only a few of the lowest eigen-pairs ( Q , k,iqk
(5.281)
k=1
(5.282) Eqs.(5.279 - 5.282) can be executed according to the following sequences: Wor i =
11 = I, then (a)
qO=O
(b)
Find ql = r O 131- 1 ; and also determine 131 so that: T
q I M q I = I == Identity Matrix (c)
pI = M ql
For j=l, 2, 3, ... until "maxiter" (or "converged") r j = K-Ipj (a)
(b)
i j = r j _qH 13J
(c)
aj=~jYMrj==~jYij
(d) (e)
pj =Mr j
(f)
Determine 13 j+1 , such that: qj+1 13 j+1 = r j ; and {qj+l
(g)
(h)
f
M qj+l = I
If enough vectors generated, then terminated the do-loop j+1 - j R-I q - r J-'j+1
Re-orthogonalized q j+1 against q I, q 2 " (hence (i)
ki rM"q j == ()ij )
pj+1 =pj 13j11 ==(Mr j)13j11 ==M(qj+l)
" ,qj
with respect to [M]
Due T . Nguyen
369
How to Compute Step # (lb) and/or Step # (20 The computational tasks involved in Steps 1band 2f can be re-casted as the following problem: Given: the matrices [B]nxb == [r j ] and [M]n xn Find: the matrices [C]bxb == [~j+Il and [A]n xb == [q j+\] such that: [B)nxb = [A)nxb * [C]bxb [A]
T
[M)[A) = [I)bxb
(5.327) (5.328)
Solution: From Eq.(5.327), one has: B
T
T
M B = (C A;) M
(J~C)
Utilizing Eq.(5.328), the above equation becomes: D==B T MB=CTC
(5.329)
(5.330)
If one selects the matrix [C]bxb to be an upper-triangular matrix , and recognizing
that: [D]bxb == [B T ]bxn[M)n xn [B)nxb = known, square matrix
(5.331)
Then Eq.(5.330), D = C T C , will represent the "Choleski" factorization of [D) (assuming [D) is a symmetrical, positive definite [or SPD] matrix!).
Remarks (a) Other formats of [C] are also possible. Thus, an upper-triangular matrix for [C] is not the only choice! (b) Besides the Choleski algorithm, which can be used to find [C] (if [D] is a SPD matrix), other procedures, such as QR algorithms, etc., can also be employed to find [C]. (c) The following "pseudo FORTRAN" codes can be used to compute the Choleski factorization matrix [C]bxb' from a given, symmetrical matrix [D]bxb
370
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Do 1
i=l ,b
f
C(i,i) = dsqrt (D(i'i)-
C(m'i) **2]
m=l
Do 2
j =i+l,b
C(i,j) = ( D(i, j) -
f
C(m,j) *C(m,i)]/C(i, i)
m=l
2
Continue mue
I
(d) Instead of using Chole ski algorithms to solve for the unknown matrices
[~T+l]==[C]bXb and [qj+I]==[A]nxb, which can only handle the case of SPD matrix, the following problem can be solved by a different algorithm. ' [r j+l] nxb G lven:
and
[MJ nxn
F· d [ q j+l] nxb ...l!L:
and
Such that:
] I
I
={~J
(6.247) (6.248)
456
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
and
K (3 ) -'-
12
-
[-1]
(6.249)
Since only sub-domains 2 and 3 are considered as "floating" sub-domains, the "generalized inverse" matrices for these sub-domains can be computed as:
[K(2»)r =r[~
~] [~]1
(6.250)
[0 0] [0]
[[1]
[ K(3)]+= [0] [0]] [0]
(6.251)
The rigid body matrices for sub-domains 2 and 3 can be computed as: R
(2)
= [- [ K :i)
r[
K};)
J] = {{a}
[I]
R Matrices
(3 )
(6.252)
{I}
= {~}
[F1 ] , [G1 ] ,
(6.253) and the right-hand-side vectors
{d}
and
{e} , can
be
computed as indicated in Eqs.(6.119, 6.120, 6.122 and 6.123):
[11]
=IB(S)K(S)+ B(sl =[30 0]1
(6.254)
s=1
[G)] =[ B(I)R (I), B(2)R (2), B(3)R (3) J= {~l}
(6.255)
{d}= IB(S)K (S)+f(S) ={l}
(6.256)
0
s=1
{e} = [f(ll R (I ), f(2l R(2) ,f(3l R (3)
r
= [0]
(6.257)
Thus, Eq.(6.118) can be assembled as:
r
[~ ~] [~]]{{~:}} = {{~}} [1 0]
[0]
at
(6.258)
{ 0}
The coefficient matrix on the left-hand side of Eq.(6.258) is an indefinite matrix. Its three sub-determinant values are +3, +3, and -I , respectively. For largescaled applications, Eq.(6.258) should be solved by the iterative solver such as
Duc T. Nguyen
457
the Pre-conditioned Conjugate Projected Gradient (PCPG) algorithm 16.4 1• However, in this example, both direct and PCPG iterative solvers are used to obtain the solutions .
B.t Direct Solver: The unknowns for Eq.(6.258) can be found as:
Finally, the unknown displacement vector for the sth sub-domain can be computed according to Eq.(6.l08) as:
U(s=l) ={OJ == {U~l)} 1
{~} j~~::) U(s=3) = {I} {U~3)}
U(s=2) =
(6.259)
u(l) 2
==
1
(6.260)
U~2)
==
1
(6.261)
u(3)
2
B.2 PCPG Iterative Solver: Based upon the step-by-step PCPG procedure given in Table 6.6, one obtains: (a) Initialized Phase From Eqs.(6.126 and 6.255), one has:
P~I-G, (GrGt Gr ~[~ ~]
(6.262)
From Eqs.(6.139 and 6.257), one obtains: O
A
~Gl(GrGr e~{~}
(6.263)
From Eq.(6.140), one gets:
rO ~ d-~AO (b) Iteration Phase Iteration k = 1
~{~}
(6.264)
458
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
(6.265) WO
01
~{~}
(6.266)
k k_I T k-I/ k-ZT k-2 2 sub-domains) (C2) The dof located at the beginning and the end of each edge of subdomains (see corner of C2 and C3 in Figure 6.11) Remarks (l) The "true" corner dof is c\ (in Figure 6.11) since it belongs to three
sub-domains. Thus, it fits the definition (C\) for corner dof. (2) The constrained "remainder dof' at nodes Band C (see Figure 6.11) can also be selected as "corner dof," based on the definition (C2) . This will assure that the sub-domain's stiffness matrix will be non-singular. This statement will soon be more obvious during the derivation of the FETl-DP formulation. (3) The definition (C2) holds only for finite element meshes composed of 2-D elements . (4) If CS = 1, then all interfaced dof will be the corner dof. Thus, the FETIDP will collapse into the "primal" D. D. formulation. (5) If c" > ns, then the number of corner dof goes to zero. Hence, FETl-DP will collapse into FETl-l "dual" D. D. formulation.
Due T. Nguyen
465
(6) If CS = 2, then the definition of comer dof will be valid for finite element meshes with both 2-D and 3-D elements. S (7) C = 3 is employed for uniform meshes with 3-D finite elements to reduce the (possible) large number of comer dof. Since each rtll subdomain only need a few comer nodes (say 2, or 3 comer nodes, or up to 6 comer dofs) to remove all its rigid body motion, the total "comer" dof required for the entire domain will be minimized if we have comer dof that belong to several sub-domains. (8) For non-uniform finite element meshes with 3-D elements, CS = 3 is selected in conjunction with appropriate procedures to assure the existence of at least three non-collinear "comer" nodes to avoid singular sub-domain matrices [6.6.6.17]. From Figure 6.11, the sub-domains' stiffness matrices and nodal displacement, vectors can be partitioned as:
[ xv:» ] = [ «;(1) K(l) cr [ K(r=2) ]
= [ K rr(2) K(2) cr
[ K(r=3) ]
= [ K rr(3) K(3) cr
rc K'l)] K(l) cc
K(2)] rc K(2) cc
K(3)] rc K(3) cc
{")}
and
{u(l)}
= :~l)
and
{U(2)}
= :~2)
and
{u(3)}
= :~3)
{ (2)}
{ (3)}
(6.317)
(6.318)
(6.319)
Remarks (1)
The prescribed Dirichlet dof, due to the physical supports in subdomains r = 1 and 2, are assumed to be already incorporated into and {U(2)} in Eqs. (6.317 and 6.318).
[K(I)], {u(I)}, [K(2)],
(2)
Compatibility requirements can be imposed on the constrained "remainder dof" as follows (see Figure 6.11): (s=l) _
Ii
(3)
(s=3)
-Ii
(6.320)
...(s=l) _ ...(s=3) '2 -'2
(6.321)
...(s=2) _ r(s=3) '3 - 3
(6.322)
(s=2) _ r(s=3) r4 - 4
(6.323)
...(s=l) _ ...(s=2) '5 -'5
(6.324)
( s=l ) _ r.(s=2) r.6 - 6
(6.325)
Comer point A is usually selected at a point where more than two sub-domains meet. While these selection criteria will help to minimize the size of the total (= system) "comer dof" (which plays a
466
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solution s
(4)
similar role as the "boundary dof" in the "primal" domain decomposition formulation), any point on the boundary of a substructure can be selected as a "corner point." However, in order to have a more meaningful (and easier) physical interpretation , comer points (or comer dof) are suggested at the beginning and ending of each edge of a sub-domain. One of the major purposes of introducing a minimum number of comer dof for each sub-domain is to assure that the sub-domain will have no rigid body motions , and therefore , special procedures for obtaining the generalized inverse and rigid body modes can be avoided. For 2-D and 3-D structural applications, usually 3 and 6 "corner dof" are required, respectively , to remove all rigid body motions.
The Boolean transformation matrix can be established in order to relate the sth subdomain's local dof to the global (= system) dof of the entire domain. Thus, one can write the following set of equations, which correspond to sub-domains s = 1,2, and 3, respectively. u (l )
{u ( s=I)}=
{"=J)} [1 U,
=
(s= l)
Uc
r
0 0
0 0 0
B;~J)}
U (2)
r
(6.326)
u (3) r
Uc
global
or, in a more compact form: {U (S=I)}
= [/(S=I)}{ u}
In Eq.(6 .326), the vector
{u c }
(6.327)
(appeared on the right-hand side) represents the total
(or system) "comer dof ' for the entire domain. Matrices [I] and [ B~s=l) ] represent the identity and Boolean transformation matrix, respectively.
-(S=I)J and {u} (see [Eq.6.327]) are obvious, as one compares [
The definitions of I
them with the right-hand side of Eq.(6 .326). Similarly, one obtains: u(l )
r
{u ( S=2)} =
{"=2)} [0 U, (s=2)
Uc
=
I
0
0 0 0
/ =2)}
U (2) r
u (3) r Uc
or
(6.328)
Duc T. Nguyen
467
J.{u}
{U (S=2)} = [j(S=2)
(6.329)
u(l)
{u (S=3)} =
or
{"=3)} =[00 ur (s=3) Uc
{U (S=3)} = [j(S=3)
0
I
0
0
B~~3)
l
r U(2) r u (3) r
(6.330)
Uc
J.{u}
(6.331)
Compatibility requirements can be imposed on the constrained "remainder dof' (interface constraints between sub-domains) as follows (similar to Eqs.[6.320 6.325]): (6.332) S
or, for the case of three sub-domains:
=0
(6.333)
or, symbolically
[Br]·{u} =0 The number of rows of
[B
r
]
(6.334)
will be equal to the total number of constraints.
± r[K(S)]{
The total strain energy can be computed as:
S.E. =!
{u(s)
U(S)}
(6.335 )
2 s=l
Substituting Eq.(6.321) into Eq.(6.335), one obtains:
un
S.E.= ~~ {(J" ) K")J(ru)}
(6336)
S.E.= ~ {u}' ~ {[I")
(6.337)
n J[rJ}{u} K" )
or, symbolically:
S.E.= k{uf[Kg]{U} Assuming s = 2!!!! sub-domain, then
(6.338 )
468
[1(S)
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
r[ J[ K(s)
/(S) ]
0
0
I
0
0
0
0
(s)1' Be
[K'" K;;'W0 rr
K(s)
K(s)
cr
I
0
ee
0 0
o ] (6.339)
B(s) e
0
0
0
0
0
K(s) rr
0
K(s) B(s)
0
0
0
0
0
(sl (sl Be K er
0
T B(s) K(s) B(s) e ee e
rc
c
n
(6.340)
The system (global) stiffness matrix can be assembled as:
[Kg]
=
~ {[I(') K'" ][I"']} 0
0
K(l) B(l) re e
0
K(Z) rr
0
K(Z)B(Z) re c
0
0
K(3) rr
K(3) B(3) rc e
K(l) rr
(Il K (Il
Be
(6.341)
er
(zl K (zl
Be
(3l K (3l
Be
cr
er
3
L B~s)
l'
(6.342)
K~~) B?)
s=J
The system (global) load vector can also be assembled in a similar way. The external load vector applied on the sth sub-domain can be given as:
{t")} = {~::: }
(6.343)
The scalar external work done by the above given load vector can be computed as: 3
W
= I{u(S)} S=! 3
W
T
= I{I(S)u}
·{f(S)} T
·{f(S)}
(6.344)
(6.345)
s=!
w ={u}' (~l"" w ={ut ·{fg}
r: J
(6.346) (6.347)
Due T. Nguyen
469
3
where
{fg} == L /(.1)
T .
r'"
(6.348)
.1=1
o T /(.1=2)
. f(s)
=
I
0
o o o
(6.349)
o (6.350)
f}l)
f?) f?)
Thus
(6.351)
3
LB?)T f}S) .1=1
The total potential energy of the entire domain, subjected to the constraints of Eq.(6.334), can be expressed as:
n = ~ { U}T [Kg]{u}- {u}T{fg} +{ A}T[s,]{U}
r
n =~{U}T [Kg ]{u}-{uf {fg}+{U}T [Br {A}
(6.352)
The equilibrium equations can be obtained as:
an au =[ KgJ{u}-{fg}+[Brr {A}=O
(6.353)
or (6.354) Th, dimension for the above equation is [
~n~")
)
+ »: '110, last term in Eq,(6354)
can be expanded as:
[Brt {A} = ([B?)J [B?)J [B?)J [O]} {A}
(6.355)
470
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
Eq.(6.353) can be symbolically represented as:
Krr Kre]{Ur}={r-B;A} [«; x; Ue t. where the sub-matrices x.: «.; Kcr' and Kee of [ Kg]
(6.356)
can be identified by
referring to Eq.(6.342). It should be noted that the constraint equations are only associated with the interface "remainder dof," and not directly related to the "comer dof." This observation reflects on the right-hand side of Eq.(6.356). Eq.(6.354) has to be solved in conjunction with the following nA additional equations:
~~ = [Br]{u} ={O}
(6.357)
From the top and bottom portions of Eq.(6.356), one obtains:
«;«, + s,», = I, -[ Br ]T A
(6.358)
s ;«, + x,», = I;
(6.359)
From Eq.(6.358), one has:
u,
r
= [K rrt (Ir -[ s, A-[Krclue)
Pre-multiplying both sides of Eq.(6.360) by
(6.360)
[B r ] , and utilizing Eq.(6.332 or 6.334),
one obtains: (6.361) Defining the following parameters:
a, :=[Br][Krrt t, r; := [Br ] [ x; t [Br r
(6.362) (6.363)
r: :=[Br][Krrt [Krcl
(6.364)
Then, Eq.(6.361) becomes:
O=dr -[Frr]A-[Frclue
(6.365)
Substituting Eq.(6.360) into Eq.(6.359), one has:
r
[Kcr][ x; t (Ir -[Br A-[ s : ]Ue)+[ x.; l-, =t; or
[K er ] [ s ;
t Ir- Ie=[Ker][ «;r' rr A+(r Ker][ «; t [B
[K
(6.366)
rel-l Keel)ue (6.367)
The following parameters are defined:
- I. +[ Ker ][Krr
r I, t
:= -
Ic•
(6.368)
Due T. Nguyen
471
[K er ] [ x;
r [Kre]- [Kee] == -[ K;e ] 1
[KerHKrrt [Brr ==[Fcrl
(6.369) (6.370)
Using the new notations, Eqs.(6.365, 6.367) can be expressed as (in terms of the unknowns A and uc ) :
r rr F :re* ]{:} = {_d [Fer Kee e I; unknown vector {uJ can be eliminated
*}
The
(6.371) from the 2nd half of Eq.(6.37I) as
follows:
{uJ=[ K;eJl([FerlA+ Ie*)
(6.372)
Substituting Eq.(6.372) into the I" half ofEq.(6.37I):
[FrrlA+[Frel{[ K;eJl ([Fcr]A+ Ie*)}=d r
(6.373)
or (6.374) or, symbolically
[K,u]A=d A
(6.375)
Remarks
(5)
Matrix [ K;e ] is sparse, symmetric positive definite, and the size of this matrix is relatively small.
(6)
Matrix
[K
rr
1is non-singular
"comer dof' to guarantee that
since there will be enough selected
[K
rr
r l
exists.
The entire FETI-DP step-by-step procedures can be summarized in Table 6.8.
472
Finite Element Methods : Parallel-Sparse Statics and Eigen-Solutions
Table 6.8 FETI-DP Step-by-Step Procedures Step 0
Step I
Step 2 Step 3
Assuming all data for the "conventional" finite element (without using Primal, FETI-I, or FETI-DP domain decomposition formulation) is already available. Based on the user's specified number of processors , and/or the number of sub-domains, and utilizing the METIS (3..3), the original finite element domain will be partitioned into NP == NS (= Number of Processors = Number of sub-domains) Post processing METIS outputs to define "comer" nodes (or dofs), "remainder" nodes, and other required sub-domains' information.
[ K~:) Step 4
Step 5
[K~:)
Construct the sth sub-domain's matrices
J' [K~:) J'
Jand [ K~:) Jand load vectors {I}S)} and {Ic(S)} .
Construct the following sub-domain' s sparse Boolean matrices:
[ B?)
J, for "comer" dofs
[ B~s)
J' for "remainder" dofs
l
Construct the following matrices and/or vectors:
[Krr ] ==
[
K(~) rr
K~:=2)
, see Eq.(6.356)
K(s=3) rr (FI)B(s=1) [ K rc c [K rc] == [K;;=2) Bt 2) see Eq.(6.356) (S=3)B(S=3)J [ K rc c
J J'
(6.376)
(6.377)
=1 )][B(s=2{ K cr(S=2)][B( s=3{ K(S=3)]) (6378) [K ] == ([B(C S=I{ K(S cr c cr . CT
C
(6.379)
[Br] == ([ B~s=I)J[B~s=2) Step 6
J[ B;s=3) J[O])
(6.380)
Construct
a, ==[Br][Krrt I,
(6.362, repeated)
r; ==[BrHKrrt [Brf
(6.363, repeated)
r: == [B
(6.364, repeated)
r ][
«;
r [K
rc ]
Due T. Nguyen
Step 7
473
Construct
- I c* == [ K cr ][K rr
r
1
Ic
[, -
(6.368, repeated)
-[ K;c] == [K cr][ x; t [Krcl-[ Kcc] [F::r] == [Kcr ][ x; [B, Step 8
r r [K,u]=(F + Frc[K;cJl Fer) d). == d; -( Frc[K;cJl Ic*)
(6.370, repeated)
Construct
rr
Step 9
(6.369, repeated)
Solve for
(6.374, repeated)
.Ii, from Eq.(6.375):
.Ii = [K).).r' d). Step 10 Solve for
(6.374, repeated)
Uc '
(6.375, repeated)
from Eq.(6.372): (6.372, repeated)
Step I I Solve for
u, ' from Eq.(6.360):
ur =
[K r r
r (Ir - [Brr .Ii- [x., ]Uc)
(6.360, repeated)
Remarks (7)
Solving for u, (shown in Eq.[6.360]) is not a major concern, because (a)
(8)
[K rr ]
is sparse, symmetrical (or unsymmetrical) and it can
be factorized by sub-domain fashion. (b) Only one right-hand-side vector is required . Solving for U c (shown in Eq.[6.372]) can be moderately computational expensive, because (a)
[K;c] has relatively small dimensions, hence it is not too expensive to factorize.
(b) However, during the process to construct [ K;c]. shown in Eq.(6.369),
the
(associated with
number
[K rr
r
l )
of
right-hand-side
vectors
is related to the system "comer
dof," which may not be a large number; however, it may not be a small number either! (c) Only one right-hand-side (RHS) vector is required for Eq.(6.372).
474
Finite Element Methods: Parallel-Sparse Statics and Eigen-Solutions
(9)
[KAA]
(see Eq.[6.374]) for the solution of
A (see
Eq.[6.375]) can be a major concern because the construction of
[KAA]
Factorizing the matrix
will
require
[ K;c
T 1
• ([
the
computation
Kcr ][«; t
associated with [ K;c
r
[By
of
or
r). Thus, the number of RHS vectors
1
(hence, associated with
[Kur l ) can be large!
Standard Pre-Conditioned Conjugate Gradient (PCG) iterative solver is recommended in [6.6] for solving the linear Eq.(6.375) since the coefficient [K.u ] is a symmetric positive definite matrix. However, a recursive (or multi-level) sub-domain approach [6.18,6.19,6.20] with "only direct sparse solvers" (without using "iterative" solvers) have also been recently proposed. 29-Bar Truss Example
In this section, the FETI-DP procedures will be applied on a 2-D truss example as shown in Figures 6.12 - 6.13.
*-..
360 in.
19
_.360 in.
*
21 20
10
22
11
7
5
29 .
24
26
14
8
6
27
25
13
12
6
4
>1
23
18
5
360 in.
28
15
.~
16
17
Y
9
10
7
1
10 kin