[petsc-users] Custom Matrix- and Vector-Class

Matthew Knepley knepley at gmail.com
Fri Sep 21 08:19:49 CDT 2012


On Fri, Sep 21, 2012 at 8:17 AM, Markus Mayr <markus.mayr at outlook.com>wrote:

> Dear list,
>
> I would like to use PETSc's linear solver for matrix free methods, but I
> think that I need to create a custom vector type in order to write an
> efficient matrix-vector multiplication. First, this is my problem:
>
> I would like to solve a system of linear equations
>
>   /   A  |  B   \    /  x  \   /  a  \
>   | -----+----- | *  | --- | = | --- |
>   \   C  |  D   /    \  y  /   \  b  /
>
> The problem is that only A is a PETSc matrix. For the other matrices, an
> external library provides a matrix-vector multiplication for PETSc vectors.
> I would like to use GMRES to solve this system.
>
> If I would like to use GMRES, I have to provide a matrix-vector
> multiplication for the whole matrix, right?. A, B, C, D and all vectors
> involved are distributed across the same set of processes. This is why I
> think it would be inefficient to use PETSc's MPIVec vector class. Is it? Or
> can I obtain the required parts of the vector efficiently, i.e. with little
> communication operations involved?
>

I think the best way to do this is to use the MATNEST matrix type, and then
put in MATSHELL entries
for B, C, and D. PETSc will automatically break down and reassemble the
vectors for you.

    Matt


> I think, it would be the best solution, to write a vector class myself,
> that contains an array of PETSc vector. I took a look at the PETSc source
> code and it does not look too hard, but first:
>
> 1.) I wanted to get some feedback, because I am a beginner with PETSc and
> there might be a way to do this in PETSc more easily.
> 2.) I do not know which functions I have to implement in order to get
> GMRES to work. Is there a comprehensive list or something? Or does PETSc
> return meaningful error messages about missing functions?
> 3.) If you do not mind, could you give a short example how new vector
> classes are created once the vector operations struct is created? I could
> not find this yet.
>
> Thanks for your help!
>
> Best regards,
> Markus Mayr




-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120921/31607619/attachment.html>


More information about the petsc-users mailing list