I am implementing a fluid simulator as my numerical methods course project and I have to compute pressure at each simulation step. Basically, that means solving an equation $Ap = b$, where $A$ is a sparse matrix: all its entries are zero except:
- Its main diagonal
- Diagonals before and after main diagonal
- For some $k$, the $k$th diagonal before and the $k$th diagonal after main
Somewhat like this:
$$\begin{bmatrix} a_{11} & a_{12} & 0 & \dots & a_{1k} & 0 & 0 & \dots & 0 \\ a_{21} & a_{22} & a_{23} & \dots & 0 & a_{2(k+1)} & 0 & \dots & 0 \\ 0 & a_{32} & a_{33} & \dots & 0 & 0 & a_{3(k+2)} & \dots & 0 \\ 0 & 0 & a_{43} & \dots & 0 & 0 & 0 & \dots & 0 \\ \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\ a_{k1} & 0 & 0 & \dots & \dots & \dots & \dots & \dots & \dots \\ 0 & a_{(k + 1)2} & 0 & \dots & \dots & \dots & \dots & \dots & \dots \\ 0 & 0 & a_{(k + 2)3} & \dots & \dots & \dots & \dots & \dots & \dots \\ \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots\\ 0 & 0 & 0 & \dots & 0 & 0 & a_{(n-1)(n-2)} & a_{(n-1)(n-1)} & a_{(n - 1) n} \\ 0 & 0 & 0 & \dots & 0 & 0 & 0 & a_{n(n-1)} & a_{nn} \end{bmatrix}$$
Since I sumulate the fluid without free surface, the matrix is not changing during the simulation, so I want to invert it before the simulation and then just compute $A^{-1} b$ at each step. However, I believe there are faster algorithms for doing it than Gaussian elimination which could exploit sparsity and the structure of such a matrix.
So, my questions are:
- Is there a commonly used name for such a matrix?
- Are there any effective algorithms for inverting it? (something similar to tridiagonal matrix algorithm, maybe?)
- If 2 is positive, are there any Java libraries doing that?