On Mon, Mar 21, 2011 at 6:40 AM, Alexander Grayver <span dir="ltr"><<a href="mailto:agrayver@gfz-potsdam.de">agrayver@gfz-potsdam.de</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;">
<div bgcolor="#ffffff" text="#000000">
On <a href="tel:21.03.2011%2012" target="_blank">21.03.2011 12</a>:37, Jed Brown wrote:
<blockquote type="cite">
<div class="gmail_quote">On Mon, Mar 21, 2011 at 12:31, Alexander
Grayver <span dir="ltr"><<a href="mailto:agrayver@gfz-potsdam.de" target="_blank">agrayver@gfz-potsdam.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div bgcolor="#ffffff" text="#000000">Would I have to rebuild
PETSc from scratch to make this wrapper working?</div>
</blockquote>
<div><br>
</div>
<div>You would put it in your project and link it with your
Fortran code.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div bgcolor="#ffffff" text="#000000">
<div><br>
<br>
<blockquote type="cite">
<div>Alternatively, the code for this is really simple,
just iterate through the rows of L and insert them
into J.</div>
</blockquote>
</div>
Do you mean using
MatGetOwnershipRange+MatGetSubMatrices+MatGetRow?</div>
</blockquote>
</div>
<br>
<div>Just translate the following (taken from MatAXPY_Basic) to
Fortran:</div>
<div><br>
</div>
<div>
<div> ierr = MatGetSize(X,&m,&n);CHKERRQ(ierr);</div>
<div> ierr =
MatGetOwnershipRange(X,&start,&end);CHKERRQ(ierr);</div>
<div> for (i = start; i < end; i++) {</div>
<div> ierr =
MatGetRow(X,i,&ncols,&row,&vals);CHKERRQ(ierr);</div>
<div> ierr =
MatSetValues(Y,1,&i,ncols,row,vals,ADD_VALUES);CHKERRQ(ierr);</div>
<div> ierr =
MatRestoreRow(X,i,&ncols,&row,&vals);CHKERRQ(ierr);</div>
<div> }</div>
<div> ierr =
MatAssemblyBegin(Y,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div>
<div> ierr =
MatAssemblyEnd(Y,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div>
</div>
<div><br>
</div>
</blockquote>
Thanks Jed, it looks simple enough for me (PETSc is great). <br>
<br>
One more question. I get matrix J out of MatMatMult operation and
then I have to add L matrix up, wouldn't there be a conflict using
MatAssemblyBegin/MatAssemblyEnd again? Generally, is it allowed to
set new values into the matrix after MatAssemblyBegin/MatAssemblyEnd
already has been done once?<br></div></blockquote><div><br></div><div>No, you can use them. However, if you are adding to existing values on your process, nothing happens.</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;"><div bgcolor="#ffffff" text="#000000">
Thanks a lot.<br>
</div>
</blockquote></div><br><br clear="all"><br>-- <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>