The code I sent compile and run at my side with petsc-3.7.6 (on debian/testing with gcc-6.3). The code you sent does not compile at my side. Anyway, no big deal.
MatGetSubMatrix/MatGetSubMatrices have been renamed to MatCreateSubMatrix/MatCreateSubMatrices in petsc-dev. I thought you were using the master branch and not the latest release. Sorry for the confusion.
To compile the code I have sent, just rename MatCreateSubMatrices with MatGetSubMatrices and it should work.
The modification you propose as far as I understand is to replace "ISCreateGeneral(PETSC_COMM_WORLD" with "ISCreateGeneral(PETSC_COMM_SELF" : still not working at my side (empty dirichlet local matrix). I will try to get that with a MPI matrix (that would contain same data that MatIS : that's what I tried to avoid as this doubles allocations - anyway, no big deal).
In the code, you are already extracting submatrices from MPIAIJ format, not from MATIS. Attached a code that compiles and runs with petsc-3.7.6 Franck
De: "Stefano Zampini" <[email protected]> À: "Franck Houssen" <[email protected]> Cc: "petsc-dev" <[email protected]>, "PETSc users list" <[email protected]>, "petsc-maint" <[email protected]> Envoyé: Mardi 23 Mai 2017 20:23:49 Objet: Re: [petsc-dev] Using PETSc MatIS, how to get local matrix (= one domain) before and after assembly ?
OK. I am supposed to destroy the matrix returned by MatISGetMPIXAIJ ?
Yes Also, my example still not get the final assembled local matrix (the MatCreateSubMatrix returns an empty matrix) but as far as I understand my (global) index set is OK: what did I miss ?
I really doubt you can use the example you have sent. It doesn’t compile, as MatCreateSubMatrix needs an extra argument. Attached a modified version that does what I guess is what you are looking for (sequential Dirichlet problems on the subdomains).
Franck
De: "Stefano Zampini" <[email protected]> À: "Franck Houssen" <[email protected]> Cc: "petsc-dev" <[email protected]>, "PETSc users list" <[email protected]>, "petsc-maint" <[email protected]> Envoyé: Mardi 23 Mai 2017 13:16:18 Objet: Re: [petsc-dev] Using PETSc MatIS, how to get local matrix (= one domain) before and after assembly ?
MatISGetMPIXAIJ is collective, as it assembles the global operator. To get the matrices you are looking for, you should call MatCreateSubMatrix on the assembled global operator, with the global indices representing the subdomain problem. Each process needs to call both functions
Stefano
<matISLocalMat.cpp>
|
out.log
Description: Binary data
matISLocalMat.cpp
Description: Binary data