streaming step

Hi all,
Can anybody explain the commands
F(:,:,1)=F([nx 1:nx-1],:,1)
F(:,:,2)=F([nx 1:nx-1],[ny 1:ny-1],2)

Thanks

Hi,

The fist line is a typical Octave/Matlab command for the streaming of particles in a direction aligned with the x-axis, and the second line a command for streaming in a diagonal direction. This type of Octave/Matlab notation is based on an interpretation of the streaming step as a permutation of space indices. Streaming in x-direction is for example equivalent to shifting the x-space indices by one cell.

To understand why your code is equivalent to a permutation of indices, I suggest that you type the following lines at the Octave/Matlab command prompt, and watch the output:


a = [10 20 30 40 50]
leftshift = [2 3 4 5 1]
a(leftshift)

As a side remark, I would recommend to replace this type of explicit index-shift notation by a call to the function “circshift”, to improve both the efficiency and the readability of the code. For examples, see the Octave/Matlab examples on lbmethod.org