In May 2017, we implemented modelling of water waves into the public, development line of OpenFOAM (
OpenFOAM-dev). Wave modelling, including the generation and damping of waves, is needed for marine and offshore engineering to simulate flow conditions experienced in those fields, e.g. on a ship in open water. Users also generally need tools for processing data, e.g. of surface elevation. This article describes this new development which was funded by DNV GL, a classification society for marine and offshore structures.
— CFD Direct OpenFOAM (@CFDdirect) June 1, 2017
Various software packages for water wave modelling have been developed by third parties for OpenFOAM, e.g.
IHFoam. The developers of those packages chose to release them independently of the OpenFOAM Foundation, so that they did not become part of the standard OpenFOAM release. Consequently, the packages suffer, to varying degrees, from the following issues.
- Installation: marine and offshore engineers face the inconvenience of having to compile source code of one of these packages rather than obtain the functionality directly from a pre-compiled, packaged version of OpenFOAM.
- Maintenance: rather than managing changes through the version control systems they use (e.g.
git), code files are either duplicated for each version of OpenFOAM or littered with
#if...#endifstatements about versions.
- Coding Standards: there is little adherence to software design standards of OpenFOAM, e.g.
olaFoamcreates a single boundary condition class with a long
ifstatement for all wave models, rather than creating a separate boundary condition class for each individual model.
- Code Provenance: many code files have incomplete copyright statements; in some cases, copyright statements have been deleted, e.g.
interFoam.C, to produce
olaFoam.C, breaching the terms of the General Public Licence (GPL) under which OpenFOAM is distributed.
We implemented a framework for wave models that generate the elevation of the wave and velocity of the flow field at a given location. It includes a mechanism to combine multiple models of different types that delivers superimposed elevations and velocities. The initial implementation included the first order Airy wave and the second order Stokes wave (Stokes II). Additional wave models, of higher order or different theoretical basis, can be added to this framework. [Update: Fifth order Stokes (Stokes V) and solitary waves were added in July 2017]. Two boundary conditions,
waveAlpha, have been included that provide an inlet condition for the velocity and phase-fraction fields in the presence of surface waves.
We implemented a
setWaves utility that applies the wave models to the entire domain for case initialisation. It is similar to
setFields but is able to do second-order accurate mapping between the analytical wave models and the finite volume fields. Second-order is achieved using level-set methods that calculate the integrals of discontinuous functions such as the wave elevation. Rather than initialise phase fraction
alpha in cells with values of
1 only, intermediate values are calculated where the interface partially intersects a cell. The level set work involved significant refactoring and extension of the tet-cutting algorithms used in conservative mapping.
Wave damping was included using a run-time selectable source term, implemented within a new
verticalDamping. It provides an explicit damping force to components of the velocity field in the direction of gravity. This can be used to damp wave motion, and is intended to be used in an outlet region to prevent reflections from the outlet boundary.
Post-processing is included within a function object named
interfaceHeight, which writes out interface height at user-defined locations. The elevation direction is defined by the direction of gravity. Elevations can be plotted conveniently with
GnuPlot and monitored during simulation with
Two tutorials cases have been added that demonstrate the new functionality:
$FOAM_TUTORIALS/multiphase/interFoam/laminar/wave: simple example of wave propagation in a structured 2D domain,
$FOAM_TUTORIALS/multiphase/interDyMFoam/RAS/DTCHullWave: demonstrates waves breaking over the bow of a ship (see video below).