Matthew Knepley <[email protected]> writes: > On Fri, Feb 28, 2020 at 2:12 PM Zane Charles Jakobs < > [email protected]> wrote: > >> Hi PETSc devs, >> >> I'm writing some C++ code that calls PETSc, and I'd like to be able to >> place the result of VecGetArray into an std::vector and then later call >> VecRestoreArray on that data, or get the same effects. It seems like the >> correct way to do this would be something like: >> > > Why are you calling Get/SetValues() instead Get/SetArray()? Shouldn't you > just get the pointer using GetArray() and stick it into > your std::vector?
Can't do this because std::vector can't be wrapped around existing memory. I would recommend not using std::vector. Dynamic resizing isn't a feature you want in this context, and since you'd like to use existing memory, you need to use a container that can accept existing memory.
