<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    thank you,<br>
    I'll try to do that.<br>
    <br>
    Yes, i have some criteria that can tell that the solution is a
    non-physical one.<br>
    Basically what I'm trying to do is very similar to a predictor
    corrector scheme.<br>
    Predictor should move solution to the right direction.<br>
    <br>
    <div class="moz-cite-prefix">On 10/08/2015 03:44 PM, Matthew Knepley
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAMYG4GkFp5cKM16_F3UufaC0=Q5MgJeHDouRzUXH8tKoKiOCkg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Thu, Oct 8, 2015 at 2:41 PM, Barry
            Smith <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
                 The easiest way for you to implement this is to simply
              call your update to the solution and then call SNESSolve()
              again. For example<br>
              <br>
                 while (1) {<br>
                   SNESSolve(snes,x,NULL);<br>
                   SNESGetConvergedReason(snes,&reason);<br>
                   if (reason > 0) break;  /* since snes has
              converged */<br>
                   change x per your way<br>
                }<br>
              <br>
              The problem with the code above is that each new call to
              SNESSolve() resets the rtol convergence factor based on
              the current latest norm of F so the code above will
              "oversolve" the problem. You can call SNESSetTolerance()
              above the while loop with an appropriate atol to get it to
              exit at the point you want to declare it converged.<br>
              <br>
                It is not worthwhile trying to "weave" your special
              update code inside the Newton method.</blockquote>
            <div><br>
            </div>
            <div>Do you know what the non-physical solutions are?</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"><span
                class="HOEnZb"><font color="#888888"><br>
                     Barry<br>
                </font></span>
              <div class="HOEnZb">
                <div class="h5"><br>
                  > On Oct 8, 2015, at 1:05 PM, Michael Povolotskyi
                  <<a moz-do-not-send="true"
                    href="mailto:mpovolot@purdue.edu">mpovolot@purdue.edu</a>>
                  wrote:<br>
                  ><br>
                  > Thank you.<br>
                  > The situation is as follows:<br>
                  > The system I need to solve does not have a unique
                  solution, but only one makes sense from physical point
                  of view.  I need to compute direction in a different
                  way based on the physics.<br>
                  ><br>
                  > In other words it should be like this:<br>
                  ><br>
                  > 1. Start with a solution guess<br>
                  > 2. Do full Newton step<br>
                  > 3. If converged, exit<br>
                  >    else if the solution improved go to step 2<br>
                  >    otherwise "update_solution_in_my_way" ang go
                  to step 2<br>
                  ><br>
                  > Is it possible to do this in PETSc?<br>
                  > Michael.<br>
                  ><br>
                  > On 10/08/2015 01:58 PM, Barry Smith wrote:<br>
                  >>> On Oct 8, 2015, at 12:26 PM, Michael
                  Povolotskyi <<a moz-do-not-send="true"
                    href="mailto:mpovolot@purdue.edu">mpovolot@purdue.edu</a>>
                  wrote:<br>
                  >>><br>
                  >>> Dear Petsc developers and users,<br>
                  >>> I'm solving a nonlinear system with
                  PETSc.<br>
                  >>> Often simple Newton iterations do not
                  work and I have to use either linear search or trust
                  region.<br>
                  >>> I would like to use my own algorithm to
                  find a next iteration approximation to solution if the
                  Newton step does not improve the residual. As far as I
                  can see I have to define my own SNELLineSearch object.
                  Is there any example that shows how to do it?<br>
                  >>    The line search model is 1) select
                  direction based on approximate solution of approximate
                  Jacobian  2) search in THAT direction for a decrease
                  in the function evaluation. You state "if the Newton
                  step does not improve the residual." so will you be
                  computing the DIRECTION in a different way than (1) or
                  will you be using the same direction but trying
                  somehow to find a decrease in the function evaluation
                  using a different technique then the standard line
                  searchs we provide?<br>
                  >><br>
                  >>    Frankly if the line searches we provide
                  don't work that means the direction is not good and no
                  "special" line search will recover.  I really
                  recommend you go through our suggestions on the FAQ <a
                    moz-do-not-send="true"
                    href="http://www.mcs.anl.gov/petsc/documentation/faq.html#newton"
                    rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html#newton</a>
                  on trying to figure out why Newton is not converging
                  before you think about writing a special line search.<br>
                  >><br>
                  >>   Barry<br>
                  >><br>
                  >><br>
                  >><br>
                  >>> Thank you,<br>
                  >>> Michael.<br>
                  >>><br>
                  >>> --<br>
                  >>> Michael Povolotskyi, PhD<br>
                  >>> Research Assistant Professor<br>
                  >>> Network for Computational Nanotechnology<br>
                  >>> Hall for Discover and Learning Research,
                  Room 441<br>
                  >>> West Lafayette, IN 47907<br>
                  >>> Phone <a moz-do-not-send="true"
                    href="tel:%28765%29%204949396" value="+17654949396">(765)
                    4949396</a><br>
                  >>><br>
                  ><br>
                  > --<br>
                  > Michael Povolotskyi, PhD<br>
                  > Research Assistant Professor<br>
                  > Network for Computational Nanotechnology<br>
                  > Hall for Discover and Learning Research, Room 441<br>
                  > West Lafayette, IN 47907<br>
                  > Phone <a moz-do-not-send="true"
                    href="tel:%28765%29%204949396" value="+17654949396">(765)
                    4949396</a><br>
                  ><br>
                  <br>
                </div>
              </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>
    <pre class="moz-signature" cols="72">-- 
Michael Povolotskyi, PhD
Research Assistant Professor
Network for Computational Nanotechnology
Hall for Discover and Learning Research, Room 441
West Lafayette, IN 47907
Phone (765) 4949396
</pre>
  </body>
</html>