Why does adapt() return false if the grid was coarsened?
According to the dune book, The adapt method returns true if the grid changed at all, and false otherwise.
This is also how I think it should work, since additional vectors and matrices might have to be updated by the user if the grid changed at all, regardless of whether it was coarsened or refined. However, both YaspGrid
bool adapt ()
{
globalRefine(adaptRefCount);
return (adaptRefCount > 0);
}
and OneDGrid
bool Dune::OneDGrid::adapt()
{
// for the return value: true if the grid was changed
bool refinedGrid = false;
// remove elements that have been marked for coarsening.
...
// refine all marked elements
...
// The grid has been modified
refinedGrid = true;
...
return refinedGrid;
do not actually implement this; they only notify the user if they added new elements, regardless of whether elements were removed (ALUGrid might also do this, at least this would explain the occasional segmentation errors I get). Is this the intended behaviour? I do not see why it would be, and the book agrees with me; but it seems to be implemented like this consistently (yet the comments in the code contradict the actual implementation?), so I am confused.
It would of course be possible to get this information in between calling mark and adapt, using either mightVanish()
(which I think would be too conservative), or by going through every level and manually determining whether entities will disappear, but I don't see why this should be necessary.