[Dune-devel] Validity of GridView after grid changes

Carsten Gräser graeser at math.fau.de
Fri Apr 11 11:41:07 CEST 2025


Hi Simon,
to me this is simple: The gridview is no longer valid once the grid
has been modified. For the standard gridviews it may work, but this
is a lucky coincidence. Even if the gridview only stores pointers
to the grid's index sets, they may change after grid modification.

For meta grids and custom grid views you're right that they should
be light weight and copyable and thus only store pointers to heavy
date. However, there's no guarantee that these pointers remain valid
once the grid has been modified.

In your downstream class you need to react to a grid change anyway,
because you will often have some grid-dependent data. E.g. a mapper
needs to recompute its size and offsets. When initiating this update
you simply have to pass a fresh grid view.

I agree that this is sometimes inconvenient, but then it's a gap in the
interface. It seems that there are two things missing to achieve what
you intend to do:

a)A mechanism to register callback that allow to react on grid modification.
b)An interface that allows to update a gridview, e.g. an update() method
   which does not take an argument. In simple cases this could be empty,
   in general it could e.g. update the index sets from the grid. But this
   method would have to be optional, since there's no generic update
   to custom grid view.

Best
Carsten

Am 11.04.25 um 10:13 schrieb Christian Engwer:
> Hi Simon,
> 
>> - If we would assume that the gridviews of the standard grid managers are
>> safe, and a meta-grid wraps such gridviews and does not manage any extra
>> data, then also meta-grids could be implemented in a safe way.
> 
> But this light weight might be that you just store the expensive data
> outside the gridview, still it must be ensured somehow that the
> hostgridview and the extra data are in sync. Otherwise you could still
> work with the gridview, but it would produce oscure results.



More information about the Dune-devel mailing list