I'm in the middle of huge refactoring, so I decided to take a break and do some water sim again. This time using the virtual pipes model, it turned out to be amazingly simple.
Don't have time for a fancy 3D viz, but still this might be the best shallow water sim I've made :)
@lisyarus nice! Do you have a good reference for the virtual pipes model? I did shallow water equations using the discrete exterior calculus in my masters thesis but was disappointed by the "flow feeling"
@artificialmind I'm using this paper: https://diglib.eg.org/bitstream/handle/10.2312/vriphys20181067/045-054.pdf (section 3.1 is the main stuff), without viscosity & without any multi-layer stuff, together with outflow scaling that they mention from this paper https://inria.hal.science/inria-00402079/document
@artificialmind Here's the whole update code. bed is NxN array of terrain elevation, water is NxN water column height (so bed + water is the height of water surface), flowx is (N+1)xN of horizontal pipes, and similarly flowy is Nx(N+1) for vertical pipes.
@lisyarus assigning to flowx / flowy functions weirded me out at first but they both return references I guess? I haven’t really seen that pattern before but I guess it’s better than raw array access (assuming inlined)
@sinbad Oh, that's my N-d array class with overloaded operator() (because multi-argument operator[] is only in C++23), and yep, it returns a reference!
@lisyarus ahh yeah - I quite like it