[petsc-users] Question about TSSetRHSJacobian for linear time dependent problem
Smith, Barry F.
bsmith at mcs.anl.gov
Sun Jan 27 16:41:02 CST 2019
> On Jan 27, 2019, at 4:26 PM, Sajid Ali <sajidsyed2021 at u.northwestern.edu> wrote:
>
> The form is u_t = A(t)u.
Got it.
You can call TSRHSJacobianSetReuse() after you create the TS object and then each time your compute jacobian is called it will be passed the same matrix as before. Then you can use MatDiagonalSet() to change only the diagonal values. Good luck.
Barry
>
> On Sun, Jan 27, 2019 at 4:24 PM Smith, Barry F. <bsmith at mcs.anl.gov> wrote:
>
>
> > On Jan 25, 2019, at 4:51 PM, Sajid Ali via petsc-users <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 ?
>
> If it is a linear PDE u_t = A u then how can A change with time? It sounds like it really isn't a linear problem?
>
> Barry
>
> >
> > 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?
> >
> >
> > Thank You,
> > Sajid Ali
> > Applied Physics
> > Northwestern University
>
>
>
> --
> Sajid Ali
> Applied Physics
> Northwestern University
More information about the petsc-users
mailing list