← Back to team overview

dolfin team mailing list archive

Re: LinearPDE invalidates function

 



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


   Dag
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev




Follow ups

References