[petsc-users] ksp_monitor_true_residual_norm
Matthew Knepley
knepley at gmail.com
Tue Apr 17 12:39:32 CDT 2012
On Tue, Apr 17, 2012 at 1:27 PM, Randall Mackie <rlmackie862 at gmail.com>wrote:
> Hi Barry,
>
> I've tried implementing this in Fortran, following ex2f.F in
> /src/ksp/ksp/examples/tutorials, but
> it is bombing out with the following message:
>
> ---------------------- Error Message ------------------------------------
> [0]PETSC ERROR: Invalid argument!
> [0]PETSC ERROR: Wrong type of object: Parameter # 1!
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 5, Sat Oct 29 13:45:54
> CDT 2011
> -------------------- Error Message ------------------------------------
> [0]PETSC ERROR: Invalid argument!
> [0]PETSC ERROR: Wrong type of object: Parameter # 1!
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 5, Sat Oct 29 13:45:54
> CDT 2011
>
>
> [1]PETSC ERROR: PetscViewerASCIIAddTab() line 277 in
> src/sys/viewer/impls/ascii/filev.c
> [1]PETSC ERROR: KSPMonitorTrueResidualNorm() line 233 in
> src/ksp/ksp/interface/iterativ.c
> [1]PETSC ERROR: ourmonitor() line 103 in
> src/ksp/ksp/interface/ftn-custom/zitfuncf.c
> [1]PETSC ERROR: KSPMonitor() line 1429 in src/ksp/ksp/interface/itfunc.c
> [1]PETSC ERROR: KSPSolve_CG() line 255 in src/ksp/ksp/impls/cg/cg.c
> [1]PETSC ERROR: KSPSolve() line 423 in src/ksp/ksp/interface/itfunc.c
>
>
> I am running PETSC 3.2-p5.
>
> I have set my monitor routine as follows:
>
> subroutine ShellKSPMonitor(ksp, n, rnorm, dummy, ierr)
>
> implicit none
>
> #include "finclude/petsc.h"
>
> KSP :: ksp
> PetscErrorCode :: ierr
> PetscInt :: n, dummy
> PetscReal :: rnorm
>
> if (n == 200) then
> call KSPMonitorTrueResidualNorm(ksp,n,rnorm,dummy,ierr)
>
I think it should work if dummy is 0, but we should really do NULL
conversion
here and you should pass PETSC_NULL.
Matt
> end if
>
> return
> end subroutine ShellKSPMonitor
>
> And then in the main program I call:
>
> call KSPMonitorSet(ksp,ShellKSPMonitor,PETSC_NULL_OBJECT,
> PETSC_NULL_FUNCTION, ierr)
>
> As I have followed the example in the PETSc documentation, I am unsure
> where I have made a mistake.
>
> Thanks,
>
> Randy M
>
>
> On Fri, Apr 13, 2012 at 5:01 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
>>
>> Write a one line monitor that calls the true residual monitor when
>> desired:
>>
>> PetscErrorCode myKSPMonitorTrueResidualNorm(KSP ksp,PetscInt
>> n,PetscReal rnorm,void *dummy)
>> {
>> if (n % 10) {
>> ierr =
>> KSPMonitorTrueResidualNorm(ksp,n,rnorm,dummy);CHKERRQ(ierr);
>> }
>> }
>>
>> then call this on the KPS
>>
>> ierr =
>> KSPMonitorSet(ksp,myKSPMonitorTrueResidualNorm,PETSC_VIEWER_STDOUT,0);CHKERRQ(ierr);
>>
>>
>> On Apr 13, 2012, at 6:52 PM, Randall Mackie wrote:
>>
>> > In using ksp_monitor_true_residual_norm, is it possible to change how
>> often this information is printed out?
>> > That is, instead of every iteration, say I only want to see it every 10
>> or 20 iterations. Is there an easy way
>> > to do this, other than creating my own monitor and doing it myself?
>> >
>> > Thanks, Randy M.
>>
>>
>
--
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120417/a778e32a/attachment.htm>
More information about the petsc-users
mailing list