Internal wave generation in a non-hydrostatic wave model

: In this work, internal wave generation techniques are developed in an open source non-hydrostatic wave model (Simulating WAves till SHore, SWASH) for accurate generation of regular and irregular long-crested waves. Two different internal wave generation techniques are examined: a source term addition method where additional surface elevation is added to the calculated surface elevation in a specific location in the domain and a spatially distributed source function where a spatially distributed mass is added in the continuity equation. These internal wave generation techniques in combination with numerical wave absorbing sponge layers are proposed as an alternative to the weakly reflective wave generation boundary to avoid re-reflections in case of dispersive and directional waves. The implemented techniques are validated against analytical solutions and experimental data including water surface elevations, orbital velocities, frequency spectra and wave heights. The numerical results show a very good agreement with the analytical solution and the experimental data indicating that SWASH with the addition of the proposed internal wave generation technique can be used to study coastal areas and wave energy converter (WEC) farms even under highly dispersive and directional waves without any spurious reflection from the wave generator.


Introduction
Numerical wave propagation models are commonly used as engineering tools for the study of wave transformation in coastal areas. The number of numerical models based on the Navier-Stokes equation has recently increased remarkably, since they offer detailed and accurate predictions of the wave field but at a very high computational cost. As a result, numerical models solving approximated equations usually averaged over the vertical-like Boussinesq and nonlinear shallow water equations-are an essential tool, especially when large domains and sea states of several hours are considered.
Boussinesq-type models [1][2][3] account for both nonlinearity and frequency-dispersion of the waves by using high-order derivative terms in the equations. As an alternative, models based on the non-hydrostatic approach [4][5][6] can resolve the vertical flow structure and can improve their frequency dispersion by using additional layers rather than increasing the order of derivatives as in the case of Boussinesq-type models. A representative model of this latter category is SWASH [7], a phase-resolving wave propagation model based on the nonlinear shallow water equations with added non-hydrostatic effects. In the field of wave transformation in coastal areas, SWASH has already reached a fairly mature stage since it can incorporate nonlinear shallow-water effects, such as the generation of bound sub-and super-harmonics and near-resonant triad interactions [8][9][10][11].
In order to simulate waves in the nearshore zone correctly, the generation and absorption of waves at the boundary of models need to be modelled accurately. In the SWASH model, incident waves are generated by prescribing their horizontal velocity component normal to the boundary of the computational domain over the vertical direction. Additionally, to absorb and to prevent re-reflections in front of the numerical wave generator, a weakly reflective wave generation boundary condition [12] is applied in which the total velocity signal is a superposition of the incident velocity signal and a velocity signal of the reflected waves [13]. Verbrugghe et al. [14] applied a similar method to create open boundaries within a Smoothed Particle Hydrodynamics (SPH) solver. However, this method is based on the assumption that the reflected waves are small amplitude shallow water waves propagating perpendicular to the boundary of the computational domain and hence this method is weakly reflective for directional, dispersive waves. Furthermore, Wei and Kirby [15] found that this type of radiation condition at the wave generator boundary can lead to numerical errors when long time simulations are performed. Recently, a generating absorbing boundary condition (GABC) has been developed which is an enhanced type of a weakly reflective wave generation boundary condition and can partially absorb dispersive and directional waves [16,17]. However, in this method the level of re-reflection strongly depends on the initial approximations since the characteristics of the reflected waves (i.e., wave angle, wave celerity) inside the numerical domain cannot be estimated a priori. In general, it is not possible to find practical boundary conditions that do the above task perfectly.
On the other hand, models utilizing a sponge layer are very effective in absorbing reflected waves. However, this implies that the waves have to be generated inside the computational domain instead of on the boundary. This internal wave generation technique in combination with numerical wave absorbing sponge layers was firstly proposed by Larsen and Dancy [18] for Peregrine's classical Boussinesq equations [19]. Later, Lee and Suh [20] and Lee et al. [21] achieved wave generation for the mild slope equations of Reference [22] and the extended Boussinesq equations of Nwogu [23], respectively, by applying the source term addition method. Lee et al. [21] have shown empirically that the velocity of disturbances caused by the incident wave can be properly obtained from the viewpoint of energy transport. Further, Schäffer and Sørensen [24] theoretically derived the energy velocity by adding the delta source function to the mass conservation type equation and integrated asymptotically the resulting equation at the generation point. However, Wei et al. [25] found that the source term addition method in a single source line may cause high frequency noise in case of non-staggered computational grid. To deal with this problem, Wei et al. [25] derived a spatially distributed (Gaussian shape) source function for internal wave generation, where a mass source is added in the continuity equation. Later, Choi and Yoon [26] and Ha et al. [27] used this technique in a Reynolds-averaged Navier-Stokes (RANS) equations model and a Navier-Stokes equations (NSE) model, respectively. However, in both cases they used directly the formula of [25], which was derived from the Boussinesq equations under the shallow water assumption. Thus, their model was not capable to accurately generating deep water waves and consequently high-frequency components in case of irregular waves.
In the present paper, a source term addition method and a spatially distributed source function for internal wave generation are implemented in the non-hydrostatic model SWASH, in order accurately generate regular and irregular long-crested waves. In addition, the energy velocity will be derived for the governing equations of SWASH in case multiple layers are implemented. To the present authors' knowledge, these internal wave generation techniques which are commonly used in Boussinesq models [3] and mild-slope wave models [28], have not been derived and used in a non-hydrostatic wave model before, due to the complexity of the governing equations. So, the main objective of the present work concerns the implementation of the internal wave generation in SWASH to accurately generate even highly dispersive and directional waves, while at the same time re-reflections Water 2019, 11, 986 3 of 18 at the position of the wave generator are vanishing. Moreover, SWASH has already been used in the field of marine energy by simulating the wave-induced response of a submerged wave-energy converter [29]. This kind of application requires a homogeneous wave field in the whole numerical domain. Thus, the implementation of internal wave generation is important as it introduces noteworthy improvements in the model, which can then make full use of its benefits for the study of WEC farms.
The paper is structured as follows. The numerical model SWASH is described in Section 2 where the governing equations are presented. The implemented internal wave generation techniques are derived in Section 3. Section 4 provides a detailed overview of the model results for regular and irregular long-crested waves. In addition, validation results are presented where the accuracy of the model is compared with experimental data. The last sections provide conclusions and a summary discussion of the present study.

Mathematical Formulation
SWASH is an open source non-hydrostatic wave model [7]. The governing equations of the model are based on the nonlinear shallow water equations with added non-hydrostatic effects, which are derived from the incompressible Navier-Stokes equations. The numerical domain is bounded vertically by the free-surface z = η(x, t) and the bottom z = −d(x), where t is time, d is the still water depth and x and z are the Cartesian coordinates, where z is directed positive upwards. The equations for the 2D vertical domain are ∂u ∂x where u(x, z, t) and w(x, z, t) are the horizontal and vertical velocities, p h and p nh are the hydrostatic and non-hydrostatic pressures, ρ 0 is density and τ xx , τ xz , τ zx , τ zz are the turbulent stresses. The kinematic boundary conditions are The dynamic boundary conditions at the surface are a constant pressure and no surface stresses. The free surface elevation η is determined by considering the continuity for the entire water column At the bottom boundary, a bottom stress is included based on a quadratic friction law where h = η + d is the total water depth, U is the depth averaged velocity and c f is a dimensionless friction coefficient. At the outlet of the domain a sponge layer can be employed to minimize reflections. The sponge layer formula as described in Reference [30] is used, where the free surface elevation η and the velocity component u are relaxed at every time step. In SWASH the full process of wave breaking is not simulated but instead a breaking wave is considered analogous with a hydraulic bore. However, a high vertical resolution is needed to resolve accurately this process. Hence, Smit et al. [31] proposed a breaking formulation which can reproduce wave breaking with a coarse vertical resolution. A hydrostatic pressure distribution is assumed when ∂η/∂t > a gh, where g is the gravitational acceleration and a is the maximum wave steepness before breaking.
The numerical implementation is based on an explicit, second order finite difference method for staggered grids, where the mass and momentum are strictly conserved at a discrete level. In the horizontal direction rectilinear or orthogonal curvilinear grid can be applied, while in the vertical direction the computational domain is divided into a fixed number of layers. A more detailed overview of the numerical methods and equations are given in Reference [7].

Wave Generation in SWASH
In the SWASH model, incident waves are generated by prescribing their horizontal velocity component normal to the boundary of the computational domain over the vertical direction. To prevent re-reflections in front of the numerical wave generator, a weakly reflective wave generation boundary condition is adopted [12]. For the case of one layer the imposed depth-averaged horizontal velocity component is given by where ω is the angular frequency, k is the wave number, d is the still water depth, g is the gravitational acceleration, η t is the target surface elevation and η i is the instantaneous surface elevation. In case of multiple layers, a hyperbolic cosine distribution is assumed for the horizontal velocity component. As it can be noticed from the second term of Equation (8), this method is valid only in case that the reflected waves are shallow water waves propagating perpendicular to the boundary of the computational domain, since a shallow water phase velocity, C = gd is used. Hence, it is assumed that the high frequency energy gets dissipated inside the numerical domain before arriving to the wave generation boundary [31]. In addition, a linear superposition of the incident and reflected wave is assumed and thus can only be applied to small amplitude waves.

Internal Wave Generation
In cases of directional and dispersive waves an internal wave generation technique can be applied to avoid re-reflections due to the weakly reflective wave generation boundary. Two different internal wave generation techniques are proposed here and are implemented in the SWASH model. The first one is a source term addition method proposed by Lee et al. [21], while the second one is a spatially distributed source function proposed by Wei et al. [25].

Energy Velocity
At first, a new energy velocity for the system of SWASH equations is mathematically derived following the methodology of Reference [24] who derived the energy velocity for Nwogu's Boussinesq equations. In this paper, the derivation for the case of two equidistant vertical layers is presented, while the extension to more layers is straightforward.
Bai and Cheung [32] showed that the governing Equations where u is the depth integrated horizontal velocity component,û is the inter-layer velocity variations, δ is the Dirac delta function and Λ is the source function applied to a single point. From Equation (9) it can be noticed that the ∂u/∂x term must be the one balancing the Dirac delta function and thus u andû have a discontinuity.
Taking the time derivative of Equation (10) and eliminating η from Equation (9) gives Eliminating the second and third term of Equation (12) using Equation (11) to get Taking the x derivative two times and eliminating the first term using Equation (11) gives Integrating 4 times Equation (14) from x = −ε to x = +ε, with the limit ε → 0 and requiring the integrals ofû to be continuous at x = 0, we get In Equation (15),û is an odd function and thus the left and right contributions are identical.
In SWASH an approximation of the exact linear dispersion relation, which depends on the number of vertical layers, is used (see Appendix A). For the case of two equidistant layers it is given by In addition, at the wave generation boundary, apart from the progressive waves, evanescent modes are included as well. These evanescent modes are a general characteristic of the Equations (9)- (11). Hence, Equation (16) can be rewritten as where k and k e are the wave numbers for progressive waves and evanescent modes, respectively. Equation (17) yields two solutions Furthermore, away from the source point, x = 0, the solutions of Equations (9)-(11) can be written as where the subscripts p and e stand for progressive and evanescent modes, respectively. By using Equations (10) and (11), the inter-layer velocity amplitudeû p0 can be expressed in terms of surface elevation amplitude η p0û In addition, the double integral ofû with respect to x gives an odd function and it must vanish at the source point, x = 0 and thus from Equation (21) we can writê Finally, Equation (21) at x → 0 + is imported in Equation (15) and eventuallyû e0 andû p0 are going to be replaced using Equations (22) and (23) respectively. As a result, Equation (15) becomes where By eliminating ω and k e using Equations (16) and (18), respectively, it can be noticed that the energy velocity C e is equal to the group velocity C g as it can be calculated from the approximated dispersion relation by taking the derivative of ω with respect to k C e = 64 dg(256 + 32(kd) 2 + 5(kd) 4 ) Similarly, the energy velocity (group velocity) C e can be derived for any number of vertical layers. In Figure 1, the normalised energy velocities C e /C g Airy for one, two and three vertical layers are plotted as a function of dimensionless depth kd. In addition, the range of dimensionless depth kd as a function of number of vertical layers where the relative error in the normalised energy velocities C e /C g Airy stays below 3% is given in Table 1. It can be observed that by increasing the number of layers, a better fit is achieved with the exact linear solution C e /C g Airy = 1, fact that makes the model applicable for higher kd values. Table 1.
Range of dimensionless depth kd as a function of number of vertical layers and the corresponding relative error in the normalised energy velocities C e /C g Airy .  Table 1. Range of dimensionless depth kd as a function of number of vertical layers and the corresponding relative error in the normalised energy velocities C C ⁄ .

Source Term Addition Method
In the source term addition method proposed by Reference [21], additional surface elevation η * is added with the desired energy to the calculated surface elevation η at the wave generation line for each time step and is given by where Δx is the grid size in the x-axis, Δt is the time step, θ is the angle of the incident wave ray from x-axis, η is the water surface elevation of incident waves and C is the energy velocity.

Spatially Distributed Source Function
In the spatially distributed source function proposed by Reference [25], a spatially distributed mass is added in the continuity equation. Hence, the spatially distributed source function is applied on an area in contrast to the source term addition method which is applied on a line as it is demonstrated in Figure 2. For a single wave component, the source function can be defined as follows where D is the source function amplitude and g(x) is the shape of the source function which can be arbitrarily chosen. Here, a smooth Gaussian shape has been applied. Wei et al. [25] derived the source function amplitude D for the extended Boussinesq equations of [23] and is given by

Source Term Addition Method
In the source term addition method proposed by Reference [21], additional surface elevation η * is added with the desired energy to the calculated surface elevation η at the wave generation line for each time step and is given by where ∆x is the grid size in the x-axis, ∆t is the time step, θ is the angle of the incident wave ray from x-axis, η I is the water surface elevation of incident waves and C e is the energy velocity.

Spatially Distributed Source Function
In the spatially distributed source function proposed by Reference [25], a spatially distributed mass is added in the continuity equation. Hence, the spatially distributed source function is applied on an area in contrast to the source term addition method which is applied on a line as it is demonstrated in Figure 2. For a single wave component, the source function can be defined as follows where D is the source function amplitude and g(x) is the shape of the source function which can be arbitrarily chosen. Here, a smooth Gaussian shape has been applied. Wei et al. [25] derived the source function amplitude D for the extended Boussinesq equations of [23] and is given by where α = −0.390, α 1 = α + 1/3 and I is the integral defined by where β = 20/W 2 and W is the width of the source area. Equation (30) is derived for the extended Boussinesq equations of Nwogu and thus cannot be applied directly to the SWASH equations for the case of multiple layers. However, Equation (30) can be written in terms of the energy velocity as Equation (32) can be implemented in SWASH by using the energy velocity that corresponds to the number of vertical layers used in the model. The energy velocity for the case of two vertical layers has already been derived in Section 3.1. In this way, we overcome the limitation that [26,27] observed, where their models, using Equation (30), were not applicable to deep water conditions.
where α = −0.390, α = α + 1 3 ⁄ and I is the integral defined by where β = 20 W ⁄ and W is the width of the source area.
Equation (30) is derived for the extended Boussinesq equations of Nwogu and thus cannot be applied directly to the SWASH equations for the case of multiple layers. However, Equation (30) can be written in terms of the energy velocity as Equation (32) can be implemented in SWASH by using the energy velocity that corresponds to the number of vertical layers used in the model. The energy velocity for the case of two vertical layers has already been derived in Section 3.1. In this way, we overcome the limitation that [26] and [27] observed, where their models, using Equation (30), were not applicable to deep water conditions.

Model Tests
The internal wave generation techniques, implemented in SWASH as described in Section 3, have been used to generate regular and irregular long-crested waves. The obtained results are validated against analytical solutions and experimental data including water surface elevations, orbital velocities, frequency spectra and wave heights.

Regular Waves
Firstly, the applicability and accuracy of the internal wave generation techniques to generate linear regular waves in transitional and deep water conditions are examined. The numerical basin is similar to the one in Figure 2 with sponge layers at the left and right boundaries with a width of 3L (where L is the wave length) and a flat bottom. The internal wave generator is positioned at a

Model Tests
The internal wave generation techniques, implemented in SWASH as described in Section 3, have been used to generate regular and irregular long-crested waves. The obtained results are validated against analytical solutions and experimental data including water surface elevations, orbital velocities, frequency spectra and wave heights.

Regular Waves
Firstly, the applicability and accuracy of the internal wave generation techniques to generate linear regular waves in transitional and deep water conditions are examined. The numerical basin is similar to the one in Figure 2 with sponge layers at the left and right boundaries with a width of 3L (where L is the wave length) and a flat bottom. The internal wave generator is positioned at a distance of 3L from the sponge layer. Two different wave conditions are examined: one in transitional water (kd = π/6) and one in deep water (kd = π, highly dispersive wave). For dimensionless depth kd = π/6 one vertical layer is applied while for dimensionless depth kd = π two equidistant vertical layers are applied in order to keep the relative error below 3% (Figure 1, Table 1). For both cases, the grid cell size is chosen so that ∆x = L/50, while the time step is equal to ∆t ≈ T/350, where T is the wave period. In Figure 3, the normalised water surface elevation η/η 0 calculated using the source term addition method (blue dashed lines) and the spatially distributed source function (red dashed lines) is presented.
The computed results at a distance of 1L from the internal generator and at a time period of t = 10T to t = 18T are compared to the results of the analytical solution (solid black lines) for the same conditions. The agreement is very good while the behavior of the two internal wave generation techniques is similar, with a small deviation for the case of the highly dispersive wave (Figure 3c,d). For the latter case, the spatially distributed source function provides a slightly better fit with the analytical solution.
distance of 3L from the sponge layer. Two different wave conditions are examined: one in transitional water (kd = π/6) and one in deep water (kd = π, highly dispersive wave). For dimensionless depth kd = π/6 one vertical layer is applied while for dimensionless depth kd = π two equidistant vertical layers are applied in order to keep the relative error below 3% (Figure 1, Table 1). For both cases, the grid cell size is chosen so that Δx = L/50, while the time step is equal to Δt ≈ T/350, where T is the wave period.
In Figure 3, the normalised water surface elevation η η ⁄ calculated using the source term addition method (blue dashed lines) and the spatially distributed source function (red dashed lines) is presented. The computed results at a distance of 1L from the internal generator and at a time period of t = 10T to t = 18T are compared to the results of the analytical solution (solid black lines) for the same conditions. The agreement is very good while the behavior of the two internal wave generation techniques is similar, with a small deviation for the case of the highly dispersive wave (Figure 3c,d).
For the latter case, the spatially distributed source function provides a slightly better fit with the analytical solution. In order to check the capability of the model for handling reflected dispersive waves a computational domain with a sponge layer at the left boundary and a fully reflective wall at the right boundary is used. The internal wave generator is positioned at the middle of the computational domain which has a total length of 12L. The wave height is H = 0.02 m, the wave period is T = 3 s and the water depth is d = 10 m. These wave conditions give a dimensionless depth of kd = 4.5 and thus two equidistant vertical layers are applied. The model is applied with a grid cell size of Δx = 0.3 m and a time step of Δt = 0.0125 s. Figure 4 shows a snapshot of normalised water surface elevation η η ⁄ at t = 50T generated using the source term addition method (blue solid line) and the spatially distributed source function (red dashed line). The two computed profiles are identical, while their agreement with the analytical solution (black markers) is excellent. The waves that are generated at the internal wave generator propagate towards both ends of the domain. The waves are fully reflected at the right boundary and then are fully absorbed at the sponge layer. This, together with the fact that the target wave is a linear wave and that the length of the numerical domain is an integer multiple of the wave length, results in a profile that is a standing wave with perfect nodal points. In addition, the results show that the reflected waves pass through the generation area without distortion and that the sponge layer is capable of absorbing the highly In order to check the capability of the model for handling reflected dispersive waves a computational domain with a sponge layer at the left boundary and a fully reflective wall at the right boundary is used. The internal wave generator is positioned at the middle of the computational domain which has a total length of 12L. The wave height is H = 0.02 m, the wave period is T = 3 s and the water depth is d = 10 m. These wave conditions give a dimensionless depth of kd = 4.5 and thus two equidistant vertical layers are applied. The model is applied with a grid cell size of ∆x = 0.3 m and a time step of ∆t = 0.0125 s. Figure 4 shows a snapshot of normalised water surface elevation η/η 0 at t = 50T generated using the source term addition method (blue solid line) and the spatially distributed source function (red dashed line). The two computed profiles are identical, while their agreement with the analytical solution (black markers) is excellent.
The waves that are generated at the internal wave generator propagate towards both ends of the domain. The waves are fully reflected at the right boundary and then are fully absorbed at the sponge layer. This, together with the fact that the target wave is a linear wave and that the length of the numerical domain is an integer multiple of the wave length, results in a profile that is a standing wave with perfect nodal points. In addition, the results show that the reflected waves pass through the generation area without distortion and that the sponge layer is capable of absorbing the highly dispersive wave. It has to be mentioned that the weakly reflective wave generation (Section 2.2) cannot be applied in this case since the assumption that the reflected waves are shallow water waves propagating with a phase velocity of C = gd is violated.
Water 2019, 11, x FOR PEER REVIEW 10 of 18 dispersive wave. It has to be mentioned that the weakly reflective wave generation (Section 2.2) cannot be applied in this case since the assumption that the reflected waves are shallow water waves propagating with a phase velocity of C = gd is violated. In the proposed internal wave generation techniques, the horizontal velocity component is not prescribed over the vertical direction in contrast to the weakly reflective wave generation (Section 2.2). However, as it can be observed from Figure 5 the horizontal and vertical velocity profiles are correctly calculated for both internal wave generation techniques at a distance of 1L from the generation point. The wave conditions are the same as in the previous test, while ten equidistant vertical layers have been applied in order to achieve a good agreement with the analytical hyperbolic profile.
Here, it has to be mentioned that in case of deep water waves, when coarse vertical resolution is applied, the weakly reflective wave generation technique needs calibration to generate the target wave height, since the hyperbolic profile of the horizontal velocity component cannot be accurately described by a small number of vertical layers. On the other hand, the internal wave generation techniques that are presented in this paper do not need calibration, since the source is directly linked with the surface elevation instead of the velocity component.
In all the previous tests in this section, linear waves have been examined. In order to study the behaviour of the internal wave generation techniques under non-linear waves, waves with different wave heights are tested. The internal wave generator is positioned at the middle of the computational domain which has a total length of 32L with sponge layers at the left and right boundaries and a flat bottom. The wave heights are H = 0.1 m, 1 m, 2 m, 3 m, while the wave period is T = 6 s and the water depth is d = 10 m. These wave conditions give a dimensionless depth of kd = 1.3 and thus two equidistant vertical layers are applied. The model is applied with a grid cell size of Δx = 2.0 m and a time step of Δt = 0.025 s. Figure 6 shows snapshots of normalised water surface elevation η η ⁄ at t = 50T for the different wave heights. Profiles generated using the spatially distributed source function are only presented here since the source term addition method becomes unstable for high wave heights. From  In the proposed internal wave generation techniques, the horizontal velocity component is not prescribed over the vertical direction in contrast to the weakly reflective wave generation (Section 2.2). However, as it can be observed from Figure 5 the horizontal and vertical velocity profiles are correctly calculated for both internal wave generation techniques at a distance of 1L from the generation point. The wave conditions are the same as in the previous test, while ten equidistant vertical layers have been applied in order to achieve a good agreement with the analytical hyperbolic profile.
Here, it has to be mentioned that in case of deep water waves, when coarse vertical resolution is applied, the weakly reflective wave generation technique needs calibration to generate the target wave height, since the hyperbolic profile of the horizontal velocity component cannot be accurately described by a small number of vertical layers. On the other hand, the internal wave generation techniques that are presented in this paper do not need calibration, since the source is directly linked with the surface elevation instead of the velocity component.
In all the previous tests in this section, linear waves have been examined. In order to study the behaviour of the internal wave generation techniques under non-linear waves, waves with different wave heights are tested. The internal wave generator is positioned at the middle of the computational domain which has a total length of 32L with sponge layers at the left and right boundaries and a flat bottom. The wave heights are H = 0.1 m, 1 m, 2 m, 3 m, while the wave period is T = 6 s and the water depth is d = 10 m. These wave conditions give a dimensionless depth of kd = 1.3 and thus two equidistant vertical layers are applied. The model is applied with a grid cell size of ∆x = 2.0 m and a time step of ∆t = 0.025 s. Figure 6 shows snapshots of normalised water surface elevation η/η 0 at t = 50T for the different wave heights. Profiles generated using the spatially distributed source function are only presented here since the source term addition method becomes unstable for high wave heights. From Figure 6, it can be observed that by increasing the ratio H/d, the waves are transforming from linear (Figure 6a

Irregular Waves
We consider two test cases of uni-directional irregular waves fitting a JONSWAP (Joint North Sea Wave Observation Project) spectrum, with a significant wave height, H s = 0.5 m, a water depth, d = 10 m, a peak enhancement factor, γ = 3.3 and two different peak wave periods, T p = 12 s and T p = 8 s. The frequency range is confined between 0.5f p and 3f p . The internal wave generator is positioned at the middle of the computational domain and sponge layers are placed at the left and right boundaries. For both test cases, the model is applied with a grid cell size of ∆x = 1.0 m and a time step of ∆t = 0.025 s. However, for the case of T p = 8 s two equidistant vertical layers have been applied to correctly describe the high-frequency part of the spectrum in contrast to the case of T p = 12 s where one layer is enough.
In Figure 7, a comparison is made between the target frequency spectrum (S t ) and the simulated frequency spectra generated using the two internal wave generation techniques for the cases of T p = 12 s (Figure 7a) and T p = 8 s (Figure 7b). The surface elevations η at the electronic wave gauges, which are positioned at a distance of 3L p (where L p is the wave length corresponding to the peak period) from the internal wave generator, are recorded from t = 25T p to t = 300T p with a sampling interval of 0.2 s. The recorded data are processed in segments of 2048 points per segment. A taper window and an overlap of 20% are used for smoother and statistically more significant spectral estimates. The resulting frequency spectra agree very well with S t apart from the one that corresponds to the source term addition method for the case of T p = 12 s, where high-frequency noise can be observed. In addition, it is found that the magnitude of this noise strongly depends on the grid resolution since a coarser resolution leads to less noise. Moreover, the small difference around the peak of the frequency spectrum in Figure 7b could be caused by numerical dissipation since the electronic wave gauges are positioned at a distance of 3L p from the internal wave generator.

Irregular Waves
We consider two test cases of uni-directional irregular waves fitting a JONSWAP (Joint North Sea Wave Observation Project) spectrum, with a significant wave height, H = 0.5 m, a water depth, d = 10 m, a peak enhancement factor, γ = 3.3 and two different peak wave periods, T = 12 s and T = 8 s. The frequency range is confined between 0.5 f and 3f . The internal wave generator is positioned at the middle of the computational domain and sponge layers are placed at the left and right boundaries. For both test cases, the model is applied with a grid cell size of Δx = 1.0 m and a time step of Δt = 0.025 s. However, for the case of T = 8 s two equidistant vertical layers have been applied to correctly describe the high-frequency part of the spectrum in contrast to the case of T = 12 s where one layer is enough.
In Figure 7, a comparison is made between the target frequency spectrum (S ) and the simulated frequency spectra generated using the two internal wave generation techniques for the cases of T = 12 s (Figure 7a) and T = 8 s (Figure 7b). The surface elevations η at the electronic wave gauges, which are positioned at a distance of 3L (where L is the wave length corresponding to the peak period) from the internal wave generator, are recorded from t = 25T to t = 300T with a sampling interval of 0.2 s. The recorded data are processed in segments of 2048 points per segment. A taper window and an overlap of 20% are used for smoother and statistically more significant spectral estimates. The resulting frequency spectra agree very well with S apart from the one that corresponds to the source term addition method for the case of T = 12 s, where high-frequency noise can be observed. In addition, it is found that the magnitude of this noise strongly depends on the grid resolution since a coarser resolution leads to less noise. Moreover, the small difference around the peak of the frequency spectrum in Figure 7b could be caused by numerical dissipation since the electronic wave gauges are positioned at a distance of 3L from the internal wave generator.

Oblique Waves in a Basin with Constant Depth
In this section, oblique waves are generated in a basin with constant depth by using the spatially distributed source function wave generation technique. The numerical basin is 190 m long, 90 m wide

Oblique Waves in a Basin with Constant Depth
In this section, oblique waves are generated in a basin with constant depth by using the spatially distributed source function wave generation technique. The numerical basin is 190 m long, 90 m wide and 1 m deep. Sponge layers are placed at the left and right boundaries with a width of 50 m while periodic boundaries are applied at the top and bottom of the domain. The internal wave generator is parallel to the y-axis and is positioned at a distance of 100 m (x = 0) from the left boundary. The wave height is H = 0.01 m, the wave period is T = 4 s and the wave propagation angle is θ = 15 • . The grid cell size is chosen so that ∆x = ∆y = 0.15 m. In order to obtain a steady state wave field, waves are generated for a duration of 180 s with a time step ∆t = 0.0125 s. Figures 8 and 9 present comparisons between the computed normalised water surface elevation η/η 0 at t = 40T and the corresponding analytical solution. It can be observed that the computed solution coincides with the analytical solution except for the region of the sponge layers. The excellent agreement indicates that the spatially distributed source function implemented in SWASH is able to accurately generate directional waves.

Wave Propagation over a Shoal in a Three-Dimensional Numerical Basin
Finally, a three-dimensional version of the developed model with the spatially distributed source function wave generation technique is applied to study regular waves propagating over a shoal. The experiment conducted by Reference [33] has served as a standard test case for validating phase resolving wave models.
The bathymetry of the experimental setup consist of an elliptic shoal resting on a plane sloping seabed and the entire slope is turned at an angle of 20 • with respect to the x-axis. Detailed information on the geometry can be found in Reference [33]. The numerical basin is 45 m long (−20 < y < 25) and 20 m wide (−10 < x < 10). The internal wave generator is parallel to the x-axis and is positioned at a distance of 10 m (y = −10 m) from the bottom boundary. The remaining numerical domain includes two sidewalls at x = −10 m and x = 10 m and two sponge layers at y = −15 m and y = 20 m with a width of 5 m.
The wave height is H = 0.0464 m, the wave period is T = 1 s and the water depth at the position of the internal wave generator is d = 0.45 m. These wave conditions give a dimensionless depth of kd = 1.9 and thus two equidistant vertical layers are applied. The model runs for 50 s without any stability issues since the reflected waves that are reaching the offshore boundary are absorbed by the sponge layer, which is positioned behind the internal wave generator. The model is applied with a grid cell size of ∆x = ∆y = 0.05 m, while the time step is automatically adjusted during the simulation depending on the CFL (Courant-Friedrichs-Lewy) condition where a maximum CFL value of 0.5 is used. Figure 10 shows the plan view of the normalised wave height H/H 0 (where H is the local wave height and H 0 is the wave height at the wave generation boundary) in the whole computational domain where the diffraction and refraction patterns of the waves are visible. The wave heights of the model are obtained by averaging those of the last ten wave periods of the simulation (from t = 40 s to t = 50 s).

Wave Propagation over a Shoal in a Three-Dimensional Numerical Basin
Finally, a three-dimensional version of the developed model with the spatially distributed source function wave generation technique is applied to study regular waves propagating over a shoal. The experiment conducted by Reference [33] has served as a standard test case for validating phase resolving wave models.
The bathymetry of the experimental setup consist of an elliptic shoal resting on a plane sloping seabed and the entire slope is turned at an angle of 20° with respect to the x-axis. Detailed information on the geometry can be found in Reference [33]. The numerical basin is 45 m long (−20 < y < 25) and 20 m wide (−10 < x < 10). The internal wave generator is parallel to the x-axis and is positioned at a distance of 10 m (y = −10 m) from the bottom boundary. The remaining numerical domain includes two sidewalls at x = −10 m and x = 10 m and two sponge layers at y = −15 m and y = 20 m with a width of 5 m.
The wave height is H = 0.0464 m, the wave period is T = 1 s and the water depth at the position of the internal wave generator is d = 0.45 m. These wave conditions give a dimensionless depth of kd = 1.9 and thus two equidistant vertical layers are applied. The model runs for 50 s without any stability issues since the reflected waves that are reaching the offshore boundary are absorbed by the sponge layer, which is positioned behind the internal wave generator. The model is applied with a grid cell size of Δx = Δy = 0.05 m, while the time step is automatically adjusted during the simulation depending on the CFL (Courant-Friedrichs-Lewy) condition where a maximum CFL value of 0.5 is used. Figure 10 shows the plan view of the normalised wave height H H ⁄ (where H is the local wave height and H is the wave height at the wave generation boundary) in the whole computational domain where the diffraction and refraction patterns of the waves are visible. The wave heights of the model are obtained by averaging those of the last ten wave periods of the simulation (from t = 40 s to t = 50 s).   Figure 11 shows the comparison of normalised wave heights H/H 0 between numerical model results (red lines) and experimental data (black circles) along eight measurement transects. Additionally, in order to evaluate the model, the root mean square error (RMSE) and the Skill factor for the normalised wave heights of each section are calculated as: where O and P indicate the observed and predicted values, respectively. Very good agreement between the numerical model and the experimental model is observed (Figure 11 and Table 2).
Water 2019, 11, x FOR PEER REVIEW 15 of 18 Figure 11 shows the comparison of normalised wave heights H/H between numerical model results (red lines) and experimental data (black circles) along eight measurement transects. Additionally, in order to evaluate the model, the root mean square error (RMSE) and the Skill factor for the normalised wave heights of each section are calculated as: where O and P indicate the observed and predicted values, respectively. Very good agreement between the numerical model and the experimental model is observed (Figure 11 and Table 2).

Conclusions
In the present paper new internal wave generation techniques have been developed in an open source non-hydrostatic wave model, SWASH, for accurate generation of regular and irregular longcrested waves.
Initially, two different internal wave generation techniques have been developed and implemented in SWASH model. The first one is a source term addition method based on the method proposed by Lee et al. [21], while the second one is a spatially distributed source function based on Figure 11. Comparison of normalised wave heights H/H 0 between numerical model results (red solid lines) and experimental data (black circles) along different measurement transects. Table 2. Root mean square error (RMSE) and Skill factor of the normalised wave heights for each section.

Conclusions
In the present paper new internal wave generation techniques have been developed in an open source non-hydrostatic wave model, SWASH, for accurate generation of regular and irregular long-crested waves.
Initially, two different internal wave generation techniques have been developed and implemented in SWASH model. The first one is a source term addition method based on the method proposed by Lee et al. [21], while the second one is a spatially distributed source function based on the method proposed by Wei et al. [25]. These techniques need an extension of the numerical domain to accommodate the sponge layer and the source area contrary to the weakly reflective wave generation boundary. Thus, the computational cost increases 15-30%, where the lower values stand for larger computational domains. However, the main advantage of the internal wave generation is that in cases of directional and dispersive waves the reflected waves are absorbed by the sponge layer that is positioned behind the internal wave generator in contrast with the weakly reflective wave generation boundary, which is not valid for these wave conditions due to the limitations as described in Section 2.2. Hence, the internal wave generation has a big advantage when wave energy converter (WEC) farms and man-made structures (e.g., breakwaters, artificial reefs, artificial islands) are examined, since the radiated and reflected waves, respectively, cannot be estimated a priori. In the source term addition method additional surface elevation is added to the calculated surface elevation while in the spatially distributed source function a spatially distributed mass is added in the continuity equation. In both cases, the source term propagates with a velocity which is called the energy velocity which for the system of SWASH equations is mathematically derived in Section 3.1.
Then, these wave generation techniques has been used to generate regular and irregular long-crested waves. The results indicate that the developed model is capable of reproducing the target surface elevations as well as the target frequency spectrum. The overall performance of the spatially distributed source function is better than the source term addition method since the latter becomes unstable for large wave heights and may cause high frequency noise. Finally, the developed model is also used to study wave transformation over an elliptic shoal (Berkhoff shoal experiment) where very good agreement is observed between the numerical model and the experimental results. The aforementioned observations reveal that the spatially distributed source function developed here in SWASH can be successfully used to study coastal areas and wave energy converter (WEC) farms even under highly dispersive and directional waves, while at the same time re-reflections at the position of the wave generator are vanishing.

Conflicts of Interest:
The authors declare no conflict of interest.