|
[Sponsors] |
May 11, 2012, 04:23 |
[solved] reRead Dict after changed
|
#1 |
Member
Martin
Join Date: Nov 2011
Posts: 35
Rep Power: 15 |
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 ) ); chears MARTIN Last edited by wernsen; May 11, 2012 at 05:27. |
|
May 11, 2012, 04:44 |
|
#2 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
IOobject::MUST_READ_IF_MODIFIED
|
|
May 11, 2012, 05:28 |
|
#3 |
Member
Martin
Join Date: Nov 2011
Posts: 35
Rep Power: 15 |
||
May 11, 2012, 05:43 |
|
#4 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
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. |
|
May 11, 2012, 06:00 |
|
#5 |
Member
Martin
Join Date: Nov 2011
Posts: 35
Rep Power: 15 |
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? |
|
May 11, 2012, 07:19 |
|
#6 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
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. |
|
November 17, 2012, 08:08 |
|
#7 |
Senior Member
Ralph Moolenaar
Join Date: Aug 2010
Location: 's-Hertogenbosch, the Netherlands
Posts: 120
Rep Power: 16 |
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 |
|
November 19, 2012, 02:48 |
|
#8 | |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
Quote:
runTimeModifiable no; it should read yes. |
||
November 19, 2012, 06:07 |
|
#9 |
Senior Member
Ralph Moolenaar
Join Date: Aug 2010
Location: 's-Hertogenbosch, the Netherlands
Posts: 120
Rep Power: 16 |
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 |
|
November 19, 2012, 07:04 |
|
#10 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
can you post the code
|
|
November 19, 2012, 07:37 |
|
#11 |
Senior Member
Ralph Moolenaar
Join Date: Aug 2010
Location: 's-Hertogenbosch, the Netherlands
Posts: 120
Rep Power: 16 |
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 |
|
|
|
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 |