[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
9.4.3 POS binary file format (Legacy)
The POS binary file format is the same as the POS ASCII file format described in POS ASCII file format (Legacy), except that:
- file-type equals 1.
- all lists of floating point numbers and characters are written in binary format
- there is an additional integer, of value 1, written before time-step-values. This integer is used for detecting if the computer on which the binary file was written and the computer on which the file is read are of the same type (little or big endian).
Here is a pseudo C code to write a post-processing file in binary format:
int one = 1; fprintf(file, "$PostFormat\n"); fprintf(file, "%g %d %d\n", 1.4, 1, sizeof(double)); fprintf(file, "$EndPostFormat\n"); fprintf(file, "$View\n"); fprintf(file, "%s %d " "%d %d %d %d %d %d %d %d %d " "%d %d %d %d %d %d %d %d %d " "%d %d %d %d %d %d %d %d %d " "%d %d %d %d %d %d %d %d %d " "%d %d %d %d %d %d %d %d %d " "%d %d %d %d\n", view-name, nb-time-steps, nb-scalar-points, nb-vector-points, nb-tensor-points, nb-scalar-lines, nb-vector-lines, nb-tensor-lines, nb-scalar-triangles, nb-vector-triangles, nb-tensor-triangles, nb-scalar-quadrangles, nb-vector-quadrangles, nb-tensor-quadrangles, nb-scalar-tetrahedra, nb-vector-tetrahedra, nb-tensor-tetrahedra, nb-scalar-hexahedra, nb-vector-hexahedra, nb-tensor-hexahedra, nb-scalar-prisms, nb-vector-prisms, nb-tensor-prisms, nb-scalar-pyramids, nb-vector-pyramids, nb-tensor-pyramids, nb-scalar-lines2, nb-vector-lines2, nb-tensor-lines2, nb-scalar-triangles2, nb-vector-triangles2, nb-tensor-triangles2, nb-scalar-quadrangles2, nb-vector-quadrangles2, nb-tensor-quadrangles2, nb-scalar-tetrahedra2, nb-vector-tetrahedra2, nb-tensor-tetrahedra2, nb-scalar-hexahedra2, nb-vector-hexahedra2, nb-tensor-hexahedra2, nb-scalar-prisms2, nb-vector-prisms2, nb-tensor-prisms2, nb-scalar-pyramids2, nb-vector-pyramids2, nb-tensor-pyramids2, nb-text2d, nb-text2d-chars, nb-text3d, nb-text3d-chars); fwrite(&one, sizeof(int), 1, file); fwrite(time-step-values, sizeof(double), nb-time-steps, file); fwrite(all-scalar-point-values, sizeof(double), ..., file); ... fprintf(file, "\n$EndView\n"); |
In this pseudo-code, all-scalar-point-values is the array of double precision numbers containing all the scalar-point-value lists, put one after each other in order to form a long array of doubles. The principle is the same for all other kinds of values.