PETSc: add a name information when constructing Vector or matrix
Warning: text below was written when the solution was not exactly the same but remains mostly valid. Please read the whole discussion, not only this description.
When there is a problem with vector deallocation at PetscFinalize()
call, the only output we get is PETSc error message which is rather unreliable (the message is not exactly the same between two runs).
Using source location provides a much better information; in my case I saw that the issue is related to:
VECTOR DESTROY; location was /Users/sgilles/opt/clang_debug/MoReFEM/include/ParameterInstances/Fiber/FiberList.hxx 71 in MoReFEM::FiberList<MoReFEM::FiberNS::AtNodeOrAtQuadPt::at_node, MoReFEM::ParameterNS::Type::scalar, MoReFEM::TimeManager<MoReFEM::TimeManagerNS::Policy::VariableTimeStep<MoReFEM::TimeManagerNS::support_restart_mode::no>>>::FiberList(const FiberListNS::unique_id, const FilesystemNS::File &, const Domain &, const FEltSpace &, const TimeManagerT &, const Unknown &) [FiberPolicyT = MoReFEM::FiberNS::AtNodeOrAtQuadPt::at_node, TypeT = MoReFEM::ParameterNS::Type::scalar, TimeManagerT = MoReFEM::TimeManager<MoReFEM::TimeManagerNS::Policy::VariableTimeStep<MoReFEM::TimeManagerNS::support_restart_mode::no>>]
It was hastily coded and needs to be cleaned up; but storing in Vector
the source_location
of the place where it was initialized is rather useful.
Same should be of course done for matrices.