On Thu, 2 Jun 2011, Vijay S. Mahadevan wrote:

> I have a question related to this. Since PetscVector does not provide
> a const version of vec(), what do you do when all you have is a const
> PetscVector, for example in the residual/assembly but want to access
> the vec() explicitly ? Petsc does not have any "const" qualifiers and
> so this needs a hack like const_cast. Is there a good suggestion to
> get around this ?

Make vec() const?  That's an accessor method that was added in 2005
when Ben was still refactoring the basic numerics classes, not a
tradition we need to preserve.  ;-)

We've already got a bunch of places where libMesh does a const_cast to
make a nonconst-that-we-know-PETSc-will-treat-as-const before passing
to their API.  (Not to pick on PETSc - we do the same for SLEPc and
Laspack and Trilinos and BLAS calls; are we some kind of oddball
nitpickers for using the const keyword in math software?)

Since there's no way to distinguish between a non-const and a const
Vec (IIRC Vec is a typedef to a pointer anyway), and since anyone
handling raw Vecs is already in "taking responsibility for your own
actions" territory, I see no reason not to hand out a Vec from a const
PetscVector.
---
Roy

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today. 
http://p.sf.net/sfu/quest-dev2dev2 
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to