BTW, perhaps you should do the same in TSGetKSP(). What do you think? 2008/9/17 Hong Zhang <hzhang at mcs.anl.gov>: > > 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/ >> >>
-- Lisandro Dalc?n --------------- Centro Internacional de M?todos Computacionales en Ingenier?a (CIMEC) Instituto de Desarrollo Tecnol?gico para la Industria Qu?mica (INTEC) Consejo Nacional de Investigaciones Cient?ficas y T?cnicas (CONICET) PTLC - G?emes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594
