← Back to team overview

dolfin team mailing list archive

Re: sub vs [] for FunctionSpace

 

On Tuesday January 18 2011 06:33:31 Anders Logg wrote:
> Can somone remind me why we have sub() instead of [] for accessing
> subspaces in Python?

This is because the way UFL handles Indexed(*). 

We have not (yet) managed to figure out how we can inherit (dynamic or static) 
from and Indexed(*). We need this when the resulting subfunction is returned.

So therefore is [] used in ufl forms and .sub when a dolfin.SubFunction is 
needed. I am also not sure it would work to extract a SubFunction and then let 
it inherite Indexed(Coefficient(MixedElement(*))) as UFL assume it is an index 
into a MixedFunction. If the underlaying dolfin.Function is a SubFunction the 
indexing might get screwed.

It might be possible with some magic to recognize a passed  
Indexed(Coefficient(MixedElement(*))) and then extract the dolfin.SubFunction 
when that is needed. It is magic but might work if the number of occasions it 
is used is limited. We might also just keep .sub for direct access to the 
SubFunction.

In what places do we need a SubFunction?

Johan



Follow ups

References