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

[Other] [fluidfoam] python package to read and plot OpenFoam data

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

Like Tree7Likes
  • 5 Post By cyss38
  • 1 Post By Edgar Alejandro Martínez
  • 1 Post By cyss38

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 1, 2020, 19:06
Smile [fluidfoam] python package to read and plot OpenFoam data
  #1
Member
 
cyss38's Avatar
 
Cyrille Bonamy
Join Date: Mar 2015
Location: Grenoble, France
Posts: 79
Rep Power: 8
cyss38 is on a distinguished road
Dear all,

The fluidfoam package (https://github.com/fluiddyn/fluidfoam) provides useful Python classes for easily reading and manipulating OpenFoam output files.
You can find some examples here : https://fluidfoam.readthedocs.io/en/...les/index.html

fluidfoam is also used to read 1D simulation outputs and put them in swak4foam format in order to use 1D data for boundary conditions and / or initial fields : https://fluidfoam.readthedocs.io/en/...cessing1d.html. (Today there is no example on this subject in the example gallery... Coming soon)

Best,

Cyrille

PS : fluidfoam is available with pip, conda or via sources from github:
https://github.com/fluiddyn/fluidfoam
cyss38 is offline   Reply With Quote

Old   September 15, 2021, 17:10
Default
  #2
New Member
 
Edgar Alejandro Martínez Ojeda
Join Date: Jul 2019
Posts: 20
Rep Power: 4
Edgar Alejandro Martínez is on a distinguished road
I have an example from a 2D actuator turbine. You can learn how to get the coordinates as well as the desired fields: https://www.youtube.com/watch?v=wFZeFDUQflQ
cyss38 likes this.
Edgar Alejandro Martínez is offline   Reply With Quote

Old   September 15, 2021, 19:25
Default
  #3
Member
 
cyss38's Avatar
 
Cyrille Bonamy
Join Date: Mar 2015
Location: Grenoble, France
Posts: 79
Rep Power: 8
cyss38 is on a distinguished road
Quote:
Originally Posted by Edgar Alejandro Martínez View Post
I have an example from a 2D actuator turbine. You can learn how to get the coordinates as well as the desired fields: https://www.youtube.com/watch?v=wFZeFDUQflQ

Thanks you very much for this tutorial
You say that the structured option of readMesh does not work in your case.
Can you send me your blockMeshDict file to solve this issue?

The best is to open an issue on the official github repository (but the blockMeshDict may be enough )
cyss38 is offline   Reply With Quote

Old   September 15, 2021, 21:52
Default
  #4
New Member
 
Edgar Alejandro Martínez Ojeda
Join Date: Jul 2019
Posts: 20
Rep Power: 4
Edgar Alejandro Martínez is on a distinguished road
I meant I had to set the option to False. I don't know what "structured mesh" means to fluidfoam. Remember that meshes generated by blockMesh are not exactly structured since every node has an ID. So blockMesh is not structured eventhough it is rectangular.

Here's my blockMeshDict, this is another similar mesh though:

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

vertices
(
( -60 -60 -1)
( 100 -60 -1)
( 100 60 -1)
( -60 60 -1)
( -60 -60 1)
( 100 -60 1)
( 100 60 1)
( -60 60 1)
);

blocks
(
hex (0 1 2 3 4 5 6 7) (240 180 1) simpleGrading (1 1 1)
);

boundary
(
inlet
{
type patch;
faces
(
(0 4 7 3)
);
}

outlet
{
type patch;
faces
(
(2 6 5 1)
);
}

top
{
type patch;
faces
(
(3 7 6 2)
);
}

bottom
{
type patch;
faces
(

(1 5 4 0)
);
}

back
{
type empty;
faces
(
(0 3 2 1)
);
}

front
{
type empty;
faces
(
(6 7 4 5)
);
}
);

// ************************************************** *********************** //
Edgar Alejandro Martínez is offline   Reply With Quote

Old   September 16, 2021, 05:05
Default
  #5
Member
 
cyss38's Avatar
 
Cyrille Bonamy
Join Date: Mar 2015
Location: Grenoble, France
Posts: 79
Rep Power: 8
cyss38 is on a distinguished road
Ok, I tested it. Indeed in this case there is a problem of precision. I don't know exactly why but there are accuracy problems in the openfoam files (generated by blockMesh).
It's not a problem but when fluidfoam/python looks for the unique values of the center of the cells for a given direction (x for example), there are cases where it doesn't work well (for 2 different y, you can have a very slightly different x when it should be constant).
To avoid this problem, there is the "precision" option in fluidfoam (the default value is 15).

In your case, :
x, y, z = readmesh(sol, True, precision = 14)

One of the interests of using structured=True is not to have to know nx, ny, nz. fluidfoam calculates them and we can easily find them :

nx, ny, nz = np.shape(x)
cyss38 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
Getting Started with OpenFOAM wyldckat OpenFOAM 24 October 2, 2019 22:35
[General] How to plot two sets of data on same axis czhe ParaView 0 June 16, 2016 16:10
[General] Contour plot: celldata2pointdata dmaz ParaView 1 April 28, 2014 17:05
Convergence Problem - Read convergence data rafacerq FLUENT 0 January 31, 2014 11:47
How to read .txt data used by sampleDict? kiddmax OpenFOAM Post-Processing 3 October 11, 2013 19:14


All times are GMT -4. The time now is 02:31.