[Dune] Example on IteratorRange

Christian Engwer christian.engwer at uni-muenster.de
Fri Jan 23 13:25:10 CET 2015


> Dune::IteratorRange<GridViewType, ????> myHappyIteratorRange =
> Dune::GridView::elements(gv,Dune::Partitions::interiorBorder)
> some_function(myHappyIteratorRange);

you usually don't store it:

some_function(Dune::GridView::elements(gv,Dune::Partitions::interiorBorder));

If you have to use such a construction in your metagrid you can also use
decltype or auto to get the type of the range.

> What is the 2nd template parameter for the IteratorRange in this case?

If you really have to/want to do it the hard way, you retriev the type
of the iterator from the GridView, as you exactly know which iterator
you are requesting.

Ciao
Christian

> 
> Thank you,
> Aleksejs
> 
> 
> 
> On 23/01/15 10:58, Steffen Müthing wrote:
> > Hi Aleksejs,
> > 
> > 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 
> > earlier.
> > 
> >> 
> >> 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
> >> 
> >> Base::f(LeafIteratorRange) 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.
> > 
> > Steffen
> > 
> >> 
> >> Cheers, Aleksejs
> >> 
> >> 
> >> 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 
> >> http://lists.dune-project.org/mailman/listinfo/dune
> > 
> 
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune
> 

-- 
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 mailing list