[Dune] How to store entities?

Carsten Gräser graeser at mi.fu-berlin.de
Tue Dec 9 15:07:27 CET 2014


Since I already typed my (slightly longer) answer:

Am 09.12.2014 um 14:59 schrieb Robert Kloefkorn:
> Hello Bernd,
> 
>> for some of our models, we store for each vertex all elements that
>> share this vertex. We currently use a
>> std::vector<EntityPointer> for this. I have a couple of questions
>> concerning this:
> 
>> 1. Is this currently a good choice or are there better choices?
> No (never has been) and Yes.
> 
>> 2. When would it be safe to store (smart) pointers to
>> Entities/EntityPointers/EntitySeeds?
> Just don't.
With the new copyable entities the answer for all
three is, that they are valid as long as the grid is
not modified. Before, the Entity was only valid, as
long as the EnitityPointer/Iterator containing it
was not changed.

>> 3. What should I use in the future when EntityPointer is gone?
> EntitySeed.
Storing EntitySeed will always be the better choice, because
this is the reason why it exists. If, for a certain grid
manager, the EntityPointer would be the most efficient choice,
then it would implement the EntitySeed using the EntityPointer.

The main point is that EntitySeed is exactly defined to be memory
efficient and will often be just a pointer or index internally,
where as EntityPointer may store a pointer to the grid, some
cached data (geometry), ... in order to provide efficient access
to Entity informaton.

Best,
Carsten





More information about the Dune mailing list