Re: [petsc-users] How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?

2023-06-20 Thread Jed Brown
Matthew Knepley writes: >> The matrix entries are multiplied by 2, that is, the number of processes >> used to execute the code. >> > > No. This was mostly intended for GPUs, where there is 1 process. If you > want to use multiple MPI processes, then each process can only introduce > some

Re: [petsc-users] How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?

2023-06-20 Thread Diego Magela Lemos via petsc-users
Using all recommended approaches it worked! Thank you all in advance. Now, I'm facing problems when solving a linear system using each approach. *COO approach* Using MatSetPreallocationCOO and then MatSetValuesCOO, I'm able to fill in the matrix when running with 1 MPI process. But, if I run

Re: [petsc-users] How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?

2023-06-20 Thread Jed Brown
You should partition the entries so each entry is submitted by only one process. Note that duplicate entries (on the same or different proceses) are summed as you've seen. For example, in finite elements, it's typical to partition the elements and each process submits entries from its elements.

Re: [petsc-users] How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?

2023-06-20 Thread Diego Magela Lemos via petsc-users
So... what do I need to do, please? Why am I getting wrong results when solving the linear system if the matrix is filled in with MatSetPreallocationCOO and MatSetValuesCOO? Em ter., 20 de jun. de 2023 às 14:56, Jed Brown escreveu: > Matthew Knepley writes: > > >> The matrix entries are

Re: [petsc-users] How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?

2023-06-20 Thread Matthew Knepley
On Tue, Jun 20, 2023 at 2:02 PM Diego Magela Lemos wrote: > So... what do I need to do, please? > Why am I getting wrong results when solving the linear system if the > matrix is filled in with MatSetPreallocationCOO and MatSetValuesCOO? > It appears that you have _all_ processes submit _all_

Re: [petsc-users] How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?

2023-06-20 Thread Matthew Knepley
On Tue, Jun 20, 2023 at 1:43 PM Diego Magela Lemos wrote: > Using all recommended approaches it worked! > Thank you all in advance. > > Now, I'm facing problems when solving a linear system using each approach. > > *COO approach* > I can answer this one. > Using MatSetPreallocationCOO and

Re: [petsc-users] Inquiry about the c++ destructor and PetscFinalize.

2023-06-20 Thread neil liu
Thanks a lot, Constantine. It works pretty well. On Fri, Jun 16, 2023 at 6:52 PM Constantine Khrulev wrote: > In your code the destructor of DMManage is called at the end of scope, > i.e. after the PetscFinalize() call. > > You should be able to avoid this error by putting "DMManage

Re: [petsc-users] How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?

2023-06-20 Thread Matthew Knepley
On Tue, Jun 20, 2023 at 10:55 AM Diego Magela Lemos via petsc-users < petsc-users@mcs.anl.gov> wrote: > Considering, for instance, the following COO sparse matrix format, with > repeated indices: > > std::vector rows{0, 0, 1, 2, 3, 4}; > std::vector cols{0, 0, 1, 2, 3, 4}; > std::vector values{2,

Re: [petsc-users] How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?

2023-06-20 Thread Barry Smith
Since you have 6 entries that needed to be added to the matrix you will need to call MatSetValues() six time for the six entries. > On Jun 20, 2023, at 11:06 AM, Matthew Knepley wrote: > > On Tue, Jun 20, 2023 at 10:55 AM Diego Magela Lemos via petsc-users >

[petsc-users] How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?

2023-06-20 Thread Diego Magela Lemos via petsc-users
Considering, for instance, the following COO sparse matrix format, with repeated indices: std::vector rows{0, 0, 1, 2, 3, 4}; std::vector cols{0, 0, 1, 2, 3, 4}; std::vector values{2, -1, 2, 3, 4, 5}; that represents a 5x5 diagonal matrix A. So far, the code that I have is: //

[petsc-users] 2023 PETSc Annual Meeting slides and videos

2023-06-20 Thread Isaac, Toby via petsc-users
Two weeks ago we held the 2023 PETSc Annual Meeting on the campus of the Illinois Institute of Technology. The meeting was a lot of fun: we had over 30 speakers from industry, academia, and national laboratories present on their research and experiences with PETSc, including several

Re: [petsc-users] How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?

2023-06-20 Thread Stefano Zampini
The loop should iterate on the number of entries of the array, not the number of local rows On Tue, Jun 20, 2023, 17:07 Matthew Knepley wrote: > On Tue, Jun 20, 2023 at 10:55 AM Diego Magela Lemos via petsc-users < > petsc-users@mcs.anl.gov> wrote: > >> Considering, for instance, the following