[petsc-users] PETSc Matrix to MatLab

Emmanuel Ayala juaneah at gmail.com
Mon May 20 09:40:55 CDT 2019


Thanks a lot for the advice, I was filling the matrix only with one process.

Best regards.

El vie., 17 de may. de 2019 a la(s) 17:49, Zhang, Hong (hzhang at mcs.anl.gov)
escribió:

> Check your petsc matrix before dumping the data by adding
> MatView(A,PETSC_VIEWER_STDOUT_WORLD);
> immediately after calling MatAssemblyEnd().
> Do you see a correct parallel matrix?
> Hong
>
>
> On Fri, May 17, 2019 at 10:24 AM Emmanuel Ayala via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
>
>> Hello,
>>
>> I am a newby with PETSc. I want to check some matrices generated in
>> PETSc, using MatLab.
>>
>> I created a matrix A (MATMPIAIJ), the partition is defined by PETSc and I
>> defined the global size.
>>
>> Then, I used the next code to save in binary format the matrix from PETSc:
>>
>> PetscViewer    viewer;
>> PetscViewerBinaryOpen(PETSC_COMM_WORLD, "matrix", FILE_MODE_WRITE,
>> &viewer);
>>
>> After that (I think) MatView writes in the viewer:
>>
>> MatView(A,viewer);
>>
>> Then I laod the matrix in MatLab with PetscBinaryRead().
>>
>> For one process everything is Ok, I can see the full pattern of the
>> sparse matrix (spy(A)). But when I generate the matrix A with more than one
>> process, the resultant matrix only contains the data from the process 0.
>>
>> What is the mistake in my procedure?
>>
>> 1. I just want to export the PETSc matrix to MatLab, for any number of
>> process.
>>
>> Regards.
>> Thanks in advance, for your time.
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190520/bed12ce9/attachment.html>


More information about the petsc-users mailing list