Jump to content

Volume Sampling in a Field to Particle Wrangle


ivr

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. 

Link to comment
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

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...