<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 15, 2016 at 6:07 AM, leejearl <span dir="ltr"><<a href="mailto:leejearl@126.com" target="_blank">leejearl@126.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div>
    Hi, Matt:<br>
        Thank you for your kind reply. Since it is a low level routine,
    is there any method which I can used for creating a <br>
    dynamic array?<br>
    </div></blockquote><div><br></div><div>I am not sure what you are asking for?</div><div><br></div><div>  Thanks,</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>    Thanks<br>
    leejearl<br>
    <br>
    <div class="m_-5870127340255563735moz-cite-prefix">On 2016年11月15日 16:20, Matthew Knepley
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Tue, Nov 15, 2016 at 1:00 AM,
            leejearl <span dir="ltr"><<a href="mailto:leejearl@126.com" target="_blank">leejearl@126.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Lawrence:<br>
              <br>
                  Thank you for your prompt reply.  It works well, but I
              encounter another problem.<br>
              <br>
               The code is as follows:<br>
              <br>
                      PetscScalar *arrayConVar, *arrayDeltaX,
              *arrayDeltaY;<br>
              <br>
                      ierr = DMPlexGetAdjacency(dm, c, &adjSize,
              &adj); CHKERRQ(ierr);<br>
              <br>
                      /*PetscSynchronizedPrintf(PETS<wbr>C_COMM_WORLD,
              "adjSize = %d\n", adjSize);*/<br>
                      adjSizeInterior = -1;<br>
                      for(i = 0; i < adjSize; i++)<br>
                      {<br>
                          if(adj[i] < cEndInterior)<br>
                          {<br>
                              adjSizeInterior++;<br>
                              /*PetscSynchronizedPrintf(PETS<wbr>C_COMM_WORLD,
              "adj[%d]= %d\n", i, adj[i]);*/<br>
                          }<br>
                      }<br>
                      /*<br>
                      PetscSynchronizedPrintf(PETSC_<wbr>COMM_WORLD,
              "adjSizeInterior = %d\n", adjSizeInterior);<br>
                      PetscSynchronizedFlush(PETSC_C<wbr>OMM_WORLD,PETSC_STDOUT);<br>
                      */<br>
              <br>
                      ierr = PetscMalloc3(adjSizeInterior*4<wbr>,
              &arrayConVar, adjSizeInterior, &arrayDeltaX,
              adjSizeInterior, &arrayDeltaY); CHKERRQ(ierr);<br>
              <br>
                      PetscFree3(arrayConVar, arrayDeltaX, arrayDeltaY);
              CHKERRQ(ierr);<br>
                      ierr = PetscFree(adj); CHKERRQ(ierr);<br>
              <br>
              The error messages are like as :<br>
              <br>
              [0]PETSC ERROR: --------------------- Error Message
              ------------------------------<wbr>------------------------------<wbr>--<br>
              [0]PETSC ERROR: Petsc has generated inconsistent data<br>
              [0]PETSC ERROR: Invalid mesh exceeded adjacency allocation
              (0)<br>
            </blockquote>
            <div><br>
            </div>
            <div>You are resetting the size to 0 in your loop. It needs
              to be set to PETSC_DETERMINE.</div>
            <div><br>
            </div>
            <div>This is a very low level routine with complicated
              memory management for efficiency. It is not intended for</div>
            <div>most user code. However, here is an example:</div>
            <div><br>
            </div>
            <div>  <a href="https://bitbucket.org/petsc/petsc/src/f98bafe09724ec53686c21e51e969e41f10d977b/src/dm/impls/plex/plexdistribute.c?at=master&fileviewer=file-view-default#plexdistribute.c-570" target="_blank">https://bitbucket.org/petsc/<wbr>petsc/src/<wbr>f98bafe09724ec53686c21e51e969e<wbr>41f10d977b/src/dm/impls/plex/<wbr>plexdistribute.c?at=master&<wbr>fileviewer=file-view-default#<wbr>plexdistribute.c-570</a></div>
            <div><br>
            </div>
            <div>  Thanks,</div>
            <div><br>
            </div>
            <div>     Matt</div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              [0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/d<wbr>ocumentation/faq.html</a>
              for trouble shooting.<br>
              [0]PETSC ERROR: Petsc Development GIT revision:
              v3.7.4-1864-ga10654c  GIT Date: 2016-11-01 22:25:06 -0500<br>
              [0]PETSC ERROR: ./cavity on a arch-linux2-c-debug named
              leejearl by leejearl Tue Nov 15 14:48:57 2016<br>
              [0]PETSC ERROR: Configure options
              --prefix=/home/leejearl/Instal<wbr>l/Petsc
              --with-mpi-dir=/home/leejearl/<wbr>Install/openmpi/1.8.5_gnu
              --download-exodusii=../externa<wbr>lpackages/exodus-5.24.tar.bz2
              --download-netcdf=../externalp<wbr>ackages/netcdf-4.3.2.tar.gz
              --download-hdf5=../externalpac<wbr>kages/hdf5-1.8.12.tar.gz
              --download-triangle=../externa<wbr>lpackages/Triangle.tar.gz
              --download-sowing=../externalp<wbr>ackages/git.sowing.tar.gz<br>
              [0]PETSC ERROR: #1 DMPlexGetAdjacency_Cone_Intern<wbr>al()
              line 193 in /home/leejearl/Software/petsc/<wbr>petsc/src/dm/impls/plex/plexdi<wbr>stribute.c<br>
              [0]PETSC ERROR: #2 DMPlexGetAdjacency_Internal() line 298
              in /home/leejearl/Software/petsc/<wbr>petsc/src/dm/impls/plex/plexdi<wbr>stribute.c<br>
              [0]PETSC ERROR: #3 DMPlexGetAdjacency() line 372 in
              /home/leejearl/Software/petsc/<wbr>petsc/src/dm/impls/plex/plexdi<wbr>stribute.c<br>
              [0]PETSC ERROR: #4 CalcConVarGradient() line 126 in
              /home/leejearl/Desktop/PETSc/G<wbr>KSCavity_Petsc/cavity.c<br>
              <br>
              It is very strange that PetscMalloc3 can arouse such an
              error. If I comment the statement relative with
              PetscMalloc3, it is ok! I can not understand what
              happened.<br>
              <br>
              Can anyone figure me out the problems of my codes?<br>
              <br>
              I attach the code and the grid, so you can compile in your
              workstation.<br>
              <br>
              Thanks<br>
              <br>
              leejearl<br>
              <br>
              <br>
              On 2016年11月14日 23:09, Lawrence Mitchell wrote:<br>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                  On 14 Nov 2016, at 14:59, leejearl <<a href="mailto:leejearl@126.com" target="_blank">leejearl@126.com</a>>
                  wrote:<br>
                  <br>
                  Hi all:<br>
                  <br>
                      I am not sure the using of the function
                  "DMPlexGetAdjacency".<br>
                  <br>
                      My codes are as follows:<br>
                  <br>
                      PetscInt adj, *adjSize=NULL;<br>
                  <br>
                      ierr = DMPlexGetAdjacency(dm, p,  &adj,
                  &adj);<br>
                </blockquote>
                <br>
                Your calling sequence is wrong:<br>
                <br>
                PetscInt adjSize;<br>
                PetscInt *adj = NULL;<br>
                <br>
                ierr = DMPlexGetAdjacency(dm, p, &adjSize,
                &adj); CHKERRQ(ierr);<br>
                <br>
                adjSize is now the size of the adj array.  You should
                remember to free it afterwards:<br>
                <br>
                /* use adj here *<br>
                ...<br>
                <br>
                ierr = PetscFree(adj); CHKERRQ(ierr);<br>
                <br>
                Lawrence<br>
              </blockquote>
              <br>
            </blockquote>
          </div>
          <br>
          <br clear="all"><span class="HOEnZb"><font color="#888888">
          <div><br>
          </div>
          -- <br>
          <div class="m_-5870127340255563735gmail_signature">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>
        </font></span></div>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">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></div>