[petsc-users] function set by TSSetRHSJacobian() not being called

Scott Dossa doss0032 at umn.edu
Tue Aug 9 14:08:02 CDT 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160809/23609ab9/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: swift.cpp
Type: text/x-c++src
Size: 8999 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160809/23609ab9/attachment-0001.cpp>


More information about the petsc-users mailing list