CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

writing subDict in a dictionary

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By ubaid

Reply
 
LinkBack Thread Tools Display Modes
Old   October 22, 2010, 16:21
Default writing subDict in a dictionary
  #1
New Member
 
Nadeem
Join Date: Mar 2009
Location: München, Bavarian, Deutschland
Posts: 24
Rep Power: 7
ubaid is on a distinguished road
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
ubaid is offline   Reply With Quote

Old   October 22, 2010, 17:16
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Rotterdam, The Netherlands
Posts: 1,510
Rep Power: 23
ngj will become famous soon enoughngj will become famous soon enough
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
ngj is offline   Reply With Quote

Old   October 24, 2010, 21:21
Default
  #3
New Member
 
Nadeem
Join Date: Mar 2009
Location: München, Bavarian, Deutschland
Posts: 24
Rep Power: 7
ubaid is on a distinguished road
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,
cfd.with.openfoam likes this.
ubaid is offline   Reply With Quote

Reply

Tags
dictionary, iodictionary, komegacoeffs, subdict

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 15:25
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 06:51
Fatal error error writing to tmp No space left on device maka OpenFOAM Installation 2 April 3, 2006 08:48
FoamX error aachenBomb case Ervin Adorean (Adorean) OpenFOAM Pre-Processing 13 March 7, 2005 03:50


All times are GMT -4. The time now is 21:14.