[Dune-devel] [GSoC]Updates and problems

Oliver Sander oliver.sander at tu-dresden.de
Thu Jul 14 10:07:18 CEST 2016

Hi Xinyun,
[please keep the discussions on the list.]

I think your BSplineLeafIterator class needs to hold a (shared) pointer so the entity it points to,
in addition to the directIndex.  Then what 'dereference' returns is not a temporary anymore.


On 14.07.2016 00:28, Xinyun wrote:
> Hey Oliver,
> In the past few days I tried to make the BSplineLeafIterator work using the Barton-Nackman trick. You can check here <http://gsoc2016xinyun.blogspot.de/2016/07/make-b-spline-grid-iterators-work.html> for more details about what I intended to do. But I encountered a specific programming problem which even hindered me to compile the code. I have spent some time to play around but still couldn't make it through. So I think it's better to ask for your help. As the code still contains errors, I didn't upload it to gitlab. I will try to explain with some code snippets here.
> I made my BSplineGridLeafIterator class a subclass of the the ForwardIteratorFacade class. The dereference overloading of the base class requires a reference return.
> "iteratorfacades.hh"
> Reference operator*() const
> {
>     return static_cast<DerivedType const*>(this)->dereference();
> }
> But in my BSpline iterator implementation, I created a BSpline entity locally which makes return by reference invalid.
> "bsplinegridleafiterator.hh"
> public:
>     BSplineEntity& dereference() const
>     {
>         return BSplineGridView_-> template getEntity<codim>(directIndex_);
>     }
> private:
>    BSplineGridView* BSplineGridView_;
>    unsigned int directIndex_;
> "bsplinegridview.hh"
>  template<int codim>
>  typename Codim<codim>::Entity getEntity(unsigned int directIndex)
> {
>      //return BSplineGridEntity<codim, BSplineGridView>(*this, directIndex);
>      return *std::make_shared<BSplineGridEntity<codim, BSplineGridView>>(*this, directIndex);
> }
> The error message I got is 
> error: invalid initialization of non-const reference of type ‘Dune::IGA::BSplineGridEntity<0, Dune::IGA::BSplineLeafGridView<2, 3> >&’ from an rvalue of type ‘Dune::IGA::BSplineLeafGridView<2, 3>::Codim<0>::Entity {aka Dune::IGA::BSplineGridEntity<0, Dune::IGA::BSplineLeafGridView<2, 3> >}’
>          return BSplineGridView_-> template getEntity<codim>(directIndex_);
> I hope the code above is able to explain. Otherwise, I can also provide more context.
> I'm not sure if I identified the problem correctly. If yes, I could not see a good solution to it. My only solution is to make a list of entities as class member of BSplineGridView so that they have a larger scope.
> Thanks,
> Xinyun

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune-devel/attachments/20160714/00906f44/attachment.pgp>

More information about the Dune-devel mailing list