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, 1995Enhanced debug facilities for code development via class methodsfloat & Cell_Class::access( int mode, int var ){#ifdef __DEBUG_CODE__if ( ( mode == NEWEST ) && ( var == TEMPERATURE ) ) {if ( data[mode][var] < 0.0 ){// Error negative temperature detected in cell data access}}#endif}return data[ mode ][ var ];Figure 13 :New data access function.The solvers available in CWNN were all based on whole matrix solving techniques.It was suggested, by a CFD researcher, that a true cell -by-cell solver should be developed.This has been implemented from some <strong>of</strong> the s<strong>of</strong>tware components produced during thisproject.The implementation <strong>of</strong> a vector class for normal and displacement vectors hasgreatly simplified the source code. The original FORTRAN code had to loop over all threedimensions for calculations whereas now, simple vector algebra can be performed. Operatoroverloading has been used to give the vector algebra a more natural syntax, as found in mostreference texts. Figure 14 shows the equivalent loops for calculating the cell centres fromthe legacy code and the re-engineered code, which uses vector methods. Such instanceswere relatively easy to find because the loop dimensions go from 1 to 3 (or 1 toDIMENSIONS). It was possible to abstract one and sometimes two levels <strong>of</strong> loopingbecause <strong>of</strong> the new operators and functions provided for vector algebra in the vector class.These functions included dot- and cross- product utilities.Original legacy code New C++ code using a vector classDO 1 I = 1, NOCELL int i, j;DO 2 J = 1, 3 for ( i=1; i

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

Saved successfully!

Ooh no, something went wrong!