|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
|
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 |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#3 |
New Member
|
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 |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Senior Member
Join Date: Mar 2009
Posts: 854
Rep Power: 22 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#6 |
New Member
|
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 |
|
![]() |
![]() |
![]() |
![]() |
#7 |
Member
olivier Petit
Join Date: Mar 2009
Location: Göteborg, Sweden
Posts: 67
Rep Power: 17 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#8 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26 ![]() |
IFstream str("filePr");
scalar a,b,c,d; str>> a >> n >> c >> d; |
|
![]() |
![]() |
![]() |
![]() |
#9 |
New Member
Aurelia Cure
Join Date: Mar 2009
Location: Lund, Sweden
Posts: 18
Rep Power: 17 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#10 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#11 |
New Member
Paweł Kuczyński
Join Date: Feb 2011
Location: Warsaw, Poland
Posts: 19
Rep Power: 15 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#12 |
New Member
Paweł Kuczyński
Join Date: Feb 2011
Location: Warsaw, Poland
Posts: 19
Rep Power: 15 ![]() |
Hey mattijs,
after using your code snippet 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
__________________
Best regards P. Kuczynski. |
|
![]() |
![]() |
![]() |
![]() |
#13 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 ![]() |
||
![]() |
![]() |
![]() |
![]() |
#14 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 ![]() |
So, apparently, the problem is, the I am trying to read four values at once, like
Code:
file >> a >> b >> c >> d; My work-around is as follows Code:
file >> a; if( !file.bad() ) { file >> b >> c >> d; // Everything else } I don't like the 'niceness' of this solution, so I am open for suggestions. |
|
![]() |
![]() |
![]() |
|
|
![]() |
||||
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 |