Format of ".pb" particle files

A .pb file carries a collection of particles with 32-bit floating-point positions, an arbitrary number of floating-point attributes with names, and an integer particle id.

It's the normal output format for the particle advection program partadv; the positions of all particles being advected, and optionally other quantities such as velocity, temperature, etc. are written to a .pb file for each timestep.

The file comprises a fixed-length header, a variable-length header including the attribute names, and a sequence of particle records. There's no particle count; the sequence ends at the end of the file.

All values are either 32-bit integers or 32-bit IEEE floats. They may be written in either big-endian or little-endian form. Readers should be prepared for either, and use the magic number to determine the endian-ness of the file.

.pb file header

  1. magic number, 0xFFFFFF98 (int32) Use this to determine endian-ness of the rest of the file.
  2. byte offset of first particle (int32)
  3. number of attributes (int32)
  4. sequence of null-terminated attribute name strings, attributename0 \0 attributename1 \0 ...
  5. possibly some pad bytes, enough to reach the specified first-particle file offset (this could also be a place to hide other commentary about the file, like the command string used to create it, or etc.)
  6. sequence of particle records, each (number-of-attributes + 4)*4 bytes long:
    1. particle-id (int32)
    2. particle X, Y, Z (3 float32's)
    3. particle attributes (number-of-attributes float32's)
    ending at the end of the file (i.e. there's no particle-count field).

Related tools: