Re: [petsc-users] Elliptic operator with Neumann conditions

2018-02-07 Thread Mark Adams
On Wed, Feb 7, 2018 at 2:24 PM, Smith, Barry F.  wrote:

>
>A square matrix with a null space results in an underdetermined system,
> that is a solution with more than one solution. The solutions can be
> written asx + alpha_1 v_1 + ... alpha_n v_n where the v_n form an
> orthonormal basis for the null space and x is orthogonal to the null space.
>
>When you provide the null space KSP Krylov methods find the norm
> minimizing solution (x) , that is it finds the x with the smallest norm
> that satisfies the system. This is exactly the same as saying you take any
> solution of the system and remove all the components in the directions of
> the null space.
>
>If you do not provide the null space then the Krylov space may find you
> a solution that is not the norm minimizing solution, thus that solution has
> a component of the null space within it. What component of the null space
> in the solution depends on what you use for an initial guess and right hand
> side.
>

Additionally, assuming your initial guess is orthogonal to the null space,
of course, your solution can "float" away from roundoff error. This is what
you were seeing initially w/o the null space. As you saw you can just
project it out yourself but as Barry said it is better to let KSP do it.


>
>When you have a preconditioner then things can get trickier because the
> preconditioner can (unless you remove them) components in the direction of
> the null space. These components can get amplified with each iteration of
> the Krylov method so it looks like the Krylov method is not converging
> since the norm of the solution is getting larger and larger (these larger
> components are in the null space.) This is why one should always provide
> the null space when solving singular systems with singular matrices.
>
>   Barry
>
>
> > On Feb 7, 2018, at 11:43 AM, Marco Cisternino <
> marco.cistern...@optimad.it> wrote:
> >
> > Hi everybody,
> > I would like to ask what solution is computed if I try to solve the
> linear system relative to the problem in subject without creating the null
> space.
> > I tried with and without the call to
> > MatNullSpaceCreate(m_communicator, PETSC_TRUE, 0, NULL, );
> > and I get zero averaged solution with and the same solution plus a
> constant without.
> > How does PETSc  work in the second case?
> > Does it check the matrix singularity? And is it able to create the null
> space with the constant automatically?
> > Thanks.
> >
> >
> > Marco Cisternino, PhD
> > marco.cistern...@optimad.it
> > ___
> > OPTIMAD Engineering srl
> > Via Giacinto Collegno 18, Torino, Italia.
> > +3901119719782
> > www.optimad.it
> >
>
>


Re: [petsc-users] Elliptic operator with Neumann conditions

2018-02-07 Thread Marco Cisternino
Barry, thanks a lot!
Exactly what I wanted to understand and clearly explained.
Again thank you very much.

Marco

Ottieni Outlook per Android<https://aka.ms/ghei36>


From: Smith, Barry F. <bsm...@mcs.anl.gov>
Sent: Wednesday, February 7, 2018 8:24:22 PM
To: Marco Cisternino
Cc: petsc-users
Subject: Re: [petsc-users] Elliptic operator with Neumann conditions


   A square matrix with a null space results in an underdetermined system, that 
is a solution with more than one solution. The solutions can be written asx 
+ alpha_1 v_1 + ... alpha_n v_n where the v_n form an orthonormal basis for the 
null space and x is orthogonal to the null space.

   When you provide the null space KSP Krylov methods find the norm minimizing 
solution (x) , that is it finds the x with the smallest norm that satisfies the 
system. This is exactly the same as saying you take any solution of the system 
and remove all the components in the directions of the null space.

   If you do not provide the null space then the Krylov space may find you a 
solution that is not the norm minimizing solution, thus that solution has a 
component of the null space within it. What component of the null space in the 
solution depends on what you use for an initial guess and right hand side.

   When you have a preconditioner then things can get trickier because the 
preconditioner can (unless you remove them) components in the direction of the 
null space. These components can get amplified with each iteration of the 
Krylov method so it looks like the Krylov method is not converging since the 
norm of the solution is getting larger and larger (these larger components are 
in the null space.) This is why one should always provide the null space when 
solving singular systems with singular matrices.

  Barry


> On Feb 7, 2018, at 11:43 AM, Marco Cisternino <marco.cistern...@optimad.it> 
> wrote:
>
> Hi everybody,
> I would like to ask what solution is computed if I try to solve the linear 
> system relative to the problem in subject without creating the null space.
> I tried with and without the call to
> MatNullSpaceCreate(m_communicator, PETSC_TRUE, 0, NULL, );
> and I get zero averaged solution with and the same solution plus a constant 
> without.
> How does PETSc  work in the second case?
> Does it check the matrix singularity? And is it able to create the null space 
> with the constant automatically?
> Thanks.
>
>
> Marco Cisternino, PhD
> marco.cistern...@optimad.it
> ___
> OPTIMAD Engineering srl
> Via Giacinto Collegno 18, Torino, Italia.
> +3901119719782
> www.optimad.it<http://www.optimad.it>
>



Re: [petsc-users] Elliptic operator with Neumann conditions

2018-02-07 Thread Smith, Barry F.

   A square matrix with a null space results in an underdetermined system, that 
is a solution with more than one solution. The solutions can be written asx 
+ alpha_1 v_1 + ... alpha_n v_n where the v_n form an orthonormal basis for the 
null space and x is orthogonal to the null space.

   When you provide the null space KSP Krylov methods find the norm minimizing 
solution (x) , that is it finds the x with the smallest norm that satisfies the 
system. This is exactly the same as saying you take any solution of the system 
and remove all the components in the directions of the null space.

   If you do not provide the null space then the Krylov space may find you a 
solution that is not the norm minimizing solution, thus that solution has a 
component of the null space within it. What component of the null space in the 
solution depends on what you use for an initial guess and right hand side.

   When you have a preconditioner then things can get trickier because the 
preconditioner can (unless you remove them) components in the direction of the 
null space. These components can get amplified with each iteration of the 
Krylov method so it looks like the Krylov method is not converging since the 
norm of the solution is getting larger and larger (these larger components are 
in the null space.) This is why one should always provide the null space when 
solving singular systems with singular matrices.

  Barry


> On Feb 7, 2018, at 11:43 AM, Marco Cisternino  
> wrote:
> 
> Hi everybody,
> I would like to ask what solution is computed if I try to solve the linear 
> system relative to the problem in subject without creating the null space.
> I tried with and without the call to
> MatNullSpaceCreate(m_communicator, PETSC_TRUE, 0, NULL, );
> and I get zero averaged solution with and the same solution plus a constant 
> without.
> How does PETSc  work in the second case?
> Does it check the matrix singularity? And is it able to create the null space 
> with the constant automatically?
> Thanks.
> 
> 
> Marco Cisternino, PhD
> marco.cistern...@optimad.it
> ___
> OPTIMAD Engineering srl
> Via Giacinto Collegno 18, Torino, Italia.
> +3901119719782
> www.optimad.it
> 



Re: [petsc-users] Elliptic operator with Neumann conditions

2018-02-07 Thread Matthew Knepley
On Wed, Feb 7, 2018 at 1:45 PM, Marco Cisternino <
marco.cistern...@optimad.it> wrote:

> I'm sorry Matt but I cannot understand what flexible gmres computes when
> no null space is created.
> Could you give me some hints, please? Even in very simple cases...
>

I don't think I can clear it up any further.

  Thanks,

Matt


> Thanks
>
>
> Marco Cisternino, PhD
> marco.cistern...@optimad.it
> ___
> OPTIMAD Engineering srl
> Via Giacinto Collegno 18, Torino, Italia.
> +3901119719782
> www.optimad.it
>
>
> 
> Da: Matthew Knepley <knep...@gmail.com>
> Inviato: mercoledì 7 febbraio 2018 19:38:08
> A: Marco Cisternino
> Cc: petsc-users
> Oggetto: Re: [petsc-users] Elliptic operator with Neumann conditions
>
> On Thu, Feb 8, 2018 at 5:29 AM, Marco Cisternino <
> marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>> wrote:
> Thanks Matt,
> I'm using KSPFGMRES and I'm sorry but what do you mean with initial
> residual?
> I also force a non-zero initial guess.
>
> If your initial residual has a component in the null space of the
> operator, it is likely to stay there.
>
>Matt
>
> Thanks again
>
>
> Marco Cisternino, PhD
> marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>
> ___
> OPTIMAD Engineering srl
> Via Giacinto Collegno 18, Torino, Italia.
> +3901119719782<tel:%2B3901119719782>
> www.optimad.it<http://www.optimad.it>
>
>
> ____________
> Da: Matthew Knepley <knep...@gmail.com<mailto:knep...@gmail.com>>
> Inviato: mercoledì 7 febbraio 2018 18:57:56
> A: Marco Cisternino
> Cc: petsc-users
> Oggetto: Re: [petsc-users] Elliptic operator with Neumann conditions
>
> On Thu, Feb 8, 2018 at 4:43 AM, Marco Cisternino <
> marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it> marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>>> wrote:
> Hi everybody,
> I would like to ask what solution is computed if I try to solve the linear
> system relative to the problem in subject without creating the null space.
> I tried with and without the call to
> MatNullSpaceCreate(m_communicator, PETSC_TRUE, 0, NULL, );
> and I get zero averaged solution with and the same solution plus a
> constant without.
> How does PETSc  work in the second case?
>
> It depends on the Krylov method you use and the initial residual. We do
> not do anything special.
>
>   Thanks,
>
>  Matt
>
> Does it check the matrix singularity? And is it able to create the null
> space with the constant automatically?
> Thanks.
>
>
> Marco Cisternino, PhD
> marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it> marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>>
> ___
> OPTIMAD Engineering srl
> Via Giacinto Collegno 18, Torino, Italia.
> +3901119719782<tel:%2B3901119719782><tel:%2B3901119719782>
> www.optimad.it<http://www.optimad.it><http://www.optimad.it>
>
>
>
>
> --
> 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
>
> https://www.cse.buffalo.edu/~knepley/<http://www.caam.rice.edu/~mk51/>
>
>
>
> --
> 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
>
> https://www.cse.buffalo.edu/~knepley/<http://www.caam.rice.edu/~mk51/>
>



-- 
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

https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>


Re: [petsc-users] Elliptic operator with Neumann conditions

2018-02-07 Thread Marco Cisternino
I'm sorry Matt but I cannot understand what flexible gmres computes when no 
null space is created.
Could you give me some hints, please? Even in very simple cases...
Thanks


Marco Cisternino, PhD
marco.cistern...@optimad.it
___
OPTIMAD Engineering srl
Via Giacinto Collegno 18, Torino, Italia.
+3901119719782
www.optimad.it



Da: Matthew Knepley <knep...@gmail.com>
Inviato: mercoledì 7 febbraio 2018 19:38:08
A: Marco Cisternino
Cc: petsc-users
Oggetto: Re: [petsc-users] Elliptic operator with Neumann conditions

On Thu, Feb 8, 2018 at 5:29 AM, Marco Cisternino 
<marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>> wrote:
Thanks Matt,
I'm using KSPFGMRES and I'm sorry but what do you mean with initial residual?
I also force a non-zero initial guess.

If your initial residual has a component in the null space of the operator, it 
is likely to stay there.

   Matt

Thanks again


Marco Cisternino, PhD
marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>
___
OPTIMAD Engineering srl
Via Giacinto Collegno 18, Torino, Italia.
+3901119719782<tel:%2B3901119719782>
www.optimad.it<http://www.optimad.it>



Da: Matthew Knepley <knep...@gmail.com<mailto:knep...@gmail.com>>
Inviato: mercoledì 7 febbraio 2018 18:57:56
A: Marco Cisternino
Cc: petsc-users
Oggetto: Re: [petsc-users] Elliptic operator with Neumann conditions

On Thu, Feb 8, 2018 at 4:43 AM, Marco Cisternino 
<marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it><mailto:marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>>>
 wrote:
Hi everybody,
I would like to ask what solution is computed if I try to solve the linear 
system relative to the problem in subject without creating the null space.
I tried with and without the call to
MatNullSpaceCreate(m_communicator, PETSC_TRUE, 0, NULL, );
and I get zero averaged solution with and the same solution plus a constant 
without.
How does PETSc  work in the second case?

It depends on the Krylov method you use and the initial residual. We do not do 
anything special.

  Thanks,

 Matt

Does it check the matrix singularity? And is it able to create the null space 
with the constant automatically?
Thanks.


Marco Cisternino, PhD
marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it><mailto:marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>>
___
OPTIMAD Engineering srl
Via Giacinto Collegno 18, Torino, Italia.
+3901119719782<tel:%2B3901119719782><tel:%2B3901119719782>
www.optimad.it<http://www.optimad.it><http://www.optimad.it>




--
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

https://www.cse.buffalo.edu/~knepley/<http://www.caam.rice.edu/~mk51/>



--
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

https://www.cse.buffalo.edu/~knepley/<http://www.caam.rice.edu/~mk51/>


Re: [petsc-users] Elliptic operator with Neumann conditions

2018-02-07 Thread Matthew Knepley
On Thu, Feb 8, 2018 at 5:29 AM, Marco Cisternino <
marco.cistern...@optimad.it> wrote:

> Thanks Matt,
> I'm using KSPFGMRES and I'm sorry but what do you mean with initial
> residual?
> I also force a non-zero initial guess.
>

If your initial residual has a component in the null space of the operator,
it is likely to stay there.

   Matt


> Thanks again
>
>
> Marco Cisternino, PhD
> marco.cistern...@optimad.it
> ___
> OPTIMAD Engineering srl
> Via Giacinto Collegno 18, Torino, Italia.
> +3901119719782
> www.optimad.it
>
>
> 
> Da: Matthew Knepley <knep...@gmail.com>
> Inviato: mercoledì 7 febbraio 2018 18:57:56
> A: Marco Cisternino
> Cc: petsc-users
> Oggetto: Re: [petsc-users] Elliptic operator with Neumann conditions
>
> On Thu, Feb 8, 2018 at 4:43 AM, Marco Cisternino <
> marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>> wrote:
> Hi everybody,
> I would like to ask what solution is computed if I try to solve the linear
> system relative to the problem in subject without creating the null space.
> I tried with and without the call to
> MatNullSpaceCreate(m_communicator, PETSC_TRUE, 0, NULL, );
> and I get zero averaged solution with and the same solution plus a
> constant without.
> How does PETSc  work in the second case?
>
> It depends on the Krylov method you use and the initial residual. We do
> not do anything special.
>
>   Thanks,
>
>  Matt
>
> Does it check the matrix singularity? And is it able to create the null
> space with the constant automatically?
> Thanks.
>
>
> Marco Cisternino, PhD
> marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>
> ___
> OPTIMAD Engineering srl
> Via Giacinto Collegno 18, Torino, Italia.
> +3901119719782<tel:%2B3901119719782>
> www.optimad.it<http://www.optimad.it>
>
>
>
>
> --
> 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
>
> https://www.cse.buffalo.edu/~knepley/<http://www.caam.rice.edu/~mk51/>
>



-- 
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

https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>


Re: [petsc-users] Elliptic operator with Neumann conditions

2018-02-07 Thread Marco Cisternino
Thanks Matt,
I'm using KSPFGMRES and I'm sorry but what do you mean with initial residual?
I also force a non-zero initial guess.
Thanks again


Marco Cisternino, PhD
marco.cistern...@optimad.it
___
OPTIMAD Engineering srl
Via Giacinto Collegno 18, Torino, Italia.
+3901119719782
www.optimad.it



Da: Matthew Knepley <knep...@gmail.com>
Inviato: mercoledì 7 febbraio 2018 18:57:56
A: Marco Cisternino
Cc: petsc-users
Oggetto: Re: [petsc-users] Elliptic operator with Neumann conditions

On Thu, Feb 8, 2018 at 4:43 AM, Marco Cisternino 
<marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>> wrote:
Hi everybody,
I would like to ask what solution is computed if I try to solve the linear 
system relative to the problem in subject without creating the null space.
I tried with and without the call to
MatNullSpaceCreate(m_communicator, PETSC_TRUE, 0, NULL, );
and I get zero averaged solution with and the same solution plus a constant 
without.
How does PETSc  work in the second case?

It depends on the Krylov method you use and the initial residual. We do not do 
anything special.

  Thanks,

 Matt

Does it check the matrix singularity? And is it able to create the null space 
with the constant automatically?
Thanks.


Marco Cisternino, PhD
marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>
___
OPTIMAD Engineering srl
Via Giacinto Collegno 18, Torino, Italia.
+3901119719782<tel:%2B3901119719782>
www.optimad.it<http://www.optimad.it>




--
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

https://www.cse.buffalo.edu/~knepley/<http://www.caam.rice.edu/~mk51/>


Re: [petsc-users] Elliptic operator with Neumann conditions

2018-02-07 Thread Matthew Knepley
On Thu, Feb 8, 2018 at 4:43 AM, Marco Cisternino <
marco.cistern...@optimad.it> wrote:

> Hi everybody,
> I would like to ask what solution is computed if I try to solve the linear
> system relative to the problem in subject without creating the null space.
> I tried with and without the call to
> MatNullSpaceCreate(m_communicator, PETSC_TRUE, 0, NULL, );
> and I get zero averaged solution with and the same solution plus a
> constant without.
> How does PETSc  work in the second case?
>

It depends on the Krylov method you use and the initial residual. We do not
do anything special.

  Thanks,

 Matt


> Does it check the matrix singularity? And is it able to create the null
> space with the constant automatically?
> Thanks.
>
>
> Marco Cisternino, PhD
> marco.cistern...@optimad.it
> ___
> OPTIMAD Engineering srl
> Via Giacinto Collegno 18, Torino, Italia.
> +3901119719782
> www.optimad.it
>
>


-- 
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

https://www.cse.buffalo.edu/~knepley/