Re: [petsc-users] Problems about Picard and NolinearGS

2019-01-04 Thread Jed Brown via petsc-users
Yingjie Wu  writes:

> Thank you very much for your answer.
> I tried to use the quasi-Newton method to solve some examples, except
> ex48(in src/snes/example/tutorial), the ex3 and the ex19 will produce the
> same error information. The error information is as follows. Is there
> anything I should pay attention to when using the quasi-Newton method?
> args: -snes_type qn -snes_qn_restart_type periodic -snes_qn_scale_type
> jacobian
>
> In ex3, it has a routine about Jacobian, while in ex19 without a Jacobian
> routine.
> Is the quasi-Newton method use the inverse of the initial Jacobian matrix
> by finite difference ?
>
> Error information in ex3:
> mpiexec -n 2 ./ex3 -snes_type qn -snes_qn_restart_type periodic
> -snes_qn_scale_type jacobian -snes_view
> atol=1e-50, rtol=1e-08, stol=1e-08, maxit=1, maxf=3
> iter = 0,SNES Function norm 5.41468
> iter = 1,SNES Function norm 0.806152
> iter = 2,SNES Function norm 0.459274
> iter = 3,SNES Function norm 0.0562937
> iter = 4,SNES Function norm 0.00756409
> iter = 5,SNES Function norm 0.00153315
> iter = 6,SNES Function norm 0.000108099
> iter = 7,SNES Function norm 2.8e-06
> iter = 8,SNES Function norm 5.56429e-08
> iter = 9,SNES Function norm 5.56429e-08
> [0]PETSC ERROR: - Error Message
> --
> [0]PETSC ERROR: Floating point exception

-snes_qn_type broyden may help.  The default (BFGS) is for symmetric
problems and this formulation (with boundary conditions) is not
symmetric.

> [0]PETSC ERROR: Vec entry at local location 0 is not-a-number or infinite
> at beginning of function: Parameter number 2
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for
> trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.10.1, Sep, 26, 2018
> [0]PETSC ERROR: ./ex3 on a arch-linux2-c-debug named yjwu-XPS-8910 by yjwu
> Fri Jan  4 09:11:00 2019
> [0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++
> --with-fc=gfortran --download-mpich --download-fblaslapack
> [0]PETSC ERROR: #1 VecValidValues() line 26 in
> /home/yjwu/petsc-3.10.1/src/vec/vec/interface/rvector.c
> [0]PETSC ERROR: #2 SNESComputeFunction() line 2234 in
> /home/yjwu/petsc-3.10.1/src/snes/interface/snes.c
> [1]PETSC ERROR: - Error Message
> --
> [1]PETSC ERROR: Floating point exception
> [1]PETSC ERROR: Vec entry at local location 0 is not-a-number or infinite
> at beginning of function: Parameter number 2
> [1]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for
> trouble shooting.
> [1]PETSC ERROR: Petsc Release Version 3.10.1, Sep, 26, 2018
> [1]PETSC ERROR: ./ex3 on a arch-linux2-c-debug named yjwu-XPS-8910 by yjwu
> Fri Jan  4 09:11:00 2019
> [1]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++
> --with-fc=gfortran --download-mpich --download-fblaslapack
> [1]PETSC ERROR: #1 VecValidValues() line 26 in
> /home/yjwu/petsc-3.10.1/src/vec/vec/interface/rvector.c
> [1]PETSC ERROR: #2 SNESComputeFunction() line 2234 in
> /home/yjwu/petsc-3.10.1/src/snes/interface/snes.c
> [1]PETSC ERROR: #3 SNESLineSearchApply_CP() line 48 in
> /home/yjwu/petsc-3.10.1/src/snes/linesearch/impls/cp/linesearchcp.c
> [1]PETSC ERROR: #4 SNESLineSearchApply() line 648 in
> /home/yjwu/petsc-3.10.1/src/snes/linesearch/interface/linesearch.c
> [0]PETSC ERROR: #3 SNESLineSearchApply_CP() line 48 in
> /home/yjwu/petsc-3.10.1/src/snes/linesearch/impls/cp/linesearchcp.c
> [0]PETSC ERROR: #4 SNESLineSearchApply() line 648 in
> /home/yjwu/petsc-3.10.1/src/snes/linesearch/interface/linesearch.c
> [0]PETSC ERROR: #5 SNESSolve_QN() line 403 in
> /home/yjwu/petsc-3.10.1/src/snes/impls/qn/qn.c
> [0]PETSC ERROR: [1]PETSC ERROR: #5 SNESSolve_QN() line 403 in
> /home/yjwu/petsc-3.10.1/src/snes/impls/qn/qn.c
> [1]PETSC ERROR: #6 SNESSolve() line 4396 in
> /home/yjwu/petsc-3.10.1/src/snes/interface/snes.c
> #6 SNESSolve() line 4396 in
> /home/yjwu/petsc-3.10.1/src/snes/interface/snes.c
> [0]PETSC ERROR: [1]PETSC ERROR: #7 main() line 277 in
> /home/yjwu/petsc-3.10.1/src/snes/examples/tutorials/ex3.c
> #7 main() line 277 in
> /home/yjwu/petsc-3.10.1/src/snes/examples/tutorials/ex3.c
> [0]PETSC ERROR: PETSc Option Table entries:
> [1]PETSC ERROR: PETSc Option Table entries:
> [1]PETSC ERROR: [0]PETSC ERROR: -snes_qn_restart_type periodic
> [0]PETSC ERROR: -snes_qn_restart_type periodic
> [1]PETSC ERROR: -snes_qn_scale_type jacobian
> [1]PETSC ERROR: -snes_qn_scale_type jacobian
> [0]PETSC ERROR: -snes_type qn
> [0]PETSC ERROR: -snes_type qn
> [1]PETSC ERROR: -snes_view
> -snes_view
> [0]PETSC ERROR: End of Error Message ---send entire
> error message to petsc-ma...@mcs.anl.gov--
> [1]PETSC ERROR: End of Error Message ---send entire
> error message to petsc-ma...@mcs.anl.gov--
> application called MPI_Abort(MPI_COMM_WORLD, 72) - process 0
> application called 

Re: [petsc-users] Problems about Picard and NolinearGS

2019-01-04 Thread Yingjie Wu via petsc-users
Thank you very much for your answer.
I tried to use the quasi-Newton method to solve some examples, except
ex48(in src/snes/example/tutorial), the ex3 and the ex19 will produce the
same error information. The error information is as follows. Is there
anything I should pay attention to when using the quasi-Newton method?
args: -snes_type qn -snes_qn_restart_type periodic -snes_qn_scale_type
jacobian

In ex3, it has a routine about Jacobian, while in ex19 without a Jacobian
routine.
Is the quasi-Newton method use the inverse of the initial Jacobian matrix
by finite difference ?

Error information in ex3:
mpiexec -n 2 ./ex3 -snes_type qn -snes_qn_restart_type periodic
-snes_qn_scale_type jacobian -snes_view
atol=1e-50, rtol=1e-08, stol=1e-08, maxit=1, maxf=3
iter = 0,SNES Function norm 5.41468
iter = 1,SNES Function norm 0.806152
iter = 2,SNES Function norm 0.459274
iter = 3,SNES Function norm 0.0562937
iter = 4,SNES Function norm 0.00756409
iter = 5,SNES Function norm 0.00153315
iter = 6,SNES Function norm 0.000108099
iter = 7,SNES Function norm 2.8e-06
iter = 8,SNES Function norm 5.56429e-08
iter = 9,SNES Function norm 5.56429e-08
[0]PETSC ERROR: - Error Message
--
[0]PETSC ERROR: Floating point exception
[0]PETSC ERROR: Vec entry at local location 0 is not-a-number or infinite
at beginning of function: Parameter number 2
[0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for
trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.10.1, Sep, 26, 2018
[0]PETSC ERROR: ./ex3 on a arch-linux2-c-debug named yjwu-XPS-8910 by yjwu
Fri Jan  4 09:11:00 2019
[0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++
--with-fc=gfortran --download-mpich --download-fblaslapack
[0]PETSC ERROR: #1 VecValidValues() line 26 in
/home/yjwu/petsc-3.10.1/src/vec/vec/interface/rvector.c
[0]PETSC ERROR: #2 SNESComputeFunction() line 2234 in
/home/yjwu/petsc-3.10.1/src/snes/interface/snes.c
[1]PETSC ERROR: - Error Message
--
[1]PETSC ERROR: Floating point exception
[1]PETSC ERROR: Vec entry at local location 0 is not-a-number or infinite
at beginning of function: Parameter number 2
[1]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for
trouble shooting.
[1]PETSC ERROR: Petsc Release Version 3.10.1, Sep, 26, 2018
[1]PETSC ERROR: ./ex3 on a arch-linux2-c-debug named yjwu-XPS-8910 by yjwu
Fri Jan  4 09:11:00 2019
[1]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++
--with-fc=gfortran --download-mpich --download-fblaslapack
[1]PETSC ERROR: #1 VecValidValues() line 26 in
/home/yjwu/petsc-3.10.1/src/vec/vec/interface/rvector.c
[1]PETSC ERROR: #2 SNESComputeFunction() line 2234 in
/home/yjwu/petsc-3.10.1/src/snes/interface/snes.c
[1]PETSC ERROR: #3 SNESLineSearchApply_CP() line 48 in
/home/yjwu/petsc-3.10.1/src/snes/linesearch/impls/cp/linesearchcp.c
[1]PETSC ERROR: #4 SNESLineSearchApply() line 648 in
/home/yjwu/petsc-3.10.1/src/snes/linesearch/interface/linesearch.c
[0]PETSC ERROR: #3 SNESLineSearchApply_CP() line 48 in
/home/yjwu/petsc-3.10.1/src/snes/linesearch/impls/cp/linesearchcp.c
[0]PETSC ERROR: #4 SNESLineSearchApply() line 648 in
/home/yjwu/petsc-3.10.1/src/snes/linesearch/interface/linesearch.c
[0]PETSC ERROR: #5 SNESSolve_QN() line 403 in
/home/yjwu/petsc-3.10.1/src/snes/impls/qn/qn.c
[0]PETSC ERROR: [1]PETSC ERROR: #5 SNESSolve_QN() line 403 in
/home/yjwu/petsc-3.10.1/src/snes/impls/qn/qn.c
[1]PETSC ERROR: #6 SNESSolve() line 4396 in
/home/yjwu/petsc-3.10.1/src/snes/interface/snes.c
#6 SNESSolve() line 4396 in
/home/yjwu/petsc-3.10.1/src/snes/interface/snes.c
[0]PETSC ERROR: [1]PETSC ERROR: #7 main() line 277 in
/home/yjwu/petsc-3.10.1/src/snes/examples/tutorials/ex3.c
#7 main() line 277 in
/home/yjwu/petsc-3.10.1/src/snes/examples/tutorials/ex3.c
[0]PETSC ERROR: PETSc Option Table entries:
[1]PETSC ERROR: PETSc Option Table entries:
[1]PETSC ERROR: [0]PETSC ERROR: -snes_qn_restart_type periodic
[0]PETSC ERROR: -snes_qn_restart_type periodic
[1]PETSC ERROR: -snes_qn_scale_type jacobian
[1]PETSC ERROR: -snes_qn_scale_type jacobian
[0]PETSC ERROR: -snes_type qn
[0]PETSC ERROR: -snes_type qn
[1]PETSC ERROR: -snes_view
-snes_view
[0]PETSC ERROR: End of Error Message ---send entire
error message to petsc-ma...@mcs.anl.gov--
[1]PETSC ERROR: End of Error Message ---send entire
error message to petsc-ma...@mcs.anl.gov--
application called MPI_Abort(MPI_COMM_WORLD, 72) - process 0
application called MPI_Abort(MPI_COMM_WORLD, 72) - process 1

Error information in ex19
mpiexec -n 2 ./ex19 -snes_type qn -snes_qn_restart_type periodic
-snes_qn_scale_type jacobian -snes_view
lid velocity = 0.0625, prandtl # = 1., grashof # = 1.
[0]PETSC ERROR: - Error Message
--
[0]PETSC ERROR: 

Re: [petsc-users] Problems about Picard and NolinearGS

2019-01-03 Thread Matthew Knepley via petsc-users
On Thu, Jan 3, 2019 at 7:36 AM Yingjie Wu via petsc-users <
petsc-users@mcs.anl.gov> wrote:

> Thanks for your reply.
> I read the article you provided. This is my first contact with the
> quasi-Newton method.
> I have some problem:
> 1. From the point of view of algorithm, the quasi-Newton method does not
> need to be solved by linear equations, so why would KSP be used?
>

It is solving the equations, but we know the analytical answer. KSP is our
abstraction for linear equation solver,
so we also use it in this case.


> 2. Where and how to  use preconditioner in quasi-Newton method?
>

You do not need a PC here. Note that this is only going to work well if you
have a good initial
guess for the inverse of your Jacobian. The optimization people who
invented have that (it is
the identity). In Jed's paper, they use a V-cycle as the good initial guess.

  Thanks,

Matt


> Thanks,
> Yingjie
>
> Jed Brown  于2018年12月27日周四 上午10:11写道:
>
>> Yingjie Wu via petsc-users  writes:
>>
>> > I my opinion, the difficulty in constructing my Jacobian matrix is
>> complex
>> > coefficient.(eg, thermal conductivity* λ* , density )
>> > For example, in temperature equation(T):
>> > ∇(*λ*∇T) - ∇(ρ* Cp* u ) + Q =  0
>> > *λ* is thermal conductivity , ρ* is density  Cp* is specific heat , u is
>> > velocity, Q is source.
>> > *λ = *1.9*(1.0e-3)*pow(T+273.0-150.0,1.29)function of T
>> > ρ=
>> >
>> (0.4814*P/1.0e3/(T+273.15))/(1.0+0.446*(1.0e-2)*P/1.0e3/(pow(T+273.15,1.2)))
>> > function of T and P
>> >
>> > In theory, the coefficient contain variable. So it is complicated to
>> > calculate the element of Jacobian.
>> > In my snes_mf_operator method, I treat λ,ρ as constant. In every
>> nonlinear
>> > step, I use the solution update the λ,ρ  and thus update the
>> > preconditioning matrix. At each residual function call(in
>> > SNESFormFunction), I also update the coefficient to ensure the
>> correction
>> > of the residual function.
>>
>> If those Jacobian entries are really that hard to get right, you can try
>> using quasi-Newton as an alternative to -snes_mf_operator; similar to
>>
>>
>> https://jedbrown.org/files/BrownBrune-LowRankQuasiNewtonRobustJacobianLagging-2013.pdf
>>
>>
>> In general, I would start with an exact Jacobian (computed by coloring,
>> AD, or just in one specific material/configuration).  Test Newton using
>> direct solvers to see your "best case" convergence (globalization may be
>> needed).  Test fieldsplit using direct solvers on the blocks so you know
>> how much error is attributable to that approximation.  Only then look at
>> backing off on the approximation of the Jacobian and the preconditioner.
>>
>

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


Re: [petsc-users] Problems about Picard and NolinearGS

2018-12-27 Thread Jed Brown via petsc-users
Yingjie Wu via petsc-users  writes:

> I my opinion, the difficulty in constructing my Jacobian matrix is complex
> coefficient.(eg, thermal conductivity* λ* , density )
> For example, in temperature equation(T):
> ∇(*λ*∇T) - ∇(ρ* Cp* u ) + Q =  0
> *λ* is thermal conductivity , ρ* is density  Cp* is specific heat , u is
> velocity, Q is source.
> *λ = *1.9*(1.0e-3)*pow(T+273.0-150.0,1.29)function of T
> ρ=
> (0.4814*P/1.0e3/(T+273.15))/(1.0+0.446*(1.0e-2)*P/1.0e3/(pow(T+273.15,1.2)))
> function of T and P
>
> In theory, the coefficient contain variable. So it is complicated to
> calculate the element of Jacobian.
> In my snes_mf_operator method, I treat λ,ρ as constant. In every nonlinear
> step, I use the solution update the λ,ρ  and thus update the
> preconditioning matrix. At each residual function call(in
> SNESFormFunction), I also update the coefficient to ensure the correction
> of the residual function.

If those Jacobian entries are really that hard to get right, you can try
using quasi-Newton as an alternative to -snes_mf_operator; similar to

  
https://jedbrown.org/files/BrownBrune-LowRankQuasiNewtonRobustJacobianLagging-2013.pdf


In general, I would start with an exact Jacobian (computed by coloring,
AD, or just in one specific material/configuration).  Test Newton using
direct solvers to see your "best case" convergence (globalization may be
needed).  Test fieldsplit using direct solvers on the blocks so you know
how much error is attributable to that approximation.  Only then look at
backing off on the approximation of the Jacobian and the preconditioner.


Re: [petsc-users] Problems about Picard and NolinearGS

2018-12-26 Thread Smith, Barry F. via petsc-users

  If I understand correctly you able to provide the right hand side function 
but only the block diagonal part of the Jacobian (with one block per field). Is 
this correct? 

  When you use the block diagonal part of the Jacobian as the preconditioner 
for the matrix free application of the Jacobian you get very slow convergence 
of KSP? 

  And you are trying to use the block diagonal part of the Jacobian as the 
operator A(x) for the Picard iteration? This will not in general work because 
Picard requires an accurate application of the operator A(), using just the 
block diagonal part of A() doesn't even provide you with a consistent nonlinear 
system to solve. 

  I think that your fundamental problem is that the block diagonal part of the 
Jacobian is simply a very poor approximation to the true Jacobian and hence any 
preconditioner built from it is a poor preconditioner. I think you need to bit 
the bullet and compute the full Jacobian including the terms that couple 
between the different fields, in this way you get a good approximation to the 
true Jacobian and can solve each KSP linear efficiently. How difficult would it 
be to compute these other terms in the Jacobian?

  Barry

> On Dec 26, 2018, at 9:24 PM, Yingjie Wu  wrote:
> 
> Thank you very much for your previous reply.
> I pay attention to Picard and NonlinearGS method because I use snes_mf method 
> with preconditioning matrix to solve my problem. The quality of 
> preconditioning matrix and initial values seriously affect the convergence of 
> my problem. Because of the poor quality of the preconditioning matrix and 
> inability to give a reasonable initial value for my problem, the convergence 
> is not good. High-order ILU ( in my case ILU20) is needed to ensure that the 
> linear step residual can be reduced  to ksp_rtol 1e-2. In the future, the 
> program may expand more complex and convergence may be worse. However, Picard 
> and NonlinearGS are two method to ensure convergence. Although the 
> convergence rate is very slow, the results of these two method can be used to 
> provide a reasonable initial value for my program. So I need a solver similar 
> to Picard or GS's iterative method, which is very useful for providing 
> initial guess or comparing with the original program.
> I tried Picard method, which split original residual function 
> SNESComputeFunction F(x)=A(x)x - b(x) in to two part, give the right-hand 
> part of the equation b(x) to SNESPicardComputeFunction,and then transfer the 
> A(x) to SNESPicardComputeJacobian(in snes_mf , I use A(x) as preconditioning 
> matrix) . Because A(x) only include the relations within a single physical 
> field, it does not consider the relationship between physical fields. So it 
> is equivalent to the diagonal block part of the Jacobian matrix J.
> I really need some advice on my question.
> 
> Thanks,
> Yingjie
> 
> Smith, Barry F.  于2018年12月26日周三 下午4:23写道:
> 
>Try with -snes_mf_operator from the manual page of SNESSetPicard() this 
> indicates that  with Newton's method using A(x^{n}) to construct the 
> preconditioner.
> 
> > On Dec 26, 2018, at 7:48 AM, Yingjie Wu via petsc-users 
> >  wrote:
> > 
> > Dear Petsc developers:
> > Hi,
> > 1. I tried to use the Picard solver in Petsc, but the program didn't 
> > converge. My program is still a thermal program that contains multiple 
> > physical fields, and is a PDEs' problem. The error message is as follows. 
> > The reason I use Picard is that it can guarantee convergence(though slow 
> > and expensive). I follow the ex15.c, but I don't use DM to organize the 
> > solution vector. So I try the SNESSetPicard().
> > 0 SNES Function norm 2.91302e+08 
> > 0 KSP Residual norm 5.79907e+08 
> > 1 KSP Residual norm 1.46843e-05 
> >   Linear solve converged due to CONVERGED_RTOL iterations 1
> >   1 SNES Function norm 2.891e+08 
> > 0 KSP Residual norm 5.5989e+08 
> > 1 KSP Residual norm 4.21314e-06 
> >   Linear solve converged due to CONVERGED_RTOL iterations 1
> >   2 SNES Function norm 2.78289e+08 
> > 0 KSP Residual norm 5.53553e+08 
> > 1 KSP Residual norm 2.04076e-05 
> >   Linear solve converged due to CONVERGED_RTOL iterations 1
> >   3 SNES Function norm 2.77833e+08 
> > 0 KSP Residual norm 5.52907e+08 
> > 1 KSP Residual norm 2.09919e-05 
> >   Linear solve converged due to CONVERGED_RTOL iterations 1
> >   4 SNES Function norm 2.77821e+08 
> > 0 KSP Residual norm 5.52708e+08 
> > 1 KSP Residual norm 2.08677e-05 
> >   Linear solve converged due to CONVERGED_RTOL iterations 1
> > Nonlinear solve did not converge due to DIVERGED_LINE_SEARCH iterations 4
> > SNES Object: 1 MPI processes
> >   type: newtonls
> >   maximum iterations=50, maximum function evaluations=1
> >   tolerances: relative=1e-08, absolute=1e-50, solution=1e-08
> >   total number of linear solver iterations=5
> >   total number of function evaluations=34
> >   norm schedule ALWAYS
> >   SNESLineSearch Object: 1 

Re: [petsc-users] Problems about Picard and NolinearGS

2018-12-26 Thread Yingjie Wu via petsc-users
Thank you very much for your previous reply.
I pay attention to Picard and NonlinearGS method because I use snes_mf
method with preconditioning matrix to solve my problem. The quality of
preconditioning matrix and initial values seriously affect the convergence
of my problem. Because of the poor quality of the preconditioning matrix
and inability to give a reasonable initial value for my problem, the
convergence is not good. High-order ILU ( in my case ILU20) is needed to
ensure that the linear step residual can be reduced  to ksp_rtol 1e-2. In
the future, the program may expand more complex and convergence may be
worse. However, Picard and NonlinearGS are two method to ensure
convergence. Although the convergence rate is very slow, the results of
these two method can be used to provide a reasonable initial value for my
program. So I need a solver similar to Picard or GS's iterative method,
which is very useful for providing initial guess or comparing with the
original program.
I tried Picard method, which split original residual function
SNESComputeFunction F(x)=A(x)x - b(x) in to two part, give the right-hand
part of the equation b(x) to SNESPicardComputeFunction,and then transfer
the A(x) to SNESPicardComputeJacobian(in snes_mf , I use A(x) as
preconditioning matrix) . Because A(x) only include the relations within a
single physical field, it does not consider the relationship between
physical fields. So it is equivalent to the diagonal block part of the
Jacobian matrix J.
I really need some advice on my question.

Thanks,
Yingjie

Smith, Barry F.  于2018年12月26日周三 下午4:23写道:

>
>Try with -snes_mf_operator from the manual page of SNESSetPicard() this
> indicates that  with Newton's method using A(x^{n}) to construct the
> preconditioner.
>
> > On Dec 26, 2018, at 7:48 AM, Yingjie Wu via petsc-users <
> petsc-users@mcs.anl.gov> wrote:
> >
> > Dear Petsc developers:
> > Hi,
> > 1. I tried to use the Picard solver in Petsc, but the program didn't
> converge. My program is still a thermal program that contains multiple
> physical fields, and is a PDEs' problem. The error message is as follows.
> The reason I use Picard is that it can guarantee convergence(though slow
> and expensive). I follow the ex15.c, but I don't use DM to organize the
> solution vector. So I try the SNESSetPicard().
> > 0 SNES Function norm 2.91302e+08
> > 0 KSP Residual norm 5.79907e+08
> > 1 KSP Residual norm 1.46843e-05
> >   Linear solve converged due to CONVERGED_RTOL iterations 1
> >   1 SNES Function norm 2.891e+08
> > 0 KSP Residual norm 5.5989e+08
> > 1 KSP Residual norm 4.21314e-06
> >   Linear solve converged due to CONVERGED_RTOL iterations 1
> >   2 SNES Function norm 2.78289e+08
> > 0 KSP Residual norm 5.53553e+08
> > 1 KSP Residual norm 2.04076e-05
> >   Linear solve converged due to CONVERGED_RTOL iterations 1
> >   3 SNES Function norm 2.77833e+08
> > 0 KSP Residual norm 5.52907e+08
> > 1 KSP Residual norm 2.09919e-05
> >   Linear solve converged due to CONVERGED_RTOL iterations 1
> >   4 SNES Function norm 2.77821e+08
> > 0 KSP Residual norm 5.52708e+08
> > 1 KSP Residual norm 2.08677e-05
> >   Linear solve converged due to CONVERGED_RTOL iterations 1
> > Nonlinear solve did not converge due to DIVERGED_LINE_SEARCH iterations 4
> > SNES Object: 1 MPI processes
> >   type: newtonls
> >   maximum iterations=50, maximum function evaluations=1
> >   tolerances: relative=1e-08, absolute=1e-50, solution=1e-08
> >   total number of linear solver iterations=5
> >   total number of function evaluations=34
> >   norm schedule ALWAYS
> >   SNESLineSearch Object: 1 MPI processes
> > type: bt
> >   interpolation: cubic
> >   alpha=1.00e-04
> > maxstep=1.00e+08, minlambda=1.00e-12
> > tolerances: relative=1.00e-08, absolute=1.00e-15,
> lambda=1.00e-08
> > maximum iterations=40
> >   KSP Object: 1 MPI processes
> > type: gmres
> >   restart=30, using Classical (unmodified) Gram-Schmidt
> Orthogonalization with no iterative refinement
> >   happy breakdown tolerance 1e-30
> > maximum iterations=1, initial guess is zero
> > tolerances:  relative=1e-05, absolute=1e-50, divergence=1.
> > left preconditioning
> > using PRECONDITIONED norm type for convergence test
> >   PC Object: 1 MPI processes
> > type: lu
> >   out-of-place factorization
> >   tolerance for zero pivot 2.22045e-14
> >   matrix ordering: nd
> >   factor fill ratio given 5., needed 5.48356
> > Factored matrix follows:
> >   Mat Object: 1 MPI processes
> > type: seqaij
> > rows=11368, cols=11368
> > package used to perform factorization: petsc
> > total: nonzeros=234554, allocated nonzeros=234554
> > total number of mallocs used during MatSetValues calls =0
> >   not using I-node routines
> > linear system matrix = precond matrix:
> 

Re: [petsc-users] Problems about Picard and NolinearGS

2018-12-26 Thread Smith, Barry F. via petsc-users


   Try with -snes_mf_operator from the manual page of SNESSetPicard() this 
indicates that  with Newton's method using A(x^{n}) to construct the 
preconditioner.

> On Dec 26, 2018, at 7:48 AM, Yingjie Wu via petsc-users 
>  wrote:
> 
> Dear Petsc developers:
> Hi,
> 1. I tried to use the Picard solver in Petsc, but the program didn't 
> converge. My program is still a thermal program that contains multiple 
> physical fields, and is a PDEs' problem. The error message is as follows. The 
> reason I use Picard is that it can guarantee convergence(though slow and 
> expensive). I follow the ex15.c, but I don't use DM to organize the solution 
> vector. So I try the SNESSetPicard().
> 0 SNES Function norm 2.91302e+08 
> 0 KSP Residual norm 5.79907e+08 
> 1 KSP Residual norm 1.46843e-05 
>   Linear solve converged due to CONVERGED_RTOL iterations 1
>   1 SNES Function norm 2.891e+08 
> 0 KSP Residual norm 5.5989e+08 
> 1 KSP Residual norm 4.21314e-06 
>   Linear solve converged due to CONVERGED_RTOL iterations 1
>   2 SNES Function norm 2.78289e+08 
> 0 KSP Residual norm 5.53553e+08 
> 1 KSP Residual norm 2.04076e-05 
>   Linear solve converged due to CONVERGED_RTOL iterations 1
>   3 SNES Function norm 2.77833e+08 
> 0 KSP Residual norm 5.52907e+08 
> 1 KSP Residual norm 2.09919e-05 
>   Linear solve converged due to CONVERGED_RTOL iterations 1
>   4 SNES Function norm 2.77821e+08 
> 0 KSP Residual norm 5.52708e+08 
> 1 KSP Residual norm 2.08677e-05 
>   Linear solve converged due to CONVERGED_RTOL iterations 1
> Nonlinear solve did not converge due to DIVERGED_LINE_SEARCH iterations 4
> SNES Object: 1 MPI processes
>   type: newtonls
>   maximum iterations=50, maximum function evaluations=1
>   tolerances: relative=1e-08, absolute=1e-50, solution=1e-08
>   total number of linear solver iterations=5
>   total number of function evaluations=34
>   norm schedule ALWAYS
>   SNESLineSearch Object: 1 MPI processes
> type: bt
>   interpolation: cubic
>   alpha=1.00e-04
> maxstep=1.00e+08, minlambda=1.00e-12
> tolerances: relative=1.00e-08, absolute=1.00e-15, 
> lambda=1.00e-08
> maximum iterations=40
>   KSP Object: 1 MPI processes
> type: gmres
>   restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization 
> with no iterative refinement
>   happy breakdown tolerance 1e-30
> maximum iterations=1, initial guess is zero
> tolerances:  relative=1e-05, absolute=1e-50, divergence=1.
> left preconditioning
> using PRECONDITIONED norm type for convergence test
>   PC Object: 1 MPI processes
> type: lu
>   out-of-place factorization
>   tolerance for zero pivot 2.22045e-14
>   matrix ordering: nd
>   factor fill ratio given 5., needed 5.48356
> Factored matrix follows:
>   Mat Object: 1 MPI processes
> type: seqaij
> rows=11368, cols=11368
> package used to perform factorization: petsc
> total: nonzeros=234554, allocated nonzeros=234554
> total number of mallocs used during MatSetValues calls =0
>   not using I-node routines
> linear system matrix = precond matrix:
> Mat Object: 1 MPI processes
>   type: seqaij
>   rows=11368, cols=11368
>   total: nonzeros=42774, allocated nonzeros=56840
>   total number of mallocs used during MatSetValues calls =0
> not using I-node routines
> Are there any other examples of Picard methods? I'm very interested in this 
> method.
> 
> 2. I found that in ex15.c and ex19.c use the NonlinearGS. I know it's a 
> iterative method. I don't know how to use this method in above examples.  As 
> for as I know, NonlinearGS is an iterative method parallel to subspace 
> method. NonlinearGS should not be required if subspace methods are used. 
> 
> Thanks,
> Yingjie
>  
> 



[petsc-users] Problems about Picard and NolinearGS

2018-12-26 Thread Yingjie Wu via petsc-users
Dear Petsc developers:
Hi,
1. I tried to use the Picard solver in Petsc, but the program didn't
converge. My program is still a thermal program that contains multiple
physical fields, and is a PDEs' problem. The error message is as follows.
The reason I use Picard is that it can guarantee convergence(though slow
and expensive). I follow the ex15.c, but I don't use DM to organize the
solution vector. So I try the SNESSetPicard().
0 SNES Function norm 2.91302e+08
0 KSP Residual norm 5.79907e+08
1 KSP Residual norm 1.46843e-05
  Linear solve converged due to CONVERGED_RTOL iterations 1
  1 SNES Function norm 2.891e+08
0 KSP Residual norm 5.5989e+08
1 KSP Residual norm 4.21314e-06
  Linear solve converged due to CONVERGED_RTOL iterations 1
  2 SNES Function norm 2.78289e+08
0 KSP Residual norm 5.53553e+08
1 KSP Residual norm 2.04076e-05
  Linear solve converged due to CONVERGED_RTOL iterations 1
  3 SNES Function norm 2.77833e+08
0 KSP Residual norm 5.52907e+08
1 KSP Residual norm 2.09919e-05
  Linear solve converged due to CONVERGED_RTOL iterations 1
  4 SNES Function norm 2.77821e+08
0 KSP Residual norm 5.52708e+08
1 KSP Residual norm 2.08677e-05
  Linear solve converged due to CONVERGED_RTOL iterations 1
Nonlinear solve did not converge due to DIVERGED_LINE_SEARCH iterations 4
SNES Object: 1 MPI processes
  type: newtonls
  maximum iterations=50, maximum function evaluations=1
  tolerances: relative=1e-08, absolute=1e-50, solution=1e-08
  total number of linear solver iterations=5
  total number of function evaluations=34
  norm schedule ALWAYS
  SNESLineSearch Object: 1 MPI processes
type: bt
  interpolation: cubic
  alpha=1.00e-04
maxstep=1.00e+08, minlambda=1.00e-12
tolerances: relative=1.00e-08, absolute=1.00e-15,
lambda=1.00e-08
maximum iterations=40
  KSP Object: 1 MPI processes
type: gmres
  restart=30, using Classical (unmodified) Gram-Schmidt
Orthogonalization with no iterative refinement
  happy breakdown tolerance 1e-30
maximum iterations=1, initial guess is zero
tolerances:  relative=1e-05, absolute=1e-50, divergence=1.
left preconditioning
using PRECONDITIONED norm type for convergence test
  PC Object: 1 MPI processes
type: lu
  out-of-place factorization
  tolerance for zero pivot 2.22045e-14
  matrix ordering: nd
  factor fill ratio given 5., needed 5.48356
Factored matrix follows:
  Mat Object: 1 MPI processes
type: seqaij
rows=11368, cols=11368
package used to perform factorization: petsc
total: nonzeros=234554, allocated nonzeros=234554
total number of mallocs used during MatSetValues calls =0
  not using I-node routines
linear system matrix = precond matrix:
Mat Object: 1 MPI processes
  type: seqaij
  rows=11368, cols=11368
  total: nonzeros=42774, allocated nonzeros=56840
  total number of mallocs used during MatSetValues calls =0
not using I-node routines
Are there any other examples of Picard methods? I'm very interested in this
method.

2. I found that in ex15.c and ex19.c use the NonlinearGS. I know it's a
iterative method. I don't know how to use this method in above examples.
As for as I know, NonlinearGS is an iterative method parallel to subspace
method. NonlinearGS should not be required if subspace methods are used.

Thanks,
Yingjie