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
- magic number, 0xFFFFFF98 (int32) Use this to determine endian-ness of the rest of the file.
- byte offset of first particle (int32)
- number of attributes (int32)
- sequence of null-terminated attribute name strings,
attributename0 \0 attributename1 \0 ...
- 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.)
- sequence of particle records, each (number-of-attributes + 4)*4 bytes long:
- particle-id (int32)
- particle X, Y, Z (3 float32's)
- particle attributes (number-of-attributes float32's)
ending at the end of the file (i.e. there's no particle-count field).
Related tools:
- "pb2parti" will dump individual particles in ASCII tabular form,
with additional stuff to make it directly readable by partiview;
- "pb2stats" computes summary statistics across one or a sequence of .pb files -- reports max, min, mean for each value.
- "pb2traj" converts a series of .pb files to one big
trajectory (.traj) file.