CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Dictionary Updating

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 9, 2011, 15:05
Default Dictionary Updating
  #1
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
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!
mturcios777 is offline   Reply With Quote

Old   April 10, 2011, 07:31
Default
  #2
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
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.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   April 11, 2011, 14:37
Default
  #3
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
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:

Code:
IOdictionary updatedDict
(
     IOobject
     (
         "updatedDict",
         runTime.constant(),
         mesh,
         IOobject::MUST_READ,
         IOobject::AUTO_WRITE,
         true
     )
);
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.
mturcios777 is offline   Reply With Quote

Old   April 11, 2011, 14:59
Default
  #4
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
For your information, this bug was fixed in 1.7.x:

http://www.openfoam.com/mantisbt/view.php?id=34
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   April 11, 2011, 15:06
Default
  #5
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Good to know, we may be migrating in the near future if we can figure the compatibility. Thanks!
mturcios777 is offline   Reply With Quote

Old   June 29, 2011, 16:23
Default
  #6
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
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?
nimasam is offline   Reply With Quote

Old   June 29, 2011, 20:54
Default
  #7
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
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.
mturcios777 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
writing subDict in a dictionary ubaid OpenFOAM Programming & Development 3 October 25, 2014 18:17
Some questions about mesh updating in dynamic mesh technique lzgwhy Main CFD Forum 0 June 14, 2009 09:01
Reading from User Defined Dictionary File brosemu OpenFOAM Running, Solving & CFD 2 March 30, 2009 16:25
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51
FoamX error aachenBomb case Ervin Adorean (Adorean) OpenFOAM Pre-Processing 13 March 7, 2005 04:50


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