# Binary File Formats

In the course of a single finite element simulation the solver converges at many time steps; here, I was only interested in the last time step, in which the muscle was generating the amount of stress I specified. So, the files I included above include information about one time increment, the last time increment of the model (this happens always to be 0.1 s). The files have the FEBio binary file format for a single time step (which is modeled on LS-DYNA's file format).

### Missed opportunity

I opted to keep only the last step from each simulation because of the hard disk space requirement for storing so many solution steps that I wasn't interested in. After I had deleted the larger files, it occured to me that I could have used the intermediate steps after all to validate my statistical models. That's because, the way I did it, the intermediate time steps had deformations associated with muscle activations between 0 MPa and 0.35 MPa. So, I lost of lot of information.

I'm going to give a description of that file here that is specific to the mesh that I used. (Anyone who knows enough to find that irritating shouldn't have any trouble figuring it out himself!)

Reminder: the mesh I used had 46,490 nodes and 245,223 elements.

Uncompressed, all of the files are 7,424,128 bytes long. These are 1,856,032 4-byte floating point values.

In Matlab, you could read a file with this code.

fid = fopen('Batch19_1_ls.bin','rb'); data = fread(fid,1856032,'float32'); fclose(fid);

The first floating point value is the time of the time step. If this is not 0.1, one of us did something wrong.

The next 139,470 values are the x-, y-, and z-coordinates for the 46,490 nodes. The pattern is x-y-z, x-y-z, x-y-z, etc. In Matlab, code to extract the x-, y-, and z-coordinates of the nodes (after the above snippet has been run) is:

x = data(2:3:139471); y = data(3:3:139471); z = data(4:3:139471);

As it happens, the first 11,331 nodes of the mesh are the exterior nodes, so you could generate a point cloud of the mesh with this command:

scatter3(x(1:11331),y(1:11331),z(1:11331),'b.');

The next 1,716,562 values are element stress values, seven values per element (7 x 245,223 = 1,716,562). The values are: Sigma-x, Sigma-y, Sigma-z, Sigma-xy, Sigma-yz, Sigma-zx, and a dummy value (always zero). You can extract the six non-dummy values with this Matlab code.

sx = data(139472:7:1856032); sy = data(139473:7:1856032); sz = data(139474:7:1856032); sxy = data(139475:7:1856032); syz = data(139476:7:1856032); szx = data(139477:7:1856032);

(The dummy value isn't really a dummy value; it's a plasticity value. But there's no plasticity in this model.)

## Converting to the file format of Tongue Viewer

One of the things you probably want to do with the files is view them in TongueViewer, which will give you a nice 3D model. To do that, you'll want to use the ls2bin.c program to convert your files. After compiling it, the usage is as follows. If you want to convert a file name “Batch19_1_ls.bin” you would type:

> ls2bin Batch19_1

The program would then create “Batch19_1.bin,” which is the appropriate file format for Tongue Viewer, when opening a “Static” tongue posture.