|
[Sponsors] |
[PyFoam] First discussion thread about PyFoam |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 28, 2007, 04:33 |
First discussion thread about PyFoam
|
#1 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi,
I tried to run the simulations using PyFoam with OpenFoam 1.4. The installation was no problem and the test of the installation (like the wiki suggested) was ok too,but as soon as I start the calculations with localhost~/OpenFOAM/fab-1.4/run/tutorials/simpleFoam$ pyFoamSteadyRunner.py simpleFoam . pitzDaily I get: [28 Jul 9:30am] Traceback (most recent call last): File "/usr/bin/pyFoamSteadyRunner.py", line 3, in ? from PyFoam.Applications.SteadyRunner import SteadyRunner ImportError: No module named SteadyRunner So it looks actually like a python problem!? I installed it with python 2.5 and 2.3. Would be nice, if anybody has an idea, how to get pyfoam running... it seems pretty powerfull! Regards! |
|
July 30, 2007, 14:15 |
Hi,
it works at work ;-) ...
|
#2 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi,
it works at work ;-) ... it seems that the wiki-test of the installation is not enough; I would say, that I forgort to load the libaries, stupid. Regards! Fabian |
|
July 31, 2007, 14:14 |
Is it something I forgot to me
|
#3 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Is it something I forgot to mention on the Wiki-page? Or did you just forget to set the PYTHONPATH-variable?
__________________
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 |
|
August 1, 2007, 06:30 |
Hi Bernhard,
I just forgot
|
#4 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi Bernhard,
I just forgot the Pythonpath... your WIKI is ok, but I am missing some more information ;-) How can I convert the openfoam data files to ensight for every variation when using your 'Parameter Variation' script? Regards! Fabian |
|
August 1, 2007, 10:23 |
The one that is one the Wiki-P
|
#5 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
The one that is one the Wiki-Page? Must revise that one of these days (It's still from the 0.1.x-version)
Add something like (don't know the exact call for the Ensight-Converter) near the call for the mass-flow calculation: eUtil=UtilityRunner(argv=["foamToEnsight",".",case,"-latestTime"],silent=True,lo gname="EnsightConversion") eUtil.start()
__________________
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 |
|
August 1, 2007, 16:29 |
Hi Bernhard,
thanks, I will
|
#6 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi Bernhard,
thanks, I will try it out! Fabian |
|
August 2, 2007, 03:17 |
Hi Bernhard,
I have one mor
|
#7 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi Bernhard,
I have one more question ... what do you think is the best way to run different solvers, e.g. potentialFoam / simpleFoam / turbFoam / oodles, one after another. Do you think one of your 'utilities' can do that? Greetings! Fabian |
|
August 2, 2007, 09:26 |
Hi Fabian!
Of course it can
|
#8 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Hi Fabian!
Of course it can. The only problem is that "different folks need different strokes": the solvers you are refering to need very different fvS.+-files (amongst other things). But if you have a template case that satisfys them all you could do the following (just a sketch): caseName="baseCase" for solver in ["potentialFoam","simpleFoam","turbFoam","oodle s"]: . case=SolutionDirectory(caseName).cloneCase(caseNam e+"."+solver) . run=ConvergenceRunner(BoundingLogAnalyzer(),argv=[solver,".",case.name],silent=T rue) . run.start() (Sorry about the points, but they're the only way I can get the MessageBoard to indent the lines) The problem with this example is of course that we're mixing steady with unsteady solvers. About the discussion in the "Foam::error::printStack"-thread (I'm moving it here because it doesn't belong there http://www.cfd-online.com/cgi-bin/Op...how.cgi?1/4603 ): I hope my answer didn't come across in such a way that I am not open to other peoples ideas/input on the scope of PyFoam. About the manipulation of boundary conditions: you are aware of the ParsedParameterFile-class? That one might be helpful. It reads a Foam-Dictionary and stores it as a Python-data-structure in memory (Foam-dictionaries become Python-dictionaries, Foam-Lists become ..... Python-lists) which you can manipulate and write back to disk (the output is ugly as f###, but valid). Ah. And don't try to use it on a 10k-nonuniform-field (I'm afraid the parser will run out of memory). Bernhard
__________________
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 |
|
August 26, 2007, 05:31 |
Hello there,
A Good Sunday
|
#9 |
Senior Member
Philippose Rajan
Join Date: Mar 2009
Location: Germany
Posts: 552
Rep Power: 25 |
Hello there,
A Good Sunday morning to everyone :-)! First of all, I must commend Bernhard Gschaider for the effort put into PyFoam. I was looking into the facilities available, and its quite mindblowing how much stuff has been packed into it :-)! Really cool !! I am considering using PyFoam for a set of batch simulations with parameter variations. Before I go deeper into making an application, I have one question.... The ConvergenceRunner, is used to run a steady state simulation, until the solution converges, which in this case would be the residuals dropping below a certain limit. I was looking through some of the examples, but could not find any example, where these "convergence limits" are specified. How can I specify what the limits of the residuals are, below which PyFoam considers the solution to be "converged" ? Have a nice day! Philippose |
|
August 26, 2007, 09:43 |
Hi,
@Bernhard:
Thanks, it se
|
#10 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi,
@Bernhard: Thanks, it seems pyfoam is usefull for everything :-) I'll try it out... @Philippose: I'll think it depends on the number of iterations, but I am not sure. I would be nice, if the convergence could be checked by monitoring some kind of physical value in the flow and define a certain range for a certain number of iterations. Fabian |
|
August 27, 2007, 11:51 |
Hi!
Fabian is right: The Co
|
#11 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Hi!
Fabian is right: The ConvergenceRunner doesn't judge the convergence himself, but lets the linear solvers do it: if all of them do 0 iterations it assumes that the solution is converged @other measures for convergence: The only means that PyFoam has to get information about a run is by checking the output of the solver. If "some kind of physical value in the flow" is output, then it can be checked for and the run can be terminated the same way the ConvergenceRunner does it. Bernhard
__________________
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 |
|
August 28, 2007, 15:41 |
Hello Bernhard and Fabian,
|
#12 |
Senior Member
Philippose Rajan
Join Date: Mar 2009
Location: Germany
Posts: 552
Rep Power: 25 |
Hello Bernhard and Fabian,
Thanks a lot for the information... I have been looking through the code, and I think I am slowly getting a hang of it, though, its really extensive :-)! And I am more or less, a beginner in Python when it comes to such large projects with tonnes of classes, etc... As far as I can see, creating a "Runner" which actually works on a convergence criteria like stopping when some or all of the variables go below a residual threshold, or even looking for convergence in a physical variable like flow, shouldnt be too difficult. Anyway, shall post questions as I progress over the next week or so :-)! Have a nice day! Philippose |
|
August 29, 2007, 15:30 |
Hi Philippose!
The problem
|
#13 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Hi Philippose!
The problem is that it happens on three levels: the Runner-class runs the solver it gets the output and sends each line to a FoamLogAnalyzer-subclass. That sends that line to all its LogLineAnalyzers (it can have as many as it wants). These are the real work-horses. They look at the lines, gather information and sometimes decide whether they think that the simulation is converged (the goOn()-method). The FoamLogAnalyzer asks all his LineAnalyzers. If one of them says "Converged" it tells the runner to stop the simulation (not without writting the current-timestep). So what you want to do is this: implement a LogLineAnalyzer-subclass that fits your idea of convergence. Add it to the ConvergenceRunner and it should terminate the run once it is converged Hope this helps Bernhard
__________________
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 |
|
August 29, 2007, 15:32 |
Forgot: a new version of PyFoa
|
#14 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Forgot: a new version of PyFoam (0.4.1) found its way to the Wiki.
__________________
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 |
|
October 2, 2007, 02:04 |
Hi Bernhard,
I would like t
|
#15 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi Bernhard,
I would like to use the utitlityrunner to extract the result of 'patchAverage', which looks in my case like: *--------------------------------------------------------------------------- ceplx049~/SCR1/OpenFOAM_Berechnung/Nottage> patchAverage . Nottage_Tetra_Fein p einlass:4 -latestTime /*---------------------------------------------------------------------------*\ | ========= | | | \ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \ / O peration | Version: 1.4.1 | | \ / A nd | Web: http://www.openfoam.org | | \/ M anipulation | | \*---------------------------------------------------------------------------*/ Exec : patchAverage . Nottage_Tetra_Fein p einlass:4 -latestTime Date : Oct 02 2007 Time : 06:33:06 Host : ceplx049 PID : 22200 Root : /v/ceplx049/fs2/scr/scr1/gcae504/OpenFOAM_Berechnung/Nottage Case : Nottage_Tetra_Fein Nprocs : 1 Create time Create mesh for time = 1850 Time = 1850 Reading field p Average of p over patch einlass:4[2] = 0.557439 End *--------------------------------------------------------------------------- Do you know what kind of regex to use, to extract the pressure average? I am kind of confused about your regex in the example... I tried this approach: *--------------------------------------------------------------------------- pUtil=UtilityRunner(argv=["patchAverage",".",case, patch, variable, " -latestTime"],silent=True,logname="patchAverage") pUtil.add("deltaP"," Average of p over patch (.+) = .*\]",idNr=1) pUtil.start() deltaP=pUtil.get("deltaP")[0] deltaPressure=pUtil.get("p",ID="einlass:4")[0] *--------------------------------------------------------------------------- but, as expected, it did not work: *--------------------------------------------------------------------------- ceplx049~/SCR1/OpenFOAM_Berechnung/Nottage> python2.5 patchAverage_pyFoam.py simpleFoam <pyfoam.execution.utilityrunner.utilityrunner> Traceback (most recent call last): File "patchAverage_pyFoam.py", line 47, in <module> deltaP=pUtil.get("deltaP")[0] TypeError: 'NoneType' object is unsubscriptable *--------------------------------------------------------------------------- Greetings! Fabian |
|
October 2, 2007, 06:44 |
Hi Fabian!
The lines you wa
|
#16 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Hi Fabian!
The lines you want to change are: pUtil.add("deltaP","Average of p over patch (.+) = (%f%)",idNr=1) In order to get added as data the pattern has to be enclosed in (). The first one is used as the ID (as specified by the option). The %f% is replaced with the regular expression that matches a floating point number (just a shorthand in the PyFoam-classes that use regular expressions) The second part took me longer (I thought my classes were broken, but in fact in your example the [2] was missing): deltaPressure=pUtil.get("deltaP",ID="einlass:4[2]")[0] Now deltaPressure has the string 0.557439 (which is what you wanted?) Bernhard
__________________
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 |
|
October 3, 2007, 06:21 |
Hi Bernhard,
thanks for you
|
#17 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi Bernhard,
thanks for your help; I will try on Thursday at the office. Fabian |
|
October 4, 2007, 04:35 |
Hi bernhard,
I'm trying to
|
#18 |
Guest
Posts: n/a
|
Hi bernhard,
I'm trying to use the DisplayBlockMesh utility: Following the message given by the --help option. I have: cue006@cfd-kf:~/OpenFOAM/cue006-1.4.1/run/tutorials/oodles> pyFoamDisplayBlockMesh.py CST/constant/polyMesh/blockMeshDict Traceback (most recent call last): File "/usr/local/bin/pyFoamDisplayBlockMesh.py", line 391, in ? DisplayPlotMesh() File "/usr/local/bin/pyFoamDisplayBlockMesh.py", line 22, in __init__ PyFoamApplication.__init__(self,description=descri ption,usage="%prog [options] <blockmeshdict>",interspersed=True,nr=1) File "/usr/local/lib64/python2.4/site-packages/PyFoam/Applications/PyFoamApplication. py", line 21, in __init__ self.run() File "/usr/local/bin/pyFoamDisplayBlockMesh.py", line 42, in run self.readFile() File "/usr/local/bin/pyFoamDisplayBlockMesh.py", line 122, in readFile self.blockMesh=ParsedBlockMeshDict(sys.argv[1]) File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/ParsedBlockMeshDi ct.py", line 11, in __init__ ParsedParameterFile.__init__(self,name,backup=back up,debug=debug) File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/ParsedParameterFi le.py", line 26, in __init__ self.readFile() File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/FileBasis.py", line 56, in readFile self.content=self.parse(self.fh.read()) File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/ParsedParameterFi le.py", line 30, in parse parser=FoamFileParser(content,debug=self.debug,bou ndaryDict=self.boundaryDict) File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/ParsedParameterFi le.py", line 77, in __init__ self.header,self.data=self.parse(content) File "/usr/local/lib64/python2.4/site-packages/PyFoam/Basics/PlyParser.py", line 50, in parse return yacc.parse(content) File "/usr/local/lib64/python2.4/site-packages/PyFoam/ThirdParty/ply/yacc.py", line 334, in parse tok = self.errorfunc(errtoken) File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/ParsedParameterFi le.py", line 304, in p_error raise "ParserError",("Syntax error at token", p) # .type, p.lineno ParserError: ('Syntax error at token', LexToken(NAME,'version',3,124)) What's wrong? Cheers pvc |
|
October 4, 2007, 06:30 |
Hi Pierre!
PyFoam thinks th
|
#19 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Hi Pierre!
PyFoam thinks tht there is a syntactical error in the blockMeshDict. The cause could either be a) there IS an error in the blockMeshDict (have you ever tried to run blockMesh on it?) b) there IS a bug in PyFoam Could you give me the blockMeshDict that is causing trouble (either per mail or here) Bernhard
__________________
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 |
|
October 4, 2007, 23:20 |
hi bernhard,
Thanks for th
|
#20 |
Guest
Posts: n/a
|
hi bernhard,
Thanks for the tip. I've tested my PyFoam installation against the pitzdaily case and it's working. My geometry was derived from a cylindermesh.m4 script (see http://www.cfd-online.com/OpenFOAM_D...es/1/3249.html). I think the answer will come by solving this simple case, since pyFoamDisplayBlockMesh was crashing when trying to open it. As you have suggested, maybe a bug? Kind regards Pierre cue006@cfd-kf:~/OpenFOAM/cue006-1.4.1/run/tutorials/oodles/m4_Files> pyFoamDispl ayBlockMesh.py cylinderMeshDict Traceback (most recent call last): File "/usr/local/bin/pyFoamDisplayBlockMesh.py", line 391, in ? DisplayPlotMesh() File "/usr/local/bin/pyFoamDisplayBlockMesh.py", line 22, in __init__ PyFoamApplication.__init__(self,description=descri ption,usage="%prog [option s] <blockmeshdict>",interspersed=True,nr=1) File "/usr/local/lib64/python2.4/site-packages/PyFoam/Applications/PyFoamAppli cation.py", line 21, in __init__ self.run() File "/usr/local/bin/pyFoamDisplayBlockMesh.py", line 42, in run self.readFile() File "/usr/local/bin/pyFoamDisplayBlockMesh.py", line 122, in readFile self.blockMesh=ParsedBlockMeshDict(sys.argv[1]) File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/ParsedBloc kMeshDict.py", line 11, in __init__ ParsedParameterFile.__init__(self,name,backup=back up,debug=debug) File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/ParsedPara meterFile.py", line 26, in __init__ self.readFile() File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/FileBasis. py", line 56, in readFile self.content=self.parse(self.fh.read()) File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/ParsedPara meterFile.py", line 30, in parse parser=FoamFileParser(content,debug=self.debug,bou ndaryDict=self.boundaryDic t) File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/ParsedPara meterFile.py", line 77, in __init__ self.header,self.data=self.parse(content) File "/usr/local/lib64/python2.4/site-packages/PyFoam/Basics/PlyParser.py", li ne 50, in parse return yacc.parse(content) File "/usr/local/lib64/python2.4/site-packages/PyFoam/ThirdParty/ply/yacc.py", line 334, in parse tok = self.errorfunc(errtoken) File "/usr/local/lib64/python2.4/site-packages/PyFoam/RunDictionary/ParsedPara meterFile.py", line 304, in p_error raise "ParserError",("Syntax error at token", p) # .type, p.lineno ParserError: ('Syntax error at token', LexToken(NAME,'version',3,124)) |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Divergence detected in AMG solver: k when udf loaded | google9002 | Fluent UDF and Scheme Programming | 3 | November 8, 2019 00:34 |
udf problem | jane | Fluent UDF and Scheme Programming | 37 | February 20, 2018 05:17 |
Guide: Getting Started with the CFD Online Discussion Forums | pete | Site Help, Feedback & Discussions | 8 | July 29, 2016 06:00 |
Error messages | atg | enGrid | 7 | August 30, 2013 12:16 |
Phase locked average in run time | panara | OpenFOAM | 2 | February 20, 2008 15:37 |