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

Problem with binary file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 16, 2015, 16:36
Default Problem with binary file
  #1
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all,

I want to open a binary file with FOAM Classes but I fail and I do not know why. The code is working with the following:

Code:
char tag[40];

std::fstream is;
is.open("Filename", std::ios::in | std::ios:binary);
is.read(tag, sizeof(tag));
Info<< tag << "\n";
Output is -> version.
If I replace it with Foam classes like:
Code:
char tag[40]

fileName name_ = "Filename";
IFstream is(name_, IFstream::BINARY);
is.read(tag, sizeof(tag));
Output is:
Code:
--> FOAM FATAL IO ERROR: 
Expected a '(' while reading binaryBlock, found on line 1 the word 'version'
I will use the first version now but do anybody know where is my mistake? Thanke in advance.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   March 5, 2015, 17:36
Default
  #2
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
maybe convert binary into ASCII then do your job? haha.
sharonyue is offline   Reply With Quote

Old   March 5, 2015, 21:31
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Let me know how?!
The binary file is closed and is generated by a closed source ...


Nontheless I solved the problem!
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   March 6, 2015, 02:23
Default
  #4
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
Quote:
Originally Posted by Tobi View Post
Let me know how?!
The binary file is closed and is generated by a closed source ...


Nontheless I solved the problem!
foamFormatConvert can do this job.
oh, maybe this will not work on your case.

Anyway, U already did it. Good luck!
sharonyue is offline   Reply With Quote

Old   March 6, 2015, 06:01
Default
  #5
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi,

i think foamFormatConvert only works with the OpenFOAM Files
__________________
Keep foaming,
Tobias Holzmann
Tobi 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
how to calculate mass flow rate on patches and summation of that during the run? immortality OpenFOAM Post-Processing 104 February 16, 2021 08:46
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch gschaider OpenFOAM Installation 225 August 25, 2015 19:43
Problem compiling a custom Lagrangian library brbbhatti OpenFOAM Programming & Development 2 July 7, 2014 11:32
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 05:18
ParaView Compilation jakaranda OpenFOAM Installation 3 October 27, 2008 11:46


All times are GMT -4. The time now is 03:15.