← Back to team overview

dolfin team mailing list archive

compile-error in python user-defined expression

 

The attached code used to work.
Now I have to explicitly inlcude dolfin.h, because GenericDofMap.h
is not included in the generated code.

The workaround I've found is simple, but it is at the same time it is somewhat counter-intuitive: the expression code get wrapped inside the namespace "dolfin", that must be closed before including "dolfin.h", and then reopened.

Marco
from dolfin import *


cppcode_d1 = """
//uncommet the four lines below to have this buildable
//}
//#include "dolfin.h"
//namespace dolfin
//{
class Delta1 : public Expression
{
public:

  Delta1() : Expression() {}

  void eval(Array<double>& values, const Array<double>& data, const ufc::cell& cell) const
  { }

  void update(const boost::shared_ptr<const Function> u, 
  	double nu, double dt, double C1,
	double U_infty, double chord)
  {
    const boost::shared_ptr<const Mesh> mesh = u->function_space()->mesh();
    const boost::shared_ptr<const GenericDofMap> dofmap = u->function_space()->dofmap();
    const uint ncells = mesh->num_cells();
    uint ndofs_per_cell;
    if (ncells > 0) 
    {
      CellIterator cell(*mesh);
      ndofs_per_cell = dofmap->cell_dimension(cell->index());
    } 
    else 
    {
       return;
    }
  }

private:


};"""

DGe = FiniteElement("DG", tetrahedron, 0, 1)
delta1 = Expression(cppcode_d1, element=DGe)

Follow ups