Good evening,
I have a problem with a C++ Expression, who helps me to construct a tensor for each cell starting from MeshFunctions. I have always used this expression but today it doesn not work. Could you tell me why?
Here is the code:
defineMatrix_code = """
#include <pybind11/pybind11.h>
#include <pybind11/eigen.h>
namespace py = pybind11;
#include <dolfin/function/Expression.h>
#include <dolfin/mesh/MeshFunction.h>
class Components_DT_D : public dolfin::Expression
{
public:
// Create expression with 6 components
Components_DT_D() : dolfin::Expression(6) {}
// Function for evaluating expression on each cell
void eval(Eigen::Ref<Eigen::VectorXd> values, Eigen::Ref<const Eigen::VectorXd> x, const ufc::cell& cell) const override
{
const uint topDim = cell.topological_dimension;
const uint cell_index = cell.index;
values[0] = (*d11)[cell_index];
values[1] = (*d12)[cell_index];
values[2] = (*d13)[cell_index];
values[3] = (*d22)[cell_index];
values[4] = (*d23)[cell_index];
values[5] = (*d33)[cell_index];
}
// The data stored in mesh functions
std::shared_ptr<dolfin::MeshFunction<double> > d11;
std::shared_ptr<dolfin::MeshFunction<double> > d12;
std::shared_ptr<dolfin::MeshFunction<double> > d13;
std::shared_ptr<dolfin::MeshFunction<double> > d22;
std::shared_ptr<dolfin::MeshFunction<double> > d23;
std::shared_ptr<dolfin::MeshFunction<double> > d33;
};
PYBIND11_MODULE(SIGNATURE, m)
{
py::class_<Components_DT_D, std::shared_ptr<Components_DT_D>, dolfin::Expression>
(m, "Components_DT_D")
.def(py::init<>())
.def_readwrite("d11", &Components_DT_D::d11)
.def_readwrite("d12", &Components_DT_D::d12)
.def_readwrite("d13", &Components_DT_D::d13)
.def_readwrite("d22", &Components_DT_D::d22)
.def_readwrite("d23", &Components_DT_D::d23)
.def_readwrite("d33", &Components_DT_D::d33);
}
"""
and this is the error I get:
ImportError: generic_type: type “Components_DT_D” referenced unknown base type “dolfin::Expression”