[solved] reRead Dict after changed
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:
chears MARTIN |
IOobject::MUST_READ_IF_MODIFIED
|
|
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. |
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? |
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. |
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 |
Quote:
runTimeModifiable no; it should read yes. |
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 |
can you post the code
|
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.
|
All times are GMT -4. The time now is 15:33. |