CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Read sample tool data (foamfile) (http://www.cfd-online.com/Forums/openfoam-programming-development/98755-read-sample-tool-data-foamfile.html)

Arnoldinho March 18, 2012 11:18

Read sample tool data (foamfile)
 
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>:
Quote:

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?

Thanks,
Arne

Arnoldinho March 18, 2012 16:12

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
Quote:

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.

Arne

dogan May 14, 2013 07:04

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?

thanks

Dogan


All times are GMT -4. The time now is 20:27.