Original Post
I'm having trouble understanding the algorithm behind liquid simulations.
I've found a source-code and therefore seen what the code looks like inside the simulation, but I still don't understand how the lines are related to each function that describes the motion of a fluid in real world. Of course, I can look at how each variable is created in the simulation, but I don't know why the calculations are what they are, as they don't have any resemblance to the real world fluid functions. And since the particles' and grid's variables have so strange abbreviations, the code is just some mumbo jumbo for me.
I've read sevelar articles and small e-books about fluid simulations, but none of them really describes how the theory is converted into a working code.
Some of the papers that I've read are:
An Informal Tutorial on Smoothed Particle Hydrodynamics for Interactive Simulation - Brandon Pelfrey
Lagrangian Fluid Dynamics Using Smoothed Particle Hydrodynamics - Micky Kelager
Particle-based Viscoelastic Fluid Simulation - Simon Clavet
Right now I'm trying to write a 2D fluid simulation using Material Point Method (MPM algorithm), which is very similar to SPH (or that's what I've heard, at least).
I have figured out that the MPM uses only two kinds of elements in the simulation: fluid particles and grid cells. The fluid particles are the visual part of the simulation and the grid is used for storing the data about density, pressure (and other physical quantities?) at any given point in space, and that data is gathered and calculated from the nearby fluid particles. The data from the grid cells is then used by the particles later on in the simulation step to calculate their new velocity and direction.
That's basically all I know about it right now. The next step is to understand how each line of code is related to the functions that describe a fluid's behaviour in the real world. I want to know where are the code chunks that control the density, pressure, viscosity, elasticity, smoothing, gravity and stiffness of the fluid - or if some of those parts do even exist in the source-code I've found.
I find it strange that first of all, very few people are willing to share the source-code of their fluid simulations, and secondly, nobody on the Internet is willing to write a comprehensive tutorial on this subject. I haven't found any source-code that has comments on the lines.
If I ever learn the logic behind fluid simulations, I surely will do a video tutorial where I teach everything about how fluids behave and I will describe every line of code and tell why it's written the way it is.
So, to put it shortly: I'm asking you to comment the code and describe what happens in each chunk of the code.
Here's the 200-line code of the fluid simulation step that I'm studying:
http://servut.us/sna...uid/Liquid.java
The full package can be found here:
http://servut.us/snaileri/fluid/
I've read sevelar articles and small e-books about fluid simulations, but none of them really describes how the theory is converted into a working code.
Some of the papers that I've read are:
An Informal Tutorial on Smoothed Particle Hydrodynamics for Interactive Simulation - Brandon Pelfrey
Lagrangian Fluid Dynamics Using Smoothed Particle Hydrodynamics - Micky Kelager
Particle-based Viscoelastic Fluid Simulation - Simon Clavet
Right now I'm trying to write a 2D fluid simulation using Material Point Method (MPM algorithm), which is very similar to SPH (or that's what I've heard, at least).
I have figured out that the MPM uses only two kinds of elements in the simulation: fluid particles and grid cells. The fluid particles are the visual part of the simulation and the grid is used for storing the data about density, pressure (and other physical quantities?) at any given point in space, and that data is gathered and calculated from the nearby fluid particles. The data from the grid cells is then used by the particles later on in the simulation step to calculate their new velocity and direction.
That's basically all I know about it right now. The next step is to understand how each line of code is related to the functions that describe a fluid's behaviour in the real world. I want to know where are the code chunks that control the density, pressure, viscosity, elasticity, smoothing, gravity and stiffness of the fluid - or if some of those parts do even exist in the source-code I've found.
I find it strange that first of all, very few people are willing to share the source-code of their fluid simulations, and secondly, nobody on the Internet is willing to write a comprehensive tutorial on this subject. I haven't found any source-code that has comments on the lines.
If I ever learn the logic behind fluid simulations, I surely will do a video tutorial where I teach everything about how fluids behave and I will describe every line of code and tell why it's written the way it is.
So, to put it shortly: I'm asking you to comment the code and describe what happens in each chunk of the code.
Here's the 200-line code of the fluid simulation step that I'm studying:
http://servut.us/sna...uid/Liquid.java
The full package can be found here:
http://servut.us/snaileri/fluid/
An Informal Tutorial on Smoothed Particle Hydrodynamics for Interactive Simulation - Brandon Pelfrey
Lagrangian Fluid Dynamics Using Smoothed Particle Hydrodynamics - Micky Kelager
Particle-based Viscoelastic Fluid Simulation - Simon Clavet
Right now I'm trying to write a 2D fluid simulation using Material Point Method (MPM algorithm), which is very similar to SPH (or that's what I've heard, at least).
I have figured out that the MPM uses only two kinds of elements in the simulation: fluid particles and grid cells. The fluid particles are the visual part of the simulation and the grid is used for storing the data about density, pressure (and other physical quantities?) at any given point in space, and that data is gathered and calculated from the nearby fluid particles. The data from the grid cells is then used by the particles later on in the simulation step to calculate their new velocity and direction.
That's basically all I know about it right now. The next step is to understand how each line of code is related to the functions that describe a fluid's behaviour in the real world. I want to know where are the code chunks that control the density, pressure, viscosity, elasticity, smoothing, gravity and stiffness of the fluid - or if some of those parts do even exist in the source-code I've found.
I find it strange that first of all, very few people are willing to share the source-code of their fluid simulations, and secondly, nobody on the Internet is willing to write a comprehensive tutorial on this subject. I haven't found any source-code that has comments on the lines.
If I ever learn the logic behind fluid simulations, I surely will do a video tutorial where I teach everything about how fluids behave and I will describe every line of code and tell why it's written the way it is.
So, to put it shortly: I'm asking you to comment the code and describe what happens in each chunk of the code.
Here's the 200-line code of the fluid simulation step that I'm studying:
http://servut.us/sna...uid/Liquid.java
The full package can be found here:
http://servut.us/snaileri/fluid/
Particle-based Viscoelastic Fluid Simulation - Simon Clavet
Right now I'm trying to write a 2D fluid simulation using Material Point Method (MPM algorithm), which is very similar to SPH (or that's what I've heard, at least).
I have figured out that the MPM uses only two kinds of elements in the simulation: fluid particles and grid cells. The fluid particles are the visual part of the simulation and the grid is used for storing the data about density, pressure (and other physical quantities?) at any given point in space, and that data is gathered and calculated from the nearby fluid particles. The data from the grid cells is then used by the particles later on in the simulation step to calculate their new velocity and direction.
That's basically all I know about it right now. The next step is to understand how each line of code is related to the functions that describe a fluid's behaviour in the real world. I want to know where are the code chunks that control the density, pressure, viscosity, elasticity, smoothing, gravity and stiffness of the fluid - or if some of those parts do even exist in the source-code I've found.
I find it strange that first of all, very few people are willing to share the source-code of their fluid simulations, and secondly, nobody on the Internet is willing to write a comprehensive tutorial on this subject. I haven't found any source-code that has comments on the lines.
If I ever learn the logic behind fluid simulations, I surely will do a video tutorial where I teach everything about how fluids behave and I will describe every line of code and tell why it's written the way it is.
So, to put it shortly: I'm asking you to comment the code and describe what happens in each chunk of the code.
Here's the 200-line code of the fluid simulation step that I'm studying:
http://servut.us/sna...uid/Liquid.java
The full package can be found here:
http://servut.us/snaileri/fluid/
I have figured out that the MPM uses only two kinds of elements in the simulation: fluid particles and grid cells. The fluid particles are the visual part of the simulation and the grid is used for storing the data about density, pressure (and other physical quantities?) at any given point in space, and that data is gathered and calculated from the nearby fluid particles. The data from the grid cells is then used by the particles later on in the simulation step to calculate their new velocity and direction.
That's basically all I know about it right now. The next step is to understand how each line of code is related to the functions that describe a fluid's behaviour in the real world. I want to know where are the code chunks that control the density, pressure, viscosity, elasticity, smoothing, gravity and stiffness of the fluid - or if some of those parts do even exist in the source-code I've found.
I find it strange that first of all, very few people are willing to share the source-code of their fluid simulations, and secondly, nobody on the Internet is willing to write a comprehensive tutorial on this subject. I haven't found any source-code that has comments on the lines.
If I ever learn the logic behind fluid simulations, I surely will do a video tutorial where I teach everything about how fluids behave and I will describe every line of code and tell why it's written the way it is.
So, to put it shortly: I'm asking you to comment the code and describe what happens in each chunk of the code.
Here's the 200-line code of the fluid simulation step that I'm studying:
http://servut.us/sna...uid/Liquid.java
The full package can be found here:
http://servut.us/snaileri/fluid/
That's basically all I know about it right now. The next step is to understand how each line of code is related to the functions that describe a fluid's behaviour in the real world. I want to know where are the code chunks that control the density, pressure, viscosity, elasticity, smoothing, gravity and stiffness of the fluid - or if some of those parts do even exist in the source-code I've found.
I find it strange that first of all, very few people are willing to share the source-code of their fluid simulations, and secondly, nobody on the Internet is willing to write a comprehensive tutorial on this subject. I haven't found any source-code that has comments on the lines.
If I ever learn the logic behind fluid simulations, I surely will do a video tutorial where I teach everything about how fluids behave and I will describe every line of code and tell why it's written the way it is.
So, to put it shortly: I'm asking you to comment the code and describe what happens in each chunk of the code.
Here's the 200-line code of the fluid simulation step that I'm studying:
http://servut.us/sna...uid/Liquid.java
The full package can be found here:
http://servut.us/snaileri/fluid/
If I ever learn the logic behind fluid simulations, I surely will do a video tutorial where I teach everything about how fluids behave and I will describe every line of code and tell why it's written the way it is.
So, to put it shortly: I'm asking you to comment the code and describe what happens in each chunk of the code.
Here's the 200-line code of the fluid simulation step that I'm studying:
http://servut.us/sna...uid/Liquid.java
The full package can be found here:
http://servut.us/snaileri/fluid/
Here's the 200-line code of the fluid simulation step that I'm studying:
http://servut.us/sna...uid/Liquid.java
The full package can be found here:
http://servut.us/snaileri/fluid/
http://servut.us/snaileri/fluid/