Re: [petsc-users] Correct use of VecGetArray with std::vector

2020-02-28 Thread Victor Eijkhout
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.

Re: [petsc-users] Correct use of VecGetArray with std::vector

2020-02-28 Thread Jed Brown
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 >>

Re: [petsc-users] Correct use of VecGetArray with std::vector

2020-02-28 Thread Junchao Zhang via petsc-users
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);

Re: [petsc-users] Correct use of VecGetArray with std::vector

2020-02-28 Thread Matthew Knepley
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

[petsc-users] Correct use of VecGetArray with std::vector

2020-02-28 Thread Zane Charles Jakobs
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;

Re: [petsc-users] Memory leak at GPU when updating matrix of type mpiaijcusparse (CUDA)

2020-02-28 Thread Junchao Zhang via petsc-users
I will take a look at it and get back to you. Thanks. On Fri, Feb 28, 2020, 7:29 AM jordic wrote: > Dear all, > > the following simple program: > > > // > > #include > > PetscInt ierr=0; > int main(int

[petsc-users] Master student exploring DMPLEX and TS/ex11.c

2020-02-28 Thread Domenico Lahaye - EWI
Dear all, I have a master student exploring DMPLEX and TS/ex11.c. He has build his own examples aiming at easing the learning curve. His examples are here GITHUB LINK ->

Re: [petsc-users] MatMatMult

2020-02-28 Thread Emmanuel Ayala
Hi, Thanks. Kind regards. El vie., 28 de feb. de 2020 a la(s) 10:04, hzh...@mcs.anl.gov ( hzh...@mcs.anl.gov) escribió: > Emmanuel: > This is a bug in petsc. I've pushed a fix > https://gitlab.com/petsc/petsc/-/commit/fd2a003f2c07165526de5c2fa5ca4f3c85618da7 > > You can edit it in your petsc

Re: [petsc-users] MatMatMult

2020-02-28 Thread hzhang--- via petsc-users
Emmanuel: This is a bug in petsc. I've pushed a fix https://gitlab.com/petsc/petsc/-/commit/fd2a003f2c07165526de5c2fa5ca4f3c85618da7 You can edit it in your petsc library, or add MatAssemblyBegin/End in your application code until petsc-release is patched. Thanks for reporting it and sending us

[petsc-users] Memory leak at GPU when updating matrix of type mpiaijcusparse (CUDA)

2020-02-28 Thread jordic
Dear all, the following simple program: // #include PetscInt ierr=0; int main(int argc,char **argv) { MPI_Comm comm; PetscMPIInt rank,size; PetscInitialize(,,NULL,help);if (ierr) return ierr;