# [petsc-users] Linear solver diverging

Matthew Knepley knepley at gmail.com
Wed Apr 1 11:39:21 CDT 2015

```On Wed, Apr 1, 2015 at 11:34 AM, bichinhoverde <
bichinhoverde at spwinternet.com.br> wrote:

> The reviewer said: "direct methods are useless for realistic problems".
> ​Unthinking prejudice?
>

The phrase realistic problems is stupid on its face. What I can say is that
a direct solver applied to
the 2D constant coefficient Poisson equation is unlikely to beat geometric
multigrid on anything
but small problems.

Thanks,

Matt

> Maybe I will just compare the performance of the non-compact iterative
> version to the compact direct one and show that it is not that bad.
>
> Thanks for the help.
>
>
>
>
> On Wed, Apr 1, 2015 at 1:24 PM, Matthew Knepley <knepley at gmail.com> wrote:
>
>> On Wed, Apr 1, 2015 at 11:07 AM, bichinhoverde <
>> bichinhoverde at spwinternet.com.br> wrote:
>>
>>> The system I am trying to solve is a 2D Poisson equation, but split into
>>> 5 1D equations. Something like this:
>>>
>>> p_xx + p_yy = f
>>> p_xx - d(p_x)/dx = 0
>>> p_yy - d(p_y)/dy = 0
>>> p_x - d(p)/dx = 0
>>> p_y - d(p)/dy = 0
>>>
>>> If I use standard finite differences, it works fine with gmres and
>>> jacobi. But when I switch to compact finite differences, only the direct
>>> solver works.
>>>
>>> It is on a staggered mesh, so p, p_xx and p_yy are on the cell center
>>> and p_x and p_y are on the edges.
>>>
>>> I recently submitted a paper and the reviewer complained about the
>>> direct linear solver. So I wanted to do a performance comparison.
>>>
>>
>> I am not sure why the direct solver is a problem, other than
>> ​​
>> unthinking prejudice.
>>
>> If you want to use an iterative solver here, you will likely need to use
>> PCFIELDSPLIT since you have saddle-point
>> structure from the constraints (I think).
>>
>>   Thanks,
>>
>>     Matt
>>
>>
>>> On Wed, Apr 1, 2015 at 12:58 PM, Matthew Knepley <knepley at gmail.com>
>>> wrote:
>>>
>>>> On Wed, Apr 1, 2015 at 10:51 AM, bichinhoverde <
>>>> bichinhoverde at spwinternet.com.br> wrote:
>>>>
>>>>> I have a linear system which I can easily solve using the Pardiso
>>>>> library, which is a direct solver. But when I try Petsc, the solver does
>>>>> not converge. It reduces the norm a little but then gets stuck.
>>>>>
>>>>> I tried several combinations of pc_type and ksp_type. It seems that
>>>>> pc=jacobi is better, since my linear system does not have the diagonal
>>>>> element in some rows.
>>>>>
>>>>> Is there some advice you can give me? Some way to analyse the matrix
>>>>> and find out why it does not work?
>>>>>
>>>>
>>>> Without knowing anything about the system, there is nothing you can say.
>>>>
>>>> Why do you want to change from using a direct solver?
>>>>
>>>> Have you looked in the literature for iterative solvers that work on
>>>> this problem?
>>>>
>>>>   Thanks,
>>>>
>>>>     Matt
>>>>
>>>> --
>>>> What most experimenters take for granted before they begin their
>>>> experiments is infinitely more interesting than any results to which their
>>>> -- Norbert Wiener
>>>>
>>>
>>>
>>
>>
>> --
>> What most experimenters take for granted before they begin their
>> experiments is infinitely more interesting than any results to which their
>> -- Norbert Wiener
>>
>
>

--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their