On Wed, Apr 09, 2008 at 06:32:48PM +0100, Garth N. Wells wrote: > > > Anders Logg wrote: > > On Wed, Apr 09, 2008 at 06:14:35PM +0200, Ola Skavhaug wrote: > >> Dag Lindbo skrev den 09/04-2008 følgende: > >>> Hello again! > >>> > >>> Why is it not possible any longer to get the Vector associated with a > >>> Function? E.g: > >>> > >>> #include <dolfin.h> > >>> using namespace dolfin; > >>> > >>> int main() > >>> { > >>> Function u; > >>> Vector& v = u.vector(); > >>> } > >> int main() > >> { > >> Function u; > >> Vector v; > >> v = u.vector(); > >> return 0; > >> } > >> > >> Should work. A Function returns a GenericVector reference, and the Vector > >> reference needs to be a Vector. Then the operator= in Vector is applied in > >> the > >> assignment. > >> > >> Ola > > > > I don't think one should need to make a copy of the vector. It should > > work to either use the vector you get by calling vector() directly, > > for example > > > > solve(A, u.vector(), b); // Doesn't work currently but it should! > > > > You may also do > > > > GenericVector& x = u.vector(); > > > > This works. Can someone remind me how to convert a GenericVector into > the underlying vector type( e.g. a uBlasVector or a PETScVector)? > > Garth
If x is a GenericVector, then PETScVector* xx = dynamic_cast<PETScVector*>(&x); if (xx == 0) error("Not a PETSc Vector."); -- Anders _______________________________________________ DOLFIN-dev mailing list DOLFIN-dev@fenics.org http://www.fenics.org/mailman/listinfo/dolfin-dev