|
[Sponsors] |
October 22, 2010, 17:21 |
writing subDict in a dictionary
|
#1 |
New Member
Nadeem
Join Date: Mar 2009
Location: München, Bavarian, Deutschland
Posts: 24
Rep Power: 17 |
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 |
|
October 22, 2010, 18:16 |
|
#2 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
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 |
|
October 24, 2010, 22:21 |
|
#3 |
New Member
Nadeem
Join Date: Mar 2009
Location: München, Bavarian, Deutschland
Posts: 24
Rep Power: 17 |
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, |
|
October 25, 2014, 18:17 |
|
#4 | |
Senior Member
Yuehan
Join Date: Nov 2012
Posts: 142
Rep Power: 14 |
Quote:
Code:
IOdictionary RASProperties(IOobject("RASProperties",runTime.con stant(),mesh,IOobject::NO_READ,IOobject::AUTO_WRIT E)); dictioanry tmpDict; RASProperties.add("RASModel","laminar"); RASProperties.add("turbulence","off"); tmpDict.add("beta", "0.04"); RASProperties.add("KOmegaCoeffs", tmpDict); |
||
Tags |
dictionary, iodictionary, komegacoeffs, subdict |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
solid to fluid heattransfer with chtMultiRegionFoam | nakor | OpenFOAM | 11 | March 21, 2011 09:28 |
Reading from User Defined Dictionary File | brosemu | OpenFOAM Running, Solving & CFD | 2 | March 30, 2009 16:25 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 07:51 |
Fatal error error writing to tmp No space left on device | maka | OpenFOAM Installation | 2 | April 3, 2006 09:48 |
FoamX error aachenBomb case | Ervin Adorean (Adorean) | OpenFOAM Pre-Processing | 13 | March 7, 2005 04:50 |