# Interpolation on staggered grid

 Register Blogs Members List Search Today's Posts Mark Forums Read

 November 4, 2016, 15:56 Interpolation on staggered grid #1 New Member   Join Date: Nov 2016 Posts: 4 Rep Power: 9 Hi, I'm a beginner trying to implement a basic/trivial 2D PIC simulation. I have a question regarding bilinear interpolation of a quantity (e.g. velocities) on staggered grid (the grid is on the picture below); I use two 2D arrays to store the velocities - one array for x-component and the other for y-component. One of the steps in the PIC algorithm is transfering velocities from particles to grid(s). Let's consider transfering the x-component of velocity from particles to the x-grid: for each particle I need to find 4 surrounding staggered points (green bars in the image above) to perform the (inverse) bilinear interpolation. Here's my question: how do I interpolate the x-velocity on the top and bottom boundary cells where there are no staggered points (green bars) below my particle (blue dot in the image)? How would you interpolate the blue particle's x-velocity component to the grid in the image above? My attempts to solution:I considered storing the velocity components on the grid vertices (the black dots in the image) for interpolation from particles to grid and from grid to particles. After transfering particles -> grid, I'd create another grid (staggered, storing velocities on the face centers, like in the image) and use it to solve the poisson equation. I'd use use only linear (not bilinear) interpolation for particles in the boundary cells. (How would this approach affect the quality of the simulation?) I'd interpolate in the same way like I interpolate for the other cells - but I would store velocities only for the existing green bars (e.g. only for the above 2 green bars in the case of the blue particle from the image above). I suppose this would result in loss of information.

November 4, 2016, 16:19
#2
Senior Member

Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,793
Rep Power: 71
Quote:
 Originally Posted by usirev Hi, I'm a beginner trying to implement a basic/trivial 2D PIC simulation. I have a question regarding bilinear interpolation of a quantity (e.g. velocities) on staggered grid (the grid is on the picture below); I use two 2D arrays to store the velocities - one array for x-component and the other for y-component. One of the steps in the PIC algorithm is transfering velocities from particles to grid(s). Let's consider transfering the x-component of velocity from particles to the x-grid: for each particle I need to find 4 surrounding staggered points (green bars in the image above) to perform the (inverse) bilinear interpolation. Here's my question: how do I interpolate the x-velocity on the top and bottom boundary cells where there are no staggered points (green bars) below my particle (blue dot in the image)? How would you interpolate the blue particle's x-velocity component to the grid in the image above? My attempts to solution:I considered storing the velocity components on the grid vertices (the black dots in the image) for interpolation from particles to grid and from grid to particles. After transfering particles -> grid, I'd create another grid (staggered, storing velocities on the face centers, like in the image) and use it to solve the poisson equation. I'd use use only linear (not bilinear) interpolation for particles in the boundary cells. (How would this approach affect the quality of the simulation?) I'd interpolate in the same way like I interpolate for the other cells - but I would store velocities only for the existing green bars (e.g. only for the above 2 green bars in the case of the blue particle from the image above). I suppose this would result in loss of information.

Consider that you know the velocity on the boundary...
for example, if the boundary is a wall and you work with viscous flows, you have zero x-component velocity so that you can add two values in the black nodes and using the bi-linear interpolation taking into account that you have a rectangular grid the height being a half of the upper.

November 4, 2016, 18:42
#3
New Member

Join Date: Nov 2016
Posts: 4
Rep Power: 9
Quote:
 Originally Posted by FMDenaro Consider that you know the velocity on the boundary... for example, if the boundary is a wall and you work with viscous flows, you have zero x-component velocity so that you can add two values in the black nodes and using the bi-linear interpolation taking into account that you have a rectangular grid the height being a half of the upper.

I'm sorry, but I think I don't understand the following part of your answer:
Quote:
 Originally Posted by FMDenaro ...so that you can add two values in the black nodes and using the bi-linear interpolation taking into account that you have a rectangular grid the height being a half of the upper.
Does that mean that to interpolate the x-velocity of the blue particle (from the image in my original question) to the grid, I should use (i.e. store the velocity on) the:
• left-upper green bar AND
• right-upper green bar AND
• bottom-left black node AND
• bottom-right black node
?

Another question: Should the 12 boundary grid-cells be marked as a wall? Then there could not be a particle in the 12 boundary cells and thus there would always be some green bars below my particle to store the velocity on (that would mean that particles are allowed only in the 4 cells inside the grid from the image). Is such an approach correct?

 November 5, 2016, 03:26 #4 Senior Member   Filippo Maria Denaro Join Date: Jul 2010 Posts: 6,793 Rep Power: 71 Yes, you can use the two lower black nodes (lower boundary) to complete the interpolation region. Setting wall or not as BC depends on your physical problem, is not a matter of interpolation.

November 5, 2016, 05:28
#5
New Member

Join Date: Nov 2016
Posts: 4
Rep Power: 9
Quote:
 Originally Posted by FMDenaro Yes, you can use the two lower black nodes (lower boundary) to complete the interpolation region. Setting wall or not as BC depends on your physical problem, is not a matter of interpolation.
Just to make sure I really understand:
given a 4x4 array of cells (like in the image) I create:
• 6x5 array for the staggered x-components of velocity (6 because apart from the green bars, I need to add the top and the bottom rows of black nodes)
• 5x6 array for the staggered y-components of velocity (analogously to the x-components)

The 2 added rows of black nodes at the top and bottom rows for x-component grid (in the case of the y-component-grid it'd be the leftmost and the rightmost columns of black nodes)
are used ONLY for interpolation when transfering velocities from particles to grid and in the opposite direction.
When solving the Poisson equation to get divergence-free field, I'd ignore the 2 rows of black nodes and I'd use just the green bars.

Is the above right?

 November 5, 2016, 06:02 #6 Senior Member   Filippo Maria Denaro Join Date: Jul 2010 Posts: 6,793 Rep Power: 71 The pressure equation requires only red and green values for computing the source term but it is solved on the centre of the cells usirev likes this.

 Tags implementation, pic, staggered grid