I'm trying to run a code written in C++ which should be the same as one I have in Python. They both use Fenics.
My problem is that I cannot translate a Python class into a C++ class.
For instance, my Python code is:
V = VectorFunctionSpace(mesh, "Lagrange", 1)
u = Function(V)
En = 5*dx - dot(3, u)*ds(2)
def f(self, x):
u.vector()[:] = x
return assemble(En)
The problem here is that the compiler cannot find En as it is not defined inside the class.
My C++ code:
double f(const GenericVector& x)
{
u.vector() = x;
return assemble(F);
}
int main()
{
//...things that apparently work...
Function u(Vh);
MyClass::BilinearForm F;
}
How can I solve this?