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

Writing IOdictionary to user-defined folder

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

Reply
 
LinkBack Thread Tools Display Modes
Old   March 19, 2012, 04:11
Default Writing IOdictionary to user-defined folder
  #1
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 8
Arnoldinho is on a distinguished road
Hi foamers,

I would like to create a specific (new) IOdictionary to store some values and save it in a used-defined folder. Generating the IOdictionary itself works, saving it to the folder does not fully work. I so far did
Quote:
fileName writeDirectory = "constant/boundaryField";
mkDir(writeDirectory);

IOdictionary vectorDict
(
IOobject
(
"a",
writeDirectory,
runTime,
IOobject::NO_READ,
IOobject::AUTO_WRITE
)
);
vectorDict.Foam::regIOobject::write();
This does not write anything to folder "constant/boundaryField" (which itself is created). When I replace "writeDirectory" in IOobject with runTime.constant(), the dict is written in the constant folder. Taking runTime.constant()/"boundaryField" again does not work.
So I guess I have to register this boundaryField folder somehow?
Btw: This is done in a post-processing tool, so not during runtime of a solver.

Arne
Arnoldinho is offline   Reply With Quote

Old   March 20, 2012, 03:14
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
Quote:
Originally Posted by Arnoldinho View Post
Hi foamers,

I would like to create a specific (new) IOdictionary to store some values and save it in a used-defined folder. Generating the IOdictionary itself works, saving it to the folder does not fully work. I so far did
This does not write anything to folder "constant/boundaryField" (which itself is created). When I replace "writeDirectory" in IOobject with runTime.constant(), the dict is written in the constant folder. Taking runTime.constant()/"boundaryField" again does not work.
So I guess I have to register this boundaryField folder somehow?
Btw: This is done in a post-processing tool, so not during runtime of a solver.

Arne
From your description, it sounds like you want to have "constant" as the _instance_ and "boundaryField" as the _local_. From your example, it sounds like you've tried to pack everything into _instance_. Take a look at the IOobject.H for more information about the different types of constructors.

If you *really* know what you are doing, and want to bypass the usual mechanisms, you can also experiment with the following constructor form ... but you are really on your own here (there is a large potential of creating something stupid if you are not careful):

Code:
        //- Construct from path, registry, io options
        //  Uses fileNameComponents() to split path into components.
        IOobject
        (
            const fileName& path,
            const objectRegistry& registry,
            readOption r=NO_READ,
            writeOption w=NO_WRITE,
            bool registerObject=true
        );
olesen is offline   Reply With Quote

Old   March 20, 2012, 03:31
Default
  #3
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 8
Arnoldinho is on a distinguished road
Thanks Mark,

maybe its not that complicated/bad as it sounds. The only reason of using an IOdictionary is that I did not know a better structure for storing several List<vectorField> object entries within one file (including header).

It does not really matter where this dictionary is saved, but I just want to keep the structure clear. Therefore a subfolder with several dictionaries in it. This came to my mind because the folder structure created by the sample tool (folder "surfaces" with subfolders) is similar and I want to create something like that.

Arne
Arnoldinho is offline   Reply With Quote

Reply

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
Creating new user defined material Vidya FLUENT 4 August 26, 2013 09:26
User Defined function for scalar gradient caculation with Star ccm+ V4 coolio CD-adapco 3 December 21, 2011 18:13
user defined sourcen term xck1986 CFX 1 July 8, 2010 08:35
user defined turbulence model manuutin STAR-CD 5 October 14, 2009 05:29
Usage of user defined functions Gowrish FLUENT 1 October 26, 2005 07:44


All times are GMT -4. The time now is 23:47.