[petsc-dev] major changes to DA in PETSc-dev

Jed Brown jed at 59A2.org
Mon Oct 18 06:26:56 CDT 2010


On Mon, Oct 18, 2010 at 03:25, Barry Smith <bsmith at mcs.anl.gov> wrote:

> DAXXX() routines are now either DMXXX() or DMDAXXX() see petscdm.h for
> details


I'm a little concerned about this because all of these have implicit
downcasting with no RTTI, so they are all totally unsafe.  When DA was a
distinct type, you couldn't call DAGetCorners with a DM that was not also a
DA.  Now the user has a generic DM, but almost every call they will make is
a memory error if their DM is not DMDA.  It could be made runtime-safe by
putting RTTI guards at the top of every public DMDA* function, but runtime
type checking is not as good as compile-time if the latter is reasonably
achievable.

Note that PETSc itself (for multigrid, DD, etc) works almost exclusively
with the DM API and should not need to call the DMDA API directly
(specialization is via DMOps).  In contrast, user code is specialized to a
particular implementation of DM, and pretty much always uses the specialized
API.  The old API was safer because the API that the user called was
explicitly specialized, rather than implicitly downcasted from DM.

Of course I agree that DM organization was messy, but I'm not convinced that
this change is an improvement for the user since it gives up a lot of safety
and offers little in return.

Jed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20101018/a9b01d10/attachment.html>


More information about the petsc-dev mailing list