1 Introduction

The grid system is the basis of the spatial discretization for geophysical fluid dynamic models. Current ocean models mainly adopt the finite difference method or the finite volume-finite difference method, and the underlying horizontal grids are curvilinear with local orthogonal quadrilaterals. Land areas correspond to inactive part of the grid system and are masked out for the modeling of the ocean. For global ocean models, in order to overcome the singularity caused by the North Pole, people usually adopt dipolar or tripolar grids that displace the North Pole onto lands, as in Murray (1996). These global grids are usually generated based on an analytical formulation, such as confocal curves. For coastal ocean modeling with regional models such as POM (The Princeton Ocean Model. http://www.ccpo.odu.edu/POMWEB/) and ROMS (Shchepetkin and McWilliams 2005), the model grids are tailored to the specific characteristics of the modeled region. One dominant design choice of these grids is that the grid lines follow coastlines, in order to (1) improve the accuracy of key coastal processes such as Kelvin waves (Greenberg et al. 2007; Griffiths 2013), land-ocean interactions (Gan et al. 2009), and the bathymetry effects and (2) reduce inactive grid points for better computational load balance and performance. On the other hand, the misalignment of coastlines to grid lines and the resulting stair-shaped piecewise linear grids are also shown to have profound effect on the simulation of large-scale ocean circulation (Adcroft and Marshall 1998).

The well-established practice for the generation of coastline-following orthogonal grids is based on Schwarz-Christoffel conformal mappings (Driscoll and Trefethen2002; Orthogonal multi-corner grid generator. https://github.com/sakov/gridgen-c; Xu et al. 2015) or the numerical solution of Poisson/Laplace equations over the modeled region (SeaGrid for Matlab. http://woodshole.er.usgs.gov/operations/modeling/seagrid/index.html). In essence, these two types of methods are equivalent to the solution of a two-dimensional lateral boundary condition problem. The grid generation relies on the modeler to manually specify the lateral boundaries (and boundary conditions) of the modeled region. For the usual case of coastlines being the lateral boundaries, the modeler in turn has to choose (the control points of) the coastal boundaries that are used for grid generation, as in (orthogonal multi-corner grid generator. https://github.com/sakov/gridgen-c; SeaGrid for Matlab. http://woodshole.er.usgs.gov/operations/modeling/seagrid/index.html).

In practice, the quality of the generated grids is mainly subjected to two important and competing factors. First, in order to maintain the precision of finite difference operators, the inner angles of the local quadrilaterals of the grid should be close to right angles. Second, the boundary that is used to generate the grid should be a close fit to the coastline, to ensure a good characterization of the actual land-sea distribution. However, in nature, the coastline bears irregularities and fractal characteristics (Mandelbrot 1977). Given any spatial scale (or grid resolution), the discretized coastline based on actual land-sea distribution will always have non-straight or non-smooth features. Non-orthogonal angles will ensue as a result of changes of local coastline directions due to the irregularity of the coastlines. If a smoother version of the coastline is used instead, the orthogonality problem can be alleviated, at the cost of a worse fit of the actual coastline. Furthermore, since the coastal boundary as used for the grid generation has to be chosen manually, for high-resolution model grids, the human work and the potential effort in tuning the resulting grid could be prohibitive. Since it is not practical for the subjective and manual choosing process of the boundary, to simplify this process, modelers usually adopt large-scale coastlines with a limited number of control points, which are usually smooth with respect to the spatial scale of the grid resolution.

In this article, we analyze the trade-off between the two competing factors: the orthogonality and the coastline alignment of the grid. The analysis is carried out based on a new grid generation method that automate the retrieval of the coastal boundary for grid generation according to the resolution requirements. By using two representative oceanic regions as sample regions for grid generation, we show that discrepancies in the trade-off is present between the two regions, mainly due to differences in their fractal characteristics. Based on the analysis, we propose new guidelines that accompany the proposed grid generation methods for the regional ocean modeling. The following part of the article is organized as follows. Section 2 outlines the grid generation methodology based on Schwarz-Christoffel conformal mappings. Section 3 introduces the two representative regions and carries out the fractal analysis. In Section 4, the resulting sample grids are evaluated under a range of resolutions. Furthermore, the idealized simulation of coastal trapped Kelvin wave are carried out in Section 5. The proposed coastline following grids achieve great reduction in the delay of simulated Kelvin waves under typical scenarios. Section 6 summarizes the article and points out future directions.

2 Coastline-following grid generation

In this section, we introduce the grid generation method for the study of the trade-off between the orthogonality and the alignment to coastlines. The method is based on Schwarz-Christoffel conformal mappings, which is briefly introduced in Section 2.1. In order to study the behavior of orthogonal grids on coastlines, we limit the grid generation to the case of logically rectangular regions with (1) only one lateral boundary of actual, irregular coastlines and (2) three oceanic lateral boundary that are strictly zonal/meridional or trivially defined. A schematic design is shown in Fig. 1a, in which the boundary 3 is the land-ocean boundary (i.e., a real coastline), and the other boundaries are straight longitudinal/latitudinal lines. Section 2.2 introduces the automatic retrieval of coastal boundaries and proposes the grid generation method.

Fig. 1
figure 1

A sample region and Schwarz-Christoffel mapping. a Sample region (grid lines shown). b Corresponding rectangular regions

2.1 Schwarz-Christoffel mapping and orthogonal grid generation

Schwarz-Christoffel (SC) mappings are a category of conformal mappings (Driscoll and Trefethen 2002), which can be constructed to map: (1) an enclosed, single-connected region on the complex plane with user bespoken, irregular boundaries, to (2) a canonical form such as the upper half of the complex plane, a rectangle, or a unit disk. The SC mapping f for a polygonal region on the complex plane defined by vertices of ω 1, ω 2, ..., ω n and internal angles at these vertices of α 1, α 2, ..., α n to the upper half plane can be defined by Eq. 1, where the constants A and C can be determined under the condition: for i = 1,2,...,n − 1, ω i = f(z i ), and f() = ω n .

$$ f(z)=A+C{\int}^{z} \prod\limits_{i=1}^{n-1} (\zeta -z_{i})^{(\alpha_{i}/\pi) -1} d\zeta $$
(1)

The numerical algorithm for the construction of f are omitted for brevity, and readers are directed to Driscoll and Trefethen (2002) for details. In this article, we focus on the application of SC mapping in the generation of orthogonal grids. Consider an oceanic region with irregular lateral boundaries such as coastlines (Fig. 1a), we firstly construct an SC mapping between this region and a rectangular region (Fig. 1b). By utilizing the angle-preserving characteristics of the SC mapping, an orthogonal grid can be trivially constructed on the rectangle (grid lines within Fig. 1b), and mapped back with the constructed mapping, to form an orthogonal grid for the user specified region (e.g., grid lines in Fig. 1a). To study the behavior of SC mapping based grid on coastal regions, we only consider the cases in which only one lateral boundary is the coastline.

2.2 Automated boundary extraction and grid generation

We design a new algorithm for extracting the coastal boundary that is used for grid generation based on physical coastlines. Figure 2 summarizes the algorithm, which is based on SC mappings. Given the oceanic region (Region I) for grid generation, we firstly choose a continental area (Region II) that is complementary to Region I and shares the coastline with Region I. Second, we retrieve the high-resolution physical coastline and construct an SC mapping f 1 for Region II. Note that in Region II, the boundary opposite to the coastline boundary is set to be sufficiently far. Third, based on resolution requirements, we retrieve a grid line within Region II, based on the constructed mapping f 1. In specific, an in-land line is chosen in the logically rectangular region of Region II, and the line is is parallel to the coastline under mapping f 1 with an offset from the coastline. This line is strictly in-land, which is a better choice than that of offsetting the coastline in the in-land direction. The value of the offset can be set to the same value of the desired resolution for the grid generation in Region I. We use this line as the coastal boundary to construct the SC mapping (f 2) and the grid for the oceanic region (Region I).

Fig. 2
figure 2

Automatic grid boundary retrieval and grid generation

The major disadvantage of using the actual coastline for the grid generation is the potential loss of coastline details. Under certain resolution, features on the coastline, especially those on the scale of the grid resolution, may protrude to either side of the discretized coastline, resulting in (1) missing land areas in the grid, such as peninsulas and (2) grid points that are physically oceanic being treated as land area. Furthermore, some ocean models require model points on the land to provide proper lateral boundary conditions, which is ensured by using a strictly in-land lateral boundary for grid generation.

The use of a coastal boundary within the land, other than the actual coastline, as the lateral boundary for grid generation can help avoid the aforementioned potential problems. The SC mapping ensures that the boundary line is strictly in-land, and the value of the offset provides additional adaptive control of the final grid. The default value for the offset is the required grid resolution; therefore, the grid generation process is automatic, involving no manual process in choosing the coastal boundary. With finer resolution, the offset is small, and the lateral boundary is closer to the coastline, bearing more small-scale characteristics of the coastline. With coarser resolution, the offset is set to a larger value, pushing the lateral boundary further into land, which provides a more smooth boundary for the grid generation. We evaluate the effect of the spatial resolution and the offset through sample grids in Section 4.

3 Sample regions—a fractal analysis

In order to study the the trade-off between the orthogonality and coastline alignment, we choose two representative coastal regions and carry out grid generation with the proposed method in Section 2. The two regions are (1) southeast Pacific ocean (SEP), and (2) Southeast China Seas (SECS), outlined by enclosed oceanic regions as shown in Fig. 3. The characteristics of the two regions differ, mainly due to the differences in the related geomorphology processes. SEP lies on the boarder of Nazca Plate and South-American Plate, with very narrow continental shelves and dense isobath lines, while SECS lies within the Eurasian Plate with much wider continental shelves. For SECS, we focus on, and limit the discussion to the continental coastline, and ignore the coastline on the Taiwan island, which is also present in SECS regions. In general, within the modeled regions, SECS features much rougher coastlines than SEP: a lot of small-scale peninsulas, islands, and river mouths are present in the coastal part of SECS.

Fig. 3
figure 3

Two sample oceanic regions for grid generation. a Region 1: Southeast Pacific Ocean. b Region 2: Southeast China Seas

We carry out fractal analysis of the two coastlines based on ETOPO1 data (Amante and Eakins 2009), after the method introduced in Mandelbrot (1967). As shown in Fig. 4, the fractal dimension (d f ) of a coastline (shown by the blue line), its fractal dimension on a certain scale can be estimated as follows. For the discretization, we choose a length scale (or spatial resolution, denote r), to measure each segment of the coastline. The total length of the coastline N with respect to r is computed as the sum of the nominal length of all the segments as measured by r. The fractal dimension d f can be defined as d f = −l o g(N)/l o g(r). For a straight line, d f equals 1, and for a real coastline with irregularities, the value of d f is larger than 1. The rougher the coastline, the larger the value d f is.

Fig. 4
figure 4

Fractal dimension d f for an irregular coastline

Table 1 summarizes the estimated fractal dimension of the two regions under various spatial scales, with the corresponding nominal values of r ranging from 1/60 to 2. On the large scale (1 to 2), the coastlines of SEP and SECS are not very rough, as reflected by a small value of d f (between 1.02 and 1.06). However, on smaller scales (down to 1/60), SEP retains similar fractal characteristics with its large-scale characteristics (d f under 1.03), while SECS shows dramatic transition to a much rougher coastline, with d f larger than 1.11. The multi-fractal characteristics of SECS and the higher fractal dimension on finer resolutions potentially pose problems for the generation of coastline-following grid at these resolutions.

Table 1 Fractal dimension d f of SEP and SECS regions

4 Grid generation, results, and analysis

4.1 Settings for grid generation

We first compute the Mercator projection of the SEP and SESC regions and then carry out the grid generation as proposed in Section 2.2. For SEP, the settings of Region I and II are the same as in Fig. 2, in which Region I corresponding to the modeled oceanic region, and Region II the “virtual” continental region (eastern to Region I). For SECS, since the shape of the modeled region can be characterized by a circular sector with the center at the geographical location of about (32 N, 110.5 E), we use a modified scheme as shown in Fig. 5. The major coastline of SECS, Region I, and Region II as in Fig. 2 is annotated correspondingly. Region I and Region II of SECS correspond to a circular sector with radial and circular lines as its boundary and are separated by the physical coastline.

Fig. 5
figure 5

Grid generation settings for SECS region

4.2 Evaluation methods

We evaluate the generated grid by the statistics with respect to the orthogonality and the quality of fit between the grid lines and the actual coastlines. We define 𝜃 O and 𝜃 A for the evaluation of orthogonality and coastline alignment for each oceanic grid point, as demonstrated in Fig. 6. The angle 𝜃 O is defined as the inner angle of the quadrilateral of each point, and the value of 𝜃 O should be close to 90 to ensure orthogonality. The angle 𝜃 A is defined as the difference between the direction of the grid line at each point, and the direction of the corresponding coastline at that point. A small value of 𝜃 A indicates good alignment of the grid line and the coastline.

Fig. 6
figure 6

Definition of 𝜃 O and 𝜃 A . a 𝜃 O . b 𝜃 A

Since the deviation from orthogonality are usually present on the coastal part of the grid, and the alignment is most important for this part of the grid, we compute the statistics of 𝜃 A and 𝜃 O for all the oceanic points that are immediately close to the coastline. The mean and variance of the two angles are analyzed and compared, under the various configurations of resolutions and offset values.

4.3 Results and analysis

For SEP, we generate the model grids under nominal spatial resolution of 0.05 , 0.1 , 0.25 , 0.5 , and 1 . For SECS, due to the smaller size of the region compared to SEP, the adopted spatial resolutions are 0.05 , 0.1 , 0.25 , and 0.5 . The statistics of 𝜃 O and 𝜃 A for SEP and SECS regions are shown in Tables 2 and 3, respectively, with the sample grids of 0.5 and 0.25 resolution shown in Fig. 7.

Fig. 7
figure 7

Grids under 0.5 and 0.25 resolutions. a 0.5 grid for SEP region. b 0.25 grid for SEP region. c 0.5 grid for SECS region. d 0.25 grid for SECS region

Table 2 Statistics of 𝜃 O and 𝜃 A for SEP region
Table 3 Statistics of 𝜃 O and 𝜃 A for SECS region

Through sample grids, we show that the grid lines are formulated to align with the coastlines under various resolutions. The innermost grid points lie strictly on land, which provides the coastal-type boundary condition for the grid. With finer scale, the features on the coast can be better presented, as shown by comparison of Fig. 7c, d. Tables 2 and 3 show that the (mean) values of 𝜃 O are close to right angles (90 ), and those of 𝜃 A close to 0. Under each resolution, with the increase of the offset, the standard deviation of 𝜃 O (denoted \(\sigma _{\theta _{O}}\)) generally decreases, while that of 𝜃 A (denoted \(\sigma _{\theta _{A}}\)) grows. This is a result of that with a larger offset, a more smooth coastline boundary which is further from the coastline and of less details of the coastline is adopted for the grid generation. In Tables 2 and 3, we also highlight the configurations (in italic) in which the values of the offsets match the desired resolutions.

The values of \(\sigma _{\theta _{O}}\) and those of \(\sigma _{\theta _{A}}\) under various combination of resolutions and offset values are further analyzed in Fig. 8, with colors representing different offset values. For SEP region (Fig. 8a), a clear quantitative trade-off is present between \(\sigma _{\theta _{O}}\) and \(\sigma _{\theta _{A}}\). With the value of offset set to the resolution, the values of \(\sigma _{\theta _{O}}\) and \(\sigma _{\theta _{A}}\) remains remarkably unchanged across the resolution range (see also Table 2). However, for SECS region (Fig. 8b), with finer resolutions and the same value for offsets), drastic increase in \(\sigma _{\theta _{A}}\) is witnessed, with respect to minor drop in \(\sigma _{\theta _{O}}\). This imply more difficulty in aligning the grid lines to the actual coastline for SECS region, which is in turn a result of the higher fractal dimension at finer scales for SECS region, as analyzed in Section 3.

Fig. 8
figure 8

The standard deviation of 𝜃 O and 𝜃 A (in degrees). a SEP region. b SECS region

From the perspective of grid generation, for SEP region, since there is no pronounced multi-fractal characteristics in the resolution range of interest, the modeler can adopt the practice of setting the values of the offset to the required spatial resolution. Under a certain resolution, if better orthogonality properties is desired, one can adopt a larger value of offset (than the resolution), but at the cost of certain loss of coastline alignment. Similar trade-off exists if coastline alignment is a priority.

When generating grids for SECS region or regions with similar multi-fractal coastlines, modelers are suggested to adopt a larger value for offsets (as compared to the required resolution). For example, for the resolution of 0.05 , with a value of 0.1 or 0.25 for the offset (larger than 0.05 ), much better orthogonality can be attained (in terms of the reduction in \(\sigma _{\theta _{O}}\)) without much loss in the coastline-fitting property of the grid (i.e., almost invariant \(\sigma _{\theta _{A}}\)).

The new grids are further compared to the traditional latitude-longitude (Lat-Lon) grids. In Lat-Lon grids, the land-sea distribution information is only used to generate land masks for the grid generation. Therefore, although Lat-Lon grids feature perfect orthogonality properties, the grid lines are not aligned to coastlines. This is indicated by Table 4, in which the mean value of 𝜃 A is much larger for Lat-Lon grids than the sample grids for both SEP and SECS regions. For SEP, the values of the standard deviation of 𝜃 A of the sample grids are significantly lower than those of Lat-Lon grids. On the contrary, for SECS, the advantage of the new grids are much less pronounced due to the high fractal dimension of the SECS coastline.

Table 4 Comparison of coastline-following characteristics (𝜃 A )

5 Numerical study with coastal trapped Kelvin waves

Kelvin waves are an important phenomena associated with key processes such as tides and ENSO (Gill 1982). Coastal trapped Kelvin waves play an important role in the large-scale modulation of sea surface height and temperature (Lyman and Johnson 2008; Frischknecht et al. 2015). The accurate simulation of Kelvin waves in ocean models are partially hindered by the treatment of coastlines. As a result of piecewise linear coastline in models, the misalignment of grid cells to the geophysical coastlines causes retarded coastal trapped Kelvin waves (Schwaba and Beletskyb 1998; Greenberg et al. 2007; Griffiths 2013). The simulated phase speed is lower than the physical speed, depending on specific configurations of wavelengths, misalignment in terms of angles, and spatial resolution, etc. By using a second-order finite difference Arakawa C-grid shallow-water model, Griffiths (2013) discovered that the second-order accuracy of Kelvin wave phase speed for a perfect alignment, and the degeneration to first-order accuracy when misalignment is present.

We evaluate the effect of the alignment of grid lines to coastlines in the new grids, by simulating typical baroclinic Kelvin waves that propagate along the coastal areas of the SEP and SECS regions. The horizontal scale of the wavelength is 300 km, with a phase speed of 3 m/s, which are typical for tropical and subtropical equatorial and coastal Kelvin waves, such as those occur in ENSO events. Since the Kelvin waves are non-dispersive, the numerical dispersion of the Kelvin waves in terms of delay with respect to theoretical results during the propagation. Figure 9 shows scheme of Kelvin wave propagation (in subfigure a and c) and the simulated delay (in subfigure b and d) of Kelvin waves for SEP and SECS regions. For both regions, the sample 0.25 grid and the standard latitude-longitude grid are both generated. The simulation is carried for both grids for each region. The wavenumber k is from 1 to 3, representing resolvable Kelvin waves under the wavelength of 300 km for k = 1. Key positions during the propagation are also marked in the propagation schemes, and further emphasized in the subfigures that show the numerical delay.

Fig. 9
figure 9

Numerical delay in coastal trapped Kelvin waves for SEP and SECS region. a Kelvin wave propagation in SEP region. b Delay of Kelvin waves for SEP region. c Kelvin wave propagation in SECS region. d Delay of Kelvin waves for SECS region

Figure 9b, d shows the comparison between the typical latitude-longitude grid and the new coastline following grid and among various wavenumbers in terms of delay in Kelvin waves for SEP (SECS) region. In theory, the propagation of Kelvin waves along the prescribed coastline in these two regions takes around 11 and 4.5 days. Due to that for latitude-longitude grids, the physical coastline is not taken into account for the grid generation, there is arbitrary alignment of grid lines to the coastlines. For the new grids, the alignment is much improved. Under nominal 0.25 resolution, the new grids achieved lower delay and better accuracy of Kelvin waves as compared with the traditional grids. For SEP region, the advantage of the new grid is mainly present for the first two segments (a to b to c), due to that the angle of coastline to grid line is larger for latitude-longitude grid. For the segment between c and d, because the coastline is mainly in the meridional direction, the behavior of the two types of grids is similar. For k = 3, the delay for the traditional grid is more than 2 days (larger than 100%) than that of the new grid, while the difference for small wavenumber (k = 1) is evident but less pronounced. For SECS region, due to the overall smooth coastline on the large spatial scale, as well as a smooth transition of the direction along the coastline, there is smaller difference in the numerical delay of Kelvin waves between the two types of grids, as compared with SEP region. For k = 1 and k = 2, the difference between the two grid is lower than 10%, while for k = 3, the difference in delay is about 20%. For both regions, with higher wavenumbers, the effective resolution of the grid per wavelength is reduced, resulting in longer delay of Kelvin waves. This indicates numerical dispersion which modulates the overall shape of the wave packages in physical simulations. For all the scenarios (both scenarios and various wavenumbers), the new grid with better alignment achieves lower numerical delay and higher accuracy when simulating coastal trapped Kelvin waves.

6 Summary

In this article, we analyze the trade-off involved in generating coastline following orthogonal grids for ocean models. The trade-off arises from the two competing factors in grid generation: the alignment of the grid line with the coastline, and the grid’s orthogonality. To facilitate the analysis, we propose a new grid generation method based on Schwarz-Christoffel conformal mappings and the automatic retrieval of resolution dependent coastal boundaries. By analyses of sample grids for two representative oceanic regions (southeast Pacific ocean and southeast China seas), we show that the difference in the fractal characteristics affect the quantitative trade-off between the grid’s orthogonality and its alignment to coastlines. For the southeast Pacific ocean, since its relatively smooth coastline and the low fractal dimension under a wide range of resolutions, there exists a good trade-off between the orthogonality and coastline alignment. In this case, the values for offsets are recommended to match the values of resolutions. For the southeast China seas, where the coastline is more rugged with multi-fractal characteristics and high fractal dimension at smaller scales, the alignment of grid lines to coastlines are much harder to achieve. The loss of effective trade-off for this kind of coastlines entail a strategy to improve orthogonality at a limited cost of misalignment, by using a larger nominal value for offsets than the desired resolution.

The effect of the trade-offs between orthogonality and coastline following on ocean modeling remains an open question. While maintaining good orthogonality ensures the quality of finite difference operators, improving alignment potentially helps in achieving better simulation of coastal processes. Therefore, the quality of the resulting grid is a subject of the process of study, the numerical formulation of the dynamic core, among other factors. Based on the methods proposed by this article, a set of grids with respect to configurations for resolution and in-land offset, can be generated for any oceanic region of study, which only depends on the physical land-sea distribution information. We further analyze the grids under typical resolutions and study the numerical dispersion of coastal Kelvin waves for the two representative regions. Under 0.25 nominal resolution, the new coastline fitting grids achieves lower delay in simulated Kelvin waves as compared with latitude-longitude grids, especially for those with high wavenumbers. The advantage of the grids can be further analyzed and applied in other oceanic process studies and coastal modeling activities.

The proposed grid generation method based on Schwarz-Christoffel mappings is based on the open-source software package SC-Toolbox (Schwarz-Christoffel Toolbox for MATLAB. http://www.math.udel.edu/driscoll/SC/) and implemented in MATLAB. The formulation to a grid generation software is currently carried out for open-source community usage. The algorithm design for more complex coastal boundaries, such as those with large-scale peninsulas and archipelago, serves as the future work for more general purposed grid generation for ocean models.