<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 21.03.2011 12:45, Matthew Knepley wrote:
    <blockquote
      cite="mid:AANLkTi=vO35+uOxHDYaH5YHQuZZJwkwDD36dtzKgu=VT@mail.gmail.com"
      type="cite">On Mon, Mar 21, 2011 at 6:40 AM, Alexander Grayver <span
        dir="ltr">&lt;<a moz-do-not-send="true"
          href="mailto:agrayver@gfz-potsdam.de">agrayver@gfz-potsdam.de</a>&gt;</span>
      wrote:<br>
      <div class="gmail_quote">
        <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"> On <a
              moz-do-not-send="true" 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">&lt;<a
                    moz-do-not-send="true"
                    href="mailto:agrayver@gfz-potsdam.de"
                    target="_blank">agrayver@gfz-potsdam.de</a>&gt;</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>&nbsp;</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>&nbsp; ierr = MatGetSize(X,&amp;m,&amp;n);CHKERRQ(ierr);</div>
                <div>&nbsp; ierr =
                  MatGetOwnershipRange(X,&amp;start,&amp;end);CHKERRQ(ierr);</div>
                <div>&nbsp; for (i = start; i &lt; end; i++) {</div>
                <div>&nbsp; &nbsp; ierr =
                  MatGetRow(X,i,&amp;ncols,&amp;row,&amp;vals);CHKERRQ(ierr);</div>
                <div>&nbsp; &nbsp; ierr =
                  MatSetValues(Y,1,&amp;i,ncols,row,vals,ADD_VALUES);CHKERRQ(ierr);</div>
                <div>&nbsp; &nbsp; ierr =
                  MatRestoreRow(X,i,&amp;ncols,&amp;row,&amp;vals);CHKERRQ(ierr);</div>
                <div>&nbsp; }</div>
                <div>&nbsp; ierr =
                  MatAssemblyBegin(Y,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div>
                <div>&nbsp; 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>&nbsp;&nbsp; Matt</div>
        <div>&nbsp;</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"> 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>
    </blockquote>
    Matt <br>
    Jed, <br>
    <br>
    Thanks a lot!<br>
  </body>
</html>