[petsc-users] MatAYPX for dense and sparse matrices

Alexander Grayver agrayver at gfz-potsdam.de
Mon Mar 21 07:49:55 CDT 2011


On 21.03.2011 12:45, Matthew Knepley wrote:
> On Mon, Mar 21, 2011 at 6:40 AM, Alexander Grayver 
> <agrayver at gfz-potsdam.de <mailto:agrayver at gfz-potsdam.de>> wrote:
>
>     On 21.03.2011 12 <tel:21.03.2011%2012>:37, Jed Brown wrote:
>>     On Mon, Mar 21, 2011 at 12:31, Alexander Grayver
>>     <agrayver at gfz-potsdam.de <mailto:agrayver at gfz-potsdam.de>> wrote:
>>
>>         Would I have to rebuild PETSc from scratch to make this
>>         wrapper working?
>>
>>
>>     You would put it in your project and link it with your Fortran code.
>>
>>
>>
>>>         Alternatively, the code for this is really simple, just
>>>         iterate through the rows of L and insert them into J.
>>         Do you mean using
>>         MatGetOwnershipRange+MatGetSubMatrices+MatGetRow?
>>
>>
>>     Just translate the following (taken from MatAXPY_Basic) to Fortran:
>>
>>       ierr = MatGetSize(X,&m,&n);CHKERRQ(ierr);
>>       ierr = MatGetOwnershipRange(X,&start,&end);CHKERRQ(ierr);
>>       for (i = start; i < end; i++) {
>>         ierr = MatGetRow(X,i,&ncols,&row,&vals);CHKERRQ(ierr);
>>         ierr =
>>     MatSetValues(Y,1,&i,ncols,row,vals,ADD_VALUES);CHKERRQ(ierr);
>>         ierr = MatRestoreRow(X,i,&ncols,&row,&vals);CHKERRQ(ierr);
>>       }
>>       ierr = MatAssemblyBegin(Y,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
>>       ierr = MatAssemblyEnd(Y,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
>>
>     Thanks Jed, it looks simple enough for me (PETSc is great).
>
>     One more question. I get matrix J out of MatMatMult operation and
>     then I have to add L matrix up, wouldn't there be a conflict using
>     MatAssemblyBegin/MatAssemblyEnd again? Generally, is it allowed to
>     set new values into the matrix after
>     MatAssemblyBegin/MatAssemblyEnd already has been done once?
>
>
> No, you can use them. However, if you are adding to existing values on 
> your process, nothing happens.
>
>    Matt
>
>     Thanks a lot.
>
>
>
>
> -- 
> 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
Matt
Jed,

Thanks a lot!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110321/05ab45b2/attachment.htm>


More information about the petsc-users mailing list