CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   writing controlDict as otherfields (

ubaid September 28, 2010 15:22

writing controlDict as otherfields
Hello Everybody,

I am trying to first read controlDict and then want to do some changes. After doing changes I am interested to write this controlDict back into system folder of my case.

What I am doing are the following steps:

I declared a dictionary first of all as..

IOdictionary m_controlDict(IOobject("controlDict", runTime.system(),mesh,IOobject::MUST_READ,IOobject ::AUTO_WRITE));


I think all the files should be written in their respective folders by using runTime.write(). But still I am not getting new controlDict file. I am sure that the value of endTime has been changed to 500 but I want to write it back to controlDict file.
I have also seen another function called as write(Ostream,bool) as a member function of dictionary, but I am not getting how can I get Ostream of controlDict.

Please guide me, how can I proceed with my case.

Thanks a lot in advance.

l_r_mcglashan September 29, 2010 05:48

runTime.write() will only write the changes at every writeInterval (within controlDict).

You can use controlDict.write(); to write to the file at any point within a simulation.

write(Ostream,bool) is no longer a member function of dictionary because IOdictionary was also inheriting write() from regIOobject. It is now writeData(Ostream,bool). You can try it using writeData(Info); and it will write the file to screen.

ubaid September 29, 2010 06:54

Thanks a lot for the reply.

I tried to use controlDict.write(), but I get always error, probably, I am not selecting accurate arguments.

I did like below:

controlDict.write(IOstream::ASCII,IOstream::versio nNumber(2.0),IOstream::UNCOMPRESSED);

but i get following error..

candidates are void Foam::regIOobject::write(Foam::Ostream&,bool)const .

Can you please guide me, what I have to write inside these arguments. For the time being I am using runTime.writeNow(); but its not good because it writes all the files at that time, I just have to write specific files.

Best Regards,

l_r_mcglashan September 29, 2010 06:57

Have you got the latest version of OF-1.7.x?

Try controlDict.Foam::regIOobject::write(); if you haven't.

ubaid September 29, 2010 07:16


Originally Posted by l_r_mcglashan (Post 277078)
Have you got the latest version of OF-1.7.x?

Try controlDict.Foam::regIOobject::write(); if you haven't.

I think so I am using old version of 1.7.

But it works now, I did as you say... I used "controlDict.Foam::regIOobject::write(); " and now it works really good.

If you dont mind, can you please tell me why it works by controlDict.Foam::regIOobject::write() and not by simple controlDict.write().

Thanks a lot for all this help...:)

l_r_mcglashan September 29, 2010 07:28


All times are GMT -4. The time now is 03:44.