|
[Sponsors] |
[PyFoam] WriteParameterFile: Orders of entries |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 21, 2012, 13:31 |
WriteParameterFile: Orders of entries
|
#1 |
Member
Florian
Join Date: Nov 2009
Posts: 59
Rep Power: 16 |
Hello,
I use pyFoam's WriteParameterFile to write to the files in 0 directory (U, p, ...) Code:
field_file = WriteParameterFile(field_name), className=_OF_units[field_name][1]) field_file["internalField"] = internalField field_file["dimensions"] = dimensions boundaryField = {} # Fill boundaryField in a loop field_file["boundaryField"] = boundaryField field_file.writeFile() Is there a way to change the order? It have to, cause the pyFoamCaseBuilder uses the "correct" order. (though python dictionaries do not have any order...) Thanks! Ok, kind of an addendum. I found that piece of code: Code:
if type(dic)==DictProxy: order=dic._order else: order=dic.keys() order.sort() |
|
September 24, 2012, 19:31 |
|
#2 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
self.content={} should be replaced with self.content=DictProxy() DictProxy is a wrapper around a regular dictionary whose purpose it is to preserve the order of the entries (and preserve comments) and for purposes of output it will order the entries in the order they were added Let me know if the fix works for you and I'll add it to the next release
__________________
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 |
||
September 26, 2012, 16:01 |
|
#3 |
Member
Florian
Join Date: Nov 2009
Posts: 59
Rep Power: 16 |
I have worked around it in another way.
After writing the internalField and dimensions I close the file and reopen it (as ParsedParameterFile). This keeps the entries so far in order that the ones that already existed are kept on top. |
|
September 26, 2012, 16:30 |
|
#4 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
OK. But I've already implemented the fix (it was as easy as described above) and it will be in the next release
__________________
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 |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] Not all entries in refinementSurfaces dictionary were used | will_ca | OpenFOAM Meshing & Mesh Conversion | 5 | November 4, 2021 22:04 |
ill defined primitiveEntry starting at keyword 'value' on line 197 ChangeDictionary | Struggle_Achieve | OpenFOAM Pre-Processing | 2 | December 20, 2017 04:58 |
[Gmsh] different orders of mesh refinement using gmsh | tjliang | OpenFOAM Meshing & Mesh Conversion | 0 | August 14, 2016 13:38 |
How to divide all entries in 0/p by rho | lentschi | OpenFOAM | 1 | March 16, 2011 14:42 |
Accessing Individual entries in a post register | sdwijeya | STAR-CD | 0 | April 29, 2010 15:18 |