In lecture there was a lot of emphasis placed on how this datastructure can get tricky when it comes to indexing. I assume a solution to this would just to have a normal grid and then store a stuct inside each entry that has all the values, that way there is no problem with indexing. Is there a reason we don't do this? I assume it might be a bit slower given the extra structures, but is it so much slower that it really wouldn't be worth it?
alvin-xu-5745
The reason we do not store the fluid state throughout the grid is not necessarily because of an "indexing" issue, but more that in our aim of trying to calculate gradients and other "difference" quantities it is better to use this "staggered" approach in order to not run into strange checkerboard "decoupled" calculations that result from just directly storing the value of these quantities in the middle of our cells.
In lecture there was a lot of emphasis placed on how this datastructure can get tricky when it comes to indexing. I assume a solution to this would just to have a normal grid and then store a stuct inside each entry that has all the values, that way there is no problem with indexing. Is there a reason we don't do this? I assume it might be a bit slower given the extra structures, but is it so much slower that it really wouldn't be worth it?
The reason we do not store the fluid state throughout the grid is not necessarily because of an "indexing" issue, but more that in our aim of trying to calculate gradients and other "difference" quantities it is better to use this "staggered" approach in order to not run into strange checkerboard "decoupled" calculations that result from just directly storing the value of these quantities in the middle of our cells.