|
[Sponsors] |
November 9, 2011, 13:58 |
|
#241 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Bernhard |
||
November 9, 2011, 22:58 |
|
#242 |
Member
Robert Ong
Join Date: Aug 2010
Posts: 86
Rep Power: 16 |
Thanks Bernhard. I should've thought about it before posting
|
|
November 14, 2011, 07:26 |
|
#243 |
Member
Antonio Liggieri
Join Date: Aug 2010
Posts: 76
Rep Power: 15 |
Hello Bernhard,
I need to change the boundary type for a specific boundary name in a p file from "calculated" to "fixedValue". The p file is a result file and contains nonuniform field at the boundary. As the file will to be used as initial condition for an other calculation, the BC values must remain as they are. I tried to realize that by using pyFoamChangeBoundaryType.py but I am getting errors. Is this command not suitable for my application? For better understanding: Field p before: 99999.8 99999.7 ) ; } outlet { type calculated; value nonuniform List<scalar> 1100 ( 100000 100000 Field p after: 99999.8 99999.7 ) ; } outlet { type fixedValue; value nonuniform List<scalar> 1100 ( 100000 100000 Thank you in advance, Toni |
|
November 14, 2011, 11:08 |
|
#244 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
|
||
November 15, 2011, 05:46 |
|
#245 |
Member
Antonio Liggieri
Join Date: Aug 2010
Posts: 76
Rep Power: 15 |
required command order:
pyFoamChangeBoundaryType <caseDirectory> <boundaryName> <new type> my 1st command beeing in the caseDirectory: pyFoamChangeBoundary ./ outlet fixedValue result: boundaryType in constant/polyMesh/boundary has been changed from "patch" to "fixedValue" --> not really what I want!! my 2nd command beeing in the caseDirectory: pyFoamChangeBoundary ./0/p outlet fixedValue result: raceback (most recent call last): File "/shared/openfoam/PyFoam-0.5.5/bin/pyFoamChangeBoundaryType.py", line 5, in <module> ChangeBoundaryType() File "/shared/openfoam/PyFoam-0.5.5/lib64/python2.6/site-packages/PyFoam/Applications/ChangeBoundaryType.py", line 25, in __init__ interspersed=True) File "/shared/openfoam/PyFoam-0.5.5/lib64/python2.6/site-packages/PyFoam/Applications/PyFoamApplication.py", line 155, in __init__ result=self.run() File "/shared/openfoam/PyFoam-0.5.5/lib64/python2.6/site-packages/PyFoam/Applications/ChangeBoundaryType.py", line 44, in run boundary=ParsedParameterFile(path.join(".",fName," constant","polyMesh","boundary"),debug=False,bound aryDict=True) File "/shared/openfoam/PyFoam-0.5.5/lib64/python2.6/site-packages/PyFoam/RunDictionary/ParsedParameterFile.py", line 66, in __init__ self.readFile() File "/shared/openfoam/PyFoam-0.5.5/lib64/python2.6/site-packages/PyFoam/RunDictionary/FileBasis.py", line 80, in readFile self.openFile() File "/shared/openfoam/PyFoam-0.5.5/lib64/python2.6/site-packages/PyFoam/RunDictionary/FileBasis.py", line 69, in openFile self.fh=gzip.open(self.name+".gz",mode) File "/usr/lib64/python2.6/gzip.py", line 33, in open return GzipFile(filename, mode, compresslevel) File "/usr/lib64/python2.6/gzip.py", line 79, in __init__ fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb') |
|
November 15, 2011, 19:01 |
|
#246 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
% pyFoamChangeBoundaryType.py --help Usage ===== pyFoamChangeBoundaryType.py <caseDirectory> <boundaryName> <new type> Changes the type of a boundary in the boundary-file Options ======= .... Better suited for your purposes is pyFoamCreateBoundaryPatches: Code:
%pyFoamCreateBoundaryPatches.py -h Usage ===== pyFoamCreateBoundaryPatches.py [options] <fieldfile> Takes a field-file. Looks up the polyMesh/boundary-file of the case and adds the corresponding patches to the boundary field setting it to zeroGradient for all patches and walls Options ======= .... |
||
November 16, 2011, 04:54 |
|
#247 |
Member
Antonio Liggieri
Join Date: Aug 2010
Posts: 76
Rep Power: 15 |
I tried that already, but if I use option -overwrite, all the values of the BC are deleted, and this is exactly what I don't want. If I don't use option -overwrite, nothing happens. Again, that values are a solution of a calculation, which schould be used as BC in an other case. This is why I need simply to change the type from calculated to fixedValue. Is that somehow possible?
|
|
November 16, 2011, 05:30 |
|
#248 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile p=ParsedParameterFile("0/p") p["boundaryField"]["outlet"]["type"]="fixedValue" p.write() Code:
pyFoamWriteDictionary.py -h Usage ===== pyFoamWriteDictionary.py [options] <dictfile> <key> <val> Write a value to a Foam-Dictionary. The description of the value is word. If the value is non-atomic (a list or a dictionary) it has to be in in Python- notation. Parts of the expression can be accessed by using the Python-notation for accessing sub-expressions. Example of usage: > pyFoamWriteDictionary.py --test pitzDaily/0/U "boundaryField['inlet']['type']" zeroGradient < |
||
November 16, 2011, 06:00 |
|
#249 |
Member
Antonio Liggieri
Join Date: Aug 2010
Posts: 76
Rep Power: 15 |
Bernhard - Thank you very much - it works properly
...this is once again exceptional and cool |
|
November 16, 2011, 07:01 |
|
#250 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Great. Could I ask you to give the PyFoam-Wiki-Page a critical look "I would have found the utility without help if the description here would have been clearer or if there would have been a usage-example there" and modify it accordingly. Thanks
|
|
January 15, 2012, 20:18 |
PyFoam - Survey
|
#251 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Hi all!
PyFoam has quite a long history and is supporting quite old python-versions. All this support makes it harder to incorporate new lanuage features of Python. Also there are utilities and classes in PyFoam that are no longer needed. To find out which parts of pyFoam I can let go (and which one I should keep) I ask everyone who uses PyFoam to please take the 6.57 minutes that it takes to fill out this survey: https://sourceforge.net/apps/limesur...=86766&lang=en Bernhard |
|
March 1, 2012, 08:48 |
Using ParsedBlockMeshDict class to change blockMeshDict
|
#252 |
New Member
Jeff Cumpston
Join Date: Oct 2011
Posts: 8
Rep Power: 15 |
Hi there,
I wasn't sure if this was the right place to post for a new problem with PyFoam or if I should start a totally new thread but I wanted to maximise my chances of being heard. I'm running OpenFOAM 2.1.0 with the latest Pyfoam 0.5.6. I have made a change to the blockMeshDict file using ParsedBlockMeshDict. I have written a python script, part of which changes the boundaries to 'wall' from 'patch'. I have no problem loading the file and changing the data in the ParsedBlockMeshDict class instance. I even have no trouble saving the file again. The problem arises with a very particular part of the saved blockMeshDict file and when I try to run blockMesh with a blockMeshDict file that has been through this process I get the following error: --> FOAM FATAL ERROR: hanging pointer, cannot dereference From function PtrList:perator[] const in file /home/opencfd/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/PtrListI.H at line 134. FOAM aborting After checking the blockMeshDict file, I found that its format is a little less human-readable, though that's not the problem. The problem was fixed when I removed the following number ("55" - in bold) that wasn't there in the original file: Code:
... (0 3.5 0.1) (-0.32 3.5 0.1) (-3.5 3.5 0.1) ); blocks 55 ( hex ( 0 1 6 ... etc Code:
blocks ( hex (0 1 6 7 22 23 28 29) (318 336 1) simpleGrading (1 1 1) hex (1 2 5 6 23 24 27 28) (32 336 1) simpleGrading (1 1 1) hex (2 3 4 5 24 25 26 27) (350 336 1) simpleGrading (1 1 1) hex (5 4 15 14 27 26 37 36) (350 11 1) simpleGrading (1 1 1) hex (7 6 9 8 29 28 31 30) (318 28 1) simpleGrading (1 1 1) hex (13 14 11 12 35 36 33 34) (16 7 1) simpleGrading (1 1 1) hex (14 15 16 11 36 37 38 33) (350 7 1) simpleGrading (1 1 1) hex (11 16 17 10 33 38 39 32) (350 11 1) simpleGrading (1 1 1) hex (10 17 18 19 32 39 40 41) (350 336 1) simpleGrading (1 1 1) hex (9 10 19 20 31 32 41 42) (32 336 1) simpleGrading (1 1 1) hex (8 9 20 21 30 31 42 43) (318 336 1) simpleGrading (1 1 1) ); Thanks for your time and I'm eager to hear is there's a workaround for this that doesn't involve me having to hack the blockMeshDict with a text editor to delete that number! Jeff |
|
March 1, 2012, 15:38 |
|
#253 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Please post a bug-report at openfoam-extend-Mantis (URL should be on the PyFoam-Wiki-page) and I'll try to do a general fix Until then go to PyFoam/Basics/FoamFileGenerator.py and look for the lines Code:
if theLen>20: s+=(" "*indent)+str(theLen)+"\n" Even if this works PLEASE do the bug-report. Unless you want to edit this out with every new release. This is one of the instances where the syntax of the OF-files can only be correctly parsed if knowing the C++-code |
||
April 16, 2012, 09:26 |
|
#254 |
Member
Tibor Nyers
Join Date: Jul 2010
Location: Hungary
Posts: 91
Rep Power: 17 |
Hi,
I couldn't get pyFoamPlotWatcher work with regular expressions if there is multiple data in a single line I would like to plot. The default ones are okay. controlDict Code:
functions { volumeIntegrateU { type volumeIntegrate; functionObjectLibs ( "libsimpleFunctionObjects.so" ); fields ( U ); factor 1.0; verbose true; } } Code:
IntegralU { expr "Integral of U = ((%f) (%f) (%f)) [0 4 -1 0 0 0 0]"; name IntegralU; theTitle "Integral of U"; titles ( Ux Uy Uz ); type regular; } Code:
pyFoamPlotWatcher.py log.openFoamSolver --with-all sample from the log file Code:
Time = 1000 smoothSolver: Solving for Ux, Initial residual = 0.000301615, Final residual = 1.25104e-05, No Iterations 3 smoothSolver: Solving for Uy, Initial residual = 0.000290449, Final residual = 1.14419e-05, No Iterations 3 smoothSolver: Solving for Uz, Initial residual = 0.000287985, Final residual = 1.17759e-05, No Iterations 3 GAMG: Solving for p, Initial residual = 0.00366477, Final residual = 8.22291e-06, No Iterations 5 time step continuity errors : sum local = 3.18785e-06, global = -4.97432e-18, cumulative = -5.3224e-15 smoothSolver: Solving for epsilon, Initial residual = 0.000120286, Final residual = 3.36425e-06, No Iterations 3 smoothSolver: Solving for k, Initial residual = 0.000212247, Final residual = 7.76297e-06, No Iterations 3 ExecutionTime = 8610.9 s ClockTime = 8755 s Integral of U = (0.00638885 -0.000674966 0.00267372) [0 4 -1 0 0 0 0] Time = 1001 smoothSolver: Solving for Ux, Initial residual = 0.000301345, Final residual = 1.25003e-05, No Iterations 3 smoothSolver: Solving for Uy, Initial residual = 0.000290066, Final residual = 1.14271e-05, No Iterations 3 smoothSolver: Solving for Uz, Initial residual = 0.000287703, Final residual = 1.17645e-05, No Iterations 3 GAMG: Solving for p, Initial residual = 0.0036754, Final residual = 8.02017e-06, No Iterations 5 time step continuity errors : sum local = 3.10923e-06, global = -3.73064e-18, cumulative = -5.32614e-15 smoothSolver: Solving for epsilon, Initial residual = 0.000120209, Final residual = 3.36217e-06, No Iterations 3 smoothSolver: Solving for k, Initial residual = 0.000212124, Final residual = 7.75821e-06, No Iterations 3 ExecutionTime = 8620.83 s ClockTime = 8765 s Integral of U = (0.00639356 -0.000714771 0.00266406) [0 4 -1 0 0 0 0] |
|
April 16, 2012, 15:22 |
|
#255 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
"Integral of U = \((%f) (%f) (%f)\) \[0 4 -1 0 0 0 0\]" Also there is a number of online tools (like http://regexpal.com/) that help with the first steps with regular expressions (note that %f% is a PyFoam-specific shorthand for the more complex regexp that matches a floating-point number) May I ask the following: should some of these links be helpful for you could you add the useful ones to the PyFoam-Wiki-page? ("Information on regular expressions" or so - in the customRegep-section). It's hard for me to tell what is the minimum amount of information required for a novice (and we don't want to go overboard (there are books about regular expressions) because the typical PyFoam user will only want to know the bare minimum) |
||
April 17, 2012, 06:08 |
|
#256 | |
Member
Tibor Nyers
Join Date: Jul 2010
Location: Hungary
Posts: 91
Rep Power: 17 |
I'm always amazed by the detailed answers you provide, thanks!
Although I have some experience in sed with regex, I would say it's very limited. I usually skim through 10+ tutorials on the issue and try to hammer my syntax to give me the desired result. Sometimes I don't even now why a particular solution is giving me the correct result ... Unfortunately, it didn't come to mind that my problem with customRegexp is related to regular expression common metacharacters. I think an example is more useful than some links - an is even more true when the syntax is like from another planet. Anyway, that's my experience with Linux text manipulation tools. So if you approve, I can add something like this: Quote:
The last page cartoon on the German cheat-sheet is priceless! |
||
April 17, 2012, 20:58 |
|
#257 | ||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Quote:
About the expression: The %f should have read %f% (people are under the misconception that just because I wrote this stuff -PyFoam, not regexp- I would know how to use it correctly) |
|||
April 19, 2012, 05:54 |
|
#258 |
Member
Tibor Nyers
Join Date: Jul 2010
Location: Hungary
Posts: 91
Rep Power: 17 |
Thanks for your time, I should have spotted that %f% typo!
|
|
April 19, 2012, 08:26 |
|
#259 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
||
May 21, 2012, 16:25 |
|
#260 |
Senior Member
|
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,
__________________
Amir |
|
|
|
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 |