|
[Sponsors] |
[Other] [fluidfoam] python package to read and plot OpenFoam data |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
Member
Cyrille Bonamy
Join Date: Mar 2015
Location: Grenoble, France
Posts: 85
Rep Power: 9 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#2 |
New Member
Edgar Alejandro Martínez Ojeda
Join Date: Jul 2019
Posts: 20
Rep Power: 5 ![]() |
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
|
|
![]() |
![]() |
![]() |
![]() |
#3 | |
Member
Cyrille Bonamy
Join Date: Mar 2015
Location: Grenoble, France
Posts: 85
Rep Power: 9 ![]() |
Quote:
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 ![]() |
||
![]() |
![]() |
![]() |
![]() |
#4 |
New Member
Edgar Alejandro Martínez Ojeda
Join Date: Jul 2019
Posts: 20
Rep Power: 5 ![]() |
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) ); } ); // ************************************************** *********************** // |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Member
Cyrille Bonamy
Join Date: Mar 2015
Location: Grenoble, France
Posts: 85
Rep Power: 9 ![]() |
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) |
|
![]() |
![]() |
![]() |
![]() |
#6 |
Member
Join Date: Apr 2014
Location: N/A
Posts: 47
Rep Power: 10 ![]() |
Late, but I guess it is newer too late to say thanks. Nice and helpful package!
|
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Getting Started with OpenFOAM | wyldckat | OpenFOAM | 25 | August 14, 2022 14:55 |
[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 |