In CFD, boundary conditions are simply boundary conditions, right? We can specify far-field velocity and turbulence profiles for a wind tunnel, atmospheric boundary layers for built environment simulations and various geometry or periodicity boundary conditions. In most cases, boundary conditions are an afterthought that rarely go wrong. There aren’t many problems to consider here, right? Wrong.
In compressible flows, one may encounter non-reflective boundaries, where an internal pressure wave in compressible flow must be allowed to depart the computational domain. Interesting work by Poinsot and Lele on LODI (Local One-Dimensional Inviscid) relations [LODI] allows us to do that with virtually zero reflection. All that is required is the thermodynamic state so that we can establish the outgoing wave speed.
Waves are different. For a simple Stokes wave, one may consider an inlet boundary condition, specifying wave elevation and velocity at the boundary. However, although incident (incoming) wave is known, the diffracted wave (caused by the body interacting with the incident wave) is not: it is a part of the solution. Flushing such waves from the domain without reflection is far from trivial, even for a monochromatic wave.
For wave packets (used in focused wave groups), or irregular sea states (described by wave energy spectra), the situation is more complex. A realistic sea state - such as the one needed for a 3-hour storm simulation of an off-shore structure - is modelled using a wave spectrum, giving the distribution of wave energy spectral density on wave frequency. For a decent distribution of a spectrum, 100-200 frequencies are selected to approximate the spectrum and initialised with random phase shifts. A non-liner potential solver will account for wave-to-wave interaction, further complicating the picture.
A wave packet or a wave spectrum is therefore described via multiple superimposed waves, either with a random or tuned relative phase shift. Disentangling this in a boundary condition to prevent reflection is out of the question.
A realistic Higher Order Spectrum irregular sea state is directional: not only does it contain many different frequencies, but also many directions. A representative sea state calculated by the non-linear potential solver in the Naval Hydro Pack is shown below.
This simulation shows free surface covered by wave elevation (red = crest; blue = trough) in a 1.2x1.2 km domain simulated using a non-linear potential flow model implemented by Gatin [HOS]. The flow solver assumes irrotational inviscid flow and it is really fast: we use it for far-field initialisation, coupled with CFD in the near-field domain.
The wave boundary condition question is therefore significantly harder: how can one introduce a complex superposition of waves and how can one stop them from bouncing from outlet boundaries?
In wave basins, the downstream side of the pool is filled with perforated plates for the same reason: to stop the wave bouncing off the the far end.
My first contact with the numerical equivalent of this was from the work of Niels G. Jacobsen on wavesToFoam [WavesToFoam]. Here, a distance from the far-field boundary is given within which a prescribed wave shape (elevation and velocity) is given. The necessary data comes from the incident wave model, be it something as simple as a Stokes wave of various order (analytical), or via coupling to a more complex potential wave theory model such as stream function waves or HOS. In Niels’s implementation, this is done by simply over-writing the p, U and alpha fields within the relaxation zone: it works, but numerically it isn’t pretty.
Recognising the objective - enforce the field values in the relaxation zone - and understanding the flexibility of FOAM, I implement the same algorithm in a different way. First, the entire domain is discretised in the usual way for the full set of governing equations. Second, field imposition within relaxation zones is written in the form
diag * U = S(U_incident),
diag * alpha = S(alpha_incident),
where S() is the matrix source term that imposes U_incident and alpha_incident, which is active only in the relaxation zone. This is termed “Incident-matrix”. Third, a blending function field gamma; 0 <= gamma < 1 is introduced, where gamma = 1 implies imposed far-field solution and gamma = 0 implies undisturbed CFD solution. The final matrix M given to the linear solver is obtained by blending
M = gamma * CFD-matrix + (1- gamma) * Incident-matrix
In this way, field imposition is treated IMPLICITLY within the relaxation zone. Provided that the relaxation zone blending function gamma does not reach 1, boundary conditions and all other machinery work in the manner we are used to.
A sample relaxation field for the wave flume is shown below.

As a guidance, width of the relaxation zone should be between 0.8 and 1 wavelength lambda of the representative wave. For irregular sea states, we may use up to 1.2 lambda.
This is a significant improvement over the original implementation which may lose connection with far-field CFD conditions. In this formulation, incident wave condition is enforced via a mechanism that numerically looks like a porous zone in the momentum equation (enforcing U towards U_incident) without interfering with the pressure equation and its boundary conditions. The usual aspects of p-U coupling, global conservation and other constraints remain undisturbed.
For the moving mesh cases, far-field relaxation zone works well. Change in point position simply means that the location where incident field is sampled has changed - it is easy to move the computational domain within the wave field. This will come handy in future free sailing simulations.
The final question is: what do we relax towards? A regular implementation of “numerical beach” boundary damping relaxes the field towards an undisturbed mean surface, see figure below.


As expected, the pressure field relaxes to zero to comply with the outgoing boundary condition. However, the velocity field - impacting the numerical beach - does not show the same smooth relaxation.
Based on this, with wave flume simulation, Naval Hydro tools by Wikki choose to relax not to the mean free surface but to the undisturbed incident wave field. Considering the decomposition above, this implies that the diffracted waves are dissipated away and incident waves exit the domain with minimal disturbance. Much better!
It is clear that relaxing towards the incident wave conditions is more consistent than enforcing a numerical beach. In a 3-D simulation, quality of waves can be checked by comparing the CFD wave in the region of interest with a side relaxation zone: any inconsistency becomes very clear!
Of course, along the way, we managed to make the wave imposition algorithm - calculating flow variables for incident fields - about a 100 times faster than the original implementation (and offered it to Niels as a Thank You). The algorithm reads as follows. Incident field (potential) free surface model provides a location of the free surface and a continuous velocity field. Based on the shape of free surface, nearest-distance-to-free-surface is calculated for all points in the mesh. If the distance is negative for all points, the cell is wet; if the distance is always positive, it is dry.
Having found a cell where the nearest distance changes sign, this cell is geometrically decomposed into the wet volume and dry volume by inserting distance = 0 points into the relevant edges. Once this is done, the “free surface face” is calculated and a single cell is converted into a two-cell mesh. Cell volume fraction is calculated exactly: the ratio of wet cell volume to original volume. For the wave velocity, a centroid of the wet cell is used to read out the value from the potential wave theory model. This effectively provides sub-cell resolution of the free surface, minimising any distortion from the CFD side.
Note that the potential wave model effectively corresponds to the solution of the pressure equation without non-linearity and rotation: therefore, imposed incident field solution actually satisfies the CFD equations.
We use further tricks such as Wheeler stretching for simple potential flow models such as Stokes waves. There are issues with superposition of the water current and the wave model; in our case, this is solved using a stream-function wave model... but I am running out of space. This will be revisited in a future post.
Validation of the wave model is a separate story. Conditions are extremely strict, comparison is done with potential flow models which handle waves extremely well and excuses about non-linearity of mesh resolution are not accepted well. Another future post, I assume...
For further details on relaxation zones, please see paper by Vukcevic [Relaxation].
All the results in this blog are produced using the NavPak and Naval Hydro Pack by Wikki. Contact me for further details at https://www.wikki.co.uk , by direct message or by E-mail.
For more information on Wikki’s naval hydrodynamics CFD products, please see our web page
and
https://wikki.co.uk/naval-hydrodynamics/
Happy reading,
Hrvoje
[LODI] T.J Poinsot, S.K Lele, Boundary conditions for direct simulations of compressible viscous flows, Journal of Computational Physics, Volume 101, Issue 1, 1992, Pages 104-129, ISSN 0021-9991, https://doi.org/10.1016/0021-9991(92)90046-2
[HOS] Inno Gatin, Vuko Vukčević, Hrvoje Jasak, A framework for efficient irregular wave simulations using Higher Order Spectral method coupled with viscous two phase model, Journal of Ocean Engineering and Science, Volume 2, Issue 4, 2017, Pages 253-267, ISSN 2468-0133, https://doi.org/10.1016/j.joes.2017.09.003
[WavesToFoam] Jacobsen, N.G.; Fuhrman, D.R.; Fredsøe, J. (2012): A Wave Generation Toolbox for the Open-Source CFD Library: OpenFoam, International Journal for Numerical Methods in Fluids, 70(9), 1073-1088
[Relaxation] Vukcevic et al: Decomposition model for naval hydrodynamic applications, Part I: Computational method, Ocean Engineering, v 121 pp 37-46, 2016


