[Dune] Storing entity iterators

Steffen Müthing steffen.muething at iwr.uni-heidelberg.de
Wed Mar 11 09:35:05 CET 2015


Hi Marco,

> Am 09.03.2015 um 13:13 schrieb Agnese, Marco <m.agnese13 at imperial.ac.uk>:
> 
> Hi Duners,
> in my code I have a bulk grid and an interface grid. I have created a mapping between the 2 grids and to accomplish that I am storing entity iterators.
> With the introduction of copyable entitites/intersections is it safe to do that?

You should not store entity iterators, that can be very expensive. With the copyable entities, you can simply store entities. But in your use case, you should probably
use an EntitySeed. An EntitySeed is a compact representation of an entity, from which the Grid can reconstruct the entity without iterating over the grid. It works like this:

typename Entity::EntitySeed es = entity.seed(); // store this es object
…
…
Entity new_entity = grid.entity(es); // reconstruct the entity from the seed

This relies on the copyable entities - before Dune 2.4, you have to EntityPointer ep = grid.entityPointer(es) instead.

Steffen

> 
> In other words, if I have an entity iterator  and I dereference it, I will obtain an entity of the grid? Or the entity iterator points to a copy of the entity and therefore it is not safe?
> 
> Moreover, is there a better/safer way to create this mapping? Instead of the iterator I can store the leafIndexSet().index(entity) but is there a way, given this index, to obtain the entity directly without looping over the grid?
> 
> Thank you,
> cheers,
> Marco.
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20150311/d36b8526/attachment.sig>


More information about the Dune mailing list