# [petsc-users] convergence slow

Matthew Knepley knepley at gmail.com
Tue Apr 20 14:31:39 CDT 2021

```On Tue, Apr 20, 2021 at 1:55 PM Sepideh Kavousi <skavou1 at lsu.edu> wrote:

> Dear Mathew,
> thank you for your response. I double checked and  snes is converged in
> all steps. following is output of -snes_converged_reason
>

Let's look at the first one:

0 SNES Function norm 1.465357113711e+01
1 SNES Function norm 1.131764004094e+02
Nonlinear solve converged due to CONVERGED_ITS iterations 1

This is not usually what we mean by convergence. The SNES has been told,
using -snes_type ksponly,
to take only one step, but it still has a huge residual. In fact, the
residual is growing. This suggests the
system is not actually being solved.

Thanks,

Matt

> 0 TS dt 0.0001 time 0.
> copy!
> Write output at step= 0!
>     0 SNES Function norm 1.465357113711e+01
>     1 SNES Function norm 1.131764004094e+02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>     0 SNES Function norm 5.657793773845e+01
>     1 SNES Function norm 9.539766295097e-02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 1 TS dt 0.0002 time 0.0001
> copy!
>     0 SNES Function norm 1.734774181586e+02
>     1 SNES Function norm 1.009139331913e+00
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 2 TS dt 0.000324496 time 0.0003
> copy!
>     0 SNES Function norm 1.200543689889e+01
>     1 SNES Function norm 1.715000763566e-02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 3 TS dt 0.000471924 time 0.000624496
> copy!
>     0 SNES Function norm 8.374168676869e+00
>     1 SNES Function norm 3.806213226152e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 4 TS dt 0.00076859 time 0.00109642
> copy!
>     0 SNES Function norm 9.316857431814e+00
>     1 SNES Function norm 3.125732297714e-02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 5 TS dt 0.00153718 time 0.00186501
> copy!
>     0 SNES Function norm 9.820005256073e+00
>     1 SNES Function norm 8.107044589689e-04
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 6 TS dt 0.00218053 time 0.00340219
> copy!
>     0 SNES Function norm 5.122834112454e+00
>     1 SNES Function norm 1.662895139952e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 7 TS dt 0.0022609 time 0.00558272
> copy!
>     0 SNES Function norm 1.423878996243e+00
>     1 SNES Function norm 1.329199025944e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 8 TS dt 0.0045218 time 0.00784362
> copy!
>     0 SNES Function norm 1.241101191899e+00
>     1 SNES Function norm 1.758309073907e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>     0 SNES Function norm 2.174982578512e+00
>     1 SNES Function norm 1.977451891592e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 9 TS dt 0.00309088 time 0.0111379
> copy!
>     0 SNES Function norm 7.952246195856e-01
>     1 SNES Function norm 3.315360582766e-04
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 10 TS dt 0.00302529 time 0.0142288
> copy!
>     0 SNES Function norm 7.852078318680e-01
>     1 SNES Function norm 6.819399397977e-04
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 11 TS dt 0.0036818 time 0.0172541
> copy!
>     0 SNES Function norm 1.269332622839e+00
>     1 SNES Function norm 1.508985874154e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 12 TS dt 0.00736361 time 0.0209359
> copy!
>     0 SNES Function norm 6.143748829896e+00
>     1 SNES Function norm 2.172457806998e-01
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 13 TS dt 0.00792431 time 0.0282995
> copy!
>     0 SNES Function norm 2.762542847702e+01
>     1 SNES Function norm 1.329294167855e+01
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>     0 SNES Function norm 2.287537833706e+01
>     1 SNES Function norm 1.608258731248e+00
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>     0 SNES Function norm 1.279894262237e+01
>     1 SNES Function norm 5.112278399366e-02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 14 TS dt 0.0017228 time 0.0301754
> copy!
>     0 SNES Function norm 4.714428103053e+00
>     1 SNES Function norm 3.141482420272e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 15 TS dt 0.00174124 time 0.0318982
> copy!
>     0 SNES Function norm 5.161696766061e+00
>     1 SNES Function norm 3.434924981822e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>     0 SNES Function norm 1.440940181693e+01
>     1 SNES Function norm 2.060277373865e-02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 16 TS dt 0.00143688 time 0.0334492
> copy!
>     0 SNES Function norm 4.954103004576e+00
>     1 SNES Function norm 1.705855165536e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 17 TS dt 0.00287377 time 0.0348861
> copy!
>     0 SNES Function norm 1.757129021431e+01
>     1 SNES Function norm 3.191948709005e-02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>     0 SNES Function norm 3.031772340693e+01
>     1 SNES Function norm 7.097653811013e-02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 18 TS dt 0.00203648 time 0.0368402
> copy!
>     0 SNES Function norm 1.629074198276e+01
>     1 SNES Function norm 9.774829708834e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>     0 SNES Function norm 4.007821179267e+01
>     1 SNES Function norm 4.322266335869e-02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>     0 SNES Function norm 2.348161408350e+01
>     1 SNES Function norm 5.218780461268e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>     0 SNES Function norm 1.789799437816e+01
>     1 SNES Function norm 2.727867493741e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 19 TS dt 0.000223859 time 0.0370644
> copy!
>     0 SNES Function norm 1.164475864748e+00
>     1 SNES Function norm 5.580165229404e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 20 TS dt 0.000209603 time 0.0372882
> copy!
> Write output at step= 20!
>     0 SNES Function norm 7.548512298179e-01
>     1 SNES Function norm 8.191710667867e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>     0 SNES Function norm 5.113158684224e+00
>     1 SNES Function norm 4.059400705957e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>     0 SNES Function norm 3.408310084009e+00
>     1 SNES Function norm 5.257240981430e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 21 TS dt 7.85133e-05 time 0.0373492
> copy!
>     0 SNES Function norm 4.156375747211e-01
>     1 SNES Function norm 3.052885436956e-02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 22 TS dt 9.58699e-05 time 0.0374277
> copy!
>     0 SNES Function norm 4.583956492983e-01
>     1 SNES Function norm 1.176944126767e-01
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 23 TS dt 9.32603e-05 time 0.0375236
> copy!
>     0 SNES Function norm 4.969090229611e-01
>     1 SNES Function norm 1.738678566558e-02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 24 TS dt 0.000186521 time 0.0376169
> copy!
>     0 SNES Function norm 6.406466977155e-01
>     1 SNES Function norm 8.183507106613e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 25 TS dt 0.000213369 time 0.0378034
> copy!
>     0 SNES Function norm 6.235579283905e-01
>     1 SNES Function norm 7.038633582283e-02
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 26 TS dt 0.000217545 time 0.0380168
> copy!
>     0 SNES Function norm 5.375653976237e-01
>     1 SNES Function norm 7.318538883142e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
> 27 TS dt 0.000384287 time 0.0382343
> copy!
>     0 SNES Function norm 8.638617026715e-01
>     1 SNES Function norm 1.596171692523e-03
>   Nonlinear solve converged due to CONVERGED_ITS iterations 1
>
> ------------------------------
> *From:* Matthew Knepley <knepley at gmail.com>
> *Sent:* Tuesday, April 20, 2021 7:23 AM
> *To:* Sepideh Kavousi <skavou1 at lsu.edu>
> *Cc:* petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
> *Subject:* Re: [petsc-users] convergence slow
>
> On Mon, Apr 19, 2021 at 5:43 PM Sepideh Kavousi <skavou1 at lsu.edu> wrote:
>
> Hello,
> I want to solve PF solidification+Navier stokes using Finite different
> method. The Poisson equation is much more complicated that the one for just
> a fluid-flow problems (because it includes different terms order parameter
> terms).
> The code converges but the convergence rate is very slow. I have tried
> different options. Following is the best options I found but the
> convergence is still very slow. I did not include the ksp_convergence data
> because it takes around 1000 liner solver steps for each snes step.
> I look in literature, but I did not find any data on PF+navierstokes
> solutions using Petsc. Do you have any suggestions how should I improve the
> convergence?
>
>
> First question: Are your nonlinear solves converging?
>
>   I see you have -snes_type ksponly, but it looks like your SNES iteration
> _diverges_ sometimes, and mostly fails to converge.
>   Is this correct?
>
>   Thanks,
>
>       Matt
>
>
> Best,
> Sepideh
>
>
> ibrun -np 136 ./one.out -ts_monitor -snes_fd_color -ts_max_snes_failures
> -1  -ts_type bdf -ts_bdf_adapt -snes_linesearch_type l2 -snes_type ksponly
> -pc_type fieldsplit -pc_fieldsplit_0_fields 0,1 -pc_fieldsplit_1_fields 2,3
> -pc_fieldsplit_2_fields 4 -pc_fieldsplit_type multiplicative
> -fieldsplit_0_pc_type bjacobi -fieldsplit_1_pc_type bjacobi
> -fieldsplit_2_pc_type ilu -fieldsplit_0_ksp_type preonly
> -fieldsplit_1_ksp_type preonly -fieldsplit_2_ksp_type preonly -sub_pc_type
> ilu -sub_ksp_type preonly -snes_monitor -log_view log.txt
>
> TACC:  Starting up job 7605521
> nu_nd=14948.511 !
> tau/w=26225.459!
> initial!
> 0 TS dt 0.0001 time 0.
> copy!
> Write output at step= 0!
>     0 SNES Function norm 1.465357113711e+01
>     1 SNES Function norm 1.131764004117e+02
>     0 SNES Function norm 5.657793773935e+01
>     1 SNES Function norm 9.539772669908e-02
> 1 TS dt 0.0002 time 0.0001
> copy!
>     0 SNES Function norm 1.734774194628e+02
>     1 SNES Function norm 1.009134558763e+00
> 2 TS dt 0.000324128 time 0.0003
> copy!
>     0 SNES Function norm 1.199860231725e+01
>     1 SNES Function norm 1.698885201785e-02
> 3 TS dt 0.000470679 time 0.000624128
> copy!
>     0 SNES Function norm 8.344934987594e+00
>     1 SNES Function norm 4.082958856578e-03
> 4 TS dt 0.000769357 time 0.00109481
> copy!
>     0 SNES Function norm 9.338443428763e+00
>     1 SNES Function norm 2.472903267511e-03
> 5 TS dt 0.00153871 time 0.00186416
> copy!
>     0 SNES Function norm 9.836384162921e+00
>     1 SNES Function norm 6.383053421790e-03
> 6 TS dt 0.00215245 time 0.00340288
> copy!
>     0 SNES Function norm 5.043289760603e+00
>     1 SNES Function norm 2.168332362305e-03
> 7 TS dt 0.0022353 time 0.00555533
> copy!
>     0 SNES Function norm 1.421255264272e+00
>     1 SNES Function norm 1.750393691475e-03
> 8 TS dt 0.0044706 time 0.00779063
> copy!
>     0 SNES Function norm 1.216746389225e+00
>     1 SNES Function norm 5.339123694240e-04
>     0 SNES Function norm 2.168489818312e+00
>     1 SNES Function norm 1.928809773415e-03
> 9 TS dt 0.00310217 time 0.0110885
> copy!
>     0 SNES Function norm 8.021629529051e-01
>     1 SNES Function norm 2.161901383228e-04
> 10 TS dt 0.00300302 time 0.0141906
> copy!
>     0 SNES Function norm 7.731190774223e-01
>     1 SNES Function norm 2.807020573793e-04
> 11 TS dt 0.00367968 time 0.0171937
> copy!
>     0 SNES Function norm 1.263830181443e+00
>     1 SNES Function norm 1.049133009231e-02
> 12 TS dt 0.00704796 time 0.0208733
> copy!
>     0 SNES Function norm 5.619818748359e+00
>     1 SNES Function norm 1.569218805659e-01
> 13 TS dt 0.00742462 time 0.0279213
> copy!
>     0 SNES Function norm 2.268051808662e+01
>     1 SNES Function norm 7.055762930884e+00
>     0 SNES Function norm 2.173806325395e+01
>     1 SNES Function norm 1.564571270312e+00
>     0 SNES Function norm 1.208038223084e+01
>     1 SNES Function norm 5.192087605517e-02
> 14 TS dt 0.00186927 time 0.0299244
> copy!
>     0 SNES Function norm 4.797722218343e+00
>     1 SNES Function norm 3.975928994156e-03
> 15 TS dt 0.00189622 time 0.0317937
> copy!
>     0 SNES Function norm 5.510229536082e+00
>     1 SNES Function norm 4.496811351139e-03
> 16 TS dt 0.00172953 time 0.0336899
> copy!
>     0 SNES Function norm 6.945417639798e+00
>     1 SNES Function norm 4.569326335543e-03
> 17 TS dt 0.00218527 time 0.0354194
> copy!
>     0 SNES Function norm 1.351474156680e+01
>     1 SNES Function norm 1.719775600164e-02
> 18 TS dt 0.00224386 time 0.0376047
> copy!
>     0 SNES Function norm 2.174969556700e+01
>     1 SNES Function norm 3.814212178889e-02
>     0 SNES Function norm 4.891415655138e+01
>     1 SNES Function norm 6.772042718901e-02
>     0 SNES Function norm 2.828143585009e+01
>     1 SNES Function norm 6.965842377755e-03
>     0 SNES Function norm 2.168193335917e+01
>     1 SNES Function norm 2.463212234975e-03
> 19 TS dt 0.000205482 time 0.0378175
> copy!
>     0 SNES Function norm 1.409435206457e+00
>     1 SNES Function norm 1.859628755245e-02
> 20 TS dt 0.000188785 time 0.0380229
> copy!
> Write output at step= 20!
>     0 SNES Function norm 5.900261363044e-01
>     1 SNES Function norm 2.653576084845e-02
>     0 SNES Function norm 5.122905363140e+00
>     1 SNES Function norm 4.297068425492e-03
>     0 SNES Function norm 3.428448792746e+00
>     1 SNES Function norm 1.000610664096e-02
> 21 TS dt 6.50511e-05 time 0.0380738
> copy!
>     0 SNES Function norm 3.700405789863e-01
>     1 SNES Function norm 6.263642369355e-02
> 22 TS dt 7.93452e-05 time 0.0381388
> copy!
>     0 SNES Function norm 5.282939288286e-01
>     1 SNES Function norm 3.003209840754e-01
> 23 TS dt 7.50242e-05 time 0.0382181
> copy!
>     0 SNES Function norm 7.079201595974e-01
>     1 SNES Function norm 1.247544399226e-02
> 24 TS dt 0.000150048 time 0.0382932
> copy!
>     0 SNES Function norm 6.197633272307e-01
>     1 SNES Function norm 3.176914154297e-02
> 25 TS dt 0.000171939 time 0.0384432
> copy!
>     0 SNES Function norm 5.849423362557e-01
>     1 SNES Function norm 9.462256964187e-03
> 26 TS dt 0.000176855 time 0.0386152
> copy!
>     0 SNES Function norm 4.304951653234e-01
>     1 SNES Function norm 3.939112950208e-03
>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> -- Norbert Wiener
>
> https://www.cse.buffalo.edu/~knepley/
>

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