[petsc-users] ts behavior question

Gideon Simpson gideon.simpson at gmail.com
Tue Nov 12 09:26:21 CST 2019


So, in principle, should we actually be using DMDAVecGetArrayRead in this
context?  I seem to be able to get away with DMDAVecGetArray with all time
steppers.

On Tue, Nov 12, 2019 at 12:33 AM Smith, Barry F. <bsmith at mcs.anl.gov> wrote:

>
>
> > On Nov 11, 2019, at 7:00 PM, Gideon Simpson via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
> >
> > I noticed that when I am solving a problem with the ts and I am *not*
> using a da, if I want to use an implicit time stepping routine:
> > 1. I have to explicitly provide the Jacobian
>
>    Yes
>
> > 2. When I do provide the Jacobian, if I want to access the elements of
> x(t) to construct f(t,x), I need to use a const PetscScalar and a
> VecGetArrayRead to get it to work.
>
>   Presumably you call VecGetArray() instead?
> >
> >
> > 3.  My code works without declaring const when I'm using an explicit
> scheme.
> >
> > In contrast, if I solve a problem using a da, my code works, I can use
> implicit schemes without having to provide the Jacobian, and I don't have
> to use const anywhere.
>
>   The use with DMDA provides automatic routines for computing the needed
> Jacobians using finite differencing of your provided function and coloring
> of the Jacobian. This results in reasonably efficient computation of
> Jacobians that work in most  (almost all) cases.
> >
> > Can someone clarify what is expected/preferred?
>
>   You should always use VecGetArrayRead() for vectors you are accessing
> but NOT changing the values in. There is no reason not and it provides the
> potential for higher performance.
>
>   The algebraic solvers have additional checks to prevent peopled from
> inadvertently changing the entries in x (which would produce bugs).
> Presumably this results in generating an error when you call VecGetArray().
> At least some of the TS explicit calls do not have such checks. They could
> be added and should be added.  https://gitlab.com/petsc/petsc/issues/493
>
>   Thanks for pointing out the inconsistency
>
>   Barry
>
> >
> > --
> > gideon
>
>

-- 
gideon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20191112/351d07d4/attachment.html>


More information about the petsc-users mailing list