CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Error Reading date file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 17, 2005, 22:42
Default I want to make a transient sim
  #1
New Member
 
Martin/Run DU
Join Date: Mar 2009
Location: Hong Kong
Posts: 25
Rep Power: 17
chnrdu is on a distinguished road
Send a message via Skype™ to chnrdu
I want to make a transient simulation of a pipe. on one end, I make the pressure as a function respect to time and write to a file as:
(
t0 p0
t1 p1
...
tN pN
)
but when I compute it, there is a error:

Reading field p

--> FOAM FATAL IO ERROR : IOstream::check(const char* operation) : error in IOstream "inletPressure.dat" for operation Istream::operator()

file: inletPressure.dat at line 1.

Function: IOstream::check(const char* operation) const
in file: db/IOstreams/IOstreams/IOcheck.C at line: 54.

FOAM exiting

what about the error? How to correct?
Thanks in advance.
__________________
rdu
------------------
Martin/Run Du
chnrdu is offline   Reply With Quote

Old   June 20, 2005, 05:11
Default 1. is the file present? 2.
  #2
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
1. is the file present?

2. what boundary condition are you using? timeVaryingUniformFixedValue?

Does it work if you remove the bracket pair? I think this b.c. reads an unformatted 2 column file to make it easy to use externally generated data.
mattijs is offline   Reply With Quote

Old   June 21, 2005, 00:26
Default Yes, I use the timeVaryingUnif
  #3
New Member
 
Martin/Run DU
Join Date: Mar 2009
Location: Hong Kong
Posts: 25
Rep Power: 17
chnrdu is on a distinguished road
Send a message via Skype™ to chnrdu
Yes, I use the timeVaryingUniformFixedValue.

I removed the bracket pair. there is the same problem. You mean the unformatted 2 column file as binary file?
__________________
rdu
------------------
Martin/Run Du
chnrdu is offline   Reply With Quote

Old   June 21, 2005, 05:22
Default Sorry, never used it. I found
  #4
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
Sorry, never used it. I found the actual reading gets done in sampling/lnInclude/graph.C where it constructs the graph from an Istream.

Looks like the format is
"title"
"x" "y"
0.0 54
0.1 24
0.2 35

or something similar.
mattijs is offline   Reply With Quote

Old   June 21, 2005, 08:24
Default The format of the file read by
  #5
Senior Member
 
Join Date: Mar 2009
Posts: 854
Rep Power: 22
henry is on a distinguished road
The format of the file read by timeVaryingUniformFixedValue is

(
t0 p0
t1 p1
...
tN pN
)

but the error message you get suggests that the file cannot be found, i.e. is not in the location you specify in the boundary condition details.
henry is offline   Reply With Quote

Old   June 21, 2005, 08:37
Default Thank u, H. Weller. I find
  #6
New Member
 
Martin/Run DU
Join Date: Mar 2009
Location: Hong Kong
Posts: 25
Rep Power: 17
chnrdu is on a distinguished road
Send a message via Skype™ to chnrdu
Thank u, H. Weller.

I find the error that u pointed out. I located it in the 0/p fold. i copy it to the caseroot fold. Now It works well.
__________________
rdu
------------------
Martin/Run Du
chnrdu is offline   Reply With Quote

Old   September 27, 2005, 15:05
Default Hi, Foam don't accept this i
  #7
Member
 
olivier Petit
Join Date: Mar 2009
Location: Göteborg, Sweden
Posts: 67
Rep Power: 17
olivier is on a distinguished road
Hi,
Foam don't accept this instruction.
How can I do this in Foam
-------------------
FILE *fp;
int i;
fp=fopen("filePr","r+");
for(i=0;i<=size;i++)
{
fscanf(fp,"%f %f %f %f",&pr[5*i],&pr[5*i+1],
&pr[5*i+2],&pr[5*i+3]);
}


fclose(fp);
-----------------------------
thanks
olivier is offline   Reply With Quote

Old   September 28, 2005, 04:53
Default IFstream str("filePr"); sca
  #8
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
IFstream str("filePr");

scalar a,b,c,d;

str>> a >> n >> c >> d;
mattijs is offline   Reply With Quote

Old   July 5, 2006, 09:14
Default Hello For postprocessing pu
  #9
New Member
 
Aurelia Cure
Join Date: Mar 2009
Location: Lund, Sweden
Posts: 18
Rep Power: 17
aurelia is on a distinguished road
Hello

For postprocessing purpose, I am using ifstream to read a file and calculate something called A, which is then wroten in an other file


fileName fileV="v.dat";
OFstream VFile(fileV);
fileName fileC= "c.dat";
IFstream CFile(fileC);
char a;char b;
double T1;double T2;scalar C1x;scalar C1y;scalar C1z;scalar C2x;scalar C2y;scalar C2z;scalar A;
while(!CFile.eof() )
{ CFile>>T1>>a>>C1x>>C1y>>C1z>>b>>T2>>a>>C2x>>C2y>>C 2z>>b;
A= ...// Here it calculates A
VFile<< T2 << " "<<A<< endl;
}


It works (read, calculate and write) for all the value in the read-file but then I get the following error:

--> FOAM FATAL IO ERROR : Attempt to get back from bad stream

file: c.dat at line 124.

From function void Istream::getBack(token& t)
in file db/IOstreams/IOstreams/Istream.C at line 44.


I think that it doesn't understand that it is the end of the file, even with the .eof()
Should I close the file (... how?) to avoid this error?
Or should the read-file have something special at the end?

Thanks
Aurelia
aurelia is offline   Reply With Quote

Old   March 6, 2008, 10:52
Default I have a file with the followi
  #10
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
I have a file with the following format.

y1 u1 v1 w1
y2 u2 v2 w2
...
yn un vn wn

I know that one can read Field<t> from IStream but how can I read such mixed format to:
scalarField y;
vectorField u;

Is there a way to do it in OpenFOAM or should I write another graph class that accepts such format? thanks.
maka is offline   Reply With Quote

Old   March 3, 2011, 08:11
Default
  #11
New Member
 
Paweł Kuczyński
Join Date: Feb 2011
Location: Warsaw, Poland
Posts: 19
Rep Power: 15
kuczmas is on a distinguished road
Hey Aurelia,
Did you manege to solve you problem? I have got the same error message, when trying to write my data into the file.

Cheers
__________________
Best regards
P. Kuczynski.
kuczmas is offline   Reply With Quote

Old   March 3, 2011, 08:18
Default
  #12
New Member
 
Paweł Kuczyński
Join Date: Feb 2011
Location: Warsaw, Poland
Posts: 19
Rep Power: 15
kuczmas is on a distinguished road
Hey mattijs,

after using your code snippet
Quote:
Originally Posted by mattijs View Post
IFstream str("filePr");

scalar a,b,c,d;

str>> a >> n >> c >> d;
in my program I got the following error message:

Code:
--> FOAM FATAL IO ERROR: 
Attempt to get back from bad stream

file: filePr at line 1.

    From function void Istream::getBack(token&)
    in file db/IOstreams/IOstreams/Istream.C at line 38.

FOAM exiting
Do you know what's wrong and how to fix it?
__________________
Best regards
P. Kuczynski.
kuczmas is offline   Reply With Quote

Old   January 29, 2013, 01:57
Default
  #13
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
Quote:
Originally Posted by aurelia View Post
--> FOAM FATAL IO ERROR : Attempt to get back from bad stream
I am encountering the same error message as above. Anyone who knows what I am doing wrong?
Bernhard is offline   Reply With Quote

Old   January 29, 2013, 02:35
Default
  #14
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
So, apparently, the problem is, the I am trying to read four values at once, like

Code:
file >> a >> b >> c >> d;
There error-message occurs on the second >> as far as I can see.

My work-around is as follows
Code:
file >> a;
if( !file.bad() )
{
    file >> b >> c >> d;
    // Everything else
}
which solves my problem.

I don't like the 'niceness' of this solution, so I am open for suggestions.
Bernhard 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
Error reading trn file OliH CFX 3 March 4, 2010 08:24
Error when reading res file Taewon Seo CFX 1 April 28, 2009 09:09
Error reading msh file ANIL FLUENT 1 January 22, 2009 00:45
error reading file limingtiger Siemens 3 September 21, 2005 20:31
Error while reading mesh file sak FLUENT 3 July 25, 2005 08:28


All times are GMT -4. The time now is 16:22.