← Back to team overview

dolfin team mailing list archive

Constructing PETScVector from raw PETSc Vec?

 

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 like

	PetscErrorCode 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>? 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)
----------------------------------------------------



Follow ups