Two-Dimensional Finite Element Analysis using - ASEE

Two-Dimensional Finite Element Analysis using Java
C.D. Wilson1, R.L. Parsons, Jr.2 and G.T. Cunningham3
Abstract
A two-dimensional finite element code for heat transfer and stress analysis was written using Java. The
program consists of an input parser, a solver, and a graphical postprocessor. The program was tested to
ensure that underlying physics was corrected coded. Several examples using the Java program are given to
demonstrate the postprocessing capabilities of the code. Time trials were conducted to further demonstrate
the feasibility of using a web-based Java applet for finite element analysis.
Introduction
Thousands of papers have been written about finite element analysis (FEA) and its application to
engineering problems. Today, the finite element method is the most popular method for developing
numerical solutions of differential equations. Many different physical phenomena can be addressed using the
method. Heat transfer and stress analysis are two common applications for mechanical engineers. There is
little need for a practicing engineer to write custom software to solve a common mechanics or heat transfer
problem because a large number of commercial, general-purpose finite element software packages are
readily available. NASTRAN, ANSYS, and COSMOS/M are examples of commercial packages that are
available for several different hardware/operating system platforms.
Currently available software packages have the distinct disadvantage of requiring separate coding for each
individual combination of hardware/operating system platforms. Common platforms include Sun Solaris on
SparcStations and Microsoft Windows on Intel-Based PCs. The large number of hardware/operating system
combinations available causes finite element software vendors choose to support only a few of the many
platforms leaving users of other platforms without the benefit of their software. Vendors wishing to support
multiple platforms find themselves in the position of maintaining multiple versions of the same software.
The burden of maintaining multiple code bases takes away valuable time and resources. Indeed, the issue of
platform dependency is a global computer problem, adversely affecting vendors of all types of computer
software.
The work described in this paper is a summary and adaptation of R.L. Parson’s master’s thesis from
Tennessee Technological University [1]. Parson’s thesis contains a complete description of the computer
program described in this paper and the corresponding technical background.
1
ME Dept., Tennessee Technological University, P.O. Box 5014, Cookeville, TN, 38505.
2
TAP Publishing Company, P.O. Box 509, Crossville, TN 38557.
3
ME Dept., Tennessee Technological University, P.O. Box 5014, Cookeville, TN, 38505.
ASEE Southeast Section Conference
1
Using Java for FEA
In 1991, Sun Microsystems, Inc., a company known for its high performance hardware and its Solaris™
operating system (OS), started work on a project to eliminate the platform dependency. The project
eventually led to what is sometimes described as a pseudo-platform known as Java [2,3]. Java provides a
programming language (also called Java) as well as support which allows it to run on virtually any
hardware/OS combination.
Java can be implemented on any hardware/OS platform by simply writing a virtual machine (VM) for that
platform. The virtual machine is a program that translates the fictional machine language into the actual
machine language for the computer’s real microprocessor. Once a Java program is written and compiled, it
can be executed on any hardware/OS combination for which there is a VM. Currently, VM implementations
are available for almost every platform. By introducing the concept of a virtual machine and creating a new
level of abstraction, Sun Microsystems has provided a means to bypass the platform dependency.
The adoption of Java as an application programming language has grown since its formal introduction in
1995. Its growth has been hampered by the added overhead required for the VM to translate intermediate
byte code to native machine code meant that Java programs were slow compared to programs written in
other languages. The promise of “write once, run everywhere” development became very appealing to
developers. The use of Java applets embedded within internet websites is widespread. Java is widely
accepted for application development and is projected to surpass C++ as the most popular application
development language by the summer of 2002 [4].
Several researchers have already explored the use of Java for finite element modeling. Cabell, Rencis, Alam,
and Grandin [5] used Java to develop a simple one-dimensional finite element applet designed specifically
for educational use. Nikishkov [6] translated a finite element program for eight-noded two-dimensional
elements and 20-noded three-dimensional elements into separate C and Java programs. Models with 1,000
to 15,000 degrees of freedom were executed. For many operations, the Java code was almost as fast as native
C; however, in some operations the Java code’s performance was only 50% that of the same routine
implemented in C code. No web-enabled software was developed.
A number of Java-based finite element codes are currently available on the internet. Because of the
transient nature of the World Wide Web, the sources of some of these codes are often not completely known
and in some cases the codes themselves are no longer available. An early attempt at web-based finite
element software originated at the University of Utah and appeared on the web in March 1996. Written by
student Jason White and simply called SimpleFE [7], this code implemented a one-dimensional bar element.
A notable feature of this code was the inclusion of a front-end graphics package to allow the user to draw a
truss system on the screen. Perhaps the most sophisticated Java-based finite element code available on the
web is the FESA-2D [8] code. Based on a stress analysis code developed by Dr. Ashok D. Belegundu of Penn
State University [9], the package allows for a variety of two-dimensional stress analyses. An impressive
front-end drawing package is included; however, a number of notable features were missing. For example,
the front-end preprocessor does not allow the user to enter exact coordinates of nodes.
Java CST Program
A fully functional browser-based finite element application was created using Java [1]. The program uses a
single element type: the two-dimensional constant strain triangle (CST) shown in Figure 1. In addition, the
program assumes a constant thermal gradient (this is the heat transfer equivalent to constrain strain).
Nodal displacements and temperatures are the assumed degrees of freedom in the program. The heat
transfer and stress analysis are uncoupled; in other words, the temperatures are solved first, then applied as
boundary conditions to a displacement-based stress analysis. The CST element was chosen for simplicity.
ASEE Southeast Section Conference
2
The element type is a very familiar one to most students of the finite element method. Its disadvantages
often limit its use to academic problems—it is seldom used in commercial applications.
The physical assumptions are as follows: a linear, elastic behavior (either plane stress or plane strain), small
strains, and constant thermal conductivity. Possible boundary conditions include: zero nodal displacements,
nodal loads, nodal temperatures, and convection along free surfaces. Details of the physics involved can be
found in reference [10]. The results include temperatures, displacements, and thermomechanical stresses.
A Java-based finite element engine was created and formed the basis of a finite element applet. The engine
was divided into four basic components: the input parser, the solver, the stress model, and the conduction
model. These parts function together to produce a working finite element engine. Portions of an existing
Fortran program by Wilson [11] were adapted.
Instead of a graphical user interface (GUI) for mesh generation, the finite element model is completely
described by an input file that contains all of the necessary material properties, boundary conditions, nodal
points, and element definitions. The term “input file” is really a misnomer since the “file” is essentially just a
block of text regardless of whether it is contained in a file or simply cut-and-pasted by the user from another
source. A sample input file is shown in Figure 1. The comments shown in Figure 1 (following the // marks)
are for explanation only. The actual input file would not contain the // marks or any text beyond. In addition,
there should not be any blank lines in the input file. Blanks lines will either cause an error to occur, or no
processing to be done. All keywords should be spelled exactly as indicated in lowercase only.
The new applet implemented a GUI that contained a text box for the input file and a “Solve” button. A
number of other buttons were added that would quickly populate the input text box with a number of test
models. The applet is activated by directing any Java-enabled web browser to a URL that contains special
HTML code, which in turn loads the applet from the web server. The applet executes and the user is
presented with a screen containing a text box (which contains the input file) and a button labeled “Solve.”
The applet will solve the model and produce output in the form of a wire mesh representation of the modeled
part. The graphics may be zoomed or scrolled about the screen. The user may view a representation of the
deformed model as determined by the displacements from the solution. Color contours may be produced
indicating a number of quantities. Elemental temperatures, temperature gradients, heat fluxes, normal
stresses, shear stresses, principal stresses, and von Mises stresses can all be displayed. Numerical values of
these quantities can also be directly drawn on the element. A formatted text output option is also available
to allow the user to export results to a third-party application such as Microsoft Excel. Provisions are
included to allow the user to show applied loads, displacement constraints, temperature constraints,
convection conditions, node numbers, and element numbers.
Example Results and Discussion
The results from two example problems are shown below. The first example, a cantilevered beam with two
applied forces is shown in Figure 2. The von Mises stresses are displayed. The second example is a hollow
disk with a temperature gradient between the inner and outer radii shown in Figure 3. Identical meshes of
the hollow disk were constructed in ANSYS. The results from the Java code matched ANSYS and both finite
element results agreed well with the analytical solution for temperature variation in a circular disk or tube
as given by Incropera and DeWitt [12] and Boley, et al [13].
Several of Java’s shortcomings were addressed while writing the finite element engine. Java does not
natively support matrices so a new Matrix class was programmatically created. Methods to perform matrix
algebra and other manipulations were added to the class. Since the objectives of the research called for the
code to be eventually deployed in an applet, some compromises had to be made. Most web browsers currently
in use do not support the latest version of Java (1.4 at the time of writing). Instead most browsers support
the older 1.1 version. This version lacked many key features such as support for numbers in scientific
ASEE Southeast Section Conference
3
notation. To work around this limitation, custom routines were written to accept scientific notation as input
and to also provide output formatted in scientific notation.
One of the biggest concerns expressed by the community about the use of the Java programming language is
the relatively slow speed of processing. The concern is especially important to the current research since the
type of processing performed by finite element codes is very processor intensive. Much work has been done
over the last few years to improve the speed of Java virtual machines. To evaluate the practicality of running
the Java finite element applet in a production environment (as opposed to a research environment), a series
of simple performance surveys were performed. The protocol simply called for a fine mesh solution to a test
case on a wide variety of hardware types and operating systems. The time to solve the problem was
measured from the click of the “Solve” button to the presentation of the output window. Table 1 summarizes
the results of these tests.
The results of the trials indicate an extremely large variation in the execution speed. The results are far
more dependent on the browser installed (and therefore the Virtual Machine implementation) than the
speed of the hardware. This is a positive indicator because it suggests that speeds will continue to get better
simply due to improvements in the Java VM software. Further improvement will also be seen as hardware
continues to increase in speed.
Conclusions
The following two conclusions can be drawn. First, the Java language can be readily used for finite element
analysis. A general-purpose, web-based, Java finite element code can be practically constructed. Second, the
performance data is somewhat slower than other, natively compiled code; however, the decrease in
performance is not sufficient to preclude the use of Java for future development. Good performance is more
of a function of the virtual machine used for execution rather than hardware considerations. It is likely that
as computer hardware gets increasingly faster every year, the slow performance issue will become less and
less of an issue.
In closing, it must be noted that the current program is still in its infancy. Future enhancements to the
program have been planned. These include a faster solver, a graphical front-end and additional boundary
conditions.
References
1. Parsons, Robert L., Jr. (2001) , Investigation of the use of the Java programming language for web-based
finite element modeling, Masters thesis, Tennessee Technological University.
2. Gosling, James, Bill Joy, Guy Steele, and Gilad Bracha (2000), The Java Language Specification Second
Edition, Addison-Wesley.
3. Lindholm, Tim and Frank Yellin (1999), The Java Virtual Machine Specification, Addison-Wesley, Second
edition.
4. Vaughan-Nichols, Steven J. (2001, September 4), “Wither Now C++?,” BYTE.com Online Magazine,
Retrieved November 4, 2001 from http://www.byte.com/documents/s=1271/byt20010831s0001/
5. Cabell, B. Q., J. J. Rencis, J. Alam, and H. T. Grandin (1997), “Using Java to Develop Interactive Learning
Material for the World-Wide Web,” The International Journal of Engineering Education, Vol. 13, No. 6.
ASEE Southeast Section Conference
4
6. Nikishkov, G. P. (2000), “Performance of a Finite Element Code Written in Java,” Advances in
Computation Engineering and Sciences 2000,Vol. 1.
7. White, Jason (2000), SimpleFE, Retrieved September 2000 from
http://www.mech.utah.edu/~jwhite/assign8/simpleFE.html.
8. De Souza, U. and A. Belegundu (2001), Finite Element Stress Analyzer-2D (FESA-2D), Retrieved
November 4, 2001 from http://urbandesouza.hypermart.net/Applets/Fesa2d/GuiApplet.html
9. Chandrupatla, T.R., and A. Belegundu (1997), Introduction to Finite Elements in Engineering, 2nd Ed.,
Prentice Hall.
10. Logan, Daryl L. (1997), A First Course in the Finite Element Method using Algor, PWS Publishing
Company.
11. Wilson, Christopher D. (1998), “Constant Strain Triangle Finite Element Code,” Retrieved November 16,
2001 from http://gemini.tntech.edu/~chriswilson/cst.html
12. Incropera, Frank P. and David P. Dewitt (1990), Fundamentals of Heat and Mass Transfer, John Wiley &
Sons.
13. Boley, Bruno A. and Jerome H. Weiner (1960, Revised 1985), Theory of Thermal Stresses, Robert E.
Krieger Publishing Company, Inc.
Table 1 Comparison of execution times for test case with 500 elements on a variety of hardware,
operating systems, and web browsers.
Hardware/OS/Browser
Execution time
(min:secs)
AMD 1.4 GHz/Windows XP/MSIE 5.5
0:11
AMD 850 MHz/Windows 2000/Netscape 4.7
0:55
AMD 1.4 GHz/Linux/Netscape 4.77
1:42
PowerPC G3 500Mhz/MacOS 9/MSIE 5.0
0:49
Sun 4500 Sparc/Solaris 7/Netscape 4.7
5:10
AMD 850MHz/Windows 2000Mozilla 0.9.3
0:31
AMD 850 MHz/Windows 2000/Netscape 6.0
0:30
AMD 1.4 GHz/Windows XP/Sun JIT Compiler
0:15
ASEE Southeast Section Conference
5
comment Simple Demo
// Up to two comments may be include on these lines
comment
// Comments are printed on output screen
analysis plane stress
// Type of analysis, “plane stress” or “plane strain”
print all
// Deprecated, retained for backward compatibility
materials 1
// Number of materials in model
1 30e6 .3 0 0 0
sections 1
// Material constants: Material Number, E, nu, alpha, kx, ky
// Number of “sections” for different thicknesses
11
// Section number and thickness
nodes 10
// Number of nodes
1 0 0
// List of node definitions follow
2 3 0
//
First parameter is node number
3 6 0
//
Second parameter is x coordinate
4 9 0
//
Third parameter is y coordinate
5 12 0
6 0 4
7 3 4
8 6 4
9 9 4
10 12 4
fixpts 2
111
// Total Number of constrained nodes
// Node number, 1 if constrained in x, 1 if constrained in y
501
loadpts 1
8 0 -1
// Total number of nodes with applied loads
// Node number, x component of load, y component of load
fixtemps 0
// Number of fixed temps nodes, normally followed by
elements 8
// Total number of elements
//
a list of nodes and prescribed temperatures
11 7 611
// List of element definitions
21 2 711
//
32 8 711
//
Format is: Element number, i node, j node, k node,
material number, section number
42 3 811
53 9 811
63 4 911
7 4 10 9 1 1
8 4 5 10 1 1
convection 0
// Number of convection surfaces
// Normally follow by a list surface definitions which
// following the format: 5 4 9 30 300
// Element #, node 1, node 2, h, tinfinity
Figure 1 A sample input file. Note that the comments are for explanation only.
ASEE Southeast Section Conference
6
Figure 2 Cantilevered beam with two applied forces
Figure 3 Quarter-symmetric model of a disk with temperature distribution shown.
.
ASEE Southeast Section Conference
7
Christopher D. Wilson
Christopher D. Wilson has a B.S. (1986) and M.S. (1988) in Mechanical Engineering from Tennessee Technological
University, a M.S. (1995) in Mathematics from The University of Alabama-Huntsville, and a Ph.D. (1997) in
Engineering Science from The University of Tennessee. He is currently Assistant Professor of Mechanical
Engineering at Tennessee Technological University (1997-Present). His teaching and research interests focus of the
mechanical behavior of materials, particularly fracture mechanics and plasticity of metals and the mechanics of
fiber-reinforced composites.
Robert L. Parsons, Jr.
Robert L. Parsons, Jr. has a B.S. (1996) and M.S. (2001) in Mechanical Engineering from Tennessee Technological
University. He currently works for TAP Publishing in Crossville, TN as a systems engineer. His area of research
interest is web-based software engineering.
Glenn T. Cunningham
Glenn T. Cunningham has a B.S. (1979) and M.S. (1982) in Mechanical Engineering from The University of
Memphis (formerly, Memphis State University) and Ph.D. in Mechanical Engineering (1990) from Tennessee
Technological University. He is currently Associate Professor of Mechanical Engineering at Tennessee Technological
University (1989-Present). He has been registered as a Professional Engineer in the State of Tennessee since 1986.
His areas of expertise are: remaining life analysis; fatigue, creep and fracture analysis; thermal sciences; energy
conservation and management; heat ventilating and air conditioning, and microelectromechanical devices.