[Dune] Feature request FieldVector

Oliver Sander sander at math.fu-berlin.de
Tue Mar 1 15:40:17 CET 2005


Hi Adrian!
If you claim to know details about the implementation of FieldVector,
then you can get access to the underlying array by writing

FieldVector<double, 69> aVector;

double* array = &aVector[0];

and there's no need to compromise the interface.  Of course this
breaks if someone changes the implementation, but you may be willing
to take that risk.

--
Oliver

************************************************************************
* Oliver Sander                **                                      *
* Freie Universität Berlin     ** email: sander at math.fu-berlin.de      *
* Institut für Mathematik II   ** phone: + 49 (30) 838 75217           *
* Arnimallee 2-6               ** fax  : + 49 (30) 838 54977           *
* 14195 Berlin, Germany        ** URL  : www.math.fu-berlin.de/~sander *
************************************************************************

On Tue, 1 Mar 2005, Adrian Burri wrote:

> Hi all,
>
> I have a (probably quite controversial) feature request for the FieldVector: 
> I'd like to have a method that gives me direct access to the underlying 
> C-array, i.e. something like this
> (&K)[n] array() { return p; }
> I know this breaks encapsulation, it is a highly dangerous quirk and against 
> all principles of good software engineering, but I am interfacing to a 
> C-library for numerical flux functions and I don't intend to copy my range 
> vectors (2*nQuadpoints*nElements*dimRange copies in one grid sweep...)
> Those array() functions (the const and the non-const version) should of 
> course be tagged with a large warning sign!
>
> I am interested to hear your opinion on this issue.
>
> Cheers
>
> Adi
>
> _______________________________________________
> Dune mailing list
> Dune at hal.iwr.uni-heidelberg.de
> http://hal.iwr.uni-heidelberg.de/cgi-bin/mailman/listinfo/dune
>


More information about the Dune mailing list