[petsc-users] Jacobian free in SNES

Jed Brown jedbrown at mcs.anl.gov
Sat Nov 5 00:04:39 CDT 2011


On Fri, Nov 4, 2011 at 03:27, Konstantinos Kontzialis <ckontzialis at lycos.com
> wrote:

> I solve the NS equations with the discontinuous galerkin method. The
> system's residual before going to petsc is the following:
>
> M udot+R(u) = 0                         (1)
>
> R(u) is the part of the residual coming from the spatially discretized
> terms. I need to say that the explicit version of my code runs very well.
>
> But, I want to implement an implicit method for time marching using first
> the backward euler scheme. After linearization I get the following form:
>
> M/dt u^{n+1} + dR/du (u^{n+1}-u^{n}) = M/dt u^{n} -R(u^{n})  (2)
>

Why not just have your SNESFormFunction compute:

G(u^{n+1}) = M (u^{n+1} - u^n) / dt + R(u^{n+1}) = 0

and then J = dG/du^{n+1}?

An alternative which I recommend is to use TSSetIFunction() and
TSSetIJacobian(). Then you can run backward Euler with -ts_type beuler, but
you can also run lots of other methods, e.g. -ts_type rosw to use
Rosenbrock-W methods with adaptive error control (these also tolerate
approximations to the Jacobian, such as dropping the non-stiff convective
terms).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111104/81c4e065/attachment.htm>


More information about the petsc-users mailing list