This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

<dolfin::Mesh>*: Mesh suddenly has no cells

–2 votes

Hello,
I work with swig. I have generated a mesh with python and have a c++
class with an pointer *. I handle the python Mesh with shared_ptr to the c++ class. Now I convert it by either doing mesh=&(*mesh_ptr) or by using the copy constructor.
Then I can print out the number of cells, which gives correctly 20000.
Now I call a function of my class. Printing out again the number of cells gives 0. The pointer is the same as before.
Does python delete the mesh?
How can I stop this? I need the mesh and do not want to hand it through every time.
Thanks for your help.

closed with the note: solution found
asked Apr 2, 2014 by cecilly FEniCS Novice (230 points)
closed Apr 10, 2014 by cecilly

Can you please provide a minimal code that reproduces your problem?

I found it my self. I have a UnitSquareMesh and had to change it to a Mesh to handle it to the c++ function. I didn't store the Mesh, only the UnitSquareMesh. So I suppose the garbage collector of python destroyed the object. If I store the Mesh everything works.

...