[Dune-devel] Validity of GridView after grid changes
Christian Engwer
christian.engwer at uni-muenster.de
Fri Apr 11 09:48:47 CEST 2025
Hi Simon,
Am Fri, Apr 11, 2025 at 09:23:53AM +0200 schrieb Simon Praetorius:
> Hi,
>
> Thanks for pointing to the "magic pointer", or change-counter to identify
> whether it is necessary to to update some data structures.
>
> But, actually I wanted to know something else (I am not sure if this is
> related):
>
> Do we need to recreate the gridview after the underlying grid is modified? I
> always thought: yes, but maybe I got this somehow wrong.
OK, sorry that perhaps read it too fast. In the early days we decided
that the grid hands out references and updates these underneath. For
these it is undocumented behaviour, that they will stay valid, but
... we also allow for externally created gridviews and these can not
automatically update.
> Examples:
> - The gridview of Dune::UGGrid just stores a pointer to the grid (and
> potentially a level int) and redirects all calls to the grid -> the gridview
> object is valid after grid adaption
> - YaspGrid implements its gridview via the DefaultGridView implementations
> that redirect everything to the grid -> the gridview object is valid after
> grid adaption
> - OneDGrid is fine
> - ALUGrid is fine
up to here (in practice) everything should be fine.
> - Some meta-grids are a little bit more complicated to check since, e.g.,
> IdGridViewBasic has an IndexSet stored in the class that contains a
> reference to the host-indexset and it needs to be checked whether the
> indexset references are valid after grid adaption. But, it seems so.
Yes, for metagrids it is more tricky, but I'd say again, as you get a
reference it should be fine.
> So, my post refers actually to the question whether we should do anything
> with the gridview or not (after grid adaption) and it seems to me, that a
> gridview is perfectly valid after the underlying grid has changed.
I think this is only partially true.
If you have a meta grid and you trigger the modification via the meta
grid, everything thould be ok, but already it you trigger the
adaptation via the hostgrid, you might run into problems, as the host
grid reference is still the same, but the additional metagrid
information, like the bool vector in subgrid are now of the wrong
size, or di I miss a trick?
For externally created gridview it is often the same problem, as these
usually have some kind of metagrid-like behaviour, but this might be
ok, as you keep them as a reference and thus know that you created
them explicitly.
Ciao
Christian
> Did I miss something? Is this a guarantee that we can give? Are there
> counterexamples?
>
> Best,
> Simon
>
> Am 10.04.25 um 21:04 schrieb Christian Engwer:
> > PS Ich denke ein genereller Bedarf besteht, wir sollten also mal über
> > eine Lösung diskutieren...
> >
> >
> > Am 10. April 2025 20:57:21 MESZ schrieb Christian Engwer
> > <christian.engwer at uni-muenster.de>:
> >
> > Deswegen gibt es den magischen Pointer den Robert aufs Gitter
> > packen möchte, damit er dort eine Liste pflegen kann, welche
> > Objekte alle aktualisiert werden müssen, wenn sich das Gitter ändert.
> >
> > Ciao Christian
> >
> >
> > Am 10. April 2025 18:19:52 MESZ schrieb Simon Praetorius
> > <simon.praetorius at tu-dresden.de>:
> >
> > Hi everyone, if I have a gridview, e.g. a leaf-gridview, of
> > some grid and I modify the grid, e.g., do some grid adaption,
> > what is the state of the gridview after this modification?
> > What can we do with a gridview after the modification? As far
> > as I was know (maybe this is documented somewhere),
> > essentially the gridview is invalid, except for the reference
> > to the grid. Is this statement correct? Background to this
> > question: Often I have stored just a gridview, in my
> > application most of the time just the leaf gridview. If the
> > underlying grid changes, how can I generate an updated
> > gridview for these classes? The gridview does not know what
> > kind of gridview it is and how it was constructed. Thus, it
> > cannot request an update of itself. Examples of such classes
> > that need to update their gridview are the MCMGMapper in
> > dune-grid, the VtkWriter from dune-vtk, the global basis from
> > dune-functions, and probably a lot more. Several grids have
> > gridviews that stay valid after grid modifications, e.g. those
> > implemented with a GridDefaultImplementation using
> > DefaultGridViewTraits. Is this, by chance, true for all grid
> > managers? In which grid managers an operation on an
> > invalidated gridview would fail (and why)? Best, Simon
> >
> >
> > _______________________________________________
> > Dune-devel mailing list
> > Dune-devel at lists.dune-project.org
> > https://lists.dune-project.org/mailman/listinfo/dune-devel
> _______________________________________________
> Dune-devel mailing list
> Dune-devel at lists.dune-project.org
> https://lists.dune-project.org/mailman/listinfo/dune-devel
--
Prof. Dr. Christian Engwer
Institut für Numerische und Angewandte Mathematik
Fachbereich Mathematik und Informatik der Universität Münster
Einsteinstrasse 62
48149 Münster
E-Mail christian.engwer at uni-muenster.de
Telefon +49 251 83-35067
FAX +49 251 83-32729
More information about the Dune-devel
mailing list