I have this code in python:
L_mat = dolfin.assemble(L)
A_mat = dolfin.assemble(a)
bc.apply(A_mat,L_mat)
solver = dolfin.LUSolver(lu_solver)
solver.set_operator(A_mat)
solver.solve(u_vector, L_mat)
where L is a linear form and a is a bilinear form, lu_solver is just a string specifying the LU solver to use and u_vector is just the vector associated to the solution function.
Now, I am trying to convert this code into c++ code but I am running into problems. My first try was:
dolfin::Matrix A_mat;
dolfin::Vector L_mat;
dolfin::assemble(L_mat,L);
dolfin::assemble(A_mat,a);
bc.apply(A_mat,L_mat);
dolfin::LinearSolver solver(lu_solver);
solver.set_operator(A_mat);
solver.solver(*(u.vector()),b);
This gives an error:
error: no viable conversion from 'dolfin::Matrix' to 'std::shared_ptr<const GenericLinearOperator>'
What I understand is that u.vector() is a std::shared_ptr but A_mat is not, but set_operator requires a std::shared_ptr of time GenericLinearOperator. Am I initialising the matrix correctly? Should I create a shared pointer? How?
Thank you for your help.