CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

reRead Dict after changed

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By niklas

Reply
 
LinkBack Thread Tools Display Modes
Old   May 11, 2012, 03:23
Default [solved] reRead Dict after changed
  #1
Member
 
Martin
Join Date: Nov 2011
Posts: 30
Rep Power: 5
wernsen is on a distinguished road
Hello coders,

this is my first thread in the coding forum since I've just started to get used to the "OF language". The code I wrote works quite good so far.

I was wondering how I can tell my code to reread my new created dict if its changed during the run. I tried to change somthing but OF does not recocnize it.

Code:
        
IOdictionary postProperties
        (
            IOobject
            (
                    "myDict",        // Name
                    runTime.constant(),     // liegt im "constant" Ordner
                    mesh,                   // registry for the dict
                    IOobject::MUST_READ,    // muss vorhanden sein, sonst fehler 
                    IOobject::NO_WRITE      // nur lesen, nicht schreiben
            )
        );
What do I have to change in order to get the same behaviour e.g. controlDict. If I change this Dict OF notice it during the run and acts on this.

chears
MARTIN

Last edited by wernsen; May 11, 2012 at 04:27.
wernsen is offline   Reply With Quote

Old   May 11, 2012, 03:44
Default
  #2
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 19
niklas will become famous soon enough
IOobject::MUST_READ_IF_MODIFIED
niklas is offline   Reply With Quote

Old   May 11, 2012, 04:28
Default
  #3
Member
 
Martin
Join Date: Nov 2011
Posts: 30
Rep Power: 5
wernsen is on a distinguished road
Thank you!

I think we should change than http://openfoamwiki.net/index.php/In...IOobject_class
wernsen is offline   Reply With Quote

Old   May 11, 2012, 04:43
Default
  #4
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 19
niklas will become famous soon enough
The MUST_READ_IF_MODIFIED was added after the wiki was written.
But that is the advantage of wiki's. You can make your own addition and correct mistakes
if you want to.
niklas is offline   Reply With Quote

Old   May 11, 2012, 05:00
Default
  #5
Member
 
Martin
Join Date: Nov 2011
Posts: 30
Rep Power: 5
wernsen is on a distinguished road
yes thats right.

One question remains. I tried to change the dict and it is noticed by OF, but the variables remained the same. I think I have to add my script some how a function which is triggered by the dict change to refresh my variables with the new chaned dict.

How could I do it or is there maybe a code where I can have a look how this will be done?
wernsen is offline   Reply With Quote

Old   May 11, 2012, 06:19
Default
  #6
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 19
niklas will become famous soon enough
Im going to assume that you have written your program in such a way that it is assumed that
your variable will never change, i.e. your readScalar statement is placed right after the dictionary.

scalar value(readScalar(Dict.lookup("value")));

Once this is read, value is set. It doesnt matter if you changed it in the dictionary.
The only thing that will happen is that your dictionary changed, but you never read it again.

If you instead place the readScalar-statement where you are using it, i.e. in the loop (probably), it will work.

This only makes sense if you have used the MUST_READ_IF_MODIFIED option,
if you used MUST_READ, it made sense to place the readScalar statement right after the dictionary,
cause the dictionary was only read once (even if changed), so reading(lookup) it over and over is pointless.
wernsen likes this.
niklas is offline   Reply With Quote

Old   November 17, 2012, 08:08
Default
  #7
Senior Member
 
Ralph Moolenaar
Join Date: Aug 2010
Location: 's-Hertogenbosch, the Netherlands
Posts: 120
Rep Power: 6
Ralph M is on a distinguished road
Hello guys,

This was just the topic that I was looking for. I tried to reposition the read-statement directly in the loop but with no effect. Are there other options to work around this problem?

Thanks!

Ralph
__________________
CFD for marine applications? Go to http://www.marinecfd.com/ and join the OF Ship Hydromechanics Group: http://www.cfd-online.com/Forums/gro...mechanics.html
Ralph M is offline   Reply With Quote

Old   November 19, 2012, 02:48
Default
  #8
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 19
niklas will become famous soon enough
Quote:
Originally Posted by Ralph M View Post
Hello guys,
This was just the topic that I was looking for. I tried to reposition the read-statement directly in the loop but with no effect. Are there other options to work around this problem?
What does it say in system/controlDict for this

runTimeModifiable no;

it should read yes.
niklas is offline   Reply With Quote

Old   November 19, 2012, 06:07
Default
  #9
Senior Member
 
Ralph Moolenaar
Join Date: Aug 2010
Location: 's-Hertogenbosch, the Netherlands
Posts: 120
Rep Power: 6
Ralph M is on a distinguished road
Dear Niklas,
I already checked that option in the controlDict; it was on yes indeed but didn't yielded the desired result.

I worked around by defining extra input parameters directly in the solver. Works fine for the moment, altough rereading the dictionairy would be more elegant!
Cheers,
Ralph
__________________
CFD for marine applications? Go to http://www.marinecfd.com/ and join the OF Ship Hydromechanics Group: http://www.cfd-online.com/Forums/gro...mechanics.html
Ralph M is offline   Reply With Quote

Old   November 19, 2012, 07:04
Default
  #10
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 19
niklas will become famous soon enough
can you post the code
niklas is offline   Reply With Quote

Old   November 19, 2012, 07:37
Default
  #11
Senior Member
 
Ralph Moolenaar
Join Date: Aug 2010
Location: 's-Hertogenbosch, the Netherlands
Posts: 120
Rep Power: 6
Ralph M is on a distinguished road
Not from this computer but I'm reading two variables from the dictionairy and then use an if-statement in the solver to chose one of the two variables.
__________________
CFD for marine applications? Go to http://www.marinecfd.com/ and join the OF Ship Hydromechanics Group: http://www.cfd-online.com/Forums/gro...mechanics.html
Ralph M is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ICEM] why is the edge color changed? ringtail ANSYS Meshing & Geometry 4 September 2, 2010 15:14
"OF uses logarithmic wall functions always" - does it changed in 1.6? yuhai OpenFOAM Running, Solving & CFD 2 September 17, 2009 12:16
Can the changed mesh file be used? Kim FLUENT 5 September 8, 2004 09:49
Reread grid missing alexandre FLUENT 0 March 5, 2003 10:40
Reread Grid Files Maurizio Barbato FLUENT 3 October 18, 2000 06:45


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