← Back to team overview

dolfin team mailing list archive

Re: Further work on python interface

 

On Saturday 08 November 2008 00:08:45 Anders Logg wrote:
> On Fri, Nov 07, 2008 at 11:57:08PM +0100, Johan Hake wrote:
> > Hello.
> >
> > I have added a function for compilation of single function, based on
> > Martins previous work. It is now coupled to the Function class and should
> > work. See poisson demo.
>
> I'm having problems with finding ufc.h when running this demo:
>
> "Unable to find 'ufc.h'"

Looks familiar. I think we can remove the %import ufc.h statement from the 
dolfin_function_pre.i, as dolfin::Function does not inherit from it any 
longer. Maybe you can try that? 

> > I got trouble with the dolfin::pow function that is defined for
> > pow(double,uint) and pow(double,double). When we define a c++ function
> > pow(x[0]-0.5,2) we get an ambigous overloading that do not compile, see
> > e.g. in the poisson demo.
> >
> > I have fixed it with a hack in compile_function, by adding 'std::'
> > infront of every pow statement. Any other way to solve it?
>
> Seems like a good solution to me.

Ok

> > Next on the list whould be the assemble.py file. Here I think we need to
> > do some work in the c++ interface. The Assembler.assemble function we
> > previously used took an ufc::form, now we need to send in a dolfin::Form.
> > This cannot be instantiated as dolfin::Form is an abstract base class.
>
> Would it be enough to add a constructor to dolfin::Form that takes a
> ufc::form?

Don't we need the functionspaces for the test and trial spaces too?

> The definition of the Source function in the demo looks nice, but
> would it be possible to avoid having to create a class just to define
> one single instance of it?
>
> It would be nice if we could do things like
>
>   f = Function(cppexpr="sin(x[0])")

I suppose you mean:

  f = Function(cppexpr="sin(x[0])",V)

Yes that would be doable. This should be doable on top of the existing 
framework. 

> What would be the optimal/simplest way to define a Function by an
> expression? I guess if we imported x as a symbol from either Swiginac
> or SymPy, we could do
>
>   f = sin(x)

Something like that should be doable, but I suppose you do not want to include 
f in your form? In 0.8.1 you can e.g. pass scalars as coefficients to the 
assembler. 

Johan


References