Thread Previous • Date Previous • Date Next • Thread Next |
mspieg wrote:
Hi all, A slightly strange query...I've been writing hybrid dolfin/Petsc codes (forgive me) that allow dolfin assembly routines to be used with PETSc native Non-linear solvers (SNES) which currentlyprovide a richer set of pre-conditioners and line-search algorithms than Dolfin's newton_solver. Anyway, in 0.8.1, it was possible (and very useful) to construct PETScVectors directly from a raw PETSc Vec that may be passed, for example, to a user-supplied function that might look something likePetscErrorCode FormFunction(Vec x, Vec f, ....) { PETScVector X(x), F(f); ... u.vector()=X; //assuming u is attached to form L assemble(F,L); ... } etc...Is there any way to do this now in 0.9.x where the PETScVector constructor now requires a boost::shared_ptr<Vec>?
It should work in much the same way, but you need to create a shared pointer. You can create a shared pointer to a new PETScVec object,
boost::shared_ptr<Vec> x(new Vec, NoDeleter<Vec>()); PetscVector v(x); or create a shared pointer to an existing PETScVec object, boost::shared_ptr<Vec> x(&Vec, NoDeleter<Vec>()); PetscVector v(x);In the former case, you could supply a function other than NoDeleter<Vec>() to to the clean up work for you (take a look at the top of PETScVector.cpp).
Garth I believe, I can
work around this with VecCopy, but it would be much nicer just to be able to wrap the pointer. Apologies if this is an obvious question...I'm still trying to get my head around shared_ptr and it is not clear to me that you can construct one directly from a raw pointer.as always, Any help greatly appreciated marc ---------------------------------------------------- Marc Spiegelman Lamont-Doherty Earth Observatory Dept. of Applied Physics/Applied Math Columbia University http://www.ldeo.columbia.edu/~mspieg tel: 845 704 2323 (SkypeIn) ---------------------------------------------------- ------------------------------------------------------------------------ _______________________________________________ DOLFIN-dev mailing list DOLFIN-dev@xxxxxxxxxx http://www.fenics.org/mailman/listinfo/dolfin-dev
Thread Previous • Date Previous • Date Next • Thread Next |