This chapter discusses the use of programs in the TRIGRID package to produce a grid suitable for use in model computations, using the demonstration data supplied with TRIGRID to illustrate the various steps required. An irregular triangulated depth grid covering the domain to be modelled (see previous chapter) must be available before development of a model grid can begin.

It is assumed that the triangular elements of the model grid are to have the following properties:

- Element areas should be approximately proportional to local mean water depth. This means that the Courant number and hence the computational efficiency of model calculations is roughly uniform throughout the grid. In physical terms, it means that roughly the same number of sample points per wavelength is used everywhere.
- The shape of every element should be as close to equilateral as possible, to minimise interpolation error when functions are evaluated within triangles.

To form appropriately sized grid elements, the TRIGRID package employs a novel method of creating variably-spaced points to form the basis for triangulation. The basic idea used is to partition the model domain into non-overlapping cells, proportional in area to the local water depth, and use the centres of area of these cells, together with selected points on the boundaries, as the nodes for the proposed model grid.

The first stage in this procedure is to create a fine resolution regular grid with square elements, covering the whole model domain, and then to calculate the water depth in every mesh of this grid by linear interpolation from the depth grid.The regular grid created for the demonstration case is shown in Figure 3.1. The resolution interval of this regular grid should be no greater than the linear size of the smallest triangles proposed for the model grid, and optimally about half this size. This dimension depends on the closeness of fit required to the model boundaries, on the number of grid points desired per wavelength (preferably more than 10) and on computer memory limits to the number of grid point variables that can be stored.

[IMAGE ]

**Figure:** The fine regular mesh that is laid over the model domain
and used by program NODER in preparation for model
grid generation.

The next step is to partition the interior of the model domain into cells whose area is proportional to water depth. Starting at the point of greatest water depth, a cluster of adjacent squares from the regular grid is built up by adding squares in a "square spiral" pattern around the original seed square, until the ratio of the cluster area to average water depth over the cluster reaches a specified value. A new seed point is chosen at the next deepest free square and another cluster is built up in the square spiral pattern, but excluding squares already belonging to existing clusters, until the required area to depth ratio is reached. Further clusters are formed in the same way until insufficient squares remain to form clusters with area/depth ratios close to the specified value. An example of a model domain partitioned into clusters of squares is shown in Fig. 3.2. Orphan squares, that is, those not belonging to any cluster, do not normally cause any problems, but it is known from experiments that poorly shaped triangles are obtained eventually if very irregularly shaped clusters are permitted. Such clusters are avoided by abandoning formation of a cluster if its second moment of area becomes 50% larger than the second moment of area of a square spiral cluster containing the same number of squares. This eliminates straggling clusters, at the cost of leaving more orphan squares.

[IMAGE ]

**Figure:** The grouping of the squares fron the regular mesh that
form clusters in program NODER.

When all suitable clusters have been formed, the centroids (centres of area) of the clusters, together with the boundary points used earlier in the depth grid are taken to serve as nodes for a preliminary model grid. The example in Fig. 3.3 shows clearly how the resulting density of node distribution varies with water depth in the demonstration case. Nodes lie progressively further apart as one moves from shallow to deep water.

[IMAGE ]

**Figure:** The centroids of the clusters in Figure 3.2 that are
used for nodes in the model grid.

Triangulation of these nodes is then carried out using the same program, GRIDIT, as was used earlier for triangulating the irregular depth grid. The property of approximately uniform area to depth ratio carries over from the clusters of square cells to the triangles based on their centroids.

The principal programs used for preparing the model grid are :

**NODER**- extracts boundary nodes from the depth grid for
further use in the model grid; creates a fine
rectangular grid over the model domain and
evaluates depths; groups the squares of the fine
regular grid into clusters whose area is dependent
on local water depth; calculates the centres of
area of the clusters; and outputs these together
with the boundary nodes as a set of nodes for the
model grid.
**GRIDIT**- triangulates the set of boundary and interior nodes
produced with the NODER to create a model grid,
using the Renka triangulation algorithm; and outputs a
grid file in NEIGH format and a triangle list in
TRIANG format.
**EDITOR**- permits interactive monitoring and editing of the
model grid; provides an option (CHECKNODES) for
checking the integrity of grid boundaries and
editing functions for correcting any errors detec
ted; and outputs an edited grid in NEIGH format.
**SPLITTER**- permits interactive positioning of open boundaries
and simultaneously removing unwanted portions of
the model grid.
**REDEP**- re-evaluates water depths at all nodes of the
edited model grid by interpolation from depth grid.