[petsc-users] custom sparse matrix

Alejandro Marcos Aragón alejandro.aragon at gmail.com
Mon Mar 21 10:14:02 CDT 2011


Hi Barry,

Thanks for your answer. I'll look into those functions, but instead of copying, do you know if there is a way to give the address of the arrays? I want to use the PETSc parallel solver capabilities, but I don't want to copy something that I already have. Now, I'm not familiar with the MatCreateShell() function that you mentioned. Could you expand on this?

Thanks again

Alejandro


On Mar 21, 2011, at 2:14 PM, Barry Smith wrote:

> 
> On Mar 21, 2011, at 6:43 AM, Alejandro Marcos Aragón wrote:
> 
>> Hi everyone,
>> 
>> I'm new to the list and to PETSc. I was wondering if this is possible: in my code I have my own sparse matrix data structure, so instead of creating a sparse matrix from PETSc and copying all the elements, I was wondering if there is a way to specify the storage of the elements. My custom data structure is a three-array compressed row format (or compressed column storage).
> 
>   If it truly is CSR you an use MatCreateSeqAIJWithArrays() or MatCreateMPIAIJWithArrays(). Otherwise you can use MatCreateShell() and provide your own function operations for MatMult() and whatever you will need. 
> 
>   Generally keeping your own sparse matrix data structure is overrated, yes you may save a little time and a little memory but then you use all the flexibility and power of PETSc sparse matrices; why bother with PETSc in that case.
> 
>   Barry
> 
>> 
>> Thank you,
>> 
>> Alejandro M. Aragón, Ph.D.
> 



More information about the petsc-users mailing list