[Dune] Default constructor in MultiLinearGeometry

Oliver Sander sander at mi.fu-berlin.de
Sun Oct 14 15:28:26 CEST 2012


Hi Martin,

> as far as I can see, this would in priciple possible if the corner
> storage has a default constructor (like std::vector) and _no_ methods
> are called on this geometry.
>
> Personally, I feel like the wrong instance to decide upon this question.
>
> Not knowing much about the UGGrid code, I don't see why you ever want an
> uninitialized geometry. From my point of view, you either construct the
> geometry directly before returning it (not holding a copy on the
> entity), or you do it like GeometryGrid and hold a reference counting
> pointer on the entity. As this might be a nullptr, you don't need a
> default constructor, here.
>
Conceptually that is what I do.  Only, to save the allocation, the
Geometry is actually a data member of the entity, and there is a bool
flag saying whether it is initialized.

Your proposal is cleaner from a design standpoint, so I don't mind going
with that.

best,
Oliver

> Apart from this, my feeling is that uninitialized objects are a very bad
> thing. Especially unexperienced programmers will have a hard time
> finding bugs caused by this. A default constructor would, of course,
> create an "uninitialized" geometry (in the sense that you may not use it
> at all).
>
> Should this question be discussed on the FlySpray?
>
> Best,
>
> Martin
>
> PS: Thanks for all the positive feedback. I was not sure whether this
> change is the right path or not.
>
> On 10/14/2012 09:03 AM, Oliver Sander wrote:
>> Hi Martin,
>> last night I tried to switch from BasicGeometry to MultiLinearGeometry
>> for various parts of UGGrid. Unfortunately, that didn't work as easily
>> as I hoped, because UGGrid expects a default constructor, which
>> BasicGeometry has, and MultiLinearGeometry hasn't. Is there any chance
>> to get a default constructor in MLG, or should a adjust the UGGrid code?
>> best,
>> Oliver
>>
>> _______________________________________________
>> Dune mailing list
>> Dune at dune-project.org
>> http://lists.dune-project.org/mailman/listinfo/dune
>




More information about the Dune mailing list