[petsc-users] Error when using TSSetRHSJacobian+DMSetMatrixPreallocateOnly

Barry Smith bsmith at mcs.anl.gov
Wed Sep 18 10:46:05 CDT 2013


   The code did not "crash", it ended with an error message 

    
On Sep 18, 2013, at 10:32 AM, "Vijay S. Mahadevan" <vijay.m at gmail.com> wrote:

> All,
> 
> When I call DMSetMatrixPreallocateOnly

    Why are you setting this flag?  If you don't set it then the code will go through.

> and then TSSetRHSJacobian
> without a matrix input argument (NULL instead), then the code crashes
> during TSSolve and more specifically during MatDuplicate. This is
> replicable with src/ts/examples/tutorials/ex2.c. Here's the error with

   Jed is reworking the logic here so the code will change. 


> stack trace.
> 
> [0]PETSC ERROR: --------------------- Error Message
> 
> 
> I hope this is not supposed to happen. The fix seems to be to call
> TSSetRHSJacobian with a user created matrix instead of letting DM
> create one,

   There is no reason to use a user created matrix since the DM can provide the correct one. One of the "main jobs" of DM is to create that matrix so we really don't intend people to use a DM but then create the matrix themselves.

   Barry


> which rectifies this issue. This behavior feels
> inconsistent and is there a way to fix this.
> 
> Vijay
> 
> PS: Just replace the following lines in ex2.c to replicate the error.
> 
> /*  ierr = TSSetRHSJacobian(ts,A,A,RHSJacobian,&appctx);CHKERRQ(ierr); */
>  ierr = TSSetRHSJacobian(ts,NULL,NULL,RHSJacobian,&appctx);CHKERRQ(ierr);
>  ierr = DMSetMatrixPreallocateOnly(appctx.da,PETSC_TRUE);CHKERRQ(ierr);



More information about the petsc-users mailing list