The ugly NaN bug
I’m building a fluid solver based off of one that Sean Flynn coded for aspiring CG devs. Eventually I’ll make my own from scratch but I don’t think it’s the best use of my time right now.
The idea is that we’re supposed to fill in the pressure solve ourselves, as an exercise. I did that based off of the given formulas…
…and I get -NaNs ALL OVER my pressure vector. It’s filled with them. This, in turn, screws up my position vector. As a result, my particles vanish into space after the first frame or two.
I’ve been stuck on this since Saturday, go me.
Tomorrow morning, I will try the following patch: Iterate through the pressure vector and manually replace all -NaN values with some other number. See if the program runs and completes properly, and if the elimination of pressure NaNs also eliminates POSITION NaNs. If it does, then we’ll have to work backwards from there. If it doesn’t, I’m phoning in for assistance. I cannot make any conclusions beyond that until this is fixed.
I still don’t know where the NaNs are coming from. I thought it was the B vector, but eliminating weird values from that vector doesn’t fix the problem.
The problem is that one step BEFORE that includes a function from the Eigen library which is a complete black box to me. The documentation for it is not good. Also, the pressure vector seems to affect the timestep??? Or at least B does.
This is how you get fat in undergrad. You think “I’ll fix this RIGHT NOW” and then you get sucked back into it and then you stay up so late that you miss the gym. Well, I won’t do that anymore. I’m later than I should be, but my schedule can still be saved. I lost my 8h sleep but I will get 7.5. Or 7.25 at least.
I’m sure this will be an amusing experience I reflect back on when chilling on my hammock in May. Right now though it is really annoying.
Anyway, gonna try not to die. Ugh.
Comments
Post a Comment