[Dune] Example on IteratorRange
steffen.muething at iwr.uni-heidelberg.de
Fri Jan 23 10:58:17 CET 2015
Am 23.01.2015 um 08:59 schrieb Aleksejs Fomins <aleksejs.fomins at lspr.ch>:
> Signierter PGP Teil
> Dear Christian,
> Thank you for your reply.
> I have a generic function which works the same way for all grid views,
> with the exception that it iterates over the gridview in some way.
That’s exactly what the DUNE-provided infrastructure is - a set of generic, freestanding functions
that work with any GridView. For the details, take another look at the DUNE help page you mentioned
> I thought it would make sense to implement this function as a
> protected member of the generic gridview class, and call it from the
> derived leafgridview as
> Can I pass iterator ranges to functions? What is their type then?
Yes, you can. Their type is unspecified on purpose, we just require them to work with a C++11
range-based for statement (for that the type needs to expose a begin() and an end() method, the
return type can be deduced via auto / decltype). In practice, the default implementations of those functions
all use the class Dune::IteratorRange for this purpose - take a look at it in Doxygen.
> On 22/01/15 21:56, Christian Engwer wrote:
> > Dear Aleksejs,
> > I'm sorry, but I don't uderstand your question. What exactly do
> > you miss in the documentation?
> > There are examples for all functions like elements(gv),
> > intersection(e), entities(gv, dim/codim)...
> > On Thu, Jan 22, 2015 at 06:05:55PM +0100, Aleksejs Fomins wrote:
> >> Dear Dune,
> >> I remember we had a discussion before on using iterator ranges
> >> for iterating over entities of gridview, as written in here
> >> http://www.dune-project.org/doc/doxygen/dune-grid-html/group___g_i_iteration.html#_details
> Would somebody be so kind to show me to an example program doing this?
> >> In particular, I do not seem to be able to derive from that
> >> documentation page on how one constructs such an iterator. Or,
> >> at least, my Eclipse is not able to direct me to the method like
> >> Dune::GridView::elements
> > as shown in the examples you are not calling methods on a class.
> > These are free functions operating on a gridview, adding syntactic
> > sugar ontop of the begin/end methods of the gridview.
> > Christian
> >> Thank you, Aleksejs
> >> _______________________________________________ Dune mailing
> >> list Dune at dune-project.org
> >> http://lists.dune-project.org/mailman/listinfo/dune
> Dune mailing list
> Dune at dune-project.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
More information about the Dune