CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   Dictionary Updating (

mturcios777 April 9, 2011 14:05

Dictionary Updating
Hello all,

Just a quick question. If I have created a dictionary as an IOdictionary, how do I go about changing the entries in a solver and then writing the updated entries to the original file.

I'm currently trying dict.subDict().set(keyword,value), which compiles but doesn't update. It seems like I should use a dict.write() function, but the compiler says the call is ambiguous.

Thanks in advance!

l_r_mcglashan April 10, 2011 06:31

Are you using 1.7 or the git repo? If the call is ambiguous you can use the full namespace of the function you want to call.

mturcios777 April 11, 2011 13:37

Using 1.6 to maintain compatibility with some external packages. So for the full namespace, that would be the Foam::IOobject etc. version of the call?

I figured out an alternative way, and that was to set WRITE_OPTIONS parameter to MUST_WRITE, in which case the dictionary gets updated every time runTime.write() gets called.

As a little background, I am logging the values of a few variables at locations on the boundary of a moving mesh. I want to specify approximate locations in a dictionary, after which I do a search for the faces whose centroid is closest to the points I've specified (at the start of the run). Since I may need to restart the solver at a later time, I need the dictionary to be updated periodically. So, in short, the new IOdictionary is declared:


IOdictionary updatedDict

Then in the runTime loop, I call updatedDict.set(key,value) to update the locations I've been logging, and once runTime.write() is called my dictionary is updated. This may be helpful to those who have been asking how to log locations on a moving boundary.

l_r_mcglashan April 11, 2011 13:59

For your information, this bug was fixed in 1.7.x:

mturcios777 April 11, 2011 14:06

Good to know, we may be migrating in the near future if we can figure the compatibility. Thanks!

nimasam June 29, 2011 15:23

hi i can't update with dict.subDict().set(keyword,value) in openFOAM 1.6 and 1.7 , is there any alternative to update Dictionary?

mturcios777 June 29, 2011 19:54

I did this on OF 1.6 with no problems. You may need to explicitly specify the subDict you are updating, as the subDict member function takes the name of the sub-dictionary as its argument.

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