CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [PyFoam] First discussion thread about PyFoam (https://www.cfd-online.com/Forums/openfoam-community-contributions/60683-first-discussion-thread-about-pyfoam.html)

gschaider May 21, 2012 18:09

Quote:

Originally Posted by Amir (Post 362277)
Dear Bernhard,

I have a trouble with both pyFoamPlotWatcher and Runner; Although I set the proper frequency of data plotting with "frequency option" but it gradually extends during iteration. What's the solution?

Bests,

I don't understand what you mean with "gradually extends during iteration".

Just to clarify: the purpose of the frequency-option is "only redo the plot every x seconds" the purpose of this is that otherwise for small runs with a lot of timesteps the plotting becomes more time-consuming than the actual calculation (because the plotting would occur several times a second)

Amir May 22, 2012 15:31

Quote:

Originally Posted by gschaider (Post 362296)
I don't understand what you mean with "gradually extends during iteration".

Just to clarify: the purpose of the frequency-option is "only redo the plot every x seconds" the purpose of this is that otherwise for small runs with a lot of timesteps the plotting becomes more time-consuming than the actual calculation (because the plotting would occur several times a second)

I meant that the time intervals between renewing plots gradually increases during iteration with a notification in terminal. Although the default frequency is 1 and I also use frequency option equal to 1 but it renews for example after 10 time steps (even it seems that plotting processes have stopped). I just want to plot them at each time step; i.e. disable automatic changing of frequency.

lindstroem June 14, 2012 05:01

Hi all!

I want to extend the pyFoamPlotWatcher so it also plots the phase fraction. I have an inlet in my computation so it would be nice to see that.

As the structure is rather complex i wanted to ask for a hint, where it makes sense to add this function. I have my own (bash)script which gives me this plot, but as a post processing step, and not during runtime. So I think it cant be too difficult to integrate that.

Thanks for any hints!

gschaider June 14, 2012 14:29

Quote:

Originally Posted by lindstroem (Post 366417)
Hi all!

I want to extend the pyFoamPlotWatcher so it also plots the phase fraction. I have an inlet in my computation so it would be nice to see that.

As the structure is rather complex i wanted to ask for a hint, where it makes sense to add this function. I have my own (bash)script which gives me this plot, but as a post processing step, and not during runtime. So I think it cant be too difficult to integrate that.

Thanks for any hints!

As much as I welcome contributions to PyFoam I would discourage that (adding it to the code). The phase fraction is a solver-specific output and for such outputs there is the customRegexp-file (see http://openfoamwiki.net/index.php/Co...Regexp-files): basically you add this file to the case, PyFoam finds it there, looks for the patterns specified in this file and plots the data.

Adding application-specific patterns to PyFoam itself will decrease its overall performance as it will look for that pattern in every line even if the solver doesn't write such a line (and looking for these patterns is currently the bottleneck in the pyFoamWatcher anyway)

Bernhard

lindstroem June 15, 2012 04:23

Hi Bernhard,

reasonable.. nothing more to say :) thanks for your comment and the hint about the custom regexp

Best wishes

ancsa July 4, 2012 05:38

AttributeError
 
Hi,

after some time of foaming I found some time to investigate pyFoam and I wish it have happened earlier, thank you for it.

However I have a problem which seems to be some quotation mark issue or similar, using the templates from the advanced Gothenburg training:
Code:

rakai@lab1:~/OpenFOAM/rakai-2.0.0/run/pyFoamAdvanced/pyFoamAdvanced.git/testSeparator$ pyFoamFromTemplate.py constant/polyMesh/blockMeshDict "{'preLen':0.2, 'cavitiyWidth':0.15, 'channelHeight':0.1, 'interLen':0.05, 'cavityDepth':0.02, 'dx':0.005}"
Traceback (most recent call last):
  File "/home/rakai/my_python/bin/pyFoamFromTemplate.py", line 5, in <module>
    FromTemplate()
  File "/home/rakai/my_python/lib/python2.6/site-packages/PyFoam/Applications/FromTemplate.py", line 30, in __init__
    interspersed=True)
  File "/home/rakai/my_python/lib/python2.6/site-packages/PyFoam/Applications/PyFoamApplication.py", line 213, in __init__
    result=self.run()
  File "/home/rakai/my_python/lib/python2.6/site-packages/PyFoam/Applications/FromTemplate.py", line 60, in run
    t.writeToFile(fName,vals)
  File "/home/rakai/my_python/lib/python2.6/site-packages/PyFoam/Basics/TemplateFile.py", line 44, in writeToFile
    output=self.getString(vals)
  File "/home/rakai/my_python/lib/python2.6/site-packages/PyFoam/Basics/TemplateFile.py", line 54, in getString
    symbols=vals.copy()
AttributeError: 'str' object has no attribute 'copy'

I tried several quotation mark types I find on the keyboard but all the time the variables are treated as string, or maybe I am wrong somewhere else.

Any hints? Thank you
Aniko

gschaider July 16, 2012 15:18

Quote:

Originally Posted by ancsa (Post 369707)
Hi,

after some time of foaming I found some time to investigate pyFoam and I wish it have happened earlier, thank you for it.

However I have a problem which seems to be some quotation mark issue or similar, using the templates from the advanced Gothenburg training:
Code:

rakai@lab1:~/OpenFOAM/rakai-2.0.0/run/pyFoamAdvanced/pyFoamAdvanced.git/testSeparator$ pyFoamFromTemplate.py constant/polyMesh/blockMeshDict "{'preLen':0.2, 'cavitiyWidth':0.15, 'channelHeight':0.1, 'interLen':0.05, 'cavityDepth':0.02, 'dx':0.005}"
Traceback (most recent call last):
  File "/home/rakai/my_python/bin/pyFoamFromTemplate.py", line 5, in <module>
    FromTemplate()
  File "/home/rakai/my_python/lib/python2.6/site-packages/PyFoam/Applications/FromTemplate.py", line 30, in __init__
    interspersed=True)
  File "/home/rakai/my_python/lib/python2.6/site-packages/PyFoam/Applications/PyFoamApplication.py", line 213, in __init__
    result=self.run()
  File "/home/rakai/my_python/lib/python2.6/site-packages/PyFoam/Applications/FromTemplate.py", line 60, in run
    t.writeToFile(fName,vals)
  File "/home/rakai/my_python/lib/python2.6/site-packages/PyFoam/Basics/TemplateFile.py", line 44, in writeToFile
    output=self.getString(vals)
  File "/home/rakai/my_python/lib/python2.6/site-packages/PyFoam/Basics/TemplateFile.py", line 54, in getString
    symbols=vals.copy()
AttributeError: 'str' object has no attribute 'copy'

I tried several quotation mark types I find on the keyboard but all the time the variables are treated as string, or maybe I am wrong somewhere else.

Any hints? Thank you
Aniko

Problem is that certain shells pass the "" with the argument and others don't.

Best fix I can offer is: go to FromTemplate.py and add the lines with the + (but without the +) after the other two lines:
Code:

            fName=self.parser.getArgs()[0]
            vals=eval(self.parser.getArgs()[1])
+            if type(vals)==str:
+                # fix a problem with certain shells
+                vals=eval(vals)

Otherwise: check whether your version already supports the --values-string-option and use that (along with options for the template files etc). That should work without modification

ancsa August 3, 2012 10:40

Problem solved, thank you
 
Thank you, adding the + lines solved the problem.

The --values-string option I tried but does not work, I am using pyFoam-Version: 0.5.7.
Code:

pyFoamFromTemplate.py: error: no such option: --values-string
Aniko

gschaider August 6, 2012 18:54

Quote:

Originally Posted by ancsa (Post 375276)
Thank you, adding the + lines solved the problem.

The --values-string option I tried but does not work, I am using pyFoam-Version: 0.5.7.
Code:

pyFoamFromTemplate.py: error: no such option: --values-string
Aniko

OK. Then this is something to come with the next version (along with a new template engine that allows branches and loops)

lakeat April 8, 2013 18:05

Btw, can pyfoam be used via ssh if I am using a remote cluster? I installed it on the remote cluster and set the path and using ssh -Y option but there is still error. :(

gschaider April 8, 2013 18:58

Quote:

Originally Posted by lakeat (Post 419211)
Btw, can pyfoambe used via ssh if I am using a remote cluster?

If it is installed on the cluster: yes ("installed on the cluster": an installation in the users home directory is sufficient if PATH and PYTHONPATH are set correctly). After all it is mainly command-line utilities

izna August 13, 2013 05:43

hello Berrnad.

i get this error
Quote:

running 500,000 cells mesh
Traceback (most recent call last):
File "./runAskervein.py", line 31, in <module>
from PyFoam.Applications.PlotRunner import PlotRunner
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/PlotRunner.py", line 8, in <module>
from PyFoam.Execution.GnuplotRunner import GnuplotRunner
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Execution/GnuplotRunner.py", line 4, in <module>
from .StepAnalyzedCommon import StepAnalyzedCommon
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Execution/StepAnalyzedCommon.py", line 6, in <module>
from PyFoam.Execution.AnalyzedCommon import AnalyzedCommon
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Execution/AnalyzedCommon.py", line 7, in <module>
from PyFoam.Basics.PlotTimelinesFactory import createPlotTimelines,createPlotTimelinesDirect
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Basics/PlotTimelinesFactory.py", line 4, in <module>
from PyFoam.Basics.GnuplotTimelines import GnuplotTimelines
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Basics/GnuplotTimelines.py", line 4, in <module>
from PyFoam.ThirdParty.Gnuplot import Gnuplot,Data
File "/usr/local/lib/python2.7/dist-packages/PyFoam/ThirdParty/Gnuplot/__init__.py", line 166, in <module>
from .PlotItems import PlotItem, Func, File, Data, GridData
File "/usr/local/lib/python2.7/dist-packages/PyFoam/ThirdParty/Gnuplot/PlotItems.py", line 31, in <module>
import numpypy
ImportError: No module named numpypy
running 5,000,000 cells
Traceback (most recent call last):
File "./runAskervein.py", line 31, in <module>
from PyFoam.Applications.PlotRunner import PlotRunner
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/PlotRunner.py", line 8, in <module>
from PyFoam.Execution.GnuplotRunner import GnuplotRunner
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Execution/GnuplotRunner.py", line 4, in <module>
from .StepAnalyzedCommon import StepAnalyzedCommon
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Execution/StepAnalyzedCommon.py", line 6, in <module>
from PyFoam.Execution.AnalyzedCommon import AnalyzedCommon
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Execution/AnalyzedCommon.py", line 7, in <module>
from PyFoam.Basics.PlotTimelinesFactory import createPlotTimelines,createPlotTimelinesDirect
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Basics/PlotTimelinesFactory.py", line 4, in <module>
from PyFoam.Basics.GnuplotTimelines import GnuplotTimelines
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Basics/GnuplotTimelines.py", line 4, in <module>
from PyFoam.ThirdParty.Gnuplot import Gnuplot,Data
File "/usr/local/lib/python2.7/dist-packages/PyFoam/ThirdParty/Gnuplot/__init__.py", line 166, in <module>
from .PlotItems import PlotItem, Func, File, Data, GridData
File "/usr/local/lib/python2.7/dist-packages/PyFoam/ThirdParty/Gnuplot/PlotItems.py", line 31, in <module>
import numpypy
ImportError: No module named numpypy

Can you please tell me what shoudl i do?

Kind regards
Izna

gschaider August 13, 2013 13:16

Quote:

Originally Posted by izna (Post 445390)
hello Berrnad.

i get this error


Can you please tell me what shoudl i do?

Kind regards
Izna

pyFoamVersion.py will show that you have no numpy installed. Install it via the package manager of your distribution (usually it is called python-numpy or so)

izna August 13, 2013 13:26

hi Bernard.. Even on installing all these i get the error that nympypy does nto exist..

I have found a case on the net and i wish to run ./Allrun and view it but try as i might it is not working..

i am sending you the case.

http://openfoamwiki.net/index.php/Fi...emplate.tar.gz


Apparently this use the pyfoam library..

Kind regard
izna

gschaider August 13, 2013 18:12

Quote:

Originally Posted by izna (Post 445497)
hi Bernard.. Even on installing all these i get the error that nympypy does nto exist..

I have found a case on the net and i wish to run ./Allrun and view it but try as i might it is not working..

i am sending you the case.

http://openfoamwiki.net/index.php/Fi...emplate.tar.gz


Apparently this use the pyfoam library..

Kind regard
izna

PyFoam wouldn't try to import numpypy if numpy was installed.

To check that numpy is not installed try
Code:

python -c "import numpy;print numpy.__version__"
Or check with pyFoamVersion.py

izna August 16, 2013 13:50

hi Bernard

NUmpy has been installed
Quote:

izna@izna-MS-7592:~$ python -c "import numpy;print numpy.__version__"
1.6.1


But when i run my case i stil get those errors!!!

Quote:

izna@izna-MS-7592:~/Desktop/BL2Dtemplate$ ./Allrun
z0 = 0.001
ks = 0.01958
us = 0.517132402802
TKE = 1.54398428071
Running blockMesh
Decomposing

Decomposition
=============

Case is decomposed for 2 processors


============ ===== =====
CPU 0 1
------------ ----- -----
Points 37998 38310
Faces 75017 75635
Cells 18673 18827
============ ===== =====
frontAndBack 37346 37654
ground 249 251
inlet 0 75
outlet 75 0
top 249 251
============ ===== =====

sh: 1: gnuplot: not found
sh: 1: gnuplot: not found
Traceback (most recent call last):
File "./run_z0.py", line 100, in <module>
main(template0, template, orig, target0, withBlock, z0)
File "./run_z0.py", line 87, in main
PlotRunner(args=["--proc=%d"%procnr,"--hardcopy","--progress","simpleFoam","-case",work.name])
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/PlotRunner.py", line 58, in __init__
description=description)
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/PyFoamApplication.py", line 155, in __init__
result=self.run()
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/PlotRunner.py", line 128, in run
jobId=self.opts.jobId)
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Execution/GnuplotRunner.py", line 159, in __init__
plottingImplementation=plottingImplementation)
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Execution/GnuplotRunner.py", line 70, in __init__
plottingImplementation=plottingImplementation)
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Execution/AnalyzedCommon.py", line 139, in createPlots
plots["cont"].setYLabel2("Global")
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Basics/GnuplotTimelines.py", line 130, in setYLabel2
self.set_string('y2label "%s"' % title)
File "/usr/local/lib/python2.7/dist-packages/PyFoam/ThirdParty/Gnuplot/_Gnuplot.py", line 383, in set_string
self('set %s' % (option,))
File "/usr/local/lib/python2.7/dist-packages/PyFoam/ThirdParty/Gnuplot/_Gnuplot.py", line 210, in __call__
self.gnuplot(s)
File "/usr/local/lib/python2.7/dist-packages/PyFoam/ThirdParty/Gnuplot/gp_unix.py", line 210, in __call__
self.flush()
IOError: [Errno 32] Broken pipe


izna August 16, 2013 13:57

hi again bernard

By the way i am running this case which i found from the internet...

izna August 16, 2013 14:01

1 Attachment(s)
attached is the case..If you wish to check it out..

wyldckat August 18, 2013 07:40

Greetings to all!

@Izna: Clearly the problem is that gnuplot is not installed:
Quote:

Code:

sh: 1: gnuplot: not found

If you have Ubuntu/Debian, you can quickly install it by running:
Code:

sudo apt-get install gnuplot
Best regards,
Bruno

izna August 19, 2013 12:26

Hi Bruno...

After having installed the application i get errors still
Quote:


Create time

--> FOAM Warning :
From function dlOpen(const fileName&, const bool)
in file POSIX.C at line 1179
dlopen error : libgroovyBC.so: cannot open shared object file: No such file or directory
--> FOAM Warning :
From function dlLibraryTable::open(const fileName&, const bool)
in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 99
could not load "libgroovyBC.so"
--> FOAM Warning :
From function dlOpen(const fileName&, const bool)
in file POSIX.C at line 1179
dlopen error : libsimpleSwakFunctionObjects.so: cannot open shared object file: No such file or directory
--> FOAM Warning :
From function dlLibraryTable::open(const fileName&, const bool)
in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 99
could not load "libsimpleSwakFunctionObjects.so"
--> FOAM Warning :
From function dlOpen(const fileName&, const bool)
in file POSIX.C at line 1179
dlopen error : libswakFunctionObjects.so: cannot open shared object file: No such file or directory
--> FOAM Warning :
From function dlLibraryTable::open(const fileName&, const bool)
in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 99
could not load "libswakFunctionObjects.so"
Create mesh for time = 0

Reading set description:
line_h
line_inlet
line_y

Time = 0

End


Plotting the following cases:
['../Bump2D_run_1.06_10.0_1500.0_200.0_200.0_0.5_2000']
Traceback (most recent call last):
File "./runBump2D.py", line 211, in <module>
plot2DBump.main(target,hSample)
File "/home/izna/Desktop/benmartinez/2DBumpTemplate/plot2DBump.py", line 38, in main
m = max(lastRun)
ValueError: max() arg is an empty sequence



All times are GMT -4. The time now is 21:30.