PDE Solver
PDE Solver
PDE Solver
PDE Solvers
Krister Åhlander1
Department of Scientific Computing
Uppsala University
Uppsala, Sweden
krister@tdb.uu.se
1996 05 10
Abstract.
An object-oriented analysis and design is presented, for a framework in
which PDE solvers (programs that numerically solves partial
differential equations) may be composed from existing components.
The motivation for this work is that object-oriented technology is more
robust to changes than traditional techniques are. The PDE solving
system has been implemented in a one-dimensional pilot
implementation, which shows that the framework is expressive,
flexible and extendible. Through an interface to an object-oriented
database on top of the classes, it is shown that PDE solvers can be
constructed and changed interactively.
1. This work was supported by a grant from TFR, the Swedish Research Council for
Engineering Sciences.
2
Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
The Cogito Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Evolution of the Pilot Implementation . . . . . . . . . . . . . . . . 25
Example: Main Program . . . . . . . . . . . . . . . . . . . . . . . . . . 28
CogitoWorkBench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Is the System Robust? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3
4
1 Introduction
Time-dependent partial differential equations, PDE:s, model many important
processes in different fields of science and engineering. In order to solve
these equations on a computer, we need to develop a program that efficiently
performs the necessary calculations. In this report, we present an object-ori-
ented (OO) approach to the construction of PDE solvers. In particular, we
stress the program’s ability to adapt to changes, i.e. the ease with which the
program can be modified. All interesting programs will have to evolve, and it
is important that necessary modifications can be made easily. Because we re-
gard these aspects as essential, we have followed an object-oriented method-
ology1 in order to develop the design. Compared with traditional design
methodologies, OO methodologies yield programs that are easier to change.
The major result of this work is an OO analysis and design for a frame-
work where a PDE solver can easily be constructed in a flexible way. We
have put special effort into making the framework extendible, which means
that it is not limited to certain PDE problems or special numerical methods.
In order to demonstrate its usefulness we use this design to implement a
framework for PDE solvers which solve problems in one dimension (even if
the design is intended for more complex problems). A number of compo-
nents are included in the framework, such as different problems and different
solution methods, and we can within this pilot implementation very easily
construct and in particular modify a PDE solver, issues that are normally dif-
ficult when the program is constructed with traditional methodologies.
Furthermore, it is possible to equip the framework with an OO database,
which makes it possible to build and experiment with a PDE solver interac-
tively.
The conclusions are that the OO approach yields a flexible and extendible
system, in which it is possible to construct PDE solvers with little coding.
This system would be beneficial both to users who basically want nothing
but to solve a PDE by means of existing methods, and to users more interest-
ed in developing new numerical methods rapidly. We would also like to point
out that even if our design is intended for and implemented as a framework,
it is also relevant when a specific PDE solver (solving a specific problem
with a specific method) is to be constructed, since we would have the same
advantages with respect to future changes.
The layout of this report is as follows. Below, we present the Cogito
project, which this work is a part of. We also compare with related research.
In Chapter 2, we motivate our work by showing an example where the tradi-
tional approach fails to yield a program that is flexible. The most important
part of this report comes in Chapter 3, where the whole process of develop-
5
ing the OO PDE solving framework is sketched. The results are assembled in
Chapter 4. The process as well as the results are discussed in Chapter 5, and
Chapter 6 concludes the thesis.
6
There also exist many projects in computer science that have similar goals
as ours with regard to flexibility and extendibility, particularly with respect to
different parallel architectures. Some projects of this kind include Correlate
[15] and CYES+ [20]. Here, C++ is extended in order to address OO issues
on parallel architectures. In our project, we instead want to explore tools that
already exist, and therefore we choose to use a well-known methodology,
OMT [25], (during the project influenced by other techniques, mainly Booch
[5] and Jacobsson [14]) and we implement the resulting design in an already
existing language, C++, without new language constructs.
7
Moreover, we require that the system shall be easily extended. It is not
enough if we can solve a predefined set of problems with a predefined set of
numerical methods. A user shall be able to describe new problems, or new
solution methods, and add these to the system. This is particularly useful if,
for instance, the user develops a new numerical method and wants to com-
pare this method against other methods.
To summarize, we have several motivations why a PDE solver shall be de-
signed in such a way that it is easy to modify. We proceed with an examina-
tion on why this issue is difficult, when traditional programming
methodologies are used.
Strongly simplified, a typical PDE problem may be solved with the algo-
rithm below. (For readers unfamiliar with the subject of scientific computing,
we have summarized some concepts of PDE problems and how to solve them
numerically in Appendix A.)
Here, u(t) denotes the numerical solution at time t. Step 1) depends on the
chosen numerical method for approximating space derivatives. Step 2) de-
pends on the result from step 1) and the chosen numerical method for ap-
proximating time derivatives as well as the PDE problem coefficients (which
may be space, time, and solution dependent). Step 3) depends on the bounda-
ry conditions from the PDE problem, and from the numerical approximation
of them.
So far, the dependencies are quite simple, but the situation is in fact more
complicated. For instance, if we have periodical boundary conditions along
some dimension, this will influence not only step 3) but also step 1) and step
2). If we want to solve the problem more accurately, we can use a higher-or-
der method for approximating the space derivatives. This may influence the
algorithm for calculating the solution u at the boundaries.
The conclusion is therefore that programs whose design has focused on the
algorithm, as traditional design techniques does, tend to be difficult to modi-
fy.
8
somewhat more thourough discussion on OO is found in Appendix B, and
the OO methodology OMT is summarized in Appendix C.
The main difference between OO software construction and traditional
techniques is that an OO solution is centred around the important data of the
problem whereas traditional techniques focus on the algorithms. Meyer
points out that the top-down design used in traditional software construction
is very vulnerable, since the correct algorithm may be difficult to know be-
fore the data abstractions are known [19].
Since software is inherently complex, we need to decompose the system in
a comprehensible way. According to Booch, OO decomposition fills this de-
mand better than traditional algorithmic approaches, and it also enhances
code reuse [5]. Other benefits of OO software construction is summarized in
[31] and include higher quality, easier maintenance, better information struc-
tures and better adaptability.
Then, what is OO software? The most important concept is the object,
which represents a relevant data abstraction either from the real world or
from the implementation domain. The conceptual similarity between objects
in the software model and real-world objects is a key to explain the success
of OO software construction. This is enhanced by program constructs which
model relationships between objects, for instance that one object is an aggre-
gate of several other objects.
An object has three features: behaviour, data and identity. Encapsulation
of data and behaviour promotes reuse. Objects that share the same behavior
are grouped together in the same class. In other words, an object is an in-
stance of a class.
The aspect of object-orientation which gives it its special flavour is inherit-
ance. This mechanism also resembles a real-world abstraction, namely when
we say that there are different kinds of some entity. With inheritance, we can
derive classes (inheritors) from other classes (ancestors) so that objects of de-
rived classes have the behaviour specified in the derived class and the ances-
tor class. Therefore, inheritance supports code reuse, but even more
important is that inheritance can be used to build models that are conceptual-
ly clear.
Objects, classes, aggregates and inheritance are thus some important fea-
tures of object-orientation. In order to use the full strength of object-orienta-
tion, many authors claim that it is not enough to use an OO programming
language, but it is equally or even more important to use an OO methodology
[31]. A methodology consists of a notation and a process to carry out the
software development from the specification to the implementation. (Booch
adds tools to be included in the definition of a methodology.)
Several methodologies have been suggested, and among the more well-
known are OMT [25] by Rumbaugh et. al., Booch [5] and Objectory/OOSE
[14] by Jacobsson et. al. This project started off with the intention to follow
9
OMT, which is described in more detail in Appendix C, but it has been influ-
enced from other methodologies too. In fact, the differences between the
models are minor, and the three key authors now work together on the Uni-
fied Method [6].
3.1 Requirements
Even if the requirements have been discussed earlier, we state them explicitly
in this section. The overall goal of the software project is to supply a soft-
ware system with the following features:
• It shall be easy to construct a program that solves PDE:s numerically.
• The system shall be flexible. Components shall be changeable.
• It shall be easy to extend the system with new components.
Furthermore, we expect the system to fit within the general framework of
Cogito. This implies that we do not need to concentrate on issues from the
other Cogito layers, such as concurrency.
10
The PDE Problem class is shown in Figure 1, where classes that represent
the initial condition and the boundary conditions also are shown. (The nota-
tion is explained in Appendix C.) We also have an association to the Grid,
representing the domain. We could have included the Grid as a part of the
PDE Problem aggregate, but we chose not to do so, emphasizing that the
Grid belongs to a lower level of abstraction. (Introducing a class represent-
ing the domain on the same level of abstraction was discarded, because it is
difficult to represent complex geometries otherwise than through a corre-
sponding Grid.)
Grid
11
Applying boundary conditions is a task in a PDE solver that is very prone
to changes, and the class BC Handler will encapsulate this process. In Fig-
ure 2, the Space Handler aggregate is shown.
Concrete
Time ...
Discretization
3.3 Scenarios
Having found some immediate key classes from the problem domain, we
look through some scenarios in order to find more classes and to validate the
object model. We consider the following scenarios (compare with [34]):
1. Solve a predefined problem with a predefined method
2. Change the boundary conditions for a given problem and then solve it
3. Solve a new kind of problem with a predefined method
(Solving a predefined problem with a new method is completely analogous
to the third scenario. Therefore, we do not discuss it here.)
12
3.3.1 Solve a predefined problem with a predefined method
The first scenario shows the interplay between the components of the sys-
tem. In order to solve a specific problem with a specific method we basically
follow the algorithm sketched in Section 2.1, but the important difference is
the separation of concerns between different parts of the process. Here, we
examine one iteration of the loop.
1. The Time Handler orders the Space Handler to calculate the right hand
side of the equation ut = right-hand-side .
2. The Space Handler accomplishes this task by delegating it to the Space
Discretization objects. They, in turn, need to cooperate with the specific
PDE Problem we are about to solve.
3. The Time Handler calculates the Grid Function on the next level, with
the aid of its Time Discretization objects.
4. Finally, the Time Handler calls the Space Handler for applying the
boundary conditions. This is carried out by the BC Handlers in coopera-
tion with the BC Descriptions.
13
Numerical
Experiment
14
3.3.2 Change the boundary conditions for a given problem
The second scenario concentrates on how to set up a particular Numerical
Experiment and the difficulties with changing the boundary conditions. We
want to be able to do as follows:
1. Choose an existing PDE Problem
2. Switch BC Descriptions
3. Add to a Numerical Experiment the PDE Problem, a Space Handler, a
Time Handler, and a Grid
4. Solve the Numerical Experiment
15
BC BC
a) Description b) Handler
To see what steps that are needed in order to realize this scenario, we have
to detail the previous model especially with respect to the interplay between
the PDE Problem and the Space Discretization.
As we already have pointed out, a new problem will be a heir to either a
Conservative Problem or a Non Conservative Problem.
By the definition in Section Appendix A, a conservative problem is ex-
pressed by the equation ut = f ( u ) x . Therefore, concrete conservative prob-
lems need to specify the flux, f ( u ) . Detailing the signature of the operation,
we find that it shall take as inparameters a Grid Function and the region of
the Grid where the flux is to be calculated. This operation will be called
upon by Conservative Space Discretization objects, who then have the re-
quired information for calculating the right hand side of the equation in their
respective parts of the Grid. To summarize, a new conservative PDE prob-
1. The difference between this use case and traditional ones is that the user extends
the run-time system by implementing a small amount of code and then compiles
it. However, with a more advanced interface the interface could generate and
compile code, making this a traditional use case. See “Conclusions and Future
Research” on page 36.
16
lem is constructed by deriving from the class Conservative PDE Problem
and implementing the pure virtual operation flux().
A Non Conservative Problem is somewhat more complicated since the
number of terms may vary:
u t = F + A 0 u + A 1 u x + ...
The order of a differential equation corresponds to the term with the high-
est derivative. We recognize this as an important attribute of Non Conserva-
tive Problems. For our purposes, we have found that the following
operations manage to represent an n:th order non conservative PDE:
Non Conservative Problem::addForce(u, region)
Add the force F to the Grid Function u in the specified region.
Non Conservative Problem::addTerm(N,u,v,region)
Add the N:th term of the PDE to the Grid Function u. The argu-
ment v symbolizes the N:th derivative of u.
Thus, a new non conservative problem would inherit from the class Non
Conservative Problem, and the operation addTerm would have to be imple-
mented. (The operation addForce is not abstract, it adds by default no force.)
A Non Conservative Space Discretization would subsequently approxi-
mate the needed derivatives and then call for the adding of the appropriate
term.
Summing up the third scenario, we find that it is fairly easy to construct a
new problem. After successful compilation of the new code, we add proper
initial conditions and boundary conditions to the problem and then we pro-
ceed as before by connecting objects with the aid of a Numerical Experi-
ment. Our analysis of the scenario also shows how the cooperation between
Space Discretizations and PDE Problems may be done.
17
3.4.1 The Numerical Method class
It is possible to introduce a class which is responsible for the complete nu-
merical method, both the approximation of space derivatives and time deriv-
atives. Since some numerical methods treat both approximations
simultaneously, this class would provide means for including these types of
numerical methods, too. See Figure 6
Numerical
Experiment
new 1
v = --- ( v j + 1 + v j – 1 ) + kaD 0 v
2
18
This algorithm may be accomplished by an ordinary Space Discretization
that calculates the right-hand-side aD0 v , together with a Time Discretization
that calculates the time derivative according to the formulae above.
By combining objects with the desired behaviour it is thus easy to con-
struct a Numerical Experiment which solves a first order PDE with the
Lax-Friedrichs scheme. Even though we do not explicitly have a Numerical
Method object for Lax Friedrichs scheme, we can create a Numerical Ex-
periment that uses the scheme. Furthermore, if the objects are stored in an
OO database we can easily reuse this scheme on other problems. Hence, the
second reason for discarding a special Numerical Method class is that the
functionality it provides can already be found in the system.
19
the equations? The advantages would be a coherent way of treating conserv-
ative as well as non-conservative governing equations.
We believe that even if this approach is tempting because the idea is rather
elegant, it would lead to object models that are more difficult to understand
and maintain. Moreover, we are afraid to loose some of the information that
the inheritance hierarchies provide. A conservative problem, for instance, ex-
press the fact that the problem has the physical property that something is
conserved. This information is useful to the user who shall choose a proper
numerical method to solve the problem.
The bottom line is that in order to keep the system easier and to keep the
existing information structures, we do not attempt to handle equations in a
completely general way. Also, we believe that the previously presented mod-
el can more easily be made efficient. Finally, the chosen subclasses of PDE
Problem, Conservative Problem and Non Conservative Problem, cover a
broad spectrum of relevant application problems.
20
and when efficiency issues are considered, C++ seems to be the most promis-
ing alternative.
The organization of the system into subsystems is shown in Figure 8. We
have already touched upon the organization of Cogito (Section 1.1). The
three layers Cogito/Solver, Cogito/Grid, and Cogito/Parallel, form a closed
architecture, which means that each layer is only allowed to use operations
from the layer immediately below. The advantage with a closed architecture
is that maintenance becomes easier; since one layer’s interface affects only
the next layer. In an open architecture, each layer can use features from any
lower layer. This enhances efficiency, and we therefore use an open architec-
ture within the Cogito/Solver layer. In particular, Grid and Grid Function
objects are usable from within any layer. Also, for some applications it may
be desirable to bypass the Numerical Experiment layer. But even if we, due
to efficiency reasons, choose an open architecture, we strive to keep depend-
encies as local as possible. As an example, we do not want the Time Han-
dler to be dependent on the PDE Problem.
Numerical Experiment
Figure 8. The organization of the system into layers. Within Cogito/Solver the sub-
layers form an open architecture, indicated by the dotted lines. The layers Cogito/Solv-
er and Cogito/Grid have a closed architecture.
Concurrency aspects are not discussed in this report. We think that a data-
parallel approach to concurrency is possible, simply by using a Grid Func-
tion class that may be serial or parallel. As mentioned, such a class exists in
Cogito/Grid.
Data storage is always important for a PDE solver, especially regarding
Grids and Grid Functions, since they are likely candidates for pre- or post-
processing. For this project, it is more interesting to study the novel aspects
of storing the states (including links) of the other objects, since we want to
reuse not only individual objects but rather several objects in an interesting
21
combination. To this end, an OO database management system is appropri-
ate. See Section 4.3
22
Thus, we equip each Space Discretization with an active region where it
is allowed to act in order to calculate the right-hand-side needed by the Time
Handler. Similarly, each Boundary Handler has an active point.
When the Numerical Experiment is set up, the PDE Problem and the
Space Handler have to cooperate in order to set the active regions of the par-
ticipating objects properly. It is possible to construct automatic algorithms
for this, but for more complicated situations, we allow the user to decide in-
teraction regions.
Note that a Non Conservative Space Discretization that solves a second
order PDE Problem is responsible for treating both the first-order derivative
and the second-order derivative in the same region.
For the Time Handling and the Time Discretization objects, the situation
is similar.
The Numerical Experiment starts in the state Not connected. The transi-
tion from the state Not connected to the state Connected occurs when enough
parts have been added, that is a PDE Problem, a Space Handler, and a
Time Handler. Further, the Space Handler must be appropriate for the
problem at hand. For example, if it is a second order Non Conservative PDE
Problem, the Space Handler must have a Space Discretization able to han-
dle problems of that kind.
Subsequent changes of the Numerical Experiment’s components may or
may not change the state to Not connected.
23
Calling the Numerical Experiment’s solve method is only allowed when
the state is Connected.
Identical state diagrams may be derived for the other key classes, for in-
stance the PDE Problem, as shown in Figure 10 The initial state is Not con-
nected, and the transition occurs when the Numerical Experiment which
the PDE Problem is a part of changes state.
This model will only work, though, if a PDE Problem object belongs to
only one Numerical Experiment at a time. Since the object model does not
impose such restrictions, and since we do not find any new information in the
PDE Problem state diagram beyond what we already have in the Numerical
Experiment state diagram, we do not push the components’ dynamic behav-
iour further. Instead we rely on the Numerical Experiment to ensure the
correct usage of the other components.
4 Results
Besides the OO analysis and design presented in the previous chapter, which
we think is a result in itself, we will in this chapter focus on some results ob-
tained through the pilot implementation.
In Section 4.1, we describe the evolution of the pilot implementation. The
purpose is to validate the design.
In Section 4.2, we demonstrate how a main program creates and combines
classes into a system which is able to solve the chosen problem.
In Section 4.3 we show that by equipping the classes we discuss in this re-
port with an OO database management system, we get a tool with which we
interactively may construct PDE solvers, and also remember the links be-
tween executions.
Finally, in Section 4.4, we show an example of the system’s robustness.
We consider a kind of method which was not considered in the original de-
24
sign, and propose a solution which does not affect the overall design. This in-
dicates that the model is sound.
Number
Order of
Problem Type of Type of BC
derivatives
unknowns
25
Table 1: Implemented problems and their characteristics
Number
Order of
Problem Type of Type of BC
derivatives
unknowns
The last problem’s equations are given below. They resemble the equations
for shallow water.
u t + uu x + v x + 5 u u = – sin ( x – t ) cos ( x – t )
26
We also need to develop a Conservative Space Discretization. A numerical
method for conservative problems that may be used is an upwind method,
implemented in the class Upwind.
Remark: For the problems at hand, it is enough to treat one derivative at
the boundaries and two in the interior. It would not be difficult to extend the
system with Space Discretizations that treat derivatives of higher order. Nei-
ther would it be difficult to implement more accurate, high-order, stencils,
nor conservative methods that have better properties.
As with the Space Discretizations, we can easily add more time stepping
methods to the system. For explicit methods, this is straightforward. Implicit
methods also fit into the framework, but rely on more expressive tools on
lower layers.
27
since Conservative and Non Conservative PDE Problems have different
interfaces, we have to do some trick in order to be able to actually compile
the code. (Remember that C++ is a strongly typed language.) The following
solutions may be considered:
1. Find out the actual type and perform a dynamic cast. We can find out
which type it is by introducing an attribute which is different for different
subtypes. (The latest C++ standard specifies run-time type checking, but it
is not yet available.)
2. Find out which type it is in the same way, but by moving the interface of
the subtypes to the PDE Problem class itself, there is no need for
dynamic casts.
int main()
{
// The main objects.
NumExp myExp;
// Prepare problem
// "ShallowWater_*" is functions declared in "user.h", used to
// initate initial conditions and boundary conditions.
1. Note that this simple Grid is only used in the pilot implementation, but the design
is intended for more complicated grids such as composite grids.
28
FcnInitCond ic( ShallowWater_IC);
BCDirichlet bcleft(left,1,ShallowWater_BC); //Same BC function
BCDirichlet bcright(right,1,ShallowWater_BC);//at both boundaries
problem->use( &ic);
problem->add( &bcleft);
problem->add( &bcright);
theSH.add( interiorSD );
theSH.add( boundarySD1 );
theSH.add( boundarySD2 );
theSH.add( bchd );
theSH.add( bchn );
return 1;
}
29
instead, we would solve a different problem!
It is as easy to change the numerical method.
4.3 CogitoWorkBench
In the previous section, we noticed that the main program consisted of three
parts, the creation phase, the composition phase, and the solving phase. It is
not completely satisfying if we want to make small changes to the program
and then have to recompile it every time. Moreover, a specific PDE problem
consists of other components as well, and what we would like is to compose
a specific problem once and for all, and then be able to reuse the problem ag-
gregate over and over again.
The solution is to equip the classes with an ODBMS (object-oriented data-
base management system). In an ODBMS, the whole state of an object, in-
cluding links, can be stored between executions of the system.
The resulting system called Cogito WorkBench (CWB) was implemented
by Strandberg [30]. It uses TPS (Texas Persistent Store) [29] to obtain per-
sistency, and has a menu-driven interface to interact with the Cogito/Solver
classes.
With this system, the complete main program from the previous section
may be created in run-time, just by choosing menu alternatives.
With CWB, it is possible to create new objects of the classes from the
Cogito/Solver layer, and then they may be combined interactively. Finally, a
Numerical Experiment object can get the task to solve its problem.
ut = u x
30
may numerically be solved with
v t = ( D + εD 2 )v
31
(Time Discreti- (Space Handler)
zation with
Dissipation)
(Space
(Space Discretization)
Handler)
(Dissipation
Discretization)
Figure 11. A Time Discretization with Dissipation uses two Space Handlers, one with
Dissipation Discretization (which is a concrete heir to Space Discretization)
5 Discussion
When software is constructed, there is always a trade-off between different
desirable but often incompatible goals. Jacobsson [14] divides quality as-
pects into two main categories: suitability and maintainability. The suitabili-
ty category includes for instance reliability and efficiency, while the
maintainability category includes understandability and modifiability. In
general, OO methods concentrate first on the latter category. As we have
pointed out, (Section 3.1), this is the case also for this project. We believe
that this is more sound, because it should be easier to make a maintainable
program suitable than the other way around.
32
However, generally it seems as if there is a price you have to pay when you
raise the abstraction level of the program. The abstraction penalty is intro-
duced in [24] and defined as:
33
early decided not to put too much effort into this class, since it was devel-
oped only for the pilot implementation in one dimension. When changing
implementation to a multi-dimensional grid function class, much more
care shall be taken to make this class efficient. A parallel grid function
class as found in Cogito/Grid would be able to use parallel high perform-
ance computers, which would increase performance. The implementation
can be made more efficient also in other ways, for instance by using
counted references as described in [8] and implemented in Overture.
• The Space Discretization and the PDE Problem communicate too much
The process of calculating the right hand side of the equation is the most
time critical part of the program. When we take this into account, it can be
concluded that the number of messages between the Space Discretization
and the PDE Problem should be minimized. The algorithm presented in
Section 3.3.3 addresses the flexibility issue, but not the issue of minimiz-
ing the number of calls. However, by precalculating all necessary deriva-
tives at once, we can decrease the number of calls. (In Overture, a similar
technique has been implemented.)
• Dynamic binding takes time
In [5], it is said that experiments suggest that calls to virtual functions
may take as long as 2.5 times longer than procedural calls. If this is done
in a very time critical part of the algorithm, it may affect the performance
negatively, but if the routine itself has not too low granularity or is not
called too many times, it does not matter that much. Further, we believe
that the price of dynamic binding is rather cheap and it is a price that one
has to pay, if the flexibility and extendibility issues are concerns.
34
small. Moreover, once a class has been successfully implemented, it can be
reused.
With an OO database on top of the classes, reuse can be enhanced, as dem-
onstrated in Section 4.3 We believe that this approach is very promising.
Still, even if we claim that the system in general is expressive, we realize
that there exist several ways to improve the system, also with respect to ex-
pressiveness. Once again, the Grid Function class could be better. For in-
stance, the add-method needs parameters for knowing which part of the grid
function it shall be applied on. This signature should be simplified, by repre-
senting the part of the grid function by some utility class. Further, it could be
possible to define an active part of the Grid Function, where all subsequent
calls would be applied. This solution would make it possible to use operator
overloading for arithmetic functions, which significantly would raise the ab-
straction level. This problem is addressed also in Cogito/Grid and Overture,
and the solutions are similar.
Finally then, what are the lessons learned? Regarding the process and the
methodology, we can draw at least one conclusion. The usage of proper tools
can not be underestimated. As mentioned in Section 2.2, Booch explicitly
states that tools are a part of the methodology, as important as the notation
and the process. Tools that would have been beneficial to our work are of
course CASE-tools such as Rose [37], so that diagrams and implementation
always can be kept up to date. But other tools that one should use more ex-
tensively are what Jacobsson calls components, classes that are developed
specially for reuse, such as lists etc. In the specific subfield of scientific com-
puting addressed by this work, a Grid Function is a strong candidate for be-
ing a component, since it represents such an important application concept.
This is recognized both in Cogito/Grid and Overture, and the success of ob-
ject-orientation for this and other fields will depend heavily on the proper de-
velopment and usage of components.
Another lesson is regarding the design of the interface of Cogito Work-
Bench. The menus are mirroring the key classes and their inheritance hierar-
chies. This is one way of easily find different classes. However, the
aggregationship relations could be used to find which objects a typical Nu-
merical Experiment consists of, and we believe that for an interface such as
this, both the inheritance hierarchy and the aggregation hierarchy should be
supported in order to get a more user-friendly system. This reflects the differ-
ence between the compile-time structure of the program and its run-time
structure.
The discussion so far has motivated the need for human efficiency, which
implies that it is sound to focus on expressibility before computer efficiency.
OO methodologies have this philosophy, and that is why we use an OO ap-
proach in our work. The results of this work are encouraging, even if we have
pointed on several weaknesses in our pilot implementation, actually both
35
with respect to efficiency and expressibility. Still, we claim that the proposed
object model is sound. Making computer programs is more than only writing
code. We think that the analysis and design which lies behind the implemen-
tation are the most important contributions of this work, especially because
of the novelty of the approach.
36
Today, it is possible via menus in Cogito WorkBench to interactively cre-
ate and compose objects into an executable PDE solver. The vision for to-
morrow is a graphical user interface (GUI) on top of classes that may be
executed in parallel. Furthermore, the GUI shall be capable not only of creat-
ing and composing objects, but also of creating new subclasses.
Acknowledgments
Michael Thuné, for invaluable guidance. Jarmo Rantakokko and Peter Ols-
son, for valuable support, and Lotta Olsson for appreciated contributions. I
thank you, and all other friends that continue to motivate me. Especially Åsa.
37
References
[1] K. Åhlander, Objects for easy construction and modification of PDE
solvers, presented at POOMA’96, Santa Fe, New Mexico, February
28 - March 1, 1996.
[2] J. Ambrosiano et. al., Data archetypes for the fusion of parallel simu-
lation codes in climate modeling and other applications, presented at
POOMA’96, Santa Fe, New Mexico, February 28 - March 1, 1996.
[9] L. Curfman McInnes et. al., PETSc: Meeting the challenge of large-
scale applications, presented at POOMA’96, Santa Fe, New Mexico,
February 28 - March 1, 1996.
38
difference methods, John Wiley & Sons, New York, 1995.
[24]A. D. Robison, The abstraction penalty for small objects in C++, pre-
sented at POOMA’96, Santa Fe, New Mexico, February 28 - March 1,
39
1996.
40
Dr. Dobb’s Journal.
41
Appendix A Brief Introduction to Scientific Computing
The intention of this appendix is to survey the application domain. Since the
report is interdisciplinary, some readers may be unfamiliar with scientific
computing. Therefore, we will very briefly explain some concepts that a nu-
merical analyst deals with in order to construct numerical software that
solves a PDE. We will touch upon PDE:s stated on conservative or non-con-
servative form, grids, composite grids, space derivative approximation by fi-
nite differences and time derivative approximation by explicit or implicit
methods. More details can be found in any textbook of scientific computing,
for instance [11].
42
A PDE in non-conservative form has the following general form:
u t = F + A 0 u + A 1 u x + ...
43
Grids and grid functions are closely related, and they are important con-
cepts of the application domain.
44
stable solutions, very small time steps need to be used. Implicit methods on
the other hand express the solution on the new time level as depending on it-
self as well as on previous time levels. This leads to a linear system of equa-
tions, which has to be solved in each step. Thus more work is required in
each step, but on the other hand longer time steps are allowed. (This far, the
Cogito group has concentrated on explicit methods, but research on tools for
implicit methods has been initiated.)
45
Appendix B Brief Introduction to Objects
Since this report is interdisciplinary, we devote this Appendix to a brief intro-
duction on objects and OO methodologies, which some readers might be un-
familiar with. For a more thorough explanation of the subject we refer to any
book on object-orientation, for instance [5,14,25,31].
46
on their class. For instance, in our aeroplane model we can assume that all
planes share the behaviour to reflect RADAR waves. We introduce an opera-
tion reflect that captures this abstraction. But for a so-called Stealth plane,
the reflection is negligible, and for this subclass we reimplement the opera-
tion yielding no reflection. In our model, we can visualize that the control
tower invokes the operation reflect for all aeroplanes in the air, but due to
polymorphism different methods will be called depending on the actual class
the planes belong to.
47
Appendix C Brief Summary of OMT
OMT, object-modelling technique, is described in [25]. (The second genera-
tion OMT is described in [26,27,28].) In this Appendix, we give a quick in-
troduction to the models that constitute the methodology and the process for
yielding the models (Section C.1). In Section C.2, we summarize the nota-
tion used in this report.
48
vantage because it does not introduce a semantic gap [16]. The difference be-
tween analysis and design is, according to Rumbaugh, basically which point
of view you take. In the analysis, you seek for classes that correctly abstract
the problem domain, the real world. In the design, on the other hand, you
study the system from the implementation perspective, and add for instance
classes that implement data structures such as lists.
OMT specifies two phases of design. The first phase, system design, re-
sembles the traditional system design stage, where you take into account the
physical aspects of how the software shall be split, concurrency issues, which
type of control to use (parallel, event driven or procedure driven), persistency
aspects etc.
In the second phase, the object design, you further refine the three models
that the analysis yielded. Implementation classes are added, associations are
detailed, operation interfaces are prescribed. The final product shall be a re-
fined object model, dynamic model and functional model, with emphasise on
how the object model is detailed to be consistent with the other models.
C.2 Notation
Below, we present a short summary of the notation used in this report. For
the purposes of this report, we have only used basic concepts from the object
model and the dynamic model. even if we during the process have used more
details.
Figure 13 shows the object diagram notation. The edge of the triangle
points at the (possibly) abstract ancestor A, which the concrete descendant B
inherits from. The ellipsis notation indicates that more subclasses may be
added. Further, C is an aggregate, which has several objects of class A. (In
OMT, the correct symbol for many is a solid ball. To simplify, and to avoid
confusing readers familiar with Booch notation, we use the letter n to illus-
trate many.) Finally, a relation is shown between C and D.
A C
n
B
...
Figure 13. Object diagram constructs
49
An instance diagram shows relations between objects, which sometimes il-
lustrate something more clearly. In Figure 14, an instance of class C has a
link to an instance of class D.
(C) (D)
A state diagram is shown in Figure 15 In this report , we have only used the
simplest constructs illustrating initial state (solid ball), states (ellipses) and
events.
50