Subject: Re: [FFC-dev] [DOLFIN-dev] bug in ConstantFunction

From: "Garth N. Wells" <[email-masked]>
Date: Thu, 03 May 2007 11:24:05 -0400

Anders Logg wrote:
> On Tue, May 01, 2007 at 02:52:28PM +0200, Garth N. Wells wrote:
>> There appears to be a bug in
>>
>> ConstantFunction::interpolate(real* coefficients,
>>                                const ufc::cell& cell,
>>                                const ufc::finite_element& finite_element)
>>
>> as it always returns zeros. Should
>>
>>   // Evaluate each dof to get coefficients for nodal basis expansion
>>    for (uint i = 0; i < finite_element.space_dimension(); i++)
>>      coefficients[i] = finite_element.evaluate_dof(i, *this, cell);
>>
>> be
>>
>>   // Evaluate each dof to get coefficients for nodal basis expansion
>>    for (uint i = 0; i < finite_element.space_dimension(); i++)
>>      coefficients[i] = value;
>>
>> ?
>>
>> Garth
> 
> No, it should be finite_element.evaluate_dof() since the constant
> value is not always equal to the value of the dof (but it is for
> Lagrange).
> 
> I'll take a look and see if I can find the problem as soon as I get a
> chance.
> 
> The call to evaluate_dof() should generate a call to the overloaded
> evaluate() function in ConstantFunction. (If you look in the code
> generated by FFC for evaluate_dof(), it should contain a call to
> evaluate().)
>

The problem is that FFC is generating

   /// Evaluate linear functional for dof i on the function f
   virtual double evaluate_dof(unsigned int i,
                               const ufc::function& f,
                               const ufc::cell& c) const
   {
     // Not implemented (only for Lagrange elements
     return 0;
   }

I'm using a discontinuous Lagrange element of order 0 for the time step 
dt. Can this easily be fixed for discontinuous Lagrange elements?

Also, could FFC generate an exception for functions which are not yet 
implemented?

Garth

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

---

From: Anders Logg <[email-masked]>
Date: Mon, 7 May 2007 10:49:03 +0200

> dt. Can this easily be fixed for discontinuous Lagrange elements?

Yes, I'll see if I can fix it.

> Also, could FFC generate an exception for functions which are not yet 

Sounds like a good idea.

/Anders