0

I am working with openfoam and I want to create csv datasets for each iteration I save, for each U and p. For instance, my case converges at 320 iterations and I write to a file every 10 iterations. So, I want to save 30 files (10.csv, 20.csv, 30.csv .... 320.csv); for each variable, U and p, with the csv containing all the values of each cell at that iteration. I do not know how to start. I tried some scripts with python's paraview, but they are not giving me what I expect. This is my current code:

import paraview
import paraview.simple as pv


a = pv.GetActiveSource()
a.UpdatePipeline()
rawData = pv.servermanager.Fetch(a)
data_cell = rawData.CELL_DATA_FIELD
data_cell = rawData.GetCellData()
print data_cell
writer = pv.CreateWriter('10.csv')
writer.UpdatePipeline()

Before working out how to do this iteratively for each file, I just first want to get one file in the csv format I want. I am wondering how to approach this.

  • I believe it is easy in Paraview. However, you could also get that from OpenFOAM files without using Paraview. Which type of simulation? 2D or 3D? what type of writeFormat (ASCII or binary)? – s.ouchene Aug 17 '20 at 19:01
  • I'm not sure how to get it in the format I want. How do I get it without using paraview? Its a 2D simulation with writeFormat as ascii – gradstudent61 Aug 18 '20 at 02:20
  • Do you want the velocity vector or velocity magnitude (or both)? – s.ouchene Aug 18 '20 at 08:29
  • You could copy the values in `internalField` for each variable, those are the values of that variable at each cell, (the line number is the index of the cell). – s.ouchene Aug 18 '20 at 08:31
  • The magnitude. Do you mean the values in internalField in the postprocessing files that show up? the file formats of the postprocessing directories are weird and have random text, and I just can't manually copy all the numbers in internalField because I want to do it for multiple iterations. Is there an easy way/script already available to grab those values? – gradstudent61 Aug 18 '20 at 15:45

0 Answers0