[petsc-users] Prelloc: Get coordinates of local diagonal submatrix
Matthew Knepley
knepley at gmail.com
Wed Apr 6 10:19:23 CDT 2016
On Wed, Apr 6, 2016 at 10:12 AM, Florian Lindner <mailinglists at xgm.de>
wrote:
> Hello,
>
> in order to preallocate I have to know whether a non-zero will be in the
> local diagonal submatrix or not.
>
>
> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html
>
> says:
>
> The DIAGONAL portion of the local submatrix of a processor can be defined
> as the submatrix which is obtained by extraction the part corresponding to
> the rows r1-r2 and columns c1-c2 of the global matrix, where r1 is the
> first row that belongs to the processor, r2 is the last row belonging to
> the this processor, and c1-c2 is range of indices of the local part of a
> vector suitable for applying the matrix to. This is an mxn matrix. In the
> common case of a square matrix, the row and column ranges are the same and
> the DIAGONAL part is also square. The remaining portion of the local
> submatrix (mxN) constitute the OFF-DIAGONAL portion.
>
> Therefore I compute the begin and end rows and cols like that:
>
> int ownerRangeBeginA = _matrixA.ownerRange().first;
> int ownerRangeEndA = _matrixA.ownerRange().second;
>
> // Uses: MatGetVecs(_matrixA.matrix, &vector, nullptr);
> petsc::Vector diagTest{_matrixA, "test", petsc::Vector::RIGHT};
>
> int localDiagColBegin = diagTest.ownerRange().first;
> int localDiagColEnd = diagTest.ownerRange().second;
>
> Debug("Local Submatrix Rows = " << ownerRangeBeginA << " / " <<
> ownerRangeEndA <<
> ", Local Submatrix Cols = " << localDiagColBegin << " / " <<
> localDiagColEnd);
>
>
> It's a little bit tainted by my PETSc C++ helper function, but I think you
> get the code.
>
> Is there a way to do it more elegantly? Without instantiating a vector
> just for the purpose of gettings its owner range? And then testing a if an
> index is inside the local diagonal submatrix?
>
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetOwnershipRangesColumn.html
Thanks,
Matt
> Thanks,
> Florian
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160406/58da7f48/attachment.html>
More information about the petsc-users
mailing list