Timothée Nicolas
2015-10-29 07:11:05 UTC
Hello all,
Eventually, I would like to use matrix-free methods in my multigrid solver,
because I have a large problem and matrix memory storage is an issue. Since
all my matrices represent operators, it is quite straightforward to make
them matrix-free, and according to the manual, I can use multigrid on them.
However, depending on the method chosen in KSP, different matrix operations
are used, which the user has to code by himself.
That is, in my understanding, coding the subroutine for MATOP_MULT (which
in principle is sufficient to describe the matrix) is actually not
sufficient, because the KSP may want internally to get, e.g., the diagonal
with MatGetDiagonal, in which case I need a routine to define the operation
MATOP_GET_DIAGONAL (as far as I understand). This means I have to know all
the matrix related routines used internally by the KSP (which will depend
on the ksp method as well as the preconditioner choice), and hard code the
corresponding routines. After all, one could probably do this, but this is
really tedious work and I have the feeling it is not the approach intended
by the developers of PETSc.
Would someone have an advice on how to do this efficiently ? Maybe I am
totally wrong ? But when I tried to do a KSP with multigrid preconditioning
on a matrix-free matrix, I got errors complaining about MatGetDiagonal and
this sort of things.
Best
Timothee
Eventually, I would like to use matrix-free methods in my multigrid solver,
because I have a large problem and matrix memory storage is an issue. Since
all my matrices represent operators, it is quite straightforward to make
them matrix-free, and according to the manual, I can use multigrid on them.
However, depending on the method chosen in KSP, different matrix operations
are used, which the user has to code by himself.
That is, in my understanding, coding the subroutine for MATOP_MULT (which
in principle is sufficient to describe the matrix) is actually not
sufficient, because the KSP may want internally to get, e.g., the diagonal
with MatGetDiagonal, in which case I need a routine to define the operation
MATOP_GET_DIAGONAL (as far as I understand). This means I have to know all
the matrix related routines used internally by the KSP (which will depend
on the ksp method as well as the preconditioner choice), and hard code the
corresponding routines. After all, one could probably do this, but this is
really tedious work and I have the feeling it is not the approach intended
by the developers of PETSc.
Would someone have an advice on how to do this efficiently ? Maybe I am
totally wrong ? But when I tried to do a KSP with multigrid preconditioning
on a matrix-free matrix, I got errors complaining about MatGetDiagonal and
this sort of things.
Best
Timothee