Commits

Jed Brown committed 0e0552e Merge

Merge branch 'jed/snesgetlinesearch'

* jed/snesgetlinesearch:
SNESGetSNESLineSearch / SNESSetSNESLineSearch: mark as deprecated (C interface only)
SNESGetLineSearch / SNESSetLineSearch: rename for consistency
SNESGetSNESLineSearch: use auto Fortran binding

Comments (0)

Files changed (23)

 PETSC_EXTERN PetscErrorCode SNESGetPC(SNES,SNES*);
 PETSC_EXTERN PetscErrorCode SNESSetPCSide(SNES,PCSide);
 PETSC_EXTERN PetscErrorCode SNESGetPCSide(SNES,PCSide*);
-PETSC_EXTERN PetscErrorCode SNESSetSNESLineSearch(SNES,SNESLineSearch);
-PETSC_EXTERN PetscErrorCode SNESGetSNESLineSearch(SNES,SNESLineSearch*);
+PETSC_EXTERN PetscErrorCode SNESSetLineSearch(SNES,SNESLineSearch);
+PETSC_EXTERN PetscErrorCode SNESGetLineSearch(SNES,SNESLineSearch*);
 PETSC_EXTERN PetscErrorCode SNESRestrictHookAdd(SNES,PetscErrorCode (*)(SNES,SNES,void*),void*);
 PETSC_EXTERN PetscErrorCode SNESRestrictHooksRun(SNES,SNES);
 
+PETSC_DEPRECATED("Use SNESGetLineSearch()") PETSC_STATIC_INLINE PetscErrorCode SNESGetSNESLineSearch(SNES snes,SNESLineSearch *ls) {return SNESGetLineSearch(snes,ls);}
+PETSC_DEPRECATED("Use SNESSetLineSearch()") PETSC_STATIC_INLINE PetscErrorCode SNESSetSNESLineSearch(SNES snes,SNESLineSearch ls) {return SNESSetLineSearch(snes,ls);}
+
 PETSC_EXTERN PetscErrorCode SNESSetUpMatrices(SNES);
 PETSC_EXTERN PetscErrorCode DMSNESSetFunction(DM,PetscErrorCode(*SNESFunction)(SNES,Vec,Vec,void*),void*);
 PETSC_EXTERN PetscErrorCode DMSNESGetFunction(DM,PetscErrorCode(**SNESSetFunction)(SNES,Vec,Vec,void*),void**);

src/docs/website/documentation/changes/dev.html

         <li> Added nonlinear additive Schwarz as SNESNASM "nasm" </li>
         <li> Added helper SNES type SNESASPIN "aspin" for setting up additive Schwarz preconditioned inexact Newton.</li>
         <li> Added Anderson Mixing as SNESANDERSON "anderson"</li>
+        <li>SNESGetSNESLineSearch() and SNESSetSNESLineSearch() renamed to SNESGetLineSearch() and SNESSetLineSearch().</li>
         </ul>
 
       <h4>SNESLineSearch:</h4>

src/snes/examples/tutorials/ex15.c

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
   ierr = SNESSetFromOptions(snes);CHKERRQ(ierr);
   ierr = SNESSetGS(snes,NonlinearGS,&user);CHKERRQ(ierr);
-  ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+  ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
   /* Set up the precheck context if requested */
   if (use_precheck == 1) {      /* Use the precheck routines in this file */
     ierr = PreCheckCreate(PETSC_COMM_WORLD,&precheck);CHKERRQ(ierr);

src/snes/examples/tutorials/ex1f.F

       call PetscOptionsHasName(PETSC_NULL_CHARACTER,'-setls',setls,ierr)
 
       if (setls) then
-        call SNESGetSNESLineSearch(snes, linesearch, ierr)
+        call SNESGetLineSearch(snes, linesearch, ierr)
         call SNESLineSearchSetType(linesearch, "shell", ierr)
         call SNESLineSearchShellSetUserFunc(linesearch, MyLineSearch,   &
      &PETSC_NULL_OBJECT, ierr)

src/snes/examples/tutorials/ex3.c

      Set an optional user-defined routine to check the validity of candidate
      iterates that are determined by line search methods
   */
-  ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+  ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
   ierr = PetscOptionsHasName(NULL,"-post_check_iterates",&post_check);CHKERRQ(ierr);
 
   if (post_check) {

src/snes/impls/fas/fas.c

     }
     ierr = PetscObjectCopyFortranFunctionPointers((PetscObject)snes, (PetscObject)fas->smoothd);CHKERRQ(ierr);
     ierr = SNESSetFromOptions(fas->smoothd);CHKERRQ(ierr);
-    ierr = SNESGetSNESLineSearch(snes,&linesearch);CHKERRQ(ierr);
-    ierr = SNESGetSNESLineSearch(fas->smoothd,&slinesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes,&linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(fas->smoothd,&slinesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchGetPreCheck(linesearch,&precheck,&lsprectx);CHKERRQ(ierr);
     ierr = SNESLineSearchGetPostCheck(linesearch,&postcheck,&lspostctx);CHKERRQ(ierr);
     ierr = SNESLineSearchSetPreCheck(slinesearch,precheck,lsprectx);CHKERRQ(ierr);
     }
     ierr = PetscObjectCopyFortranFunctionPointers((PetscObject)snes, (PetscObject)fas->smoothu);CHKERRQ(ierr);
     ierr = SNESSetFromOptions(fas->smoothu);CHKERRQ(ierr);
-    ierr = SNESGetSNESLineSearch(snes,&linesearch);CHKERRQ(ierr);
-    ierr = SNESGetSNESLineSearch(fas->smoothu,&slinesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes,&linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(fas->smoothu,&slinesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchGetPreCheck(linesearch,&precheck,&lsprectx);CHKERRQ(ierr);
     ierr = SNESLineSearchGetPostCheck(linesearch,&postcheck,&lspostctx);CHKERRQ(ierr);
     ierr = SNESLineSearchSetPreCheck(slinesearch,precheck,lsprectx);CHKERRQ(ierr);
     if (!next->vec_sol) {ierr = SNESFASCreateCoarseVec(snes,&next->vec_sol);CHKERRQ(ierr);}
     if (!next->vec_rhs) {ierr = SNESFASCreateCoarseVec(snes,&next->vec_rhs);CHKERRQ(ierr);}
     ierr = PetscObjectCopyFortranFunctionPointers((PetscObject)snes, (PetscObject)next);CHKERRQ(ierr);
-    ierr = SNESGetSNESLineSearch(snes,&linesearch);CHKERRQ(ierr);
-    ierr = SNESGetSNESLineSearch(fas->next,&slinesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes,&linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(fas->next,&slinesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchGetPreCheck(linesearch,&precheck,&lsprectx);CHKERRQ(ierr);
     ierr = SNESLineSearchGetPostCheck(linesearch,&postcheck,&lspostctx);CHKERRQ(ierr);
     ierr = SNESLineSearchSetPreCheck(slinesearch,precheck,lsprectx);CHKERRQ(ierr);
   /* set up the default line search for coarse grid corrections */
   if (fas->fastype == SNES_FAS_ADDITIVE) {
     if (!snes->linesearch) {
-      ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+      ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
       ierr = SNESLineSearchSetType(linesearch, SNESLINESEARCHL2);CHKERRQ(ierr);
     }
   }

src/snes/impls/ls/ls.c

   snes->iter = 0;
   snes->norm = 0.0;
   ierr       = PetscObjectAMSGrantAccess((PetscObject)snes);CHKERRQ(ierr);
-  ierr       = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+  ierr       = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
   if (!snes->vec_func_init_set) {
     ierr = SNESComputeFunction(snes,X,F);CHKERRQ(ierr);
     ierr = SNESGetFunctionDomainError(snes, &domainerror);CHKERRQ(ierr);
   ierr = PetscOptionsTail();CHKERRQ(ierr);
   /* set the default line search type */
   if (!snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchSetType(linesearch, SNESLINESEARCHBT);CHKERRQ(ierr);
   }
   PetscFunctionReturn(0);

src/snes/impls/nasm/aspin.c

   ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);
   ierr = PCSetType(pc,PCNONE);CHKERRQ(ierr);
   ierr = PetscObjectGetComm((PetscObject)snes,&comm);CHKERRQ(ierr);
-  ierr = SNESGetSNESLineSearch(snes,&linesearch);CHKERRQ(ierr);
+  ierr = SNESGetLineSearch(snes,&linesearch);CHKERRQ(ierr);
   ierr = SNESLineSearchSetType(linesearch,SNESLINESEARCHBT);CHKERRQ(ierr);
 
   /* set up the shell matrix */

src/snes/impls/ncg/snesncg.c

   }
   ierr = PetscOptionsTail();CHKERRQ(ierr);
   if (!snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
     if (!snes->pc) {
       ierr = SNESLineSearchSetType(linesearch, SNESLINESEARCHCP);CHKERRQ(ierr);
     } else {
   F      = snes->vec_func;           /* residual vector */
   B      = snes->vec_rhs;            /* the right hand side */
 
-  ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+  ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
 
   ierr       = PetscObjectAMSTakeAccess((PetscObject)snes);CHKERRQ(ierr);
   snes->iter = 0;

src/snes/impls/ngmres/anderson.c

   ierr = PetscOptionsTail();CHKERRQ(ierr);
   /* set the default type of the line search if the user hasn't already. */
   if (!snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes,&linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes,&linesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchSetType(linesearch,SNESLINESEARCHBASIC);CHKERRQ(ierr);
   }
   PetscFunctionReturn(0);

src/snes/impls/ngmres/snesngmres.c

 
   /* set the default type of the line search if the user hasn't already. */
   if (!snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes,&linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes,&linesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchSetType(linesearch,SNESLINESEARCHBASIC);CHKERRQ(ierr);
   }
   PetscFunctionReturn(0);

src/snes/impls/qn/qn.c

                           (PetscEnum)qn->type,(PetscEnum*)&qn->type,NULL);CHKERRQ(ierr);
   ierr = PetscOptionsTail();CHKERRQ(ierr);
   if (!snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchSetType(linesearch, SNESLINESEARCHCP);CHKERRQ(ierr);
   }
   if (monflg) {

src/snes/impls/richardson/snesrichardson.c

   ierr = PetscOptionsHead("SNES Richardson options");CHKERRQ(ierr);
   ierr = PetscOptionsTail();CHKERRQ(ierr);
   if (!snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchSetType(linesearch, SNESLINESEARCHL2);CHKERRQ(ierr);
   }
   PetscFunctionReturn(0);

src/snes/impls/vi/rs/virs.c

 
   /* set the line search functions */
   if (!snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchSetType(linesearch, SNESLINESEARCHBT);CHKERRQ(ierr);
   }
   PetscFunctionReturn(0);

src/snes/impls/vi/ss/viss.c

   ierr = PetscOptionsTail();CHKERRQ(ierr);
   /* set up the default line search */
   if (!snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchSetType(linesearch, SNESLINESEARCHBT);CHKERRQ(ierr);
     ierr = SNESLineSearchBTSetAlpha(linesearch, 0.0);CHKERRQ(ierr);
   }

src/snes/impls/vi/vi.c

     ierr = SNESMonitorSet(snes,SNESMonitorVI,0,0);CHKERRQ(ierr);
   }
   if (!snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchSetType(linesearch, SNESLINESEARCHBT);CHKERRQ(ierr);
     ierr = SNESLineSearchBTSetAlpha(linesearch, 0.0);CHKERRQ(ierr);
   }

src/snes/interface/ftn-custom/zsnesf.c

 #define snesmonitorlgresidualnorm_       SNESMONITORLGRESIDUALNORM
 #define snesmonitorsolutionupdate_       SNESMONITORSOLUTIONUPDATE
 #define snesmonitorset_                  SNESMONITORSET
-#define snesgetsneslinesearch_           SNESGETSNESLINESEARCH
 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
 #define matmffdcomputejacobian_          matmffdcomputejacobian
 #define snessolve_                       snessolve
 #define snesmonitorsolution_             snesmonitorsolution
 #define snesmonitorsolutionupdate_       snesmonitorsolutionupdate
 #define snesmonitorset_                  snesmonitorset
-#define snesgetsneslinesearch_           snesgetsneslinesearch
 #endif
 
 static struct {
   }
 }
 
-PETSC_EXTERN void PETSC_STDCALL snesgetsneslinesearch_(SNES *snes,SNESLineSearch *linesearch, int *__ierr)
-{
-  *__ierr = SNESGetSNESLineSearch(*snes, linesearch);
-}
-

src/snes/interface/snes.c

   }
   if (snes->linesearch) {
     ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
-    ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchView(linesearch, viewer);CHKERRQ(ierr);
     ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
   }
   ierr = KSPSetFromOptions(snes->ksp);CHKERRQ(ierr);
 
   if (!snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes, &snes->linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes, &snes->linesearch);CHKERRQ(ierr);
   }
   ierr = SNESLineSearchSetFromOptions(snes->linesearch);CHKERRQ(ierr);
 
   }
 
   if (!snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes, &snes->linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes, &snes->linesearch);CHKERRQ(ierr);
   }
 
   if (snes->pc && (snes->pcside == PC_LEFT)) {
     ierr = SNESSetFromOptions(snes->pc);CHKERRQ(ierr);
 
     /* copy the line search context over */
-    ierr = SNESGetSNESLineSearch(snes,&linesearch);CHKERRQ(ierr);
-    ierr = SNESGetSNESLineSearch(snes->pc,&pclinesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes,&linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes->pc,&pclinesearch);CHKERRQ(ierr);
     ierr = SNESLineSearchGetPreCheck(linesearch,&precheck,&lsprectx);CHKERRQ(ierr);
     ierr = SNESLineSearchGetPostCheck(linesearch,&postcheck,&lspostctx);CHKERRQ(ierr);
     ierr = SNESLineSearchSetPreCheck(pclinesearch,precheck,lsprectx);CHKERRQ(ierr);
   ierr = PetscObjectSetOptionsPrefix((PetscObject)snes,prefix);CHKERRQ(ierr);
   if (!snes->ksp) {ierr = SNESGetKSP(snes,&snes->ksp);CHKERRQ(ierr);}
   if (snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes,&snes->linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes,&snes->linesearch);CHKERRQ(ierr);
     ierr = PetscObjectSetOptionsPrefix((PetscObject)snes->linesearch,prefix);CHKERRQ(ierr);
   }
   ierr = KSPSetOptionsPrefix(snes->ksp,prefix);CHKERRQ(ierr);
   ierr = PetscObjectAppendOptionsPrefix((PetscObject)snes,prefix);CHKERRQ(ierr);
   if (!snes->ksp) {ierr = SNESGetKSP(snes,&snes->ksp);CHKERRQ(ierr);}
   if (snes->linesearch) {
-    ierr = SNESGetSNESLineSearch(snes,&snes->linesearch);CHKERRQ(ierr);
+    ierr = SNESGetLineSearch(snes,&snes->linesearch);CHKERRQ(ierr);
     ierr = PetscObjectAppendOptionsPrefix((PetscObject)snes->linesearch,prefix);CHKERRQ(ierr);
   }
   ierr = KSPAppendOptionsPrefix(snes->ksp,prefix);CHKERRQ(ierr);
 }
 
 #undef __FUNCT__
-#define __FUNCT__ "SNESSetSNESLineSearch"
+#define __FUNCT__ "SNESSetLineSearch"
 /*@
-  SNESSetSNESLineSearch - Sets the linesearch on the SNES instance.
+  SNESSetLineSearch - Sets the linesearch on the SNES instance.
 
   Collective on SNES
 
 - linesearch   - the linesearch object
 
   Notes:
-  Use SNESGetSNESLineSearch() to retrieve the preconditioner context (for example,
+  Use SNESGetLineSearch() to retrieve the preconditioner context (for example,
   to configure it using the API).
 
   Level: developer
 
 .keywords: SNES, set, linesearch
-.seealso: SNESGetSNESLineSearch()
+.seealso: SNESGetLineSearch()
 @*/
-PetscErrorCode SNESSetSNESLineSearch(SNES snes, SNESLineSearch linesearch)
+PetscErrorCode SNESSetLineSearch(SNES snes, SNESLineSearch linesearch)
 {
   PetscErrorCode ierr;
 
 }
 
 #undef __FUNCT__
-#define __FUNCT__ "SNESGetSNESLineSearch"
-/*@C
-  SNESGetSNESLineSearch - Returns a pointer to the line search context set with SNESSetLineSearch()
+#define __FUNCT__ "SNESGetLineSearch"
+/*@
+  SNESGetLineSearch - Returns a pointer to the line search context set with SNESSetLineSearch()
   or creates a default line search instance associated with the SNES and returns it.
 
   Not Collective
   Level: developer
 
 .keywords: SNES, get, linesearch
-.seealso: SNESSetSNESLineSearch()
+.seealso: SNESSetLineSearch()
 @*/
-PetscErrorCode SNESGetSNESLineSearch(SNES snes, SNESLineSearch *linesearch)
+PetscErrorCode SNESGetLineSearch(SNES snes, SNESLineSearch *linesearch)
 {
   PetscErrorCode ierr;
   const char     *optionsprefix;

src/snes/linesearch/impls/shell/linesearchshell.c

 $
 $  ...
 $
-$  ierr = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
+$  ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
 $  ierr = SNESLineSearchSetType(linesearch, SNESLINESEARCHSHELL);CHKERRQ(ierr);
 $  ierr = SNESLineSearchShellSetUserFunc(linesearch, shellfunc, NULL);CHKERRQ(ierr);
 

src/snes/linesearch/interface/linesearch.c

 
    Notes:
    This happens automatically when the line search is gotten/created with
-   SNESGetSNESLineSearch().  This routine is therefore mainly called within SNES
+   SNESGetLineSearch().  This routine is therefore mainly called within SNES
    implementations.
 
    Level: developer

src/ts/examples/tutorials/ex22.c

    * this problem is linear, we deactivate the line search. For a linear problem, it is usually recommended to also use
    * SNESSetType(snes,SNESKSPONLY). */
   ierr = TSGetSNES(ts,&snes);CHKERRQ(ierr);
-  ierr = SNESGetSNESLineSearch(snes,&linesearch);CHKERRQ(ierr);
+  ierr = SNESGetLineSearch(snes,&linesearch);CHKERRQ(ierr);
   ierr = SNESLineSearchSetType(linesearch,SNESLINESEARCHBASIC);CHKERRQ(ierr);
 
   ftime    = 1.0;

src/ts/examples/tutorials/ex22f.F

       call TSSetIJacobian(ts,J,J,FormIJacobian,user,ierr)
 
       call TSGetSNES(ts,snes,ierr)
-      call SNESGetSNESLineSearch(snes,linesearch,ierr)
+      call SNESGetLineSearch(snes,linesearch,ierr)
       call SNESLineSearchSetType(linesearch,SNESLINESEARCHBASIC,ierr)
 
       ftime = 1.0

src/ts/examples/tutorials/ex27.c

   ierr = TSSetFromOptions(ts);CHKERRQ(ierr);
 
   ierr = TSGetSNES(ts,&snes);CHKERRQ(ierr);
-  ierr = SNESGetSNESLineSearch(snes,&linesearch);CHKERRQ(ierr);
+  ierr = SNESGetLineSearch(snes,&linesearch);CHKERRQ(ierr);
   ierr = SNESLineSearchSetPostCheck(linesearch, ReactingFlowPostCheck, (void*)&ctx);CHKERRQ(ierr);
   ierr = SNESSetFromOptions(snes);CHKERRQ(ierr);
   ierr = TSSolve(ts,x);CHKERRQ(ierr);