20.07.2015 Views

PhD Thesis - staffweb - University of Greenwich

PhD Thesis - staffweb - University of Greenwich

PhD Thesis - staffweb - University of Greenwich

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

APPENDIX 2 : Journal Paper "Case Study : An Incremental Approach to Re-Engineeringa Legacy FORTRAN C.F.D. Code in C++", Ewer J., Knight B. and Cowell D.,Advances in Engineering S<strong>of</strong>tware, Vol. 22, pp 153-168, 1995afforded by the original s<strong>of</strong>tware architecture. Previously the s<strong>of</strong>tware could only calculatefor all objects at once whereas it may be desirable (as in the case <strong>of</strong> mesh adaption andmesh refinement) to limit the calculation to selected objects.The identification <strong>of</strong> class methods from FORTRAN legacy code was quite straightforwardbecause numerical codes tend to be optimised for speed rather than for memoryusage. This means that developers introduce variables to hold values like face areas,volumes and normals rather than repetitively re-calculating them. This allows methods to beidentified in the initialisation stages <strong>of</strong> the s<strong>of</strong>tware where these values are first set. Thevariable storage was also kept for optimal performance. The initial development may notrequire the flexibility afforded by this approach but subsequent research is likely to benefit.Another area where methods were identified was in routin es that were "copymodified"versions <strong>of</strong> others. Some code fragments had the same algorithmic structure butused different variables. These were relatively simple to parameterise and abstract t<strong>of</strong>unction calls.Stage (9):Optimisation and enhancements.The initial class oriented C++ version used statically declared arrays <strong>of</strong> objects.Dynamically declared arrays were considered to be desirable and were easy to implement.This gives much greater code flexibility without the need to re-compile for largersimulations. It was also possible to implement arrays <strong>of</strong> pointers to objects so thatindividual objects could be created and destroyed as required. This could be very importantfor cell refinement where more cells are created during the running <strong>of</strong> the program.The debugging <strong>of</strong> CFD codes has traditionally been a problem. The initial reengineeredsystem used direct data access to cell objects but such access cannot be easilycontrolled or monitored. The approach finally adopted was to use access functions thatreturn references rather than data values. Such access functions can then be used on eitherside <strong>of</strong> assignment statements to set or get values. Figure 13 shows the implementation <strong>of</strong>the access function in C++. Since data access was implemented as a function, debug codecould be planted to monitor the usage <strong>of</strong> a chosen cell or variable. This is demonstrated bythe debug code to watch for negative temperatures. An optimised version <strong>of</strong> this accessfunction uses an inline definition so that it has no greater performance overhead than adirect array access.Appendix 11.2 Page 142-18 18

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!