[petsc-users] ts behavior question
Gideon Simpson
gideon.simpson at gmail.com
Tue Nov 12 14:09:55 CST 2019
So this might be a resolution/another question. Part of the reason to use
the da is that it provides you with ghost points. If you're only accessing
the dependent variables entries with DMDAVecGetArrayRead, then you can't
modify the ghost points. If you can't modify the ghost points here, where
would you do so in the context of a problem with, for instance, time
dependent boundary conditions?
On Tue, Nov 12, 2019 at 10:43 AM Smith, Barry F. <bsmith at mcs.anl.gov> wrote:
>
> For any vector you only read you should use the read version.
>
> Sometimes the vector may not be locked and hence the other routine can
> be used but that may change as we add more locks and improve the code. So
> best to do it right
>
> > On Nov 12, 2019, at 9:26 AM, Gideon Simpson <gideon.simpson at gmail.com>
> wrote:
> >
> > 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.
>
> I am not sure why DMDAVecGetArray would work if VecGetArray did not
> work. Internally it calls VecGetArray() that will do the check. If you call
> it on local ghosted vectors it doesn't check if the vector is locked since
> the ghosted version is a copy of the true locked vector.
>
> Barry
>
> >
> > 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
>
>
--
gideon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20191112/ce0ec8b4/attachment.html>
More information about the petsc-users
mailing list