I'm a novice in object-oriented programming, but this design technique seems very interesting for me. I have a Fortran 90 CFD package , not very complex, but it is already very hard to maintain and to add new physics or other features. As I learnt for now it can reduce complexity of program, but most important from my point of view - intrinsic object orientation of mathematical abstractions. Now I'm trying to draw some parallels between CFD mathematics and object-oriented concepts introduced in Fortran 2003 standard. CFD begins with introducing field abstraction. In most general case it is three-dimensional tensor field, which can be described as five-dimensional array tensor_field(:,:,:,:,:). That array stores nodal values of the tensor field. Similarly , scalar field scalar_field(:,:,:) and vector_field(:,:,:,:). For now everything is clear and straightforward. But when one starts to try to develop classes for this field types it becomes tricky. There are some questions that arise :
- If that arrays are parts of corresponding classes than how to implement grad and div operations ? In elegant mathematical way grad should be procedure in scalar_field class , that gives vector_field as its result. But similarly , div should be in vector_field class and should result scalar_field. How can be achieved such interactions between objects in object oriented paradigm ?
- From mathematical point of view tensor_field should be parent class to vector and scalar classes. But it seems a bit overwhelming to use only five-dimensional arrays. I thought about using scalar class as a parental, but it seems more like an element of vector class, not a parent.
To conclude, the main idea of my questions is : are there any object-oriented design pattens for CFD programming , that are wide acceptable and tested ? Maybe you can share here yours implementations in pseudo code, in Fortran or in C++ to discuss them ?
Best regards, Ivan Y.