← Back to team overview

dolfin team mailing list archive

Re: LinearPDE invalidates function

 



Anders Logg wrote:
On Fri, Feb 15, 2008 at 04:53:50PM +0000, Garth N. Wells wrote:

Dag Lindbo wrote:
Hello,

I have struggled today with a mysterious problem. It occurred in my solver, where the assembly and linear algebra happens in a different function from the output. The Function that holds the data after the call to pde.solve(u) seems to be invalidated after the LinearSolver goes out of scope.

To illustrate what I mean, I made a small modification to the Poisson demo:

   PoissonBilinearForm a;
   PoissonLinearForm L(f, g);
   LinearPDE* pde = new LinearPDE(a, L, mesh, bc); // dynamic allocation

   // Solve PDE
   Function u;
   pde->solve(u);

   // Save solution to file
   File file("poisson.pvd");
   file << u;                             // this works

   delete pde;                            // pde goes out of scope

   File file2("poisson2.pvd");
   file2 << u;                            // segfault here

I do realize that the destructor in LinearPDE does not delete the pointer!

The problem looks to be that LinearPDE owns the vector associated with the Function. This should probably be changed.

Garth

Yes, definitely (but perhaps not before the release if not someone else
has time to fix it).

It seems there has been some increased activity on the mailing list
lately (user requests, bug reports). Maybe it's time we start using
the bug tracking system more?

    http://www.fenics.org/wiki/Bugzilla

It's sometimes hard to keep track of all bugs/requests we've promised
to fix (which can sometimes be good since then we can forget about
them... :-).

So please file a bug report.

Done. Thanks for all the attention on the list this week!

  Dag


References