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

OpenFOAM files into csv format

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 30, 2014, 09:21
Default OpenFOAM files into csv format
  #1
New Member
 
Join Date: Nov 2011
Posts: 22
Rep Power: 14
kd55 is on a distinguished road
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 is offline   Reply With Quote

Old   June 4, 2014, 11:15
Default
  #2
New Member
 
Join Date: Nov 2011
Posts: 22
Rep Power: 14
kd55 is on a distinguished road
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.
kd55 is offline   Reply With Quote

Old   July 25, 2014, 22:18
Default
  #3
New Member
 
David H.
Join Date: Oct 2013
Posts: 25
Rep Power: 12
djh2 is on a distinguished road
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.
djh2 is offline   Reply With Quote

Old   August 16, 2014, 07:44
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
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
kiski, linyanx and GuillaumeD like this.
__________________
wyldckat is offline   Reply With Quote

Old   May 16, 2023, 03:58
Default
  #5
Member
 
sadra mahmoudi
Join Date: Feb 2021
Location: Austria
Posts: 39
Rep Power: 5
sadra2003 is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
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
sadra2003 is offline   Reply With Quote

Reply


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
[General] Particle Tracking by providing particle position in CSV format t.teschner ParaView 3 June 21, 2014 16:12
Converting CSV to tecplot format xiyuqiu Tecplot 1 November 12, 2010 06:30
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 03:01
64bitrhel5 OF installation instructions mirko OpenFOAM Installation 2 August 12, 2008 18:07
[making animations] fclose fails to close files? Mika FLUENT 0 March 30, 2001 08:19


All times are GMT -4. The time now is 10:12.