<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi Matt,<br>
      <br>
      How to check in the explicit method? This kind of errors does come
      out in the explicit method. <br>
      <br>
      What do you mean "You should never be changing the input guess"?
      Do you mean that the value of the solution vector X in
      FormFunction are not allowed to be changed by the user defined
      function?<br>
      <br>
      Best regards,<br>
      Rongliang<br>
      <br>
      On 04/02/2016 08:19 PM, Matthew Knepley wrote:<br>
    </div>
    <blockquote
cite="mid:CAMYG4GmU9sRjXFeDZ3evyVQpKMyobQFgnXo-N=UAdJTmBDzsyg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Sat, Apr 2, 2016 at 7:15 AM,
            Rongliang Chen <span dir="ltr"><<a
                moz-do-not-send="true" href="mailto:rl.chen@siat.ac.cn"
                target="_blank">rl.chen@siat.ac.cn</a>></span> wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000">
                <div>Hi Matt,<br>
                  <br>
                  That's right. The FormMassTimeStep() is inside the
                  FormFunction() and I call the FormFunction() in this
                  way: SNESSetFunction(user->snes, algebra->f,
                  FormFunction, (void*)user). How can I know the X is
                  read-only or not? <br>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>Exactly that you get this error message, and it should
              be in the documentation.</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">
                <div> If I do not use the SNESSolve, that is I use the
                  explicit method with the same function
                  FormMassTimeStep(), this error disappeared. So it
                  seems that the SNESSolve locked the vector X. <br>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>Then we need to put that check in the explicit method
              as well. You should never be changing the input guess.</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 bgcolor="#FFFFFF" text="#000000">
                <div> Best regards,<br>
                  Rongliang<br>
                  <br>
                  On 04/02/2016 07:59 PM, Matthew Knepley wrote:<br>
                </div>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div class="gmail_extra">
                      <div class="gmail_quote">On Sat, Apr 2, 2016 at
                        6:49 AM, Rongliang Chen <span dir="ltr"><<a
                            moz-do-not-send="true"
                            href="mailto:rl.chen@siat.ac.cn"
                            target="_blank">rl.chen@siat.ac.cn</a>></span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div bgcolor="#FFFFFF" text="#000000">
                            <div>Hi Dave,<br>
                              <br>
                              I did not call any VecGetArrary and
                              VecGetArraryRead in function
                              FormMassTimeStepFunction().<br>
                            </div>
                          </div>
                        </blockquote>
                        <div><br>
                        </div>
                        <div>It looks like you have a function
                          FormMassTimeStep() inside your FormFunction()
                          method. This</div>
                        <div>has an argument X, the solution guess,
                          which is read-only. However, you are calling
                          DMLocalToGlobal()</div>
                        <div>using that X, which is illegal, since its
                          read-only. Is this right?</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">
                            <div> Best regards,<br>
                              Rongliang<br>
                              <br>
                              On 04/02/2016 06:20 PM, Dave May wrote:<br>
                            </div>
                            <blockquote type="cite">
                              <div dir="ltr"><br>
                                <div class="gmail_extra"><br>
                                  <div class="gmail_quote">On 2 April
                                    2016 at 11:18, Rongliang Chen <span
                                      dir="ltr"><<a
                                        moz-do-not-send="true"
                                        href="mailto:rl.chen@siat.ac.cn"
                                        target="_blank">rl.chen@siat.ac.cn</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
                                      Shri,<br>
                                      <br>
                                      Thanks for your reply.<br>
                                      <br>
                                      Do you mean that I need to change
                                      the VecGetArrary() in
                                      /home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c
                                      to VecGetArrayRead()?<br>
                                    </blockquote>
                                    <div><br>
                                    </div>
                                    <div>No - you should change it in
                                      your function
                                      FormMassTimeStepFunction().<br>
                                    </div>
                                    <div>The input vector x passed into
                                      SNESComputeFunction() is read
                                      only.<br>
                                    </div>
                                    <div> <br>
                                      <br>
                                    </div>
                                    <blockquote class="gmail_quote"
                                      style="margin:0px 0px 0px
                                      0.8ex;border-left:1px solid
                                      rgb(204,204,204);padding-left:1ex">
                                      <br>
                                      I tried it and I got a warning
                                      when I make the petsc:<br>
                                      <br>
                                      /home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c:

                                      In function
                                      ‘DMLocalToGlobalBegin’:<br>
                                      /home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c:1913:5:


                                      warning: passing argument 2 of
                                      ‘VecGetArrayRead’ from
                                      incompatible pointer type [enabled
                                      by default]<br>
                                      In file included from
                                      /home/rlchen/soft/petsc-3.6.3/include/petscmat.h:6:0,<br>
                                      from
                                      /home/rlchen/soft/petsc-3.6.3/include/petscdm.h:6,<br>
                                      from
                                      /home/rlchen/soft/petsc-3.6.3/include/petsc/private/dmimpl.h:6,<br>
                                      from
                                      /home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c:1:<br>
                                      /home/rlchen/soft/petsc-3.6.3/include/petscvec.h:420:29:


                                      note: expected ‘const PetscScalar
                                      **’ but argument is of type
                                      ‘PetscScalar **’<br>
                                      <br>
                                      Best regards,<br>
                                      Rongliang<br>
                                      <br>
                                      ---------------------<br>
                                      Rongliang Chen,   PhD<br>
                                      Associate Professor<br>
                                      <br>
                                      Laboratory for Engineering and
                                      Scientific Computing<br>
                                      Shenzhen Institutes of Advanced
                                      Technology<br>
                                      Chinese Academy of Sciences<br>
                                      Address: 1068 Xueyuan Avenue,
                                      Shenzhen University Town,
                                      Shenzhen, Guangdong (518055), P.
                                      R. China<br>
                                      E-mail:  <a
                                        moz-do-not-send="true"
                                        href="mailto:rl.chen@siat.ac.cn"
                                        target="_blank">rl.chen@siat.ac.cn</a><br>
                                      Phone: <a moz-do-not-send="true"
                                        href="tel:%2B86-755-86392312"
                                        value="+8675586392312"
                                        target="_blank">+86-755-86392312</a>
                                      <div>
                                        <div><br>
                                          <br>
                                          On 04/02/2016 05:03 PM,
                                          Abhyankar, Shrirang G. wrote:<br>
                                          <blockquote
                                            class="gmail_quote"
                                            style="margin:0px 0px 0px
                                            0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex"> Use VecGetArrayRead instead of
                                            VecGetArray<br>
                                            <br>
                                            <a moz-do-not-send="true"
href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecGetArray"
                                              rel="noreferrer"
                                              target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecGetArray</a><br>
                                            Read.html<br>
                                            <br>
                                            <br>
                                            Shri<br>
                                            <br>
                                            -----Original Message-----<br>
                                            From: Rongliang Chen <<a
                                              moz-do-not-send="true"
                                              href="mailto:rl.chen@siat.ac.cn"
                                              target="_blank">rl.chen@siat.ac.cn</a>><br>
                                            Date: Saturday, April 2,
                                            2016 at 3:51 AM<br>
                                            To: PETSc users list <<a
                                              moz-do-not-send="true"
                                              href="mailto:petsc-users@mcs.anl.gov"
                                              target="_blank">petsc-users@mcs.anl.gov</a>>,

                                            "<a moz-do-not-send="true"
                                              href="mailto:rongliang.chan@gmail.com"
                                              target="_blank">rongliang.chan@gmail.com</a>"<br>
                                            <<a
                                              moz-do-not-send="true"
                                              href="mailto:rongliang.chan@gmail.com"
                                              target="_blank">rongliang.chan@gmail.com</a>><br>
                                            Subject: [petsc-users] Vec
                                            is locked read only<br>
                                            <br>
                                            <blockquote
                                              class="gmail_quote"
                                              style="margin:0px 0px 0px
                                              0.8ex;border-left:1px
                                              solid
                                              rgb(204,204,204);padding-left:1ex">
                                              Dear All,<br>
                                              <br>
                                              My code got the following
                                              error messages, but the
                                              code works well for<br>
                                              the petsc optimized
                                              version
                                              (--with-debugging=0).
                                              Anyone can tell me how<br>
                                              to fix this problem?<br>
                                              <br>
                                              Best regards,<br>
                                              Rongliang<br>
                                              <br>
                                              <br>
                                              [0]PETSC ERROR:
                                              ---------------------
                                              Error Message<br>
--------------------------------------------------------------<br>
                                              [0]PETSC ERROR: Object is
                                              in wrong state<br>
                                              [0]PETSC ERROR:  Vec is
                                              locked read only, argument
                                              # 1<br>
                                              [0]PETSC ERROR: See <a
                                                moz-do-not-send="true"
                                                href="http://www.mcs.anl.gov/petsc/documentation/faq.html"
                                                rel="noreferrer"
                                                target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a><br>
                                              for trouble shooting.<br>
                                              [0]PETSC ERROR: Petsc
                                              Release Version 3.6.3,
                                              Dec, 03, 2015<br>
                                              [0]PETSC ERROR: ./Nwtun on
                                              a 64bit-debug named rlchen
                                              by rlchen Sat Apr<br>
                                              2 15:40:32 2016<br>
                                              [0]PETSC ERROR: Configure
                                              options --download-blacs
                                              --download-scalapack<br>
                                              --download-metis
                                              --download-parmetis
                                              --download-exodusii<br>
                                              --download-netcdf
                                              --download-hdf5<br>
--with-mpi-dir=/home/rlchen/soft/Program/mpich2-shared<br>
                                              --with-debugging=1
                                              --download-fblaslapack
                                              --download-chaco<br>
                                              [0]PETSC ERROR: #1
                                              VecGetArray() line 1646 in<br>
/home/rlchen/soft/petsc-3.6.3/src/vec/vec/interface/rvector.c<br>
                                              [0]PETSC ERROR: #2
                                              DMLocalToGlobalBegin()
                                              line 1913 in<br>
/home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c<br>
                                              [0]PETSC ERROR: #3
                                              FormMassTimeStepFunction()
                                              line 191 in<br>
/home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/SetupF<br>
                                              unctions.c<br>
                                              [0]PETSC ERROR: #4
                                              FormFunction() line 46 in<br>
/home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/SetupF<br>
                                              unctions.c<br>
                                              [0]PETSC ERROR: #5
                                              SNESComputeFunction() line
                                              2067 in<br>
/home/rlchen/soft/petsc-3.6.3/src/snes/interface/snes.c<br>
                                              [0]PETSC ERROR: #6
                                              SNESSolve_NEWTONLS() line
                                              184 in<br>
/home/rlchen/soft/petsc-3.6.3/src/snes/impls/ls/ls.c<br>
                                              [0]PETSC ERROR: #7
                                              SNESSolve() line 3906 in<br>
/home/rlchen/soft/petsc-3.6.3/src/snes/interface/snes.c<br>
                                              [0]PETSC ERROR: #8
                                              SolveTimeDependent() line
                                              843 in<br>
/home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/Nwtun.<br>
                                              c<br>
                                              [0]PETSC ERROR: #9 main()
                                              line 452 in<br>
/home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/Nwtun.<br>
                                              c<br>
                                              <br>
                                              <br>
                                            </blockquote>
                                            <br>
                                          </blockquote>
                                          <br>
                                          <br>
                                        </div>
                                      </div>
                                    </blockquote>
                                  </div>
                                  <br>
                                </div>
                              </div>
                            </blockquote>
                            <br>
                          </div>
                        </blockquote>
                      </div>
                      <br>
                      <br clear="all">
                      <span class="HOEnZb"><font color="#888888">
                          <div><br>
                          </div>
                          -- <br>
                          <div>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">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>
    </blockquote>
    <br>
  </body>
</html>