Hello,
I’m trying to create a tensor function on the mesh and I’m following the “Tensor-weighted Poisson” tutorial.
https://fenicsproject.org/docs/dolfin/1.3.0/python/demo/documented/tensor-weighted-poisson/python/documentation.html
In the tutorial, a Mesh Function is created for each entry of the tensor and then these functions are converted to Expressions.
However, when I run the supplied C++ code for creating an Expression from the functions, I get an error.
That is, when I run:
# Code for C++ evaluation of conductivity
conductivity_code = """
class Conductivity : public Expression
{
public:
// Create expression with 3 components
Conductivity() : Expression(3) {}
// Function for evaluating expression on each cell
void eval(Array<double>& values, const Array<double>& x, const ufc::cell& cell) const
{
const uint D = cell.topological_dimension;
const uint cell_index = cell.index;
values[0] = (*c00)[cell_index];
values[1] = (*c01)[cell_index];
values[2] = (*c11)[cell_index];
}
// The data stored in mesh functions
boost::shared_ptr<MeshFunction<double> > c00;
boost::shared_ptr<MeshFunction<double> > c01;
boost::shared_ptr<MeshFunction<double> > c11;
};
"""
# Define conductivity expression and matrix
c00 = MeshFunction("double", mesh, "c00.xml.gz")
c01 = MeshFunction("double", mesh, "c01.xml.gz")
c11 = MeshFunction("double", mesh, "c11.xml.gz")
c = Expression(cppcode=conductivity_code)
I get the following error:
RuntimeError: Must supply C++ code to Expression. You may want to use UserExpression
Is there something I need to download to get the C++ code working correctly? Or is there something in this tutorial that is outdated?
Thanks for the help,
T