writing subDict in a dictionary
Hello Everybody,
I am trying to write subDict inside a dictionary. I know how to setup a dictionary but dont know how to add a subDict inside the dictionary. Say for example, i want to write RASProperties file as below. RASModel laminar; turbulence off; KOmegaCoeffs { beta = 0.04; } for declaring dictionary one do as follows. IOdictionary RASProperties(IOobject("RASProperties",runTime.con stant(),mesh,IOobject::NO_READ,IOobject::AUTO_WRIT E)); RASProperties.set("RASModel","laminar"); RASProperties.ser("turbulence","off"); this write the file. RASProperties.Foam::IOobject::write(); I did till here... But i am not getting how to add following section inside this same dictionary. KOmegaCoeffs { beta = 0.04; } Please let me know how to add subDict inside a IOdictionary. Thanks a lot in advance |
Hi Nadeem
I assume you mean that you want to figure out how to access a sub-dictionary? Just apply the subDict method of, e.g. dictionary mySubDict(RASProperties.subDict("subDictName")); Good luck Niels |
Thanks a lot for the reply.
Well, I know how to read, but i wanted to add a directory inside another directory. but now i got it, how to do it. its like following. IOdictionary dict1; IOdictionary dict2; dict1.add("x",x_value); dict1.add("y",y_value); dict2.add("z",value); dict1.add("dict2asSUBDICT",dict2); output will be... x x_value; y y_value; dict2asSUBDICT { z z_value; } I hope it works if someone else needs it... Best Regards, |
Quote:
Code:
IOdictionary RASProperties(IOobject("RASProperties",runTime.con stant(),mesh,IOobject::NO_READ,IOobject::AUTO_WRIT E)); |
All times are GMT -4. The time now is 09:49. |