3. The BOV file format

The BOV (Brick Of Values) format is a binary format used to represent a single variable defined on a regular mesh. The BOV file consists of two files, a file with the binary data, and a small text file describing it.

3.1. The structure of a BOV file

The BOV header file consists of a text file with keyword / value pairs, one per line. The BOV header file may be interspersed with comment lines that begin with a #. The supported keywords are:

3.1.1. BRICK_ORIGIN

This is the origin of your grid.

Here is an example of specifying the origin of your grid.

BRICK_ORIGIN: 0. 0. 0.

3.1.2. BRICK_SIZE

This is the size of your grid.

Here is an example of specifying the size of your grid.

BRICK_SIZE: 10. 10. 10.

The i component varies the fastest, then j, then k. This means that if BRICK_SIZE is 2. 2. 2., the first float in the data file corresponds to [0,0,0], the second to [1,0,0], the third to [0,1,0], the fourth to [1,1,0], the fifth to [0,0,1], and so on.

3.1.3. BYTE_OFFSET

This is a byte offset into the file to start reading the data. It lets you specify some number of bytes to skip at the front of the file. This can be useful for skipping the 4-byte header that Fortran tends to write to files. If your file does not have a header then DO NOT USE BYTE_OFFSET.

Here is an example of specifying the size of your grid.

BYTE_OFFSET: 4

3.1.4. CENTERING

This is the centering of your variable. Valid values are ZONAL and NODAL.

Here is an example of specifying the centering of your variable.

CENTERING: ZONAL

3.1.5. DATA_BRICKLETS

Specifies the size of the chunks when DIVIDE_BRICK is true. The values chosen for DATA_BRICKLETS must be factors of the numbers used for DATA_SIZE.

Here is an example of specifying the data bricklets of your grid.

DATA_BRICKLETS: 5 5 5

3.1.6. DATA_COMPONENTS

Specifies the number of components in your variable. 1 specifies a scalar, 2 specifies a complex number, 3 specifies a vector, and any value beyond 3 specifies an array variable. You can use COMPLEX instead of 2 for complex numbers. When your data consists of multiple components, all components for a cell or node are written sequentially to the file before going to the next cell or node.

Here is an example of specifying the data bricklets of your grid.

DATA_COMPONENTS: 1

3.1.7. DATA_ENDIAN

This is the Endian representation of your data. Valid values are BIG and LITTLE. Data from Intel processors is LITTLE, while most other processors are BIG.

Here is an example of specifying the Endian representation of your variable.

DATA_ENDIAN: LITTLE

3.1.8. DATA_FILE

This is the name of the file with the binary data.

Here is an example of specifying the name of the data file.

DATA_FILE: density.bof

3.1.9. DATA_FORMAT

This is the type of your data. Valid values are BYTE, SHORT, INT, FLOAT and DOUBLE.

Here is an example of specifying the type of your variable.

DATA_FORMAT: FLOAT

3.1.10. DATA_SIZE

These are the dimensions of your variable.

Here is an example of specifying the dimensions of your variable.

DATA_SIZE: 10 10 10

3.1.11. DIVIDE_BRICK

A flag indicating if the array should be divided into chunks that can be processed in parallel. Valid values are TRUE and FALSE. When DIVIDE_BRICK is true, the values stored in DATA_BRICKLETS specifies the size of the chunks.

Here is an example of specifying divide brick.

DIVIDE_BRICK: TRUE

3.1.12. TIME

This is the time associated with the variable.

Here is an example of specifying the time.

TIME: 10.

3.1.13. VARIABLE

This is the name of your variable.

Here is an example of specifying the name of your variable.

VARIABLE: density

3.2. An example of a BOV file

Here is an example header file representing a 10 by 10 by 10 array of density values.

TIME: 10.
DATA_FILE: density.bof
DATA_SIZE: 10 10 10
DATA_FORMAT: FLOAT
VARIABLE: density
DATA_ENDIAN: LITTLE
CENTERING: ZONAL
BRICK_ORIGIN: 0. 0. 0.
BRICK_SIZE: 10. 10. 10.

Here is a sample python script that creates the 10 by 10 by 10 array of density values.

import math
from array import array
nx = 10
ny = 10
nz = 10
vals = array('f')
for iz in range(nz):
    z = float(iz)
    for iy in range(ny):
        y = float(iy)
        for ix in range(nx):
            x = float(ix)
            vals.append(math.sqrt(x*x+y*y+z*z))

f = open("density.bof", "wb")
vals.tofile(f)
f.close()