My research project involves an alternate way of calculating the pressure field in a fluid simulation. I chose Houdini as a platform for conducting my experiments because I knew it was highly customizable and programmable, but came to realize that the Gas Project Non Divergent node is a bit monolithic, not as modular as I had hoped.
The node seems to calculate the pressure field AND tweak the velocity field to make it divergent free. I'd rather not waste effort on something that will take me many, many hours to figure out, so I thought I'd ask here:
Does anyone know of an open source re-implementation of the node so that I can inject my new pressure calculation method into it? (It doesn't have to be fancy, just work well enough to be acceptable) Or, if not, would anyone be confident in answering some HDK questions? My professor had some code he hacked together back in Houdini 12 but when I checked the documentation, it seems like most the methods or parameters have changed. (I'm on 15.5)
Thanks for reading, hope someone can help.
Alternate implementation of "Gas Project Non Divergent" node
5278 7 1- Javid Pack2
- Member
- 5 posts
- Joined: 6月 2014
- Offline
- Enivob
- Member
- 2629 posts
- Joined: 6月 2008
- Offline
- rgoldade
- Member
- 73 posts
- Joined: 9月 2014
- Offline
- Javid Pack2
- Member
- 5 posts
- Joined: 6月 2014
- Offline
EnivobThanks, that video had great visuals but ultimately doesn't help me.
You may find some information in this video on constructing a solver from scratch.
rgoldadeMy project will further explore the possibilities of data-driven/machine-learned fluid simulations most recently explored in the Accelerating Eulerian Fluid Simulation With Convolutional Networks [cims.nyu.edu] paper. Basically the process involves 2 parts:
What is it that you're looking to do differently at the pressure projection step? I can try and answer your questions.
1. Training a Convolutional Neural Network with a whole lot of simulation data.
2. Using the trained CNN model to drive novel simulations. (By this I mean take the data from the simulation, run it through the CNN, use the output as the solved pressure field, thereby avoiding the expensive pressure solve for speed and less accuracy)
I can already do part 1, I write out the feature vectors using a python node and then train a CNN in TensorFlow. No problem.
I can't figure out part 2 yet, since I would need to replace the “Gas Project Non Divergent” node with my own implementation. That node both does the pressure solve and makes the velocity field divergence free. What I need is some way to replace the current matrix solve (you know, the A x = b thing) with a call to my own code that would run the data through the CNN to get the resulting pressure values. It would then do whatever I need to do to make the velocity divergence free, or maybe a 2nd node would. (I think I know this equation, but if you know the method in the HDK, that would be neat.)
I know I'll have to code up my own replacement node, I'm just running into problems.
OK, I've typed way too much, here is an actual, concrete question:
The code my professor wrote in Houdini 12 makes use of the UT_SparseMatrixT< T, IsPaged >::solveConjugateGradient method: http://www.sidefx.com/docs/hdk12.0/class_u_t___sparse_matrix_t.html#aac7909665ae1c4bf3d85764705ec35b [sidefx.com]
In 15.5, I see this: http://www.sidefx.com/docs/hdk15.5/class_u_t___sparse_matrix_t.html#a6f65cbf692907404ba4154b6617e5ca3 [sidefx.com]
Basically, I have this code:
A.solveConjugateGradient( p, b );
const UT_SparseMatrixT< T, IsPaged > * GT,
I think figuring this out is the first step.
- rgoldade
- Member
- 73 posts
- Joined: 9月 2014
- Offline
- jlait
- スタッフ
- 6413 posts
- Joined: 7月 2005
- Offline
Javid Pack2
The node seems to calculate the pressure field AND tweak the velocity field to make it divergent free. I'd rather not waste effort on something that will take me many, many hours to figure out, so I thought I'd ask here:
Isn't updating the velocity field from the pressure is just a matter of adding the gradient of the pressure to the velocity?
The code for the projection is approximately this:
1) Compute divergence of the velocity field
2) Add in the user provided divergence
3) Solve for a pressure field giving the divergence field
4) Add gradient of pressure field back to the velocity field.
If you just want to replace step #3, you can mimic the other steps by using Gas Analysis to compute divergence & gradients, and Gas Linear Combine for the addition operations.
I'm a bit uncertain if velocity is where the feature vectors should come from; there is two extra degrees of freedom here that have nothing to do with the resulting pressure that your system will have to train out. I'd suggest pulling feature vectors from the divergence field instead. Formulated this way, a deep convolutional network starts to look like a multigrid V cycle with the weights being what you train…
A research problem I'd like to see addressed is using this to learn an algebraic multigrid solver that can properly handle collisions in smoke sims with multigrid by training the correct weights to deal with collision masks.
- Javid Pack2
- Member
- 5 posts
- Joined: 6月 2014
- Offline
rgoldadeThanks. A couple days ago I came across the documentation for UT_SparseMatrixELLT rather than UT_SparseMatrixT and it had the same method but this time it actually had documentation. (I didn't think to look at similar classes for documentation)
Okay I see. I believe GT is meant to be the preconditioner matrix. You should be able to pass in 0 for GT's pointer and the solver will default to diagonal jacobi for the preconditioner.
Thanks for replying to me. Had I not found that myself a few days ago I still wouldn't have known to pass in null there.
- tricecold
- Member
- 260 posts
- Joined: 7月 2006
- Online
have a look at this link and maybe contact them, they have been developing solvers with machine learning
https://vimeo.com/209397181 [vimeo.com]
https://vimeo.com/209397181 [vimeo.com]
Head of CG @ MPC
CG Supervisor/ Sr. FX TD /
https://gumroad.com/timvfx [gumroad.com]
www.timucinozger.com
CG Supervisor/ Sr. FX TD /
https://gumroad.com/timvfx [gumroad.com]
www.timucinozger.com
-
- Quick Links