[petsc-users] Scale the diagonal entries of a Mat
Hui Zhang
mike.hui.zhang at hotmail.com
Sat Feb 23 07:54:29 CST 2013
Sorry, I found the answer from the source code of Petsc. All the MatZero things are not for unassembled matrix.
On Feb 23, 2013, at 2:43 PM, Hui Zhang wrote:
> Should MatZeroRowsColumnsLocalIS also be done before MatAssembly?
>
> I used MatZeroRows one year ago. At that time, petsc asked me the Mat must have already been assembled.
>
> On Feb 23, 2013, at 2:37 PM, Jed Brown wrote:
>
>> (You should really not use penalties, but if you insist on doing it, you should implement it the way I describe. There is no point assembling before imposing boundary conditions.)
>>
>> On Feb 23, 2013 7:32 AM, "Jed Brown" <jedbrown at mcs.anl.gov> wrote:
>> You should really use MatSetValuesLocal with ADD_VALUES *before* assembling.
>>
>> On Feb 23, 2013 7:28 AM, "Hui Zhang" <mike.hui.zhang at hotmail.com> wrote:
>>
>> On Feb 23, 2013, at 1:37 PM, Matthew Knepley wrote:
>>
>>> On Sat, Feb 23, 2013 at 7:35 AM, Hui Zhang <mike.hui.zhang at hotmail.com> wrote:
>>>
>>> On Feb 23, 2013, at 1:32 PM, Matthew Knepley wrote:
>>>
>>>> On Sat, Feb 23, 2013 at 7:29 AM, Hui Zhang <mike.hui.zhang at hotmail.com> wrote:
>>>> I want to implement diagonal penalty method for enforcing the Dirichlet boundary conditions. That is, the diagonal entries corresponding to Dirichlet boundary are going to be scaled by a large number.
>>>>
>>>> What is the easiest way to do this? Thanks!
>>>>
>>>> http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatDiagonalScale.html
>>>
>>> But it seems not what I want. That routine scales all the entries of a mat. I want to scale only the diagonal entries.
>>>
>>> Then use http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatDiagonalSet.html
>>
>> I want to do the following on an already assembled matrix (FINAL_ASSEMBLY).
>>
>> MatGetLocalSubMatrix .. to get 'submat',
>> MatGetDiagonal .. to get diagonal vector 'diag',
>> VecScale .. to scale 'diag'
>> MatDiagonalSet .. to set scaled 'diag' to 'submat'
>> MatRestoreLocalSubMatrix .. to restore 'submat'
>>
>> After the above process, do I need MatAssemblyBegin/End again? I do not know why the penalty method is bad. Maybe because the bad conditioning? I just want to try out and compare with MatZeroRowsColumns (lift and remove) method.
>>
>>>
>>> As Jed says, you really really do not want to do this.
>>>
>>> Matt
>>>
>>>>
>>>> Matt
>>>>
>>>> --
>>>> 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
>>>
>>>
>>>
>>>
>>> --
>>> 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
>>
>
>
More information about the petsc-users
mailing list