On , 2020Feb28, at 14:14, Jed Brown
mailto:jed.br...@colorado.edu>> wrote:
Can't do this because std::vector can't be wrapped around existing memory.
That’s why I use gsl::span which ?will be in c++20?
Victor.
Matthew Knepley writes:
> On Fri, Feb 28, 2020 at 2:12 PM Zane Charles Jakobs <
> zane.jak...@colorado.edu> 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
>>
You can create the C++ vector vals and resize it to a proper size, get its
data pointer, then pass it to PETSc,
int n;
Vec x;
std::vector vals;
vals.resize(n); /* You need to calculate n by other means */
ierr =
VecCreateMPIWithArray(PETSC_COMM_WORLD,bs,n,PETSC_DECIDE,vals.data(),);CHKERRQ(ierr);
On Fri, Feb 28, 2020 at 2:12 PM Zane Charles Jakobs <
zane.jak...@colorado.edu> 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
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:
Vec x;