A graphical representation for convergence

Discussion about coding and new developments
Post Reply
Takala
Posts: 186
Joined: 23 Aug 2009, 23:59

A graphical representation for convergence

Post by Takala »

Hi All,

I'm usually launching ElmerSolver from the command line. This means that I can see only text and it is
harder to understand the convergence progress. Is there an easy/elegant way to get the graphical
representation for the convergence like in ElmerGUI? Meanwhile, I will post my solution, in case
someone is interested:

ElmerSolver is outputting a lot of useful information when it is launched from command line, for example:
MAIN:
MAIN: -------------------------------------
MAIN: Time: 1/20 0.10000000000000001
MAIN: -------------------------------------
MAIN:
Varname:magnfdens
axisCurrSolve: Nonlinear iteration no. 1 of max. 4
ComputeChange: NS (ITER=1) (NRM,RELC): ( 0.64550053E-04 2.0000000 ) :: test
axisCurrSolve: Result Norm : 6.45500526565041675E-005
axisCurrSolve: Relative Change : 2.0000000000000000
axisCurrSolve: Nonlinear iteration no. 2 of max. 4
ComputeChange: NS (ITER=2) (NRM,RELC): ( 0.80950724E-03 1.7045958 ) :: test
axisCurrSolve: Result Norm : 8.09507235507350600E-004
axisCurrSolve: Relative Change : 1.7045957809374008
axisCurrSolve: Nonlinear iteration no. 3 of max. 4
ComputeChange: NS (ITER=3) (NRM,RELC): ( 0.23644080E-03 1.0957838 ) :: test
axisCurrSolve: Result Norm : 2.36440800450868409E-004
axisCurrSolve: Relative Change : 1.0957837585716805
axisCurrSolve: Nonlinear iteration no. 4 of max. 4
ComputeChange: NS (ITER=4) (NRM,RELC): ( 0.31561966E-02 1.7212307 ) :: test
axisCurrSolve: Result Norm : 3.15619663799652107E-003
axisCurrSolve: Relative Change : 1.7212306888188165
From this we only want the relative change, which can be easily parsed with for example "awk":

Code: Select all

$ ElmerSolver | stdbuf -oL awk '/  Relative / { print  $5}'
2.0000000000000000
1.7045957809374008
1.0957837585716805
1.7212306888188165
1.9595103488742003
0.19755711729703090
0.11431966114014758
the stdbuf -oL is to avoid buffering (http://www.pixelbeat.org/programming/stdio_buffering/),
because we need a stream.

now, this can be piped in to feedGnuplot (https://github.com/dkogan/feedgnuplot)

Code: Select all

$ ElmerSolver | stdbuf -oL awk '/  Relative / { print $5 }' | feedGnuplot --stream --extracmds 'set logscale y' --lines
et voilà, there you have it!

Cheers,

Eelis
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: A graphical representation for convergence

Post by raback »

Hi Eelis

Yes, this is lacking a good solution. Thanx for providing one.

Another alternative way is to use SaveScalars solver and use for the variables of interest "nonlin change", "steady state change" or "norm" as the corresponding operator. Then the result file includes necessary information for convergence analysis. This would probably be favored way if one needs to gather convergence data for publications, for example.

To do the plotting in real time there is a Java tool called Live Graph, http://www.live-graph.org/. I tried it out a few years ago and then it lacked the logirithmic scale. Haven't tried it since but the development seems to have halted. Note that you need to set "Live Graph = Logical True" for SaveScalars to get the .csv format. Your solution certainly is probably more compelling for many power users.

-Peter
Post Reply