[petsc-users] How to get Matrix from MatGetArray()

behzad baghapour behzad.baghapour at gmail.com
Sat Oct 1 10:44:35 CDT 2011


OK. All I am concering is:

1- define matrix A in sparse format AIJ.
2- Get the content of A.
3- change the content of A for some elements
4- Restore the changed matrix back into origin.

I test MatGetArray( Mat A, PetscScalar* a ) but I couldnt find the correct
content of matrix by using a[i*n+j]. I need to know how to access the
elements of an assembled sparse matrix.

Am I clear now?

Thanks
Behzad

On Sat, Oct 1, 2011 at 6:56 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

>  On Sat, Oct 1, 2011 at 10:23, behzad baghapour <
> behzad.baghapour at gmail.com> wrote:
>
>> I meant by MatAssembly, the global indices of matrix elements (related to
>> a dense format) which is changed into sparse one.
>
>
> I don't understand what you mean. It doesn't make sense to convert "dense"
> indices into sparse ones.
>
>
>> So what would be right pattern to read the content of the Matrix from
>> MatGetArray if I know that the original matrix is created by AIJ?
>
>
> Use MatGetRow() if you need access to this. (The internal data structures
> are different in parallel and serial, so accessing them directly is bad.)
>



-- 
==================================
Behzad Baghapour
Ph.D. Candidate, Mechecanical Engineering
University of Tehran, Tehran, Iran
https://sites.google.com/site/behzadbaghapour
Fax: 0098-21-88020741
==================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111001/a12d46ee/attachment-0001.htm>


More information about the petsc-users mailing list