An Object Oriented Analysis
An Object Oriented Analysis
net/publication/264594463
Article in International Journal of Advanced Computer Science and Applications · August 2014
DOI: 10.14569/IJACSA.2014.050709
CITATION READS
1 386
1 author:
SEE PROFILE
All content following this page was uploaded by Bryan James Mac Donald on 11 August 2014.
Abstract—Smartphones are becoming increasingly ubiquitous in comparison to supercomputers and suggests that multicore
both in general society and the workplace. Recent increases in clusters of mobile processors may actually represent the future
mobile processing power have shown the current generation of of high powered computing.
smartphones has equivalent processing power to a
supercomputer from the early 1990s. Many industries have Given that fig. 1 shows that a current mobile device is
abandoned desktop computing and are now entirely reliant on approximately equivalent in computing power to an early
mobile devices. Given these facts it is logical that smartphones 1990’s supercomputer or a late 2000’s desktop and,
are considered as the next platform for finite element analysis considering the pioneering finite element analyses work done
(FEA). This paper presents an architecture for a smartphone on these machines at the time, it is reasonable to consider
FEA application using object-oriented programming. A MVC current smartphones as capable of performing useful finite
design pattern is adopted and a demonstration FEA application element analyses.
for the Android smartphone platform is presented.
I. INTRODUCTION
Since the introduction of smartphones in 2007 they have
had a profound effect on lifestyles by significantly changing
the way that people live, work and learn. Smartphones have
become the dominant mobile device for communication
information and entertainment. In many cases smartphones
(and associated tablets) have become the dominant computing
platform in many industries. Smith [1] demonstrates that in
excess of 46% of American adults own a smartphone and the
rate of ownership rises to in excess of 60% when college
graduates and high income households (in excess of $75,000)
are considered. When considering these statistics, it is Fig. 1. Development in Computing Power (Mflops) since 1970. Trend lines
reasonable to assume that the majority of engineers, scientists show (a) supercomputers, (b) desktop PC’s and (c) mobile processors.
and analysts will own, or have access to, a smartphone (or
related tablet). There are currently two major operating systems available
for smartphones: iOS (Apple Inc.) and Android (Google Inc.).
Many smartphone users are unaware of the computing Both of these platforms are based on objected-oriented
power available in their devices and/or the potential of the programming languages: objective-C in the case of iOS and
smartphone as a platform for finite element analysis. Fig. 1 Java in the case of Android. Hence, any finite element code
shows a comparison of computing power (in mega-flops) for written for smartphones must be object-oriented.
different processors. The leftmost line (a) links the processing
power of three supercomputers (Cray C1, Cray C90 and Cray Zimmermann et al. [3] described the governing principles
Jaguar). The centre line (b) shows the processing power of for object-oriented finite element programming, before
desktop PC processors over time (Intel 386, Intel Pentium and describing an implementation using SmallTalk [4] and C++
Intel Core i7). The final line (c) illustrates the increase in [5]. A number of authors [6-9] have described object-oriented
computing power of mobile processors commonly used in implementations of the finite element method using C++.
Android smartphones and tablets. It is clear from fig. 1 that Following the popularisation of Java in the late 1990’s a
comparing a current high end mobile processor (e.g. Nvidia number of researchers began to explore the possibilities of
Tegra 4 which is built on ARM technology) with desktop and writing FEA codes using Java. Many researchers, however,
supercomputer processors, shows that current mobile processor were reluctant to engage with Java as it had a reputation for
capability is on par with desktop processors from circa 2008 slow performance in comparison to more established non-
and supercomputer processors from the early 1990’s. Rajovic object-oriented languages. In order to investigate this
et al [2] discusses the development of mobile processor power Nikishkov [10] compared the performance of a Java FEA code
59 | P a g e
www.ijacsa.thesai.org
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 5, No. 7, 2014
with a similar code written in C. It was found that with the use The view is also responsible for receiving user input and
of proper coding and tuning it is possible to obtain similar passing it to the controller. On a smartphone this is quite easy
performance from the Java and C finite element codes. In a to grasp as the touchscreen on an Android device is used to
subsequent presentation, Nikishkov [11] described the design both display the app and receive touch gestures. The controller
of an object-oriented Java finite element code for the 2D and receives user input from the view and acts accordingly. In most
3D analysis of elastic and elasto-plastic structural solids. The cases the controller will update the model state however it is
code was developed using Java 1.5 and utilised the Java3D API also possible that the controller will just change the view
to allow for visualisation of the results. A user interface was without changing the model, for example, if a cosmetic change
not developed and model specification was handled via an to the interface was requested by the user. The model stores
input text file which was read using a scanner. data in its properties, implements application methods and
implements the application logic. The model changes its state
This paper describes an object-oriented smartphone based on instructions from the controller. When the model
application written in Android, which is effectively a subset of changes its state it informs the view which updates
Java. Android was chosen as it is an open source platform accordingly.
which runs on many devices including smartphones, tablets,
netbooks and smart televisions. Graphical user interface (GUI)
design on Android is relatively straightforward as the Android
API contains a multitude of classes that can easily be sub-
classed to allow for complex displays and user inputs.
II. DESIGN OF THE FE APPLICATION
In order to simplify the discussion that follows we will
initially consider a very simple finite element application that
only solves 2D truss problems. The code outlined here may
easily have additional classes defined which will allow the
analysis of different structural problems using different types
of finite element. The requirements for the application are
shown in table I.
60 | P a g e
www.ijacsa.thesai.org
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 5, No. 7, 2014
The TrussActivity class will take user input and create Effectively, the onCreate() method links us into the
objects from the classes contained in the com.example. Android API via android.app.Activity and provides us with a
simpletruss.model package and will call methods from View using setContentView() via android.view.View.
these classes in order to build and solve the finite element
The controller part of the MVC pattern will consist of the
model.
other methods contained in TrussActivity which are not
The classes within the com.example.simpletruss. inherited from the superclass. These are methods which are
model package are largely self-explanatory. The Node class is custom written for the FE application. These methods are
used to create Node objects and contains helper methods summarised in table II.
associated with the manipulation of Node objects. The
Truss2D class is a subclass of the LineElement class which TABLE II. CONTROLLER METHODS IN TRUSSACTIVITY
in turn is a subclass of the Element class. These classes are Method Description
used to create Element objects. The Assembly class is used to addNode() Creates a Node object using user input from
create an assembly of finite elements and contains methods to a dialog box
create a global stiffness matrix, global force vector and a global deleteNode() Deletes a Node object from the database
nodal displacement vector. The TrussSolver class contains using a dialog box
methods that can take these assembled global matrices and use addElement() Creates an Element object using a dialog
them to obtain a solution to a finite element problem. The box
TrussPost class contains methods that can further process the deleteElement() Deletes an Element object from the database
obtained solution to obtain derived results such as element addConstraint() Sets a constraint on a Node object using a
stress and strain. The FeConstants class contains a list of dialog box
symbolic constants that may be used by all other classes within deleteConstraint() Modifies a constraint on a Node object
the package. addForce() Sets a force on a Node object using a dialog
box for user input
deleteForce() Modifies a force on a Node object
calculate() Uses the database of Node and Element
objects to create an assembly of finite
elements, solves the global problem and then
creates a new View to display the results,
simultaneously saves the results to a text file
for sharing
Each of the methods described in Table II performs two
basic functions: instructing the view what view to provide (add
a node dialog, delete a force dialog, results screen etc.) and
processing user input from this view and using it to change the
state of the model (add a new node object, change the force on
Fig. 3. Schematic of the Packages and Classes in the Android Application a node object, etc.).
By resolving the MVC pattern shown in fig. 1 with the So, in summary, the com.example.simpletruss.model
schematic shown in fig. 2 it is clear that the package contains the Model, the onCreate() method in
com.example.simpletruss.model package will function exactly TrussActivity class and its associated XML files contain the
as the model is described in the MVC pattern. The View and the other methods in TrussActivity class define the
TrussActivity class provides a method of linking into the controller. This is illustrated in fig. 4
Android API by sub classing android.app.Activity. Each
Activity must implement the onCreate() method inherited from
the superclass. In its simplest form the onCreate() method will
be:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
}
The final line in the above code snippet calls the superclass
method setContentView() to set the View that will be
shown to the user when the application is started. This layout is
usually specified in an XML layout file named
main_layout.XML. This XML layout file may be edited to
display the buttons, text fields, checkboxes, images, etc. that
make up the applications GUI. Fig. 4. A MVC Implementation for the FE Smartphone Application
61 | P a g e
www.ijacsa.thesai.org
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 5, No. 7, 2014
62 | P a g e
www.ijacsa.thesai.org
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 5, No. 7, 2014
C. Assembly Class
The Assembly class essentially consists of five methods
which assemble the global problem equations. The global
stiffness matrix is assembled from the individual element
stiffness matrices and placed into a 2D array of double
precision numbers. Similarly the global force vector and global
displacement vector are assembled by interrogating each
element to find its constituent Node objects and their relevant
force and boundary condition data. Two further methods are
used to assemble global data which will be useful during post-
processing of results. An ArrayList of element strain-
displacement matrices and an ArrayList of element elastic-
modulii are produced by calling these methods. The Assembly
class is written in a non-element specific manner so that it may
be used with any element type, not just the truss elements
being considered here.
D. TrussSolverClass
The TrussSolver class contains one method named
Fig. 5. Graphical User Interface (GUI) for the Smartphone Application Pre-
calculateDisplacements() which returns the solved nodal Processor
displacement vector to the calling method or class. A direct
equation solver performs solution of the system equation using The screen layout is divided into a number of steps that the
symmetric LDU decomposition of the matrix. user is required to complete in order to successfully build a
E. TrussPost Class finite element model. The layout was constructed in this
manner in order to avoid user confusion and also, as one of the
The TrussPost class contains a number of methods for post- aims of the application was for it to be used as an educational
processing the results from a truss analysis. The strains() tool to teach FEA to new users. In the first step a drop down
method is used to return an array of doubles which effectively menu (known as a “Spinner” in Android) is used to capture the
gives the strain in each element in the finite element model. user’s preference in terms of unit system. The selected unit
Similarly, method stress() provides an array listing the axial system is used to prompt the user for input quantities during
stress in each element in the finite element model. Finally, the model generation and also during the display of results. The
method reactionForces() is used to return an array listing the user is offered three choices: no units (which is the default), the
reaction forces at each node in the finite element model. SI system (Kg-m-sec) or the Imperial system (lb-ft-sec). Step 2
F. A Note on the Model Classes requires the user to pick an element type: currently there are
three options available: 1DTruss, 2DTruss and Beam. The
Clearly, there are several possibilities available for class
class system for a 2D truss analysis was discussed in section
construction and interaction when using an objected-oriented
III. A 1D truss can be easily formed by simply setting the
approach. The above description attempts to take the four
appropriate coordinates and DOF to zero. A beam element was
principles of object-oriented design (Encapsulation,
implemented by adding additional classes to the structure
inheritance, polymorphism and abstraction) into account at all
discussed in section III and, for the sake of clarity, will not be
times. It could be argued that the Assembly, Solver and Post-
discussed here. Step 3 requires the user to specify nodal
Processor classes could be either combined into one class, or,
coordinates. Touching on either the add node or delete node
are not really classes at all and their methods should be
button opens a dialog box which allows the user to define the
combined into other classes (e.g. one of the element classes).
nodal coordinates. Similarly the add element, delete elements,
Alternatively, these methods could be placed in a class which
add constraint, delete constraint, add nodal force and delete
contains only a list of static methods and thus does not require
nodal force buttons all open appropriate dialog boxes for the
instantiation in order to call the methods. Both of these
user to interact with. The two lower buttons allow for the
strategies, however, would remove the flexibility of the
application of distributed loads if a beam element type has
software and make it more difficult to add additional element
been selected – if a truss element is selected then these buttons
types to the finite element application.
63 | P a g e
www.ijacsa.thesai.org
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 5, No. 7, 2014
will display a warning. Fig. 6 shows examples of the “Add Touching the “File” button allows the user to load or save a
Node” and “Add Element” dialogs. model and clear the database. The “Build” button brings up the
pre-processor screen shown in fig. 5. The “Display Model”
button is used to show a graphical representation of the model,
as shown in fig. 8. The “Examine” button is used for post-
processing the results from the finite element model. The other
buttons in fig. 7 are largely self-explanatory.
Each of the screens described above are created using XML
layout files which specify the relative position of the various
UI elements. These layouts are displayed by the corresponding
Android activity class when required. In some cases, such as
with dialogs, the display is created dynamically using only
Java code without the need for a XML layout to be defined in
advance. This is achieved using one of the many “builder”
classes provided with the Android API. The graphical display
of the model is also created dynamically by filling an empty
frame layout with a Canvas object when the user requests the
model be displayed.
Fig. 8 shows a typical graphical display from a 2D Truss
problem. In this case three nodes and two elements have been
used. Node numbers are displayed near the associated nodes.
Fig. 6. Dialog Boxes are Used to Capture User Input Constraint and load symbols are placed on relevant nodes,
using the helper methods described in section III. A facility for
During the XML definition of the buttons shown in fig. 5 a zooming in/out and an option to fit the finite element model to
method name in TrussActivity is required in order to link the the screen are provided in the lower right corner of the GUI.
button to that method. For example the “Add a Node” button
definition contains a reference to the addNode() method in
TrussActivity. When the button is touched/clicked then the
relevant method is called and the object reference of the View
calling the method is passed as a parameter to the method.
The full suite of Android’s user interface was utilised to
capture input from the user: including spinners, checkboxes,
radio-buttons, textboxes etc. Touching the application icon at
the top of the screen slides a menu out from the left hand side
which allows the user to navigate through the application, as
shown in fig. 7.
V. CONTROLLER
The TrussActivity class is the main activity for a truss
analysis. As mentioned above, the first task of TrussActivity is
to call the onCreate() method from its superclass. This method
is called when the application is started and is responsible for
Fig. 7. Smartphone FE Application Navigation Menu
providing the View for the Activity by linking to the
appropriate XML layout file.
64 | P a g e
www.ijacsa.thesai.org
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 5, No. 7, 2014
The main task of TrussActivity is to act as controller in the to listen for either the cancel or OK buttons in the dialog box to
MVC pattern and to take user input in order to use the Model be touched by the user. If the cancel button is touched then the
classes to construct a finite element model. Table VII shows a dialog is simply dismissed and control is returned to the calling
description of the TrussActivity class, focusing on the methods method. If the OK button is touched then data entered by the
dealing with control. A number of EditText object references user is checked for viability. If the data is not viable then a
are initially described as private class variables. EditText’s are message is displayed to the user explaining why this is the
editable text boxes that are used to obtain user input. In this case. If the data is viable then a new Node object is created
case they are required to capture nodal coordinates, element using the object constructor in the Node class. This Node
properties, etc. Two ArrayList objects are defined which object is then added to the nodes ArrayList and the numNodes
effectively act as the finite element model database. The nodes variable is incremented by 1 before returning control to the
ArrayList holds a list of currently defined Node objects and the calling method.
elements ArrayList holds a list of currently defined
LineElement objects. ArrayLists are effectively mutable arrays Some of the other methods require more checks before
and so allow for the addition and subtraction of objects from displaying a dialog requesting user input. The addElement()
the list as required. Two integer variables are defined in order method, for example, first checks that at least two Node objects
to conveniently hold the number of currently defined nodes and have been defined before allowing the user to proceed. In each
elements. case where a problem is encountered an explanatory message is
presented to the user.
TABLE VII. DESCRIPTION OF THE TRUSSACTIVITY CLASS
65 | P a g e
www.ijacsa.thesai.org
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 5, No. 7, 2014
then the printTrussResults() method is called and results are [3] T. Zimmermann, Y. Dubois-Pélerin and P. Bomme, Object-oriented
automatically post-processed and displayed to the user. Fig. 9 Finite Element Programming: I. Governing Principles, Computer
Methods in Applied Mechanics and Engineering, 1992, 98, No. 2, pp.
shows a typical display of results from a simple 2D truss 291-303.
analysis. [4] T. Zimmermann, Y. Dubois-Pélerin and P. Bomme, Object-oriented
Finite Element Programming: II. A Prototype Program in Smalltalk,
VI. CONCLUSION Computer Methods in Applied Mechanics and Engineering, 1992, 98,
The architecture of a demonstration finite element No.3, pp. 361-397.
analysis application for an Android smartphone has been [5] T. Zimmermann, Y. Dubois-Pélerin and P. Bomme, Object-oriented
Finite Element Programming: II. An Efficient Implementation in C++,
presented. The application has been designed according to Computer Methods in Applied Mechanics and Engineering, 1993, 108,
object-oriented principles using a MVC design pattern. No.1-2, pp. 165-183.
Smartphone user interfaces provide exciting opportunities to [6] P. Donescu & Tod. A Laursen, A Generalized Object-Oriented
revolutionise the generation and analysis of finite element Approach to Solving Ordinary and Partial Differential Equations Using
models. In this case the objective was to produce a functioning Finite Elements, Finite Elements in Analysis and Design, 1996, 22, pp.
finite element application which could also be used as an 93-107
educational tool to teach new users basic FEA principles. The [7] J. Besson & R. Foerch, Large Scale Object-oriented Finite Element
Android platform makes it relatively easy to design an intuitive Code Design, Computer Methods in Applied Mechanics and
Engineering, 1997, 142, pp. 165-187.
and educational user interface. The architecture provided here
[8] G.C. Archer, G. Fenves & C. Thewalt, A New Object-oriented Finite
can easily be expanded to include more complex elements and Element Analysis Program Architecture, Computers and Structures,
analysis capabilities. The demonstration application is 1999, 70, pp. 63-75
available for free download [12]. [9] B. Patzák & Z. Bittnar, Design of Object-oriented Finite Element Code,
Advances in Engineering Software, 2001, 32, 759-767
REFERENCES
[10] G.P.Nikishkov, Yu.G.Nikishkov and V.V.Savchenko, Comparison of C
[1] A. Smith, 46% of American Adults are now Smartphone Owners, Pew
And Java Performance In Finite Element Computations, Computers and
Internet, 2012 (http://pewinternet.org/Reports/2012/Smartphone-Update-
Structures, 2003, 81, pp. 2401-2408
2012.aspx)
[11] G.P.Nikishkov, Object oriented design of a finite element code in Java.
[2] N. Rajovic, P. Carpenter, I. Gelado, N. Puzovic and A. Ramirez, Are
Computer Modeling in Engineering and Sciences, 2006, 11, No. 2, pp.
Mobile Processors Ready for HPC?, edaWorkshop13, Dresden,
81-90
Germany, May 14-16, 2013.
[12] https://play.google.com/store/apps/details?id=ie.jion.fetab
66 | P a g e
www.ijacsa.thesai.org
View publication stats