Hi,
I need to implement an elementwise multiplication of two functions on the same 3D mesh in C++. My first approach is to implement a class called CustomFunction based on dolfin::Function and implement the operator* as :
CustomFunction operator*(dolfin::Function func, dolfin::Mesh mesh){
dolfin::Function f(this->function_space())
for (dolfin::MeshEntityIterator e(mesh, 0); !e.end(); ++e)
{
auto tmp = func.vector();
for (dolfin::MeshEntityIterator e(mesh, 1); !e.end(); ++e)
{
for (dolfin::MeshEntityIterator e(mesh, 2); !e.end(); ++e)
{
f[e->index()] = (*this)[e->index()]*func[e->index()]
}
}
}
}
It is basically an iteration over each dimension and it does not work. Is there any better way to do this?
Thanks in advance,
Justus