|
[Sponsors] |
October 17, 2012, 13:58 |
how to export data into binary format?
|
#1 |
Senior Member
Jian Zhong
Join Date: Feb 2012
Location: Birmingham
Posts: 109
Rep Power: 14 |
Dear foamers,
I am new to the openfoam programming. In the solve, I want to add a set of code to write out the binary format data? My current code is : ......... ofstream output_file; //(It should be ASCII format, but I want binary. Foam::string output_file_name; ........ output_file.open (output_file_name.c_str()); forAll(mesh.C(), pointI) { output_file << mesh.C()[pointI].x() << " " << mesh.C()[pointI].y() << " " << mesh.C()[pointI].z() << " " << U.internalField()[pointI].x() << " " << U.internalField()[pointI].y() << " " << U.internalField()[pointI].z() << "\n"; } output_file.close(); Many thanks, I just want to binary format data for post-processing. Best regards, Jian |
|
October 20, 2012, 16:13 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Greetings Jian,
You'll need to open the file with the binary mode option: Code:
output_file.open (output_file_name.c_str(), ios::out | ios::binary); Best regards, Bruno
__________________
|
|
October 21, 2012, 17:42 |
|
#3 |
Senior Member
Jian Zhong
Join Date: Feb 2012
Location: Birmingham
Posts: 109
Rep Power: 14 |
It works. Many thanks.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Automatic Data Export (ascii format) | A Kourm | FLUENT | 4 | March 7, 2021 14:08 |
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem | Attesz | OpenFOAM Meshing & Mesh Conversion | 12 | May 2, 2013 10:52 |
Format data in Fluent | phinix | FLUENT | 1 | February 11, 2013 08:17 |
Generating a binary data file without using tecio | tom10 | Tecplot | 0 | June 18, 2012 19:16 |
export data at nodes | Meenu | FLUENT | 1 | December 30, 2011 01:24 |