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.

> 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.

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.

Garth



> Johan
> 
>> Disadvantages are:
>>
>> - It may be unclear that u0 and u share data.
>> - If u goes out of scope, u0 is will keep the vector belonging to u
>> alive (only an issue if the vector is very large compared to that
>> required by u0).
>>
>> Garth
>> _______________________________________________
>> DOLFIN-dev mailing list
>> [email protected]
>> http://www.fenics.org/mailman/listinfo/dolfin-dev


_______________________________________________
DOLFIN-dev mailing list
[email protected]
http://www.fenics.org/mailman/listinfo/dolfin-dev

Reply via email to