SimFlowCFD / RapidCFD-dev

RapidCFD is an OpenFOAM fork running fully on CUDA platform. Brought to you by
https://sim-flow.com
Other
326 stars 95 forks source link

How to scale the linear system Ax = b? #91

Open klausbu opened 3 years ago

klausbu commented 3 years ago

Hello,

I am working on a stronger preconditioner for symmetric matrices which requires scaling of the linear system Ax = b as follows:

A' = D^-1/2 A D^-1/2

x' = D^1/2 x

b' = D^-1/2 b

Where A'x' = b' is the scaled linear system and D is the Diagonal as defined in the OpenFOAM standard LDU matrix storage format.

Are you aware of functors/transformations I could reuse, implemented in other parts of RapidCFD?

Klaus

daniel-jasinski commented 3 years ago

Hi,

You can take a look at the AINVPreconditioner. Instead of using the divideOperatorSFFunctor<scalar,scalar,scalar>(1.0), apply sqrtUnaryFunctionFunctor<scalar,scalar>().

You can then use the computed scaling field and use it in the actual preconditioner kernel.

The AINV implementation is a bit more complicated than it could be, because of some optimization tricks. Just to make your implementation working, you can remove half of the branches in preconditionImpl by assuming that fastPath is always false.

Daniel