dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #14783
Re: SubFunctions
On ma., 2009-08-17 at 13:14 +0100, Garth N. Wells wrote:
>
> Johan Hake wrote:
> > On Monday 17 August 2009 14:03:55 Garth N. Wells wrote:
> >> Johan Hake wrote:
> >>> On Monday 17 August 2009 13:33:21 Garth N. Wells wrote:
> >>>> Please send any comments on how a SubFunction should work as I'm going
> >>>> to work on it soon (the Cahn-Hilliard demo runs in parallel(!) ;) with
> >>>> the exception of the extraction of sub-Functions for output). I'm
> >>>> inlined to change a sub function such that for
> >>>>
> >>>> Function u0 = u[0]
> >>>>
> >>>> the Function u0 will only point the vector belonging to u rather than
> >>>> creating a new vector. The advantages are:
> >>>>
> >>>> - No need to copy a vector
> >>>> - DofMap will not require 'is_view'
> >>>> - Possible to do things like
> >>>> u0 = 0.0;
> >>>> u1 += v;
> >>>> u0.interpolate();
> >>> What would Function::vector() for a SubFunction then return? The original
> >>> full Vector?
> >> Yes.
> >
> > Ok.
> >
> >>> It would be cool to add a view of the original Vector that only
> >>> represents the values of the dofs in the SubFunction, without coping
> >>> data. I fiddled around with this when adding slicing for the PyDOLFIN la
> >>> interface, but realized that it would be too difficult.
> >> This is more or less what I plan to do, although internally. A user
> >> wouldn't see the vector, but operations like interpolate would only
> >> involve part of the vector.
> >
> > I see. Other direct Vector operations would then operate directly on the
> > shared Vector, like get, set, aso.
> >
> >> We could add a class like
> >>
> >> VectorView(GenericVector& x, DofMap& dof),
> >>
> >> which could derive from GenericVector, to provide views. It isn't a
> >> priority for me though.
> >
> > Yes, I also thought along these lines, however I did not think of doing it
> > using a DofMap, which really is the natural thing. I will also not have
> > possibility to priorities it for now.
> >
>
> On second thought,
>
> VectorView(GenericVector& x, std::vector<uint> map& map)
>
> would be better. The DofMap could produce the map,
>
> std::vector<uint> map = dofmap.view();
>
> Garth
>
This would be great! This is sort of the reason why I implemented block
matrices in the first place, but this is far more general and there
is no need to mess with the block structure during assembly.
Kent
Follow ups
References