PreCheck on SNES Line Search and solution constraints (PreCheck not working)

Matthew Knepley knepley at gmail.com
Fri Nov 28 13:37:50 CST 2008


On Fri, Nov 28, 2008 at 1:18 PM, Edson Tadeu <e.tadeu at gmail.com> wrote:
> Hi,
>
>   I'm using the Cubic Line Search algorithm to solve some non-linear systems
> where the solution vector is constrained to a given space, e.g., some of its
> elements are only allowed in the range 0 <= x <= 1... outside this domain,
> the evaluation of the Jacobian is "undefined", and may lead to wrong
> directions or unwanted solutions.
>
>   I'm trying to use a PreCheck to limit the value of lambda, so that the
> solution vector would never leave the domain. Is this the right approach?

Yes.

>   Anyway, I'm facing the following problem: I'm calling
> SNESLineSearchSetPreCheck(snes, MyPreCheck, ctx), but it seems that the
> PreCheck is not being set correctly... it actually never enters the
> MyPreCheck function when solving. I'm using petsc-2.3.3-p13... I've tried to
> trace the problem inside Petsc code, and it seems that the problem is that
> this line:
>
>   ierr =
> PetscObjectQueryFunction((PetscObject)snes,"SNESLineSearchSetPreCheck_C",(void
> (**)(void))&f);CHKERRQ(ierr);
>
>   is actually returning PETSC_NULL on f.
>
>
>   The calling sequence is the following:
>
>     SNESCreate
>     SNESSetFunction
>     SNESSetJacobian
>     SNESLineSearchSetPreCheck
>     SNESMonitorSet
>     SNESSetFromOptions

The problem is that the SNES type is not set until SNESSetFromOptions().
Therefore, you called SNESLineSearch*() without knowing whether the
solver actually did line searches, and thus it was ignored. If you move the
call after SetFromOptions, it should work.

   Matt

>     SNESSetApplicationContext
>     SNESSolve
>
>
>   Thanks for any help,
> Edson
>
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which
their experiments lead.
-- Norbert Wiener




More information about the petsc-users mailing list