[petsc-users] zero diagonals

Barry Smith bsmith at mcs.anl.gov
Fri Apr 30 13:03:48 CDT 2010


   No, nor is there likely a reason you would want to do that. It is  
practically mathematically meaningless.

   You can write a routine that loops over each local row, checks if  
the row has zero diagonal, keep the list of these rows and then call  
MatSetValues() for the diagonals of those rows and put whatever value  
you want in there. Note: you cannot mix calls to MatGetRow() and  
MatSetValues() so call ALL the MatGetRows() and then call all the  
MatSetValues().

    Barry

On Apr 30, 2010, at 12:42 PM, hxie at umn.edu wrote:

>
> Hi,
>
> The Matshift will shift all the diagonals. Is there a function to  
> shift only the zero diagonals?
>
> Bests,
> Hui
>
>
>
>
>> Date: Mon, 19 Apr 2010 16:08:34 -0500
>> From: Barry Smith <bsmith at mcs.anl.gov>
>> Subject: Re: [petsc-users] zero diagonals
>> To: PETSc users list <petsc-users at mcs.anl.gov>
>> Message-ID: <8CCA772D-DD35-4396-9951-DF23AC833863 at mcs.anl.gov>
>> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>>
>>
>>   -pc_factor_mat_shift_type nonzero or -sub_pc_factor_shift_type   
>> nonzero or -mg_coarse_pc_factor_shift_type nonzero depending on  
>> where  it is used.
>>
>>   You can always run with -help and grep for shift_type to find  
>> out  which one is needed
>>
>>   Barry
>>
>>
>> On Apr 19, 2010, at 4:04 PM, hxie at umn.edu wrote:
>>
>>> Hi,
>>> I have a matrix with some zero diagonals. Now I create a new  
>>> matrix  for preconditioner and use Matshift to avoid the zero  
>>> diagonals in  the preconditioner matrix. It works fine. Is that  
>>> possible to just  use the command line options? If I just want to  
>>> shift the zero  diagonals, how can I do that? Thanks.
>>>
>>> Bests,
>>> Hui
>>>
>>>
>>
>>
>>
>



More information about the petsc-users mailing list