In FEM/FV codebases, I stumbled upon the fact that the discretized functionspaces are represented within the code as a tree structure. I find this very puzzling.
Example: lets say somebody wants to simulate the navier stokes equations. The codebase expects the discretized function spaces to be put into a data structure like:
So an hierarchical tree structure. I do not understand why that should be a reasonable choice because:
There is no intrinsic hierarchy of the fields. In the image, the pressure variables are listed at a higher level than the velocity components. But that is purely cosmetic display. There is no intrinsic hierarchy of the components influencing our coupled system. If there is no hierarchy, then a tree structure does not seem sensible to me.
Data locality. I have an option where I can tell the programm to align the data cell-wise or in lexicographic ordering. That is a nice feature, but it is, at it's heart, the age-old question of (array-of-structs vs. struct-of-arrays). This also does not explain to me why I should use a tree.
Limited Complexity. I have not come across any codebase or scenario, where the function spaces are so many, or so complex, that that would justify a non-trivial data structure. Even if you do full MHD simulations, you could easily fit your fields into (array-of-structs vs. struct-of-arrays). And it is questionable whether a tree structure would simplify or confuse your code.
What am I missing? Why would anybody use a tree structure for this? (Thanks in advance!)