How to clear data of triangulation completely

24 views
Skip to first unread message

Felix Lorenz

unread,
Aug 1, 2017, 1:26:00 PM8/1/17
to deal.II User Group
Hello everybody,
I have the following problem:

Class C{
 
...

  Triangulation <1,2>            boundary_triangulation;

  FE_Q<1,2>                      boundary_fe;                    

 DoFHandler <1,2>               boundary_dof_handler;
  MappingQGeneric <1,2>          boundary_map;    
 
...              
 /

  void run ();
}

void C::run(){

 for (unsigned int cycle=0; cycle< ncycles; ++cycle)  //works for ncycles=1, error for ncycles > 1

{

   boundary_triangulation.create_triangulation (vertices, cells, SubCellData());// for every cycle I have here other vertices and cells to create
                                                                               
// a new triangulation

  ... //here I do some finite element calculation, it works
   
...

   boundary_dof_handler.clear();
   boundary_triangulation.clear();// Reset this triangulation into a virgin state by deleting all data. This operation is only allowed if no    
                                  //subscriptions to this object exist any more, such as DoFHandler objects using it

}
}

After the call of boundary_triangulation.clear() lots of vertices and cells are still stored by boundary_triangulation. Resulting to this I get the error in the function create_triangulation:

"You have a vertex in your triangulation " "at which more than two cells come together. "

 
How can I delete the data of the triangulation completely? Why does the clear() function not delete all data?

Best regards 
Felix



Bruno Turcksin

unread,
Aug 1, 2017, 4:40:40 PM8/1/17
to deal.II User Group
Felix,

it should work. I have done something similar in the past. Can you send a small example that shows the problem.

Best,

Bruno

Jean-Paul Pelteret

unread,
Aug 2, 2017, 1:38:01 AM8/2/17
to deal.II User Group
Dear Felix,

Like Bruno said, if you call clear() on the triangulation at the end of this cycle then it should work. Here you can see that regardless of what other objects are "subscribed" (i.e. dependent on) the triangulation, the call to clear() will should the triangulation. 

This is the area around which your code is failing - are you sure that the data that you're trying to build the triangulation with on the second cycle is valid? You could also try to create a brand new triangulation in each cycle iteration and then use boundary_triangulation.copy_from(new_triangulation) to transfer the mesh to the primary triangulation. This would confirm whether or not you have a valid mesh each time you call create_triangulation().

Kind regards,
Jean-Paul

Felix Lorenz

unread,
Aug 2, 2017, 5:17:21 AM8/2/17
to deal.II User Group
Yes, you are both right. This part of the code is correct. The problem was that I declared the size of cells as static const, which is not good when the size varies.
Best regards,
Felix

Reply all
Reply to author
Forward
0 new messages