CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Programming & Development

Read sample tool data (foamfile)

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

Like Tree1Likes
  • 1 Post By Arnoldinho

LinkBack Thread Tools Display Modes
Old   March 18, 2012, 11:18
Default Read sample tool data (foamfile)
Senior Member
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 11
Arnoldinho is on a distinguished road
Hi foamers,

I used the sample tool to sample data on a cuttingPlane for several time steps and variables. To use these ones as boundary conditions I'd now like to save the single variable values from every time step in one big file as a vectorListIOList and scalarListIOList.

Problem: Although I chose "foamfile" as surfaceFormat in sampleDict, only vectorFields and scalarFiels are written out. So the headers are missing. I therefore cannot read them as an e.g. IOField<scalar>:
Create mesh for time = 0

timeI: 0 Time = 0
directory: "surfaces/0/cuttingPlane1/scalarField"
--> FOAM Serious Error :
From function IOobject::readHeader(Istream&)
in file db/IOobject/IOobjectReadHeader.C at line 90
Reading "/home/stahlmann/OpenFOAM/stahlmann-1.6-ext/run/scour/cylinder/p_04_cylinder2_vanDriest_delta2.2_step1/surfaces/0/cuttingPlane1/scalarField/k" at line 2
First token could not be read or is not the keyword 'FoamFile'
So how can I read these fields and convert them into scalarFields and vectorFields, to then store them as vectorListIOList and scalarListIOList? By using fstream?

Arnoldinho is offline   Reply With Quote

Old   March 18, 2012, 16:12
Senior Member
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 11
Arnoldinho is on a distinguished road
Ok, I think I already got it. Using an IOobject does not seem to be a good idea for reading the files because of the missing header. These files can simply be read using the IFstream which I have not known before, like
scalarField readScalar;
IFstream dataStream(directory/scalarList[scalarI]);
dataStream >> readScalar;
with directory and scalarList being the variable folder and variable (file name) in this case (declared beforehand). An IOobject could then be constructed out of these fields.

mgg likes this.

Last edited by Arnoldinho; March 18, 2012 at 16:33.
Arnoldinho is offline   Reply With Quote

Old   May 14, 2013, 07:04
Join Date: Nov 2012
Location: Bochum/Germany
Posts: 42
Rep Power: 7
dogan is on a distinguished road
Hi Arne,

i am receiving the same error message, and because of my so limited programming knowledge, i didn't understand what you meant. Could you please tell me how did you menage to solve this problem? Did you use IFstream instead of IOobject? is it is so, how did you set this in the case directory?


dogan is offline   Reply With Quote


Thread Tools
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read the data from the graph Kottam Main CFD Forum 2 June 14, 2008 16:46
heat conducting in a solid domain Rogerio Fernandes Brito Siemens 0 March 18, 2008 18:23
How to read a file with inlet velocity data? dorin CFX 13 July 20, 2007 02:16
Mesh data to be read by Fortan code seckin Main CFD Forum 6 May 13, 2003 17:59
Read the Mesh data from Gambit David Main CFD Forum 7 September 5, 2000 19:56

All times are GMT -4. The time now is 09:26.