[opencurrent-users] Help with Navier-Stokes

16 views
Skip to first unread message

sklesser

unread,
May 22, 2010, 1:59:15 AM5/22/10
to opencurrent-users
I'm trying to do a plain particle-based fluid simulation in a box
where I provide the starting particle positions and starting particle
velocities. I basically just built off the code from the included
NSTest and can provide the positions, perform the simulation, and
visualize what's going on just fine. However, it doesn't seem like
giving the starting simulation velocity (setting the values in
vx,vy,vz) has any effect. The only way I'm getting the particles to
move is by adjusting the values for params.init_temp.at(i,j,k).

Other simulations I've played around with haven't used any sort of
temperature parameter so I'm a bit confused as to what
params.init_temp is doing. Any help in explaining what
params.init_temp does or how I can use my particle velocities to seed
the movement of the simulation instead of the params.init_temp values
would be really helpful.

Thanks!

dpephd

unread,
May 22, 2010, 2:56:45 AM5/22/10
to opencurrent-users
I would advise looking at looking at http://www.jcohen.name/papers/Cohen_Fast_2009.pdf
which describes the system of equations being solved N-S +
temperature, not just the N-S eqns.

dpephd

Jonathan Cohen

unread,
May 22, 2010, 9:00:24 PM5/22/10
to opencurr...@googlegroups.com
You need to set the initial state of the simulation via the  params.init_[u,v,w] fields.  They are Grid3DHost structures - you can set them to whatever you want.  They will be set as the initial condition for the fluid velocity fields.

Setting the velocities on the particles directly won't have any effect, since in the call to sample_points_mac_grid(), all the vx,vy,vz values will be directly overwritten.

Post again if you have more questions.

-Jon

sklesser

unread,
May 24, 2010, 7:03:03 PM5/24/10
to opencurrent-users
Great! Thanks for the help, I can see the particles moving from the
initial velocities now.

I do have another question about controlling how the fluid moves. How
can I add my own forces in the system? Am I forced to global constant
forces like gravity, or can I add forces at grid locations?

Thanks!

PS If you're interested, a quick overview of my project is
implementing Horvath and Geiger's Directable, High-Resolution
Simulation of Fire on the GPU which calls for two types of fluid
simulations. A coarse 3D simulation which I'm using OpenCurrent for.
And a series of more highly detailed 2D simulation which I was hoping
to just build off the CUDA SDK example of the FFT fluid solver.

On May 22, 6:00 pm, Jonathan Cohen <jco...@jcohen.name> wrote:
> You need to set the initial state of the simulation via the
> params.init_[u,v,w] fields.  They are Grid3DHost structures - you can set
> them to whatever you want.  They will be set as the initial condition for
> the fluid velocity fields.
>
> Setting the velocities on the particles directly won't have any effect,
> since in the call to sample_points_mac_grid(), all the vx,vy,vz values will
> be directly overwritten.
>
> Post again if you have more questions.
>
> -Jon
>

Jonathan Cohen

unread,
May 24, 2010, 9:46:42 PM5/24/10
to opencurr...@googlegroups.com
Sounds good.

You might want to implement a more stable advection scheme then, such as semi-Lagrangian.  All of the building blocks are there (e.g. the sample_points_mac_grid is really all you need), it's just a matter of putting them together.  Otherwise, the code will force you to take lots of small timesteps.  That level of accuracy probably isn't warranted to implement Horvath & Geiger's paper.

As for adding forces, you can add them arbitrarily inside the Eqn_IncompressibleNS3D::advance() routine, similar to add_therml_force.  You basically just add forces onto _deriv_[uvw]dt however you want.  Adding custom forces should be pretty easy here.
Reply all
Reply to author
Forward
0 new messages