← Back to team overview

dolfin team mailing list archive

PyDOLFIN interface

 

Hello!

I have started the work on the PyDOLFIN. We can now define the forms in the 
poisson demo, using the syntax previously discussed, see python poisson demo.

A FunctionSpace now inherits both dolfin::FunctionSpace and ffc.FiniteElement, 
and it can be used to instantiate user defined Functions which can be used to 
define forms.

We need to discuss how to implement a discrete function. This is a bit 
complicated using the metaclass magic that is implemented now. Now we cannot 
do:

  u = Function(V)
  x = u.vector()

as Function is just a dummy class for creation of userdefined functions.

Is it possible to define a DiscreteFunction class in c++ (or just in swig?) 
that inherits dolfin::Function, and in its constructor calls vector()? 

Then we can use this class in python to create discrete functions. We then 
avoid the director class that is created by swig for all functions that 
inherits the cpp_Function. The obvious syntax would then be

  u = DiscreteFunction(V)

in python. I think with some python magic we still can have the syntax

  u = Function(V)

which would imply that a discrete function is created, but I haven't 
implemented it.

We also have a problem with MixedElements. Now the FunctionSpace inherits 
ffc.FiniteElement and a MixedElement is not a FiniteElement. I suppose we 
could overload the __add__ operator for the FunctionSpace together with a new 
class MixedFunctionSpace, to fix this?

Johan


Follow ups