On Fri, Sep 21, 2012 at 8:17 AM, Markus Mayr <span dir="ltr"><<a href="mailto:markus.mayr@outlook.com" target="_blank">markus.mayr@outlook.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear list,<br>
<br>
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:<br>
<br>
I would like to solve a system of linear equations<br>
<br>
/ A | B \ / x \ / a \<br>
| -----+----- | * | --- | = | --- |<br>
\ C | D / \ y / \ b /<br>
<br>
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.<br>
<br>
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?<br>
</blockquote><div><br></div><div>I think the best way to do this is to use the MATNEST matrix type, and then put in MATSHELL entries</div><div>for B, C, and D. PETSc will automatically break down and reassemble the vectors for you.</div>
<div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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:<br>
<br>
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.<br>
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?<br>
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.<br>
<br>
Thanks for your help!<br>
<br>
Best regards,<br>
Markus Mayr </blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>