[petsc-users] Question about TSSetRHSJacobian for linear time dependent problem
Zhang, Hong
hongzhang at anl.gov
Fri Jan 25 19:29:09 CST 2019
On Jan 25, 2019, at 4:51 PM, Sajid Ali via petsc-users <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>> wrote:
Hi,
If I have a linear time dependent equation I'm trying to solve using TS, I can use :
TSSetProblemType(ts,TS_LINEAR);
TSSetRHSFunction(ts,NULL,TSComputeRHSFunctionLinear,NULL);
TSSetRHSJacobian(ts,A,A,YourComputeRHSJacobian, &appctx);
If the matrix that's being evaluated by YourComputeRHSJacobian is such that the non-zero structure stays the same and only the diagonal changes with time, is there a way to optimize the function so that it doesn't create the whole matrix from scratch each time ?
The matrix A should be created only once before TSSetRHSJacobian() is called. YourComputeRHSJacobian() does not need to create the whole matrix each time; it updates the values in A and assembles it.
Naively I can make a dummy matrix and store the copy from t=0 and change the diagonal at each iteration but that unnecessarily doubles the memory consumption, is there a better way?
A is the working matrix storing the Jacobian. The matrix passed to YourComputeRHSJacobian() is actually A. There is no need to save an extra copy.
Hong (Mr.)
Thank You,
Sajid Ali
Applied Physics
Northwestern University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190126/b18ddc91/attachment.html>
More information about the petsc-users
mailing list