I guess Barry meant “implicit method”. To use backward Euler, change TSEULER to TSBEULER in the function call of TSSetType().
Hong > On Aug 9, 2016, at 2:13 PM, Barry Smith <bsm...@mcs.anl.gov> wrote: > > > The Euler method is an explicit method that does not require the Jacobian. > Hence the Jacobian you provide is never used. > > If you use any implement method, for example backward Euler beuler then > you will see the Jacobian being used. > > Barry > >> On Aug 9, 2016, at 2:08 PM, Scott Dossa <doss0...@umn.edu> wrote: >> >> Hi all, >> >> I adapted ex13.c from .../ts/examples/tutorials/ex13.c to solve a 1D TD PDE >> (swift-hohenberg). >> Long story short: the function which sets the Jacobian is never being called >> despite being assigned by TSSetRHSJacobian(). >> >> I create the TS environment with the following commands (omitting some code >> before and after -- Full code attached): >> >> --------------------------------------------------------------------------------------------------------------------------------------------------------------------- >> ierr = DMDACreate1d(PETSC_COMM_WORLD, DM_BOUNDARY_NONE, 15, 1, 1, NULL, >> &da); CHKERRQ(ierr); >> >> /*================================================================== >> >> >> >> Let DMDA create vector >> >> >> >> ==================================================================*/ >> >> ierr = DMCreateGlobalVector(da, &x);CHKERRQ(ierr); >> >> /*================================================================== >> >> >> >> Create timestepper context which will use Euler Method >> >> >> >> ==================================================================*/ >> >> ierr = TSCreate(PETSC_COMM_WORLD,&ts);CHKERRQ(ierr); >> ierr = TSSetDM(ts, da);CHKERRQ(ierr); >> ierr = TSSetType(ts, TSEULER);CHKERRQ(ierr); >> >> ierr = TSSetRHSFunction(ts, x, RHSFunction, NULL);CHKERRQ(ierr); >> >> /*================================================================= >> >> >> >> Create Jacobian for Euler Method >> >> >> >> =================================================================*/ >> ierr = DMSetMatType(da, MATAIJ);CHKERRQ(ierr); >> ierr = DMCreateMatrix(da,&J);CHKERRQ(ierr); >> ierr = TSSetRHSJacobian(ts,J,J,RHSJacobian,NULL); CHKERRQ(ierr) >> --------------------------------------------------------------------------------------------------------------------------------------------------------------------- >> >> I define the function RHSJacobian later, PetscPrintf(PETSC_COMM_WORLD, >> "Jacobian function called") is used to see if the function is ever called. >> >> Neither is the message ever called, nor is the Jacobian matrix ever >> non-zero. The J matrix is checked with MatView( ). No error messages are >> produced either at compiling nor runtime. >> >> Has anyone else run into such an issue or have any advice of how best to >> probe the problem? >> Thanks so much! >> -Scott Dossa >> >> >> <swift.cpp> >