[Dune-devel] Random-Access Iterators

Markus Blatt markus at dr-blatt.de
Wed Oct 1 10:28:33 CEST 2014


Hi Jö,

On Tue, Sep 30, 2014 at 11:17:28PM +0200, Jö Fahlke wrote:
> Hi!
> 
> The random-access entity iterators are now ready for general review.
> https://cgit.dune-project.org/repositories/dune-grid/log/?h=feature/random-access-entity-iterators
>

from a quick glance there seems to be something fishy with the
comparison operators. For operator<(o) you seem to test whether
distanceTo(o) is less than zero. Ergo a<b <=> b-a<0. Shouldn't this be
the other way around?

This brings me directly to the next point. Is there a special reason
not to use the iterator facades? These are already tested and might
help prevent the above mistakes. In addition it would reduce
replication of boilerplate code and increase maintainability.
 
> @Carsten: are you willing to include this in 2.4, provided noone finds any
>           serious issues?
> 

Will this put a lot of work onto grid maintainers?

> [...]
> 
> There is one function that has been omitted from random access iterators for
> the time being, namely operator[].  There are three possibilities for the
> return type of operator[]: Either return the entity by value -- but that needs
> copyable entities, which are not ready yet.  Or return a reference to the
> entity -- not possible, since we have nothing that stores that entity.  Or
> return a proxy object -- but I'm too lazy to implement that, since we will
> have copyable entities soon.  Note that instead of the (currently) invalid
> expression "it[n]" you can write "*(it+n)": The + creates a temporary
> iterator that holds the entity.
> 

They are supposed to return the reference_type as defined in the
iterator_traits. This might also be a proxy object. IMHO it is
problematic to say something is a random access iterator but at the
same time omit implementing the full functionality. This means that
many of the STL algorithms are not usable with it and prevents people
from getting some parallel speedup just by using parallel versions of
it. (I know that we still tend to write raw loops mostly but that
might be worse improving anyhow)

> I also omitted implementing bidirectional iterators, since I could not come up
> with a use case for iterating backwards through the grid.  If a grid declares
> an iterator implementation as bidirectional, the resulting EntityIterator will
> nevertheless just be a forward iterator.  It should be easy to add
> bidirectional iterators, should the need arise.

Here is one: Implementing a matrix free backwards gauss seidel method.

Markus

-- 
Do you need more support with DUNE or HPC in general? 

Dr. Markus Blatt - HPC-Simulation-Software & Services http://www.dr-blatt.de
Hans-Bunte-Str. 8-10, 69123 Heidelberg, Germany
Tel.: +49 (0) 160 97590858
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <https://lists.dune-project.org/pipermail/dune-devel/attachments/20141001/837366c0/attachment.sig>


More information about the Dune-devel mailing list