How to build the EGG model with GAWPS by using deckformat:
How to detect cell boundaries in arbitrary grids:
Verification steps:
How to understand accumarray above:
G.faces.neighbors(bndyfac,:) extracts an n x 2 array containing the indices of cells on opposite sides of the faces given by bndyfac. Each row in this array will have two entries, but if bndyfac only contains boundary faces, one of the entries will always be zero. We can then extract the nonzero entry in each row by summing in the second dimension.
The sum(G.faces....) operation has given us an array with indices of cells that lie next to the boundary. This array may contain repeated entries, since boundary cells may have more than one boundary face. The accumarray() counts the number of occurrences for each cell index (from 1 to the maximum returned by sum()). We can then use find(accumarray(..) > 0) to extract the cell indices that appear at least once in the list.