Adding PetscMap getters
Barry Smith
bsmith at mcs.anl.gov
Fri Aug 22 10:14:14 CDT 2008
Dave,
This has been a controversial issue over the years. We didn't
have a map concept, it was introduced, it was then
"hidden". The fact that there exist public PetscMap functions at all
is my compromise for a persistent user.
Two key "rules" I use in making decisions in PETSc code are:
1) try really really hard to minimize the number of abstract objects
in the PETSc interface (this is because I believe
the difficulty of using a "class" library grows exponentially
with the number of abstract objects in the interface)
(obviously not everyone believes this, it seems most class
libraries add new classes at the drop of a hat)
2) there should be ONE way to do each operation in the package (this
is because I believe having multiple ways to
do the same thing is confusing to most users). For example, to set
the size of a vector you can only use VecSetSizes(),
to solve a nonlinear system you call SNESSolve()*.
If we bring PetscMap up as "first class user object" this violates
both 1 and 2. It is a new basic object and manipulating/accessing
Vec/Mat size information would have TWO ways of doing everything:
VecGetSizes(), VecGetPetscMap() -> PetscMapGetSizes() etc.
I actually dream about the opposite; shrinking PetscMap down so it is
so small it can be strangled in a bathtub. I tried once
to remove the VecGetSizes() etc and have access only through PetscMap
(to satisfy rule 2) but ended up removing the public
PetscMap because I didn't see having PetscMap as the basic "layout
definer" as a good PETSc interface.
So my answer is, I really do not want to add these getters. you
really have to convince me that the PetscMap object
is so fundamentally powerful it is worth violating 1 and 2.
Barry
Note that the PetscMap() methods are prototyped in vecimpl.h,
indicating they are not public methods for PETSc.
*sadly there is also DMMGSolve(), this I view as an interface bug and
dream about someday merging this functionality
back to the SNES.
On Aug 21, 2008, at 5:52 PM, Dave May wrote:
> Hello,
> Would it be possible to have the following small getters added to
> petsc-dev?
> VecGetOwnershipRanges()
> Since we are just manipulating the maps why not include the
> following as well
> VecGetMap()
> MatGetRowMap()
> MatGetColumnMap()
>
> It seems reasonable to add these (to me at least) given there a few
> interfaces for
> PetscMap already made public.
>
> Cheers,
> Dave.
>
More information about the petsc-dev
mailing list