|
Neko 1.99.2
A portable framework for high-order spectral element flow simulations
|
This appendix documents the Nek5000 file format as written and read by Neko in src/io/fld_file.f90. We refer to this format as .fld for brevity. Neko writes .fld files using MPI-IO, and the layout on disk follows the code paths in that module.
Neko writes a file series in Nek5000 style:
<base>0.f##### (zero-padded index)<base><start_counter>.nek5000The .nek5000 file contains the file template and time range for the series and is used by Neko when reading a series.
Each .fld data file is binary and consists of:
6.54321)glb_nelv integers)The presence and ordering of the field blocks is described by rdcode in the header.
The header is a 132-character record written with the format:
In code, this is:
Fields:
fld_data_size: byte size of field data (MPI_REAL_SIZE or MPI_DOUBLE_PRECISION_SIZE). In practice, this is either 4 or 8.lx, ly, lz: polynomial orders (GLL grid size per element direction)glb_nelv: global number of elements (written twice)time: simulation timestep: output counteri6 values are currently written as 1rdcode: 10-character field descriptorrdcode is a compact descriptor of which fields are present and in which order:
X: mesh coordinatesU: velocity (vector)P: pressure (scalar)T: temperature (scalar)Snn: scalars, with a two-digit count (S00 .. S99)The writer appends S followed by two digits for the scalar count. The reader parses these digits to determine the number of scalar fields.
Immediately after the header, the writer stores a single-precision real with value 6.54321. The reader validates this value to guard against format or endianness mismatches.
After the test pattern, the file contains glb_nelv integers storing the global element ids. Each MPI rank reads/writes its own slice based on offset_el.
Field data is written in the order indicated by rdcode. Within each block, Neko writes data in element-major order:
e = 1..nelvj = 1..lxyzFor vector fields, the layout per element is:
x values (j = 1..lxyz)y values (j = 1..lxyz)z values (j = 1..lxyz) if gdim == 3The block size is gdim * lxyz * glb_nelv values. Note that if U is written, all three components have to be present. One cannot, for example, write only one component of velocity.
If X is not written, then the files does not contain the mesh!
Scalar fields are stored as lxyz * glb_nelv values in element-major order. Scalars are written in sequence S1, S2, ....
Field blocks are written in either single or double precision, depending on the fld_data_size header value. Neko writes single precision by default unless configured otherwise.
For 3D output (gdim == 3), Neko appends per-element min/max metadata for all written fields. These metadata blocks are always single precision and follow the same field ordering as the data blocks.
2 * gdim * glb_nelv valuesxmin, xmax, ymin, ymax, zmin, zmax per element2 * glb_nelv valuesmin, max per elementFor 2D output, these metadata blocks are not written.
When writing 2D fields, Neko sets gdim = 2 (lz = 1). If a Z-velocity component exists, it is stored as an additional scalar field in the output. This is a semantic convention rather than a special file layout.
The .fld format is not self-describing beyond the header. It depends on:
MPI_INTEGER sizeMPI_REAL and MPI_DOUBLE_PRECISION sizesFor robust I/O, use Neko's fld_file reader/writer or convert using tools that understand the Nek5000 format.