<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, May 9, 2014 at 3:15 AM, marco restelli <span dir="ltr"><<a href="mailto:mrestelli@gmail.com" target="_blank">mrestelli@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">2014-05-09 5:47 GMT+0200, Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>>:<br>

<div><div class="h5">> marco restelli <<a href="mailto:mrestelli@gmail.com">mrestelli@gmail.com</a>> writes:<br>
>> Matt, thanks but this I don't understand. What I want is getting three<br>
>> arrays (i,j,coeff) with all the nonzero local coefficients, so that I<br>
>> can send them around with MPI.<br>
>><br>
>> MatGetSubmatrices would give me some PETSc objects, which I can not<br>
>> pass to MPI, right?<br>
><br>
> I'm not sure you want this, but you can use MatGetRowIJ and similar to<br>
> access the representation you're asking for if you are dead set on<br>
> depending on a specific data format rather than using generic<br>
> interfaces.<br>
><br>
<br>
</div></div>Jed, thank you. This is probably not the PETSc solution, but still it<br>
might a solution!<br>
<br>
I have found this example for MatGetRowIJ:<br></blockquote><div><br></div><div>I really do not think you want to do this. It is complex, fragile and I believe the performance</div><div>improvement to be non-existent. You can get the effect you want JUST by using one function.</div>
<div>For example, suppose you want 2 procs to get rows [0,5] and two procs to get rows [1,3], then</div><div><br></div><div>procs A.B</div><div><br></div><div>  MatGetSubmatrices(A, 2, [0,5], 2, [0,5], ..., &submat)</div>
<div><br></div><div>procs C, D</div><div><br></div><div>  MatGetSubmatrices(A, 2, [1,3], 2, [1,3], ..., &submat)</div><div><br></div><div>and its done. No MPI, no extraction which depends on the Mat data structure.</div>
<div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<a href="http://www.stce.rwth-aachen.de/trac/petsc/browser/src/mat/examples/tests/ex79f.F?rev=a52934f9a5da430fdd891fa538a66c376435ec4c" target="_blank">http://www.stce.rwth-aachen.de/trac/petsc/browser/src/mat/examples/tests/ex79f.F?rev=a52934f9a5da430fdd891fa538a66c376435ec4c</a><br>

<br>
My understanding is that I need to:<br>
<br>
1) get the sequential part of the matrix, i.e. those rows stored on<br>
this processor<br>
      call MatMPIAIJGetSeqAIJ(A,Ad,Ao,icol,iicol,ierr)<br>
<br>
2) get the indexes of these rows<br>
      call MatGetOwnershipRange(A,rstart,rend,ierr)<br>
<br>
3) get the indexes i,j of the local portion of the matrix (compressed<br>
form)<br>
      call MatGetRowIJ(Ad,one,zero,zero,n,ia,iia,ja,jja,done,ierr)<br>
<br>
4) get the corresponding elements<br>
      call MatGetArray(Ad,aa,aaa,ierr)<br>
<br>
5) WARNING: the row indexes obtained with MatGetRowIJ are local to<br>
this processor, so they must be corrected with rstart to obtain the<br>
corresponding global indexes<br>
<br>
6) clean-up<br>
<br>
<br>
Does this make sense?<br>
<span class=""><font color="#888888"><br>
<br>
Marco<br>
</font></span></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
</div></div>