← Back to team overview

dolfin team mailing list archive

Re: Even more Expression problems

 

On Friday 16 October 2009 18:11:37 Anders Logg wrote:
> On Fri, Oct 16, 2009 at 03:31:45PM +0200, Johan Hake wrote:
> > On Friday 16 October 2009 15:24:42 Anders Logg wrote:
> > > On Fri, Oct 16, 2009 at 03:14:24PM +0200, Johan Hake wrote:
> > > > On Friday 16 October 2009 15:09:03 Anders Logg wrote:
> > > > > Here's another problem I just ran into:
> > > >
> > > > You just keep bring it on do you!! ;)
> > > >
> > > > I wonder why I keep thinking:
> > > >
> > > >    unittest, unittest, unittest ...
> > >
> > > Good idea. :-)
> > >
> > > > > class BoundaryValue(Expression):
> > > > >     def eval(self, values, x):
> > > > >         values[0] = ...
> > > > >
> > > > > This works:
> > > > >
> > > > >   g = BoundaryValue(V)
> > > > >
> > > > > or
> > > > >
> > > > >   g = BoundaryValue(V=V)
> > > > >
> > > > > But this does not work:
> > > > >
> > > > >   g = BoundaryValue(element=element)
> > > > >
> > > > > I get this error:
> > > > >
> > > > > Exception: Swig director method error. Error detected when calling
> > > > > 'Expression.eval_data'
> > > > >
> > > > > when calling bc.apply() with the above function as argument (which
> > > > > results in a call to eval).
> > > >
> > > > Could you pass a minimal script that reproduce it so I can look into
> > > > it?
> > >
> > > Sorry, my fault. I forgot that the "Swig director method" error
> > > signals that I have done something wrong inside the eval function
> > > which I had or rather I had initialized with the wrong element so I
> > > wasn't allowed to set values[1]...
> >
> > Ok!
> >
> > It should be possible to access the original error message. That would
> > have helped you in this case.
> 
> I think this worked a while back. If I remember correctly, Kent fixed
> this at some point. (Getting sensible error messages when doing
> something wrong inside a director callback.)

Yes I also remember that it worked a while ago. 

However I think the addition of the eval_data (eval(double*,Data)) has screwed 
this up. The calls are dispatched back and fourth between Python and C++ 
because eval(double*,Data) calls eval(double*,double*). Both are virtual 
methods which each has a director method. So there are some inefficiency here 
that contributes to the slow Python callbacks.

Johan


References