### 3D Large Scale Grain Boundary Motion Code

 This is Matlab code, with some C subroutines (mex files), that implements grain boundary motion of networks with arbitrary surface tensions and fixed mobilities, in three space dimensions. Note carefully that the mobility of each interface = 1 / its surface tension, i.e.  ${\mu }_{i,j}=\frac{1}{{\sigma }_{i,j}}$. The algorithm is based on the following paper: Esedoglu, S.; Otto, F. Threshold dynamics for networks with arbitrary surface tensions. Communications on Pure and Applied Mathematics. 68:5 (2015), pp. 808-864. The research that led to this software was supported by the National Science Foundation grant DMS-074333.
 Version 1 November 15, 2015.
 Instructions: After downloading the linked zipped directory, unzip it. For each C source file contained in the directory, issue the command     mex filename.c from within Matlab, where filename.c is the name of the C source file. This will compile the C files, so that they can be called by matlab .m files. The main subroutine is called gbm3d.m. It contains extensive explanations and examples, which can be displayed by issuing the command     help gbm3d in Matlab. Here is an example of how to call the program in Matlab:     dims = [128 128 128];   grains = voronoidata(1000,dims);   ori = 2*pi*rand(1000,1);   [grains,ori] = gbm3d(10,0.0005,grains,dims,ori);   showgrain(grains,dims,50); This will generate randomly (via Voronoi construction) 1000 initial grains in three dimensions on a 128x128x128 grid. The grains will have random orientations, but all surface tensions are set to 1. This can be easily changed (e.g. to Read-Shockley surface tensions) in the subroutine updatelevelsetdata.c. Currently, the orientations are specified by a single parameter (rotation angle about a fixed axis), so the material has fiber texture (this is easy to extend to 3D crystallography, where orientations are specified by a rotation matrix; an extension of Read-Shockley to 3D can then be used). 10 time steps are taken above, with time step size 0.0005. The command showgrain can then be used to look at a specific grain (50th one, in the example above). Note that the ordering (and number, of course, since some grains may disappear) of grains changes from one iteration to the next, so what's 50th grain now may be labeled as e.g. 35th grain later! (Their orientations are copied along with the grain to a new label, however; this is why orientations are also part of the output).