Matt is giving you some misguided advice. All the submatrices in a MatNest have to share the same communicator. This restriction could be lifted in the future, but that's how it is now.<div><br></div><div>Why do you want to concatenate these sequential blocks?</div>
<div><br></div><div>Using MatSetValues() is the standard answer and what I would recommend. You may also be able to create a new MPIAIJ matrix with the correct local sizes, then<br><br><div style="text-align:left">MatMPIAIJGetSeqAIJ(Ampi,&Aseq,&Bseq,&colmap);<br>
MatCopy(myblock,Aseq,DIFFERENT_NONZERO_PATTERN);</div></div><div style="text-align:left"><br></div><div style="text-align:left">you'll have to do a dummy assembly if you go this route.</div><div><br><div class="gmail_quote">
On Tue, Sep 4, 2012 at 9:23 AM, Thomas Witkowski <span dir="ltr"><<a href="mailto:thomas.witkowski@tu-dresden.de" target="_blank">thomas.witkowski@tu-dresden.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>    Mat seqMat;<br>
          MatCreateSeqAIJ(PETSC_COMM_SELF, 10, 10, 0, PETSC_NULL,
      &seqMat);<br>
          <br>
          Mat nestMat;<br>
          MatCreateNest(PETSC_COMM_WORLD, 1, PETSC_NULL, 1, PETSC_NULL,
      &seqMat, &nestMat);<br>
      <br>
      Results in the following error message:<br>
      <br>
      [0]PETSC ERROR: PetscSplitOwnership() line 93 in
      /home/thomas/software/petsc-3.3-p0/src/sys/utils/psplit.c Sum of
      local lengths 20 does not equal global length 10, my local length
      10<br>
        likely a call to VecSetSizes() or MatSetSizes() is wrong.<br>
      See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html#split" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html#split</a><br>
      [1]PETSC ERROR: PetscSplitOwnership() line 93 in
      /home/thomas/software/petsc-3.3-p0/src/sys/utils/psplit.c Sum of
      local lengths 20 does not equal global length 10, my local length
      10<br>
        likely a call to VecSetSizes() or MatSetSizes() is wrong.<br>
      <br>
      <br>
      Thomas<br>
      <br>
      <br>
      Am 04.09.2012 17:36, schrieb Matthew Knepley:<br>
    </div><div><div class="h5">
    <blockquote type="cite">On Tue, Sep 4, 2012 at 10:28 AM, Thomas Witkowski <span dir="ltr"><<a href="mailto:thomas.witkowski@tu-dresden.de" target="_blank">thomas.witkowski@tu-dresden.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 text="#000000" bgcolor="#FFFFFF">
            <div>Am 04.09.2012 17:20, schrieb Matthew Knepley:<br>
            </div>
            <blockquote type="cite">On Tue, Sep 4, 2012 at 9:52 AM,
              Thomas Witkowski <span dir="ltr"><<a href="mailto:thomas.witkowski@tu-dresden.de" target="_blank">thomas.witkowski@tu-dresden.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 text="#000000" bgcolor="#FFFFFF">
                    <blockquote type="cite">
                      <div class="gmail_quote"><br>
                        <div><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MATNEST.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MATNEST.html</a></div>
                        <div><br>
                        </div>
                      </div>
                    </blockquote>
                    As I wrote in my initial question, each rank
                    contains one and only one seqaij matrix, which all
                    should be joined to one global matrix such that each
                    local matrix is the corresponding diagonal block of
                    the mpiaij matrix. I think, this does not work with
                    nested matrices?<br>
                  </div>
                </blockquote>
                <div><br>
                </div>
                <div>Why does this not work? I really think you are
                  making this harder than it has to be.</div>
                <div><br>
                </div>
              </div>
            </blockquote>
            Mh, maybe I have an incomplete view of the possibilities how
            to use nested matrices.<br>
            <br>
            To become more specific: In the case of two mpi tasks, each
            containing one seqaij matrix, how to call MatCreateNest? Is
            this correct:<br>
            <br>
            Mat A;<br>
            MatCreaeteNest(PETSC_COMM_WORLD, 2, PETSC_NULL, 2,
            PETSC_NULL, V ,&A);<br>
          </div>
        </blockquote>
        <div>                                                           
               ^^^ This should be 1. </div>
        <div><br>
        </div>
        <div>   Matt</div>
        <div><br>
        </div>
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div text="#000000" bgcolor="#FFFFFF"> and V is defined on
            rank 0 as<br>
            <br>
            Mat V[2] = {seqMat, PETSC_NULL} ;<br>
            <br>
            and and rank 1 as<br>
            <br>
            Mat V[2] = {PETSC_NULL, seqMat};<br>
            <br>
            <br>
            Thomas<br>
            <blockquote type="cite">
              <div class="gmail_quote">
                <div>   Matt</div>
                <div> </div>
                <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div text="#000000" bgcolor="#FFFFFF"> Thomas<br>
                    <br>
                    <blockquote type="cite">
                      <div class="gmail_quote">
                        <div> </div>
                        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                          <div text="#000000" bgcolor="#FFFFFF"><br>
                            <blockquote type="cite">
                              <div>Hong<br>
                                <div class="gmail_quote">
                                  <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                                    <div text="#000000" bgcolor="#FFFFFF">
                                      <div>
                                        <div>
                                          <blockquote type="cite"> <br>
                                            <div class="gmail_quote">Thomas
                                              :<br>
                                              <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In
                                                my FETI-DP code, each
                                                rank creates a SEQAIJ
                                                matrix that represents
                                                the discretization of
                                                the interior domain.
                                                Just for debugging, I
                                                would like to join these
                                                sequential matrices to
                                                one global MPIAIJ
                                                matrix. This matrix has
                                                no off diagonal nnzs and
                                                should be stored
                                                corresponding to the
                                                ranks unknowns, thus,
                                                first all rows of the
                                                first rank and so on.
                                                What's the most
                                                efficient way to do
                                                this? Is it possible to
                                                create this parallel
                                                matrix just as a view of
                                                the sequential ones, so
                                                without copying the
                                                data? Thanks for any
                                                advise.</blockquote>
                                              <div><br>
                                              </div>
                                              <div><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateMPIAIJConcatenateSeqAIJ.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateMPIAIJConcatenateSeqAIJ.html</a></div>

                                              <div><br>
                                              </div>
                                              <div>Note: entries in
                                                seqaij matrices are
                                                copied into a mpiaij
                                                matrix without</div>
                                              <div>inter-processor
                                                communication. Use
                                                petsc-3.3 for this
                                                function.</div>
                                            </div>
                                          </blockquote>
                                          <br>
                                        </div>
                                      </div>
                                      The function does not do what I
                                      expect. For example, if we have
                                      two mpi task and each contains one
                                      local square matrix with n rows, I
                                      want to create a global square
                                      matrix with 2n rows. This function
                                      create a non-square matrix of size
                                      2n x n.<span><font color="#888888"><br>
                                          <br>
                                          Thomas<br>
                                        </font></span></div>
                                  </blockquote>
                                </div>
                                <br>
                              </div>
                            </blockquote>
                          </div>
                        </blockquote>
                      </div>
                    </blockquote>
                  </div>
                </blockquote>
              </div>
              <br>
              <br clear="all">
              <span><font color="#888888">
                  <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>
                </font></span></blockquote>
            <br>
          </div>
        </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>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br></div>