Hello,
I am developing a Finite Element System. As usual, the simulation consists of set of mesh nodes, each with a set of properties (floating-points), like for example several material properties, coordinates or physical quantities that evolve within time.
You can either employ two extreme approaches:
Property-wise: Maintain a single array for each property:
double* x, *y, *z, *e_field, *b_field, *conductivity;
Entry-wise: Maintain one single array, where each array is struct
struct { double x, y, z, e_field, b_field, conductivity; } *meshnodedata;
Between these, one could mix, like applying the second approach only for the coordinates x, y, z, and using the first approach for the remaining properties. The more properties your simulation maintains for each mesh node, the possibilities to mix.
On the one hand, I have got the classical question which of these approaches (and their mixes) is best for scientific computing with regards to performance of the program and maintainability of the code. On the other hand, I wonder how to implement code in such a way that migration between different approaches becomes easy. Furthermore, it might even be a solution to migrate between different memory layouts for different parts of the program.
To come to the point:
- What have been your experiences whit these different approaches?
- How significant have these differences been?
- Have you gained experience in migrating between these two layouts?