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

Writing IOdictionary to user-defined folder

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

Like Tree1Likes
  • 1 Post By ttsurvase

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 19, 2012, 03:11
Default Writing IOdictionary to user-defined folder
  #1
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 17
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, 02:14
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
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, 02:31
Default
  #3
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 17
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

Old   June 16, 2021, 04:04
Default
  #4
New Member
 
Tushar Survase
Join Date: Nov 2020
Posts: 7
Rep Power: 5
ttsurvase is on a distinguished road
fileName writeDirectory = "constant/boundaryField";


IOdictionary vectorDict
(
IOobject
(
"a",
runTime.constant(),

writeDirectory,
runTime,
IOobject::NO_READ,
IOobject::AUTO_WRITE
)
);
vectorDict.Foam::regIOobject::write();




This will work.
Kojote likes this.
ttsurvase is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Defined function for scalar gradient caculation with Star ccm+ V4 coolio STAR-CCM+ 4 August 11, 2023 05:38
Creating new user defined material Vidya FLUENT 4 August 26, 2013 09:26
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 22:54.