Game Development Reference
In-Depth Information
class JacobiPrecon:public Preconditioner
{ public:
//Solves the system P J x=b
virtual void solve
(Matrix &P, const Vector &b, Vector &x) const ;
JacobiPrecon( void );
virtual ˜JacobiPrecon( void );
}
;
void JacobiPrecon::solve
(Matrix &P, const Vector &b, Vector &x) const
{ for ( int k=0;k < b.size();k++)
x[k]=b[k]/P(k,k);
}
Listing 10.8.
Implementation of the Jacobi preconditioner class.
the use of the Jacobi preconditioner P J , which is a diagonal matrix made by
the diagonal elements of S . Now, solving Equation (10.23) has the same cost as
multiplying two N -dimensional vectors. And there is no need for extra memory
space, because P J can be stored in S . More-complex preconditioners can reduce
the number of iterations, but their associated cost does not usually lead to any
improvement.
Note that Young's modulus values are relatively small for soft bodies when
compared with hard materials. For example, the Young's modulus of hard rub-
ber (with small strain) is about 20,000 times smaller than the Young's modulus
of steel. Softer bodies will have even smaller values, which is good for 32-bit
floating-point accuracy. On this, the accuracy of the CG method is affected when
using 32-bit floating-point precision, which is not really an issue since the simu-
lation will be only an approximate solution leading to a plausible simulation only
and not to an unstable simulation. Therefore, instead of stopping the CG method
using a threshold error, it is better to use a fixed number of 20 iterations, which
gives, in general, good approximations. More information about the CG method
can be found in [Shewchuk 94] and [Press et al. 07].
10.4.2 Cholesky Factorization and Gauss Elimination
When S does not change during the simulation, the first solution that comes to
mind to improve performance would be to precompute S 1
to solve
Search Nedrilad ::




Custom Search