CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   writeFile problem with PyFoam (http://www.cfd-online.com/Forums/openfoam-solving/105512-writefile-problem-pyfoam.html)

ganeshv August 1, 2012 12:14

writeFile problem with PyFoam
 
I'm trying to set boundary conditions on a decomposed case. I'm assuming the ParsedParameterFile should work on decomposed solution files as well. I installed the latest version of PyFoam from the svn repo. I was debugging this case for a long time thinking something was wrong in the way I was setting boundary conditions using PyFoam when I realised that PyFoam couldn't just open and close the file without modifying anything. Could someone tell me what's wrong?

Quote:

Python 2.7.1 (r271:86832, Feb 9 2011, 08:44:16)
[GCC 4.3.4 [gcc-4_3-branch revision 152973]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
>>> f = ParsedParameterFile('processor5/0/nuSgs')
>>> f.writeFile()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/users/5/guv106/OpenFOAM/PyFoam/lib/python2.7/site-packages/PyFoam/RunDictionary/FileBasis.py", line 91, in writeFile
self.fh.write(str(self))
File "/usr/users/5/guv106/OpenFOAM/PyFoam/lib/python2.7/site-packages/PyFoam/RunDictionary/ParsedParameterFile.py", line 124, in __str__
string+=generator.makeString(firstLevel=True)
File "/usr/users/5/guv106/OpenFOAM/PyFoam/lib/python2.7/site-packages/PyFoam/Basics/FoamFileGenerator.py", line 41, in makeString
result+=self.strDict(self.data,firstLevel=firstLev el)
File "/usr/users/5/guv106/OpenFOAM/PyFoam/lib/python2.7/site-packages/PyFoam/Basics/FoamFileGenerator.py", line 102, in strDict
s+=self.strDict(v,indent+2)
File "/usr/users/5/guv106/OpenFOAM/PyFoam/lib/python2.7/site-packages/PyFoam/Basics/FoamFileGenerator.py", line 102, in strDict
s+=self.strDict(v,indent+2)
File "/usr/users/5/guv106/OpenFOAM/PyFoam/lib/python2.7/site-packages/PyFoam/Basics/FoamFileGenerator.py", line 125, in strDict
s+=" "+str(v)+";"+end
File "/usr/users/5/guv106/OpenFOAM/PyFoam/lib/python2.7/site-packages/PyFoam/Basics/DataStructures.py", line 27, in __str__
result+="nonuniform "+self.name+" "
TypeError: cannot concatenate 'str' and 'int' objects

gschaider August 6, 2012 18:27

Quote:

Originally Posted by ganeshv (Post 374875)
I'm trying to set boundary conditions on a decomposed case. I'm assuming the ParsedParameterFile should work on decomposed solution files as well. I installed the latest version of PyFoam from the svn repo. I was debugging this case for a long time thinking something was wrong in the way I was setting boundary conditions using PyFoam when I realised that PyFoam couldn't just open and close the file without modifying anything. Could someone tell me what's wrong?

Not quite sure. Could you give me the file in question and I'll have a look

ganeshv August 17, 2012 16:30

Quote:

Originally Posted by gschaider (Post 375675)
Not quite sure. Could you give me the file in question and I'll have a look


Sorry for the late reply. I figured out what the problem was and a temporary fix around it. My installation of PyFoam could not parse

Quote:

value nonuniform 0();
This seems to be generated in decomposed cases, whenever a boundary is not located on a particular processor. A work around to this is


Quote:

sed 's/nonuniform 0()/uniform 0/' processor2/0/nut
or whatever file you want to work with pyFoam later. You may also have to change it to

Quote:

sed 's/nonuniform 0()/uniform (0 0 0)/' processor2/0/U
for a vectorField.

Bernard, I really want to file a bug report this time. Could you just point me where?

ganesh

gschaider August 20, 2012 17:07

Quote:

Originally Posted by ganeshv (Post 377555)
Sorry for the late reply. I figured out what the problem was and a temporary fix around it. My installation of PyFoam could not parse



This seems to be generated in decomposed cases, whenever a boundary is not located on a particular processor. A work around to this is




or whatever file you want to work with pyFoam later. You may also have to change it to



for a vectorField.

Bernard, I really want to file a bug report this time. Could you just point me where?

ganesh

Seems like the parser can't handle fields of length 0. I'll fix that for the next release

Reporting is described at
http://openfoamwiki.net/index.php/Co...#Bug_reporting
(in your case the info from pyFoamVersion.py is not needed)


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