Jump to content
Sign in to follow this  

Volume Sampling in a Field to Particle Wrangle

Recommended Posts

Hello, everyone!

I'm writing my own Gas Field to Particle to project a velocity field to my particles. 

I have tried with both a Point and an Attribute Wrangle connected to my particles and the velocity field. 

First I'm getting the voxel index at the position of the particle:

vector voxelindex = volumepostoindex(1, 'velN', @P);

Each particle needs to consider information from surrounding voxels. So I'm taking the voxel index at the position of the particle and add to it voxel index shifts. I'm storing these shifts in a vector array.

foreach(vector index; voxel_shifts_array)
    current_voxel_index = voxelindex + index;
    current_voxel_pos = volumeindextopos(1, 'velField', current_voxel_index);
    vector vel = volumesamplev(1, 'velField', current_voxel_pos); 
  //weight calculation based on distance between particle position and voxel position
    foreach(index1, i; abs(@P - current_voxel_pos)){
  vel_pic = vel_pic + @TimeInc * weight * set(getcomp(vel, 0), getcomp(vel, 1), getcomp(vel, 2));

The foreach loop contains the weight calculation based on the distance between the particle and the current voxel.

I believe there is something wrong with my volume sampling but I cannot pinpoint what. 

Share this post

Link to post
Share on other sites

why don't you just sample the vector field directly at the particle position?

vector vel = volumesamplev(1, 'velField', @P);

it will automatically interpolate the value from neighboring voxels, you don't have to do that part

Share this post

Link to post
Share on other sites

Thanks, Tomas! I was doing that because I didn't know how many voxels Houdini was considering when interpolating values inside Gas Particle to Field. So I was experimenting with writing my own. 

I thought the volume sample was only returning the value of that particular voxel.

Also, I couldn't find much information about the interpolation function used inside the Gas microsolver interpolations, so I wanted to be able to control that aspect as well. 

Edited by ivr

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this