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

reRead Dict after changed

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 1 Post By niklas
  • 1 Post By niklas
  • 3 Post By niklas

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 11, 2012, 04:23
Default [solved] reRead Dict after changed
  #1
Member
 
Martin
Join Date: Nov 2011
Posts: 35
Rep Power: 15
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 05:27.
wernsen is offline   Reply With Quote

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

Old   May 11, 2012, 05:28
Default
  #3
Member
 
Martin
Join Date: Nov 2011
Posts: 35
Rep Power: 15
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, 05:43
Default
  #4
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas 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.
makaveli_lcf likes this.
niklas is offline   Reply With Quote

Old   May 11, 2012, 06:00
Default
  #5
Member
 
Martin
Join Date: Nov 2011
Posts: 35
Rep Power: 15
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, 07:19
Default
  #6
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas 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.
makaveli_lcf, wernsen and wht like 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: 16
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: 29
niklas will become famous soon enoughniklas 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: 16
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: 29
niklas will become famous soon enoughniklas 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: 16
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


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
[ICEM] why is the edge color changed? ringtail ANSYS Meshing & Geometry 4 September 2, 2010 16:14
"OF uses logarithmic wall functions always" - does it changed in 1.6? yuhai OpenFOAM Running, Solving & CFD 2 September 17, 2009 13:16
Can the changed mesh file be used? Kim FLUENT 5 September 8, 2004 10:49
Reread grid missing alexandre FLUENT 0 March 5, 2003 10:40
Reread Grid Files Maurizio Barbato FLUENT 3 October 18, 2000 07:45


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