1. petsc
  2. PETSc
  3. petsc
  4. Issues
Issue #71 resolved

Make public the Fortran interface for TaoDefaultConvergenceTest

Tianyi Li
created an issue

If the user only wants to modify certain part of the convergence test, having access to the default convergence test routine is useful.

In my case (dynamic problem where I use TAO at each time step) sometimes the solver claims to converge within zero iteration (because the initial guess, which is the solution at last time step, meets the tolerance)...but I still want it to do at least one iteration. So I can setup my own convergence test using if and TaoDefaultConvergenceTest.

diff --git a/src/tao/interface/ftn-custom/ztaosolverf.c b/src/tao/interface/ftn-custom/ztaosolverf.c
index 1baa906..dd74df9 100644
--- a/src/tao/interface/ftn-custom/ztaosolverf.c
+++ b/src/tao/interface/ftn-custom/ztaosolverf.c
@@ -22,6 +22,7 @@
 #define taoview_                            TAOVIEW
 #define taogethistory_                      TAOGETHISTORY
 #define taosetconvergencetest_              TAOSETCONVERGENCETEST
+#define taodefaultconvergencetest_          TAODEFAULTCONVERGENCETEST
 #define taogetoptionsprefix_                TAOGETOPTIONSPREFIX
 #define taosetoptionsprefix_                TAOSETOPTIONSPREFIX
 #define taoappendoptionsprefix_             TAOAPPENDOPTIONSPREFIX
@@ -47,6 +48,7 @@
 #define taoview_                            taoview
 #define taogethistory_                      taogethistory
 #define taosetconvergencetest_              taosetconvergencetest
+#define taodefaultconvergencetest_          taodefaultconvergencetest
 #define taogetoptionsprefix_                taogetoptionsprefix
 #define taosetoptionsprefix_                taosetoptionsprefix
 #define taoappendoptionsprefix_             taoappendoptionsprefix
@@ -366,6 +368,13 @@ void PETSC_STDCALL taosetconvergencetest_(Tao *tao, void (PETSC_STDCALL *func)(T

+void PETSC_STDCALL taodefaultconvergencetest_(Tao *tao, void *ctx, PetscErrorCode *ierr)
+    PetscObjectAllocateFortranPointers(*tao,NFUNCS);
+    *ierr = TaoDefaultConvergenceTest(*tao,ctx);

 void PETSC_STDCALL taosetconstraintsroutine_(Tao *tao, Vec *C, void (PETSC_STDCALL *func)(Tao*, Vec *, Vec *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr)

Comments (1)

  1. Log in to comment