About SNES solver of TS objects

Hong Zhang hzhang at mcs.anl.gov
Tue Sep 16 22:06:27 CDT 2008


TSGetSNES() must be called after TSSetType(),
otherwise the nonlinear context 'snes' is
being created.
Attached please find updated ex7.c, which
illustrates how to set uer-defined SNESMonitor().

This example is pushed to petsc-dev.
I also added an error flag in petsc-dev to prevent
calling of TSGetSNES() before TSSetType().
Thanks for reporting the problem!

Best,

Hong

On Fri, 12 Sep 2008, tsjb00 wrote:

>
> Many thanks for your reply! The code I tried was very similar to the code in:
> ts/examples/tutorials/ex7.c
> except that I changed the r.h.s. function.
>
> The code related to TS:
>     ierr = TSCreate(PETSC_COMM_WORLD,&ts);CHKERRQ(ierr);
>     ierr = TSSetProblemType(ts,TS_NONLINEAR);CHKERRQ(ierr);
>     ierr = TSSetRHSFunction(ts,FormFunction,&appctx);CHKERRQ(ierr);
>
>     ierr = DAGetColoring(appctx.da,IS_COLORING_GLOBAL,&iscoloring);CHKERRQ(ierr);
>     ierr = MatFDColoringCreate(J,iscoloring,&matfdcoloring);CHKERRQ(ierr);
>     ierr = ISColoringDestroy(iscoloring);CHKERRQ(ierr);
>     ierr = MatFDColoringSetFunction(matfdcoloring,(PetscErrorCode (*)(void))FormFunction,&appctx);CHKERRQ(ierr);
>     ierr = MatFDColoringSetFromOptions(matfdcoloring);CHKERRQ(ierr);
>     ierr = TSSetRHSJacobian(ts,J,J,TSDefaultComputeJacobianColor,matfdcoloring);CHKERRQ(ierr);
>
>     dt = appctx.dtmin;
>     ierr = TSSetInitialTimeStep(ts,0.0,dt);CHKERRQ(ierr);
>      ierr = TSSetType(ts,TS_BEULER);CHKERRQ(ierr);
>
> Then I tried to add the snes monitor:
>   PetscViewerASCIIOpen(PETSC_COMM_WORLD,"snes.log",&rviewer);
>    ierr = TSGetSNES(ts,&ts_snes);
>    ierr = SNESMonitorSet(ts_snes,SNESMonitorDefault,&rviewer,PETSC_NULL);
> I got the snes.log with long lines which started with countless blank/space and ended at the very end with the SNES iteration info.  As a result, the file took a lot of memory space even with one line of outputs.
>
> Please let me know if I did something wrong.
>
> Have a nice weekend!
>
>
> _________________________________________________________________
> аæÊÖ»úMSN£¬Âú×ãÄã¶à²ÊÐèÇ󣡲μÓÇÀÏÊÌåÑé»î¶¯£¬ÁìÈ¡ÌØÉ«½±Æ·£¡
> http://mobile.msn.com.cn/
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex7.c
Type: text/x-csrc
Size: 11109 bytes
Desc: ex7.c
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20080916/66422e64/attachment.c>


More information about the petsc-users mailing list