3618 zyxwvutsrqponm IEEE TRANSACTIONS ON MAGNETICS, VOL. 30. NO. 5, SEPTEMBER 1994 zy An Object-Oriented Finite-Element Program for Electromagnetic Field Computation E. J. Silva, R. C. Mesquita, R. R. Saldanha and P. F. M. Palmeira Departamento de Engenharia ElCtrica zyxwvuts - Universidade Federal de Minas Gerais AV. do Contomo 842, Centro, Belo Horizonte, MG, 301 10, Brazil zyxwv Abstrud - The purpose of this paper zyxwvutsr is to illustrate how the concepts of object-oriented programming can be applied to the finite element method, and to illustrate the advantages of this approach. The basic concepts of the object-oriented programming method are also presented. A 3-D magnetostatic program that uses nodal elements and edge elements has been developed and implemented using the zyxwvutsrq C++ language. INTRODUCTION When it is necessary to change finite element programs to implement a new formulation, a lot of adaptations must be done. Even in well structured programs this task is not easily peIfOtTIled. Normally, it is necessary to change routines included in large libraries, adapt data structures, etc. Some changes done in some modules propagate through all the program involving rewriting thousands of lines of code. A new programming paradigm called object-oriented programming (OOP) has been developed to modify this situation. Its main purpose is to achieve portability, reusability, reliability and ease of maintenance of complex programs. This paper describes the basic concepts on which the object-oriented model is built. These concepts are applied to develop a 3D magnetostatic finite element program. The concept of the reusability is applied. Nowadays several programming languages support the object-oriented methodology, such as Smalltalk, that was the first object-oriented programming language, C++, Object Pascal and Eiffel. Each programming language is most adapted to an area of application. For the finite element analysis we choose the C++ language because it is an object- oriented extension of the C language that offers resources for numerical analysis. BASIC CONCEPTS OF OBJECT-ORIENTED PROGRAMMING The OOP has received a lot of attention in the last few years [1],[2],[3],[4]. It is based in the concepts of objects, classes, methods, inheritance and polymorphism. The concepts of class, object and method are presented in this section. Inheritance and polymorphism are presented in the next section that shows their importance in the finite element program based in the object-oriented paradigm. Objects are self-contained structures. They contain attributes (data) and procedures (methods). This union of data and methods which manipulate that data is called encapsulation. The objects communicate with each other by messages. When an object receives a message it interprets that message and executes an action based on its nature. A Class is a type defined by the programmer. Each object is an instance of class. It is characterized by its name, its attributes and the set of methods it implements. A graphical representation of a class is shown in Fig. 1 [5]. Class-&- Objects is an expression that means a class and the objects that belong to it, Fig. 1 (a). A class like the one in Fig. 1 @) represents a special kind of class called abstract class. The abstract class does not have objects. A class in C++ can be understood as an extension of the structure concept of the C language. This extension supports the use of member functions in classes. The layout of the structures in C and C++ is identical. So, such structures can be freely used in the Same program. The details of representation of data and methods can be hidden using classes in such a way that only members of class can have access to them. The keywords "private", "protected" and "public" do this control in C++. A class can have links with other classes, Fig. 2. This link is applied to represent the concept of the inheritance. In this case, the classes B and C are descendants of class A. Note that the lines link the internal rectangle (the class). Relationships between objects can also be shown graphically as in Fig. 3. The purpose of this link is to represent the fact that an object can be part of the other. For example, in the finite element method node is a part of element. Attributes Methods Attribute a Methods (h) Fig. 1. Graphical representation of Class-%-objects and Class. Manuscript received November 1, 1993. 0018-9464/94$4.00 Q 1994 IEEE Authorized licensed use limited to: UNIVERSIDADE FEDERAL DE MINAS GERAIS. Downloaded on August 19, 2009 at 11:41 from IEEE Xplore. Restrictions apply.