← Back to team overview

dolfin team mailing list archive

Undefined behavior for finite_element->evaluate_basis

 

Hi,

I am struggling with some undefined behavior which I don't seem to be able to resolve. In the DiscreteFunction class I have added my own function for evaluating the function in a point x. For this purpose I need to calculate the value of the basis functions in the respective point and multiply them by the expansion coefficients. That I do as follows:

  //step #2: get expansion coefficient on the cell
   uint n = finite_element->space_dimension();
   real* coefficients = new real[n];
   this->interpolate(coefficients,ufc_cell,*finite_element);

  //step #3: multiply with basis functions on the cell
   real* basis_val = new real[1];
   real value=0.;
   for(uint j=0; j<n; j++)
   {
       finite_element->evaluate_basis(j,basis_val,x,ufc_cell);
       value += basis_val[0] * coefficients[j];
       cout << "Basis value: " << basis_val[0] << endl;
   }

The undefined behaviour occurs in the call to the evaluate_basis method of the finite_element. The output from the print statement is:

Basis value: 5.14e-268
Basis value: 5.14e-268
Basis value: 5.14e-268

Not good.
Any ideas of what is going wrong here ?

Kristen