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

Change file and directory output structure for OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By rushs777

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 15, 2015, 18:26
Default Change file and directory output structure for OpenFOAM
  #1
New Member
 
Túlio Abreu Cardinal
Join Date: Oct 2015
Location: RS, Brazil
Posts: 3
Rep Power: 11
ThuliumC is on a distinguished road
Hello

I would like to have the output of OpenFOAM files and directories modified and I don't know where to get started.
The solver used for the cases is a settMixingFoam, a modified version of twoLiquidMixingFoam.
The file structure I would like to have is binary volScalarField with no header and no trailer for all fields. And the directory structure I wold like to have is one directory per field, one file per time (not one directory per time, one file per field; as is the default); all inside another directory (e.g. data). For example, the file "$FOAM_RUN/case/14/alpha1" could be "$FOAM_RUN/case/data/alpha1/014".

So I wold like to know:
Is it reasonable to write the directories in this format or is it preferable to change the structure after the case is run?
Is it possible to write and read the velocity field U (volVectorField) as Ux, Uy, Uz (volScalarField)? I believe modifying the files after the case is run would have a significant cost for processing and data storage.
Is it reasonable to write and read binary files without the header and trailer or is it preferable to remove the headers and trailers after the case is run? I believe it would be better to write the files with no headers and trailers, as this could take a significant time to write.
How do I remove the headers and trailers from binary files? I have a case that was already run and I need to do the post processing now.

Thank you


Here is an example of the header I refer to:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.2                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      binary;
    class       volScalarField;
    location    "6";
    object      alpha1;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 0 0 0 0 0 0];

internalField   nonuniform List<scalar>
1182465
("
Here is an example of the trailer I refer to:
Code:
        valueExpression "0";
        gradientExpression "alpha1*Res";
        fractionExpression "0";
        evaluateDuringConstruction 0;
        variables       "Res=-1600;";
        timelines       (
);
        lookuptables    (
);
    }
    frontBack
    {
        type            empty;
    }
}


// ************************************************************************* //
ThuliumC is offline   Reply With Quote

Old   November 26, 2015, 10:07
Default
  #2
Member
 
Jo Mar
Join Date: Jun 2015
Posts: 54
Rep Power: 11
KingKraut is on a distinguished road
Dear ThuliumC,

have you managed to solve your problem or gotten an idea how to tackle the issue?
I have a similar problem concerning the file output. In order to reduce the ouput file number of a simulated case I would like to write just one output file for each field which combines all timesteps of the simulated case.
Since we are both interested in manipulating the output format of an OpenFOAM case I think our approaches could be similar.
I would be glad if you let me know how you approached the problem and for any advice you could give me!
Thank you very much in advance for any help.

Best regards
Johannes
KingKraut is offline   Reply With Quote

Old   December 10, 2015, 17:43
Default
  #3
New Member
 
Túlio Abreu Cardinal
Join Date: Oct 2015
Location: RS, Brazil
Posts: 3
Rep Power: 11
ThuliumC is on a distinguished road
Johannes,

Sadly, I have not yet managed to solve this issue and do not know the best way to tackle it.
Indeed, I believe our approaches could be similar. As soon as I have any advice to you, I will let you know, and please let me know of any advice you may have.
Thanks for replying.

Túlio A. C.
ThuliumC is offline   Reply With Quote

Old   July 1, 2016, 11:19
Default Particular interest in having all time folders stored in a single "data" folder
  #4
New Member
 
Join Date: May 2016
Posts: 3
Rep Power: 10
rushs777 is on a distinguished road
I was wondering if y'all had been able to come up with a method for having OF store all of the individual time directories into a "data" folder?
doppler likes this.
rushs777 is offline   Reply With Quote

Old   July 19, 2016, 04:40
Default
  #5
Member
 
Jo Mar
Join Date: Jun 2015
Posts: 54
Rep Power: 11
KingKraut is on a distinguished road
Dear rushs777, sorry, no news on this...
at least as far as I am concerned...

Last edited by KingKraut; July 19, 2016 at 04:41. Reason: addition
KingKraut is offline   Reply With Quote

Old   August 4, 2021, 15:14
Default
  #6
New Member
 
Join Date: Oct 2020
Posts: 3
Rep Power: 6
m0nzderr is on a distinguished road
As far as I can see from the codebase, the field data storage/retrieval is provided by the object registry. In particular, the Time class implementation
looks responsible for a final layout of time-based files:
(https://www.openfoam.com/documentati...8H_source.html)
```
//- Return path
fileName path() const
{
return rootPath()/caseName();
}

//- Return read access to the controlDict dictionary
const dictionary& controlDict() const
{
return controlDict_;
}

virtual const fileName& dbDir() const
{
return fileName::null;
}

//- Return current time path
fileName timePath() const
{
return path()/timeName();
}

```

Since there is no (evident to me) configurable parameters for changing the this directory structure, the only way to tackle this would be though building your own modification of either the OF or the a solver application that uses a a modified Time class implementation.

- BTW, being able to relay time-data to an arbitrary location somewhere outside the project dir would be a great feature (without recompiling the whole codebase). Maybe it's worth a feature request...
m0nzderr is offline   Reply With Quote

Old   August 25, 2021, 08:32
Default
  #7
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 736
Rep Power: 14
Tobermory will become famous soon enough
The simplest way, surely, is to just write a shell script that is executed after the run and which reformats the directory structure as you wish. eg moves data files to some other folder. I would not try to update OF itself to write out in a different structure ... that seems to be asking for trouble.

For adjusting headers, again you can write shell scripts to reprocess those as well.
Tobermory is offline   Reply With Quote

Old   August 31, 2021, 10:29
Default
  #8
New Member
 
Join Date: Oct 2020
Posts: 3
Rep Power: 6
m0nzderr is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
The simplest way, surely, is to just write a shell script that is executed after the run and which reformats the directory structure as you wish. eg moves data files to some other folder.
- Not applicable for my scenario, I need a different layout while the case is running as well. The main goal here to separate the sources from data (by telling OF where to look for data, instead of telling where to look for sources).

Quote:
Originally Posted by Tobermory View Post
I would not try to update OF itself to write out in a different structure ... that seems to be asking for trouble.
- That depends available skills and the size of the trouble you already into Being able to change things is the one of the greatest advantages of the *Open*FOAM.
m0nzderr is offline   Reply With Quote

Old   September 1, 2021, 00:39
Default
  #9
Senior Member
 
shinji nakagawa
Join Date: Mar 2009
Location: Japan
Posts: 113
Blog Entries: 1
Rep Power: 18
snak is on a distinguished road
How about creating symbolic links to data files and directories. You can arrange the files and directories as you like, aren't you?
snak is offline   Reply With Quote

Old   September 10, 2021, 11:46
Default
  #10
New Member
 
Join Date: Oct 2020
Posts: 3
Rep Power: 6
m0nzderr is on a distinguished road
Quote:
Originally Posted by snak View Post
How about creating symbolic links to data files and directories. You can arrange the files and directories as you like, aren't you?
- Yes, symlinks will do just fine in many scenarios! But not ideal for our production workflow, mostly due to the OS limitations and "fragility" when used across different network storage/filesystems and OSs.
m0nzderr is offline   Reply With Quote

Reply

Tags
binary, directory, file, output, volscalarfield


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
how to calculate mass flow rate on patches and summation of that during the run? immortality OpenFOAM Post-Processing 104 February 16, 2021 09:46
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 04:30
[Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 Seroga OpenFOAM Community Contributions 9 June 12, 2015 18:18
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 07:42
ParaView Compilation jakaranda OpenFOAM Installation 3 October 27, 2008 12:46


All times are GMT -4. The time now is 06:25.