Good overview:
http://software.intel.com/en-us/articles/fluid-simulation-for-video-games-part-1/
Some algorithmics:
http://www.colinbraley.com/Pubs/FluidSimColinBraley.pdf
Conjugate Gradient:
http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf
http://planetmath.org/encyclopedia/ConjugateGradientAlgorithm.html
Sparse symmetric matrix implementation:
package yarangi.math.algebra; import java.util.HashMap; import java.util.Map; public class SparseSymmetricMatrix implements IMatrix { private Mapmatrix; private int width; public SparseSymmetricMatrix(int width) { this.width = width; this.matrix = new HashMap(width*width/4); } public SparseSymmetricMatrix(int width, double loadFactor) { this.width = width; this.matrix = new HashMap((int)(loadFactor*width*width)); } public void set(double value, int i, int j) { matrix.put(index(i, j), value); if(index(i, j) < 0) } public double get(int i, int j) { Double value = matrix.get(index(i, j)); return value == null ? 0 : value; } private int index(int i, int j) { if(i > j) return j * width + i; return i * width + j; } public IVector mul(IVector vector) { IVector result = new Vector(width); for(int key : matrix.keySet()) { double value = matrix.get(key); int row1 = key % width; int row2 = key / width; result.set(result.get(row1)+value*vector.get(row2), row1); if(row1 != row2) result.set(result.get(row2)+value*vector.get(row1), row2); } return result; } public IVector mulTranspose(IVector vector) { return mul(vector); } }
May also be of interest:
No comments:
Post a Comment