Question

I have sequential block AIJ matrices which are written in c++ and I am going to use PETSc to create MPI matrices. So, I have to substitute my sparse block AIJ matrices into MPI block AIJ PETSc matrices. Does anyone have any example on how to do that? I would appreciate any suggestions regarding to the task I want to do.

Was it helpful?

Solution

A good starting point may be http://www.mcs.anl.gov/petsc/petsc-current/src/mat/examples/tutorials/ex5.c.html :

Opens a separate file for each process and reads in ITS portion
of a large parallel matrix. Only requires enough memory to store
the processes portion of the matrix ONCE.

It makes use of MatSetValues() to set values. Carefully read the documentation to understand what you should do : http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValues.html . The chapter of PETSC'manual on Mat will also help you.

If you would like to work with blocked matrix (BAIJ), you may use MatSetValuesBlocked() http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValuesBlocked.html#MatSetValuesBlocked (and MatSetBlockSize())

Bye,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top