[Solved] CFD boundary conditions


I won’t attempt to wade through the whole paper, but I can explain the
syntax and make some educated guesses about what’s going on.

#define IX(i,j) ((i)+(N+2)*(j))

This looks to me like they’re transforming two-dimensional coordinates
i,j into a one-dimensional array index. j is the row number and i
is the column number, which jibes with your description, and the total
number of columns is N+2.

      0       1       2  ...   (N+2)-1
(N+2)+0 (N+2)+1 (N+2)+2  ...  2(N+2)-1
...

Then we have this:

x[IX(0,i)] = b==1 ? -x[IX(1,i)] : x[IX(1,i)]

In C, a ? b : c means if a, b, else c. It’s an expression whose
value is either b or c, depending on whether a is true or not.
It’s called the ternary operator, read more here.

Python has its own ternary operator, with the operands in a different
order:

b if a else c

So x[IX(0,i)] = b==1 ? -x[IX(1,i)] : x[IX(1,i)] is equivalent to
saying:

if (b == 1)
    x[IX(0,i)] = -x[IX(1,i)]
else
    x[IX(0,i)] = x[IX(1,i)]

So, in row i, the new value at column 0 is the value at column 1,
possibly negated. Looking at page 10, this seems to have something to do
with the boundaries. This is at the left edge, so we’re setting it to
the value at one cell inward, or the negation of that, depending on b.

Hope this clears things up somewhat.

solved CFD boundary conditions