clarification about convergence

Dominik Szczerba dominik at itis.ethz.ch
Wed Dec 9 14:44:12 CST 2009


Barry Smith wrote:
> On Dec 9, 2009, at 2:06 PM, Dominik Szczerba wrote:
> 
>> Great hint, I found the tolerances not as I was setting them...
>>
>> Which brings me to the problem how to consistently set them. I am  
>> calling first:
>>
>> PetscOptionsInsertString()
>>
>> where I obtain the string from a user config file, and then am  
>> calling several times later:
>>
>> KSPSetFromOptions()
>>
>> I found experimentally that only the options ABSENT in the config  
>> string are eventually accepted from the command line. Those that  
>> were PRESENT will not be overwriten from the commandline - behavior  
>> not quite intuitive. Or am I doing something wrong?
> 
>     You call PetscInitialize(args) then PetscOptionsInsertString().  
> The args are processed before the string since it comes first. If you  
> want to process the string first then the args you can do:
>     PetscInitialize(args); PetscOptionsInsertString();  
> PetscOptionsInsert(args); now the args will overwrite the string.

Great! Thanks a lot.

Dominik


> 
>     You can also pass PetscOptionsInsertFile() to pass options  
> directly from a file
> 
>     Barry
> 
>> Is there a way to completely disable processing of the options from  
>> the command line? Or at least to specify what has higher priority? I  
>> prefer to set the options only in one way not to confuse the users.
>>
>> Many thanks,
>> Dominik
>>
>> Matthew Knepley wrote:
>>> On Wed, Dec 9, 2009 at 12:49 PM, Dominik Szczerba <dominik at itis.ethz.ch 
>>>  <mailto:dominik at itis.ethz.ch>> wrote:
>>>    Excellent point. Where it broke the reason was:
>>>    Starting KSPSolve
>>>     0 KSP Residual norm 7.841852910113e-04
>>>     1 KSP Residual norm 8.927576540999e-05
>>>     2 KSP Residual norm 1.694401713084e-05
>>>     3 KSP Residual norm 5.069425875318e-06
>>>    Linear solve converged due to CONVERGED_RTOL iterations 3
>>>    which I assume means that the norm became exactly 0
>>> I don't think so. It would have printed that for the residual.
>>>     HOWEVER: putting -ksp_rtol -1 still does not eliminate the  
>>> problem.
>>>    Any further suggestions?
>>> You -ksp_view to see the tolerances used.
>>>  Matt
>>>     Dominik
>>>    Matthew Knepley wrote:
>>>        Did you use -ksp_converged_reason to determine why PETSc  
>>> stopped
>>>        iterating?
>>>         Matt
>>>        On Wed, Dec 9, 2009 at 11:45 AM, Dominik Szczerba
>>>        <dominik at itis.ethz.ch <mailto:dominik at itis.ethz.ch>
>>>        <mailto:dominik at itis.ethz.ch <mailto:dominik at itis.ethz.ch>>>  
>>> wrote:
>>>           I am using
>>>           -ksp_rtol 0 -ksp_atol 1e-6 (defaults for all the rest)
>>>           and observe for most of the times convergence, as expected.
>>>           Starting KSPSolve
>>>            0 KSP Residual norm 6.315132950112e-04
>>>            1 KSP Residual norm 9.139539245601e-05
>>>            2 KSP Residual norm 1.869750068013e-05
>>>            3 KSP Residual norm 6.788145356909e-06
>>>            4 KSP Residual norm 1.729115712274e-06
>>>            5 KSP Residual norm 7.214445966641e-07
>>>           solved in 2.328146e+00/4.144644e+00 s
>>>           solution converged in 5 iterations
>>>           ||Ax-b|| = 7.21445e-07
>>>           with ||...|| being residue computed on my own for a check.
>>>           However, SOMETIMES, I do observe:
>>>           Starting KSPSolve
>>>            0 KSP Residual norm 1.228562818225e-02
>>>            1 KSP Residual norm 4.045833318123e-04
>>>            2 KSP Residual norm 6.589999324657e-05
>>>            3 KSP Residual norm 1.494849372638e-05
>>>            4 KSP Residual norm 4.311592172896e-06
>>>           solved in 1.368086e+00/2.235830e+00 s
>>>           solution converged in 4 iterations
>>>           ||Ax-b|| = 4.31159e-06
>>>           which means that the iterations break sooner than they  
>>> should.
>>>           Again, this is not often, but worries me why this should
>>>        happen...
>>>           Using or not -ksp_converged_use_initial_residual_norm does
>>>        not make
>>>           any difference to this behavior: the last output Residual  
>>> norm is
>>>           sometimes higher than the requested atol.
>>>           Any clarifications are highly appreciated.
>>>           Dominik
>>>        --         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