CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   OpenFOAM files into csv format (https://www.cfd-online.com/Forums/openfoam-post-processing/136535-openfoam-files-into-csv-format.html)

kd55 May 30, 2014 09:21

OpenFOAM files into csv format
 
hi there,

Does anybody have a bit of code to post-porcess the openfoam data files into csv format; needing to do quite a few files, so doing it manually is pretty tedious. Trying to analyse data in matlab.

Kind regards,

Kit

kd55 June 4, 2014 11:15

Ok, I kind of found a work around which will do for certain situations. If you use the sample utility or 'foamCalc components U', it puts the data (providing you can get it with these two utilities) in an easy format to extract - I'm using matlab and can use text scan quite easily with it.

djh2 July 25, 2014 22:18

It's possible to create a data structure in Matlab that uses the output from "writeCellCentres". This OpenFOAM utility will write your cell-centered x y and z points "ccx" "ccy" and "ccz" to 0. These files are lists that correspond to the cells where the field data is stored, such as in the output file "p".

Eg:
CCX:
3
(
(0.00)
(0.01)
(0.02)
)

p:
3
(
(10)
(9.9)
(9.8)
)

This way you can construct your Matlab data structure and say "Give me p at x=0.01" and get out "9.9".

This is just the conceptual implementation, but I have used this method with OpenFOAM, based on my research advisor's Matlab scripts.

wyldckat August 16, 2014 07:44

Greetings to all!

I've finally managed to take a look at this thread.
Regarding the original question, it really depends on the level of detail you want to extract. Because if it's just a matter of sampling the data to CSV file, it's possible to do it with sample. A detailed example is provided in the file "applications/utilities/postProcessing/sampling/sample/sampleDict".

If it's regarding a complete export of the fields to CSV, then I'm not aware of any public application which provides such a feature. It's actually not that complicated to do, specially since there are already several "foamTo*" utilities in OpenFOAM that can be used as a reference. But I guess the problem is that a specification for the types of CSV exports that are needed hasn't been drawn yet, so there hasn't been such a utility created yet.

On the other hand, it's somewhat easier to simply use ParaView to load the case, use the "Python Trace" feature to record the steps used for exporting the desired data to CSV and then use pvpython pr pvbatch to run the Python script.

Best regards,
Bruno

sadra2003 May 16, 2023 03:58

Quote:

Originally Posted by wyldckat (Post 506240)
Greetings to all!

I've finally managed to take a look at this thread.
Regarding the original question, it really depends on the level of detail you want to extract. Because if it's just a matter of sampling the data to CSV file, it's possible to do it with sample. A detailed example is provided in the file "applications/utilities/postProcessing/sampling/sample/sampleDict".

If it's regarding a complete export of the fields to CSV, then I'm not aware of any public application which provides such a feature. It's actually not that complicated to do, specially since there are already several "foamTo*" utilities in OpenFOAM that can be used as a reference. But I guess the problem is that a specification for the types of CSV exports that are needed hasn't been drawn yet, so there hasn't been such a utility created yet.

On the other hand, it's somewhat easier to simply use ParaView to load the case, use the "Python Trace" feature to record the steps used for exporting the desired data to CSV and then use pvpython pr pvbatch to run the Python script.

Best regards,
Bruno


Hi All,

I have a question abot using csv files in openfoam and I would be thankful if you help me.
I am doing some experimental research and I have the velocity vector in a domain in a csv file. I would like ti read this file in the paraview in order to postprocess it. As far as I know, after importing the file, I need to use "table to point" filter. I did it successfully. Now, I would like to plot velocity over a line, but it does not work. I think there are some missing seteps in between in order to be able to post process further. I would be thankful if you share your opinion with me.

Best regards


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