CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[PyFoam] pyFoamPlotWatcher and customRegexp

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 28, 2012, 04:46
Default pyFoamPlotWatcher and customRegexp
  #1
Member
 
Martin
Join Date: Nov 2011
Posts: 35
Rep Power: 15
wernsen is on a distinguished road
Hello everybody,

I am having problems plotting of variables out of the logfiles with the help of pyFoam 0.5.5. Neither can I see any plot nor do I get any error while starting the plot.

It would be nice if anyone can help me

Thanks

Code:
Custom01
{
  accumulation first;
  enabled yes;
  expr " MassFlows:   inlet = (%f%)  outlet = (%f%)";
  name Custom01_massflow;
  persist no;
  raisit no;
  theTitle "Custom 1 - MassFlows";
  titles
    (
      min
      max
    );
  type regular;
  with lines;
}
My logFile looks like:
Code:
...
MassFlows:   inlet = -0.03416099  outlet = 0.0341609
Time = 597
smoothSolver:  Solving for Ux, Initial residual = 7.440172e-05, Final residual = 3.728601e-06, No Iterations 4
smoothSolver:  Solving for Uy, Initial residual = 0.0001222075, Final residual = 1.202023e-05, No Iterations 3
smoothSolver:  Solving for Uz, Initial residual = 5.190061e-05, Final residual = 4.436034e-06, No Iterations 3
DILUPBiCG:  Solving for h, Initial residual = 6.815629e-05, Final residual = 4.644949e-06, No Iterations 1
GAMG:  Solving for p, Initial residual = 2.698017e-05, Final residual = 1.007462e-06, No Iterations 2
time step continuity errors : sum local = 0.0081001, global = -3.721162e-05, cumulative = 0.4522695
rho max/min : 1.200515 1.06891
smoothSolver:  Solving for omega, Initial residual = 1.341662e-05, Final residual = 1.333425e-06, No Iterations 3
bounding omega, min: -11603.2 max: 6.233842e+07 average: 106296.4
smoothSolver:  Solving for k, Initial residual = 0.0003323861, Final residual = 2.379521e-05, No Iterations 4
bounding k, min: -8.03594e-05 max: 240.341 average: 3.479831
ExecutionTime = 3112.29 s  ClockTime = 3258 s
...
wernsen is offline   Reply With Quote

Old   March 28, 2012, 08:49
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by wernsen View Post
Hello everybody,

I am having problems plotting of variables out of the logfiles with the help of pyFoam 0.5.5. Neither can I see any plot nor do I get any error while starting the plot.

It would be nice if anyone can help me

Thanks

Code:
Custom01
{
  accumulation first;
  enabled yes;
  expr " MassFlows:   inlet = (%f%)  outlet = (%f%)";
  name Custom01_massflow;
  persist no;
  raisit no;
  theTitle "Custom 1 - MassFlows";
  titles
    (
      min
      max
    );
  type regular;
  with lines;
}
My logFile looks like:
Code:
...
MassFlows:   inlet = -0.03416099  outlet = 0.0341609
Time = 597
smoothSolver:  Solving for Ux, Initial residual = 7.440172e-05, Final residual = 3.728601e-06, No Iterations 4
smoothSolver:  Solving for Uy, Initial residual = 0.0001222075, Final residual = 1.202023e-05, No Iterations 3
smoothSolver:  Solving for Uz, Initial residual = 5.190061e-05, Final residual = 4.436034e-06, No Iterations 3
DILUPBiCG:  Solving for h, Initial residual = 6.815629e-05, Final residual = 4.644949e-06, No Iterations 1
GAMG:  Solving for p, Initial residual = 2.698017e-05, Final residual = 1.007462e-06, No Iterations 2
time step continuity errors : sum local = 0.0081001, global = -3.721162e-05, cumulative = 0.4522695
rho max/min : 1.200515 1.06891
smoothSolver:  Solving for omega, Initial residual = 1.341662e-05, Final residual = 1.333425e-06, No Iterations 3
bounding omega, min: -11603.2 max: 6.233842e+07 average: 106296.4
smoothSolver:  Solving for k, Initial residual = 0.0003323861, Final residual = 2.379521e-05, No Iterations 4
bounding k, min: -8.03594e-05 max: 240.341 average: 3.479831
ExecutionTime = 3112.29 s  ClockTime = 3258 s
...
Regular expressions are sensitive to spaces. I'm not 100% percent sure, but the leading spaces in your regexp might be the problem (I don't see them in your log). As far as I remember leading spaces are removed from the log-line before matching, but not from the expression

The way I usually "develop" a regexp is by copying a log-line between "" and then replace the numbers I want to match with (%f%)
rajibroy likes this.
gschaider is offline   Reply With Quote

Old   March 28, 2012, 09:07
Default
  #3
Member
 
Martin
Join Date: Nov 2011
Posts: 35
Rep Power: 15
wernsen is on a distinguished road
Hello Bernhard,

what a honor to get the answer from the father of pyFoam itself. It is a realy helpfull set of tools. Actually like a swizz knife

I found my Problem. I had to delete the space as you adviced and the customRegexp-File have to be placed where the logfile is.

-> now it works greatfull

Thanks Bernhard,
MARTIN
wernsen is offline   Reply With Quote

Old   March 28, 2012, 13:01
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by wernsen View Post
what a honor to get the answer from the father of pyFoam itself. It is a realy helpfull set of tools. Actually like a swizz knife
Thanks. But I think father is the wrong word. I like to think about myself as the sinister mastermind behind PyFoam

Quote:
Originally Posted by wernsen View Post
I found my Problem. I had to delete the space as you adviced and the customRegexp-File have to be placed where the logfile is.

-> now it works greatfull
Great. If you feel that information that would have helped you to avoid that problem in the first place is missing from the Wiki-page could you be so kind to add it? Thanks
gschaider is offline   Reply With Quote

Old   December 12, 2012, 05:45
Default
  #5
Senior Member
 
JNSN's Avatar
 
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 144
Rep Power: 20
JNSN is on a distinguished road
Hi PyFoamers,

is it possible to skip a value from the expression? E.g. plotting only the outlet value in the above example?

Thanks in advance!
Jan
JNSN is offline   Reply With Quote

Old   December 12, 2012, 13:38
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by JNSN View Post
Hi PyFoamers,

is it possible to skip a value from the expression? E.g. plotting only the outlet value in the above example?

Thanks in advance!
Jan
Yep. Only pattern groups are being plotted. So instead of

Code:
expr " MassFlows:   inlet = (%f%)  outlet = (%f%)"
write

Code:
expr " MassFlows:   inlet = %f%  outlet = (%f%)"
or

Code:
expr " MassFlows:   inlet = .+  outlet = (%f%)"
would work too
rajibroy likes this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   December 13, 2012, 05:08
Default
  #7
Senior Member
 
JNSN's Avatar
 
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 144
Rep Power: 20
JNSN is on a distinguished road
Hi Bernhard,

thanks a lot for the quick reply!

Best regards,
Jan
JNSN is offline   Reply With Quote

Old   March 5, 2013, 09:48
Default
  #8
Member
 
Join Date: Mar 2009
Posts: 90
Rep Power: 17
aerogt3 is on a distinguished road
Is there any way to plot, on the same graph axes, two variables which are on different lines of the log file? I am having trouble defining multiple expressions in a single graph!
aerogt3 is offline   Reply With Quote

Old   March 5, 2013, 10:09
Default
  #9
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by aerogt3 View Post
Is there any way to plot, on the same graph axes, two variables which are on different lines of the log file? I am having trouble defining multiple expressions in a single graph!
Yes there is. And it is even described on the Wiki-page: http://openfoamwiki.net/index.php/Co...oam#New_format (look for "type slave")
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   September 26, 2013, 12:45
Default Additional Information
  #10
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
I don't mean to hijack this thread, but I found out, that parentheses make problems with the regexp. I had this line of solver output

Code:
Concentration = 0.0823725  Min(T) = 0.00958365  Max(T) = 0.326796
and tried this regexp

Code:
{"expr":"Concentration = (%f%)  Min(T) = (%f%)  Max(T) = (%f%)","name":"Concentration"}
But it did not work. However, after some trial and error I found out that the parenthesis were causing the problem. So I changed my output accordingly:

Code:
Concentration = 0.0505933  Min T = 0.00492903  Max T = 0.217095
Now this regexp works

Code:
{"expr":"Concentration = (%f%)  Min T = (%f%)  Max T = (%f%)","name":"Concentration","titles":["avg","min","max"]}
Voulet likes this.
GerhardHolzinger is offline   Reply With Quote

Old   September 26, 2013, 14:12
Default
  #11
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by GerhardHolzinger View Post
I don't mean to hijack this thread, but I found out, that parentheses make problems with the regexp. I had this line of solver output

Code:
Concentration = 0.0823725  Min(T) = 0.00958365  Max(T) = 0.326796
and tried this regexp

Code:
{"expr":"Concentration = (%f%)  Min(T) = (%f%)  Max(T) = (%f%)","name":"Concentration"}
But it did not work. However, after some trial and error I found out that the parenthesis were causing the problem. So I changed my output accordingly:

Code:
Concentration = 0.0505933  Min T = 0.00492903  Max T = 0.217095
Now this regexp works

Code:
{"expr":"Concentration = (%f%)  Min T = (%f%)  Max T = (%f%)","name":"Concentration","titles":["avg","min","max"]}
Parenthesis have a special meaning in regular expressions: they define "groups". PyFoam uses these groups to say "this is important". You can say "I really mean '(' not a group" by escaping with \: \( and \) (BTW: the same is true for [ and ])

I think I wrote this in one of my PyFoam-presentations (but probably not on the Wiki-page)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   September 27, 2013, 04:58
Default
  #12
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
Thanks for the explanation.

As you say on in the wiki

Quote:
regular expression need some getting used to
So I need to get used to regular expressions. Had nothing to do with them yet.

By the way: In the wiki in section 9.1.2 Information on regular expression both links to summaries on regular expressions are broken.
GerhardHolzinger is offline   Reply With Quote

Old   September 27, 2013, 07:22
Default
  #13
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by GerhardHolzinger View Post
Thanks for the explanation.

As you say on in the wiki



So I need to get used to regular expressions. Had nothing to do with them yet.

By the way: In the wiki in section 9.1.2 Information on regular expression both links to summaries on regular expressions are broken.
That kind of link is so common (google "regular expression cheat sheet": http://www.cheatography.com/davechil...r-expressions/) that people move it all the time. I'm also not sure whether these cheat sheets are the best place for a beginner. If you find a good link it'd be nice if you replace the old links with it (I'm not an expert on regular expressions but I guess you're nearer to beginner level so you're the better judge what is good for newbies)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   December 3, 2014, 14:23
Default
  #14
New Member
 
Marko Josic
Join Date: Dec 2010
Posts: 20
Rep Power: 16
emjay is on a distinguished road
Hallo may somebody can help me:

my logFile looks like:

Code:
PIMPLE: converged in 3 iterations
ExecutionTime = 75513.4 s  ClockTime = 75651 s

forces forces output:
    sum of forces:
        pressure : (0.603027 -0.0244227 -4.07056e-21)
        viscous  : (0.060363 0.0116136 -1.30133e-21)
        porous   : (0 0 0)
    sum of moments:
        pressure : (2.66751e-19 -2.65314e-17 -1.75474e-12)
        viscous  : (5.0719e-19 -2.74569e-18 -0.000137971)
        porous   : (0 0 0)
How should my customRegExp should look like, to plot the sum of pressure ans viscous components?
pressure in x : 7.7394e-19
pressure in y : 0.09


Thanl you for your help
emjay is offline   Reply With Quote

Old   December 3, 2014, 17:48
Default
  #15
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by emjay View Post
Hallo may somebody can help me:

my logFile looks like:

Code:
PIMPLE: converged in 3 iterations
ExecutionTime = 75513.4 s  ClockTime = 75651 s

forces forces output:
    sum of forces:
        pressure : (0.603027 -0.0244227 -4.07056e-21)
        viscous  : (0.060363 0.0116136 -1.30133e-21)
        porous   : (0 0 0)
    sum of moments:
        pressure : (2.66751e-19 -2.65314e-17 -1.75474e-12)
        viscous  : (5.0719e-19 -2.74569e-18 -0.000137971)
        porous   : (0 0 0)
How should my customRegExp should look like, to plot the sum of pressure ans viscous components?
pressure in x : 7.7394e-19
pressure in y : 0.09


Thanl you for your help
Matching this hasn't been possible until last week as the match has to go over multiple lines. Last week PyFoam 0.6.4 came out and if you look at the release notes http://sourceforge.net/p/openfoam-ex...Notes.md#sec-1 then this is now possible.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   April 22, 2015, 15:10
Question Plot residuals of any region in a multi region solver
  #16
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
Hi all!

I apologize for pulling up this old thread but I'm struggling with some issue that I think that fits well in it...

I'm solving some cases with chtMultiRegionSimpleFoam solver with a few solid regions and a fluid one. When I run pyFoamPlotWatcher it only shows the residuals plot for the fluid region. What I would like to study is the residuals for some of the solid regions and after having searched for some info in the net I think that it would be possible by using customRegexp. The problem is that I don't have enough knowledge to tackle it on my own so here comes my question: How should my file look like? The solver's output looks like
Code:
Solving for solid region regionName
DICPCG:  Solving for h, Initial residual = 0.02194378, Final residual = 0.0001580524, No Iterations 4
DICPCG:  Solving for h, Initial residual = 0.01952452, Final residual = 0.0001349324, No Iterations 4
DICPCG:  Solving for h, Initial residual = 0.01921998, Final residual = 0.000115592, No Iterations 4
DICPCG:  Solving for h, Initial residual = 0.01896599, Final residual = 0.0001086326, No Iterations 4
Min/max T:min(T) [0 0 0 1 0 0 0] 937.6767 max(T) [0 0 0 1 0 0 0] 962.7659
and as per what I saw in the wiki page the file should be similar to
Code:
ReactionSpeed
{
  expr "Reaction Speed: (%f%) min (%f%) max";
  name Custom01_Reaction_speed;
  theTitle "Custom 1 - Reaction speed";
  titles
   (
     min
     max
   );
  type regular;
}
but I don't know what I should do in oder to create the proper customRegexp file to be able to plot the residuals for any other region than the fluid one...

Any word of wisdom that can enlighten me about this matter will be much appreciated!

Best regards,

Alex
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com

The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in!
zfaraday is offline   Reply With Quote

Old   April 23, 2015, 10:40
Default
  #17
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
After some attempts to make it work I didn't succeed...

My attempt was to create a file within the case directory with the name customRegexp as suggested in the wiki. In my case, the file contains the following information:

Code:
alumina_residuals
{
  expr "Solving for solid region alumina\n\nDICPCG:  Solving for h, Initial residual = (%f%), Final residual = .+, No Iterations .+";
  name Custom01_alumina_res;
  theTitle "Custom 1 - Residuals for region alumina";
  titles
   (
     Initial Residuals
   );
  type regular;
}
As one can see, my intention is to plot the initial residual for the last correction step (the third line for the region in the example). I used \n to indicate pyFoam that it must read the line number n in order to pick the information I want to plot. Not sure if I used it correctly (probably not as I'm unexperienced in using regular expressions). I also tried to leave a sapce between the new line characters and the rest of the characters ("region alumina \n \n DICPCG:") but it also gave no outputs...

I'm using pyFoam version 0.6.4 and the order I type in the terminal is:
Code:
pyFoamPlotWatcher.py --silent --progress --no-default log.chtMultiRegionSimpleFoam &
to what the terminal says:
Code:
Reading regular expressions from customRegexp
so it seems that everything is fine. However, no plot is shown...

Can anyone give me some advice on how to proceed correctly in order to write the proper regular expression to be able to plot the residuals for any region? I would really appreciate the help given!

Best regards,

Alex
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com

The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in!
zfaraday is offline   Reply With Quote

Old   April 24, 2015, 12:45
Question Residuals plot with vertical axis in logarithmic scale
  #18
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
Dear colleagues,

Finally I could manage to solve it (more or less). I get a a residuals plot by using this customRegexp file:

Code:
alumina_residuals
{
  expr "Solving for solid region alumina\nDICPCG:  Solving for h, Initial residual = (%f%), Final residual = .+, No Iterations .+";
  name Custom_alumina_res;
  theTitle "Residuals for region: alumina";
  titles
   (
     "h (1st iter.)"
   );
  type regular;
}
This is the initial residual for the first correction step, I also managed to plot the last correction step but I realized that it makes more sense to plot the first initial residual.

Now I have another problem, the plot shows the residuals using a linear vertical axis instead of a logarithmical axis which is not much useful because I can barely see anything... I tried to add a line in the customRegexp file in order to convert the vertical axis into logarithmic scale using the gnuplot grammar, i.e. set logscale y, but it did nothing, the plot was done in linear scale any way.

How can I plot the residuals with the vertical axis in logarithmic scale? Is it possible to do that?

Many thanks in advance!

Alex
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com

The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in!
zfaraday is offline   Reply With Quote

Old   May 18, 2015, 10:37
Default
  #19
Senior Member
 
JNSN's Avatar
 
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 144
Rep Power: 20
JNSN is on a distinguished road
Code:
  logscale true;
zfaraday likes this.
JNSN is offline   Reply With Quote

Old   May 18, 2015, 10:43
Default
  #20
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
Amazing! As simple as that... Thanks!

Regards,

Alex
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com

The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in!
zfaraday is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[PyFoam] First discussion thread about PyFoam braennstroem OpenFOAM Community Contributions 338 March 17, 2022 15:05


All times are GMT -4. The time now is 20:56.