# Smoothing kernels for fluid dynamics

## Recommended Posts

I'm working on creating water using smoother-particle-hydrodynamics as described in this paper: http://graphics.ethz.ch/Downloads/Publications/Papers/2003/mue03b/p_Mue03b.pdf One of the key points of the algorithm is to smooth values like pressure across multiple water particles using a smoothing kernel. They give some rules about how the kernel works - it must be normalized is one. Then the kernel they use is this: W(h,r) = (315/(64*3.14*h^9)) * ((h^2-r^2)^3) where h is the smoothing size, and r is the value you're asking for. Problem is, this function isnt normalized?? If you take the integral for h=1, it's .71, not 1. And the integral for h=.1 is 71. But this smoothing kernel is used in numerous other papers. So am I understanding it wrong? Does it not need to be normalized? Or maybe I need to normalize it myself by identifying what ratio i should divide the function? I'm not sure what would happen if it isn't normalized, I suppose it would return values larger than it should when you queried for them, but maybe thats ok because it balances out on both sides? Anyone have any experience with this kind of thing?

##### Share on other sites
My guess is that you're integrating in R whereas the smoothing function is defined on R^2 or R^3.

##### Share on other sites
Based on the exponents, it's for R3.

##### Share on other sites
The rule as listed is:

Integral W(r)dr = 1

I would think it would have some other notation if I was supposed to integral r^3? Though the equation for the smoothing kernel is kind of strange:

Why is there a seperate term on the right after the brackets? I assume youre just supposed to multiply that but why didnt they put it in the original equation.. Then again its been a long time since my calculus classes..

##### Share on other sites
The bracket with the conditional terms just makes sure that the equation stays non-negative and limits the influence of a particle. The stuff on the left is just for normalisation.

If you spherically integrate over the function that is multiply with 4*pi*r^2 for the spherical symmetry and integrate from 0 to h with respect to r you should get 1. That's at least what I just got. And AFAICT this result makes sense too.

So as long as you are simulating in R^3 the function is fine. If you are working in 2D you will need to change the normalisation term.

Good luck,
n115

##### Share on other sites
As a matter of fact I am planning to use it for a 2d simulation rather than a 3d, so I'll need to modify the function to work in 2d space.

Now I get to demonstrate my calculus ignorance with some easy questions :)

How do I spherically integrate a function? And how is it different if I just want to integrate it circularly, in 2 dimensions?

Thanks for everyones help!
-John

##### Share on other sites
I get it now :)

I'll explain it case anyone else comes across this thread (and just to get it out of my head).

The equation (h^2 - r^2)^3 is a nice unnormalized smoothing function. For the purposes in the paper, though, they needed it to be normalized in 3 dimensions.

So how do you normalize it? First you have to integrate it, and in the paper they do that spherically. To integrate it spherically, each value of 'r' needs to apply not just to a single value, but the entire 3d-shell at that radius, a shell of width 'dr'.

So if we multiple our smoothing kernel by 4*pi*r^2 (the formula for surface area of a sphere of radius 'r'), then we can integrate it to get the sum in 3d space. Thus the integral we need to normalize is:

(h^2-r^2)^3 * 4*pi*r^2

After multiplying this all out, integrating, and combining terms we get:
(pi/315) * (420h^6r^3 - 756h^4r^5 + 540h^2r^7 - 140r^9)

This equation gives the integral up to location 'r', and when r=h we want this equation to equal 1, since we need it to be normalized across h. So we can assign r=h and substitute that in and make it equal to 1. Solving that, we get:
315/(64*pi*h^9)

And thats where they get that term from. So all that is the easy stuff they left out of the paper for people who understand calculus better than me :P

Sooo for 2d, we do the same thing, but this time multiply by the circumference of a circle, 2pi*r, since that is the area the kernel will affect at 'r' in a 2d simulation. This proceeds using the same logic as above and yields the term:

4/(pi*h^8)

I tested this and it works! The integral will indeed be normalized. So the final kernel function for the "Particle-Based Fluid Simulation for Interactive Applications" paper if you're using 2D instead of 3D is:

W(r,h) = (4/pi*h^8)*(h^2-r^2)^3

Hope this helps someone, it was kind of fun relearning all this stuff. Thanks heaps to everyone who replied!
-John

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627719
• Total Posts
2978797

• 10
• 9
• 21
• 14
• 12