Dear all,
I tried to polish my C++ code by returning a function. However, something's wrong since I get an EXEC_BAD_ACCESS
error.
Here's my code:
// MAIN FILE
auto u = linearElastic(mesh, pts, lambda);
File vtk_file(path + "displacement.pvd", "compressed");
vtk_file << u; // <========= EXEC BAD ACCESS
and the linearElastic
function:
// Vector space
Elasticity::Form_a::TestSpace V(mesh);
// Solution
Function u(V);
// Solver
PETScLUSolver solver;
// Solve
solver.solve(A, *(u.vector()), b);
return u;
Now, since the code compiled I thought a Function
could be assigned, but it seems this is not the case. Maybe the underlying .vector()
is uninitialized,
What's the correct way of returning a function? Right now I have an additional reference parameter in the function, but it's not very neat.
Thanks!