Contrib/waves2Foam

From OpenFOAMWiki
< Contrib
Revision as of 13:37, 28 April 2013 by NGJ (Talk | contribs)

The library waves2Foam is a toolbox used to generate and absorb free surface water waves. Currently the method applies the relaxation zone technique (active sponge layers) and a large range of wave theories are supported and the relaxation zones can take arbitrary shapes.

The library also comes with pre- and postprocessing utilities tailored for use for free surface flows within the fields of coastal, marine and maritime engineering.

1 waves2Foam

The package is to be used in the modelling of free surface water waves. The package contains the following:

  • One library libwaves2Foam. See description below.
  • Solver(s) to be used with 1.5 and 1.6+ (see below in section "Compatibility"). The foundation in the solvers is interFoam, where the relaxationZone part of libwaves2Foam has been added to the solver.
  • Preprocessing tools used to:
    • setWaveParameters: Sets the wave parameters for a given wave theory based on a set of input variables. E.g. for Airy wave theory, the period, water depth, and magnitude of the gravitational acceleration produces the wave number. The utility goes through all sub-dictionaries in waveProperties file, see below.
    • setWaveField: This utility sets initial conditions in the files U and gamma (v. 1.5)/alpha1 (v. 1.6 and more recent) based on a runTime selectable wave theory.
    • relaxationZoneLayout: Produces an overview of the spatial layout of the relaxation zone.
  • Tutorials
  • Since setWaveParameters is not working for all wave theories, a set of Matlab® functions are provided for the missing wave theories (Currently: stream function waves and cnoidal first waves).

1.1 Supported Versions of OF

Valid versions: OF Version 16ext.png OF Version 171.png OF Version 17x.png OF Version 21.png OF Version 211.png OF Version 21x.png OF Version 22x.png

NB: The code is only compatible with OpenFoam version 1.5 up to and including svn-revision number 1950.

NB: The code is also compilable this the version 2.0 of OpenFoam, however, the solvers are not distributed along with the SVN-repository. Nevertheless, minor changes are needed in order to modify interFoam to get it to work; see below.

Please report on successful applications of the toolbox.

1.2 Referencing

Whenever used please do make proper referencing to the following journal paper:

@article { jacobsenFuhrmanFredsoe2011,
Author = {Jacobsen, N G and Fuhrman, D R and Freds\o{}e, J},
title = {{ A Wave Generation Toolbox for the Open-Source CFD Library: OpenFoam\textregistered{} } },
Journal = {{ Int. J. Numerl. Meth. Fluids} },
Year = {2012},
Volume = {70},
Number = {9},
Pages = {1073-1088},
DOI = {{10.1002/fld.2726} },
}

The paper has now been published.

http://onlinelibrary.wiley.com/doi/10.1002/fld.2726/abstract

1.3 Ideas / Improvements / Suggestions / Contributions

If you have any ideas on how to improve this toolbox, or if you have developed pieces of code/functionalities, which you think would fit nicely into the framework, then please do not hesitate contacting me, e.g. via the cfd-online forum, where my user name is ngj.

1.4 Discussions on cfd-online.com

There are two main threads on cfd-online.com, which are related to waves2Foam.

For announcements please consider (Note, that questions will generally not be answered here. It is a source of communication on developmemt/release topics):

http://www.cfd-online.com/Forums/openfoam-news-announcements-other/94251-release-wave-generation-absorption-toolbox.html

For enquiries, discussion, etc, please use:

http://www.cfd-online.com/Forums/openfoam-solving/100091-waves2foam-related-topics.html

1.5 Also Used in These Works

  • Bredmose, H. and Jacobsen, N. G. (2010). Breaking Wave Impacts on Offshore Wind Turbine Foundations: Focused Wave Groups and CFD. Proceedings of the 29th ASME International Conference on Ocean, Offshore and Arctic Engineering, Shanghai, China, 3, 397-404
  • Bredmose, H. and Jacobsen, N. G. (2011). Vertical wave impacts on offshore wind turbine inspection platforms. Proceedings of the 30th ASME International Conference on Ocean, Offshore and Arctic Engineering, Rotterdam, The Netherlands (on CD)
  • Jacobsen, N. G. (2011). A Full Hydro- and Morphodynamic Description of Breaker Bar Development. Ph.D. Thesis. DCAMM Special Report no. S136, Technical University of Denmark, Deparment of Mechanical Engineering. Available at [1]
  • Jacobsen, N. G. and Fredsoe, J. (In print). Cross-Shore Re-Distribution of Nourished Sand Near a Breaker Bar. J. of Waterway, Port, Coastal and Ocean Engineering - ASCE, --, --
  • Jacobsen, N. G. and Fredsøe, J (2011). A Full Hydrodynamic Modelling of 2D Breaker Bar Development. Proceedings to Coastal Sediments, Miami, Florida, U.S.A.
  • Paulsen, B. T., Bredmose, H. and Bingham, H. B. (2012). Accurate computation of wave loads on a bottom fixed circular cylinder. International Workshop on Water Waves and Floating Bodies, Copenhagen, Denmark (http://www.iwwwfb.org)
  • Paulsen, B. T., Bredmose, H. and Bingham, H. B. (2013). Focused Wave Impact on a Vertical Cylinder: Experiment, Numerical Reproduction and a Note on Higher Harmonics. International Workshop on Water Waves and Floating Bodies, Marsaille, France (http://www.iwwwfb.org)
  • Piro, D. J. and Maki, K. J. (2013). Whipping Response of a Box Barge in Oblique Seas. International Workshop on Water Waves and Floating Bodies, Marsaille, France (http://www.iwwwfb.org)
  • Stahlmann, A. and Schlurmann, T. (2012). Investigations of Scour Development at Tripod Foundations for Offshore Wind Turbines: Modeling and Application. Proceedings of the International Conference on Coastal Engineering, Santander, Spain (http://journals.tdl.org/icce)

2 Distributed Library

2.1 Overview of Content

Schematics of the code structure in the library

The library libwaves2Foam contains the following functionality:

  • A namespace called waveTheories, where the abstract base class, waveTheory, defines the interface for the implementation of free surface water waves. At present the interface requires the definition of the velocity, the surface elevation, and the surface normal pressure gradient (the last only used on the boundaries). It is optional to implement the actual pressure. The set of wave theories presently available is given below.
It is extremely simple to extend the number of implemented wave theories, as long as the needed algebraic expressions are available.
  • An abstract base class called setWaveProperties. From this a definition file to each of the wave theories is implemented. These are addressed from the utility setWaveParameters, which sets the needed wave parameters for each wave theory based on a minimum of input parameters. See below.
  • A relaxation framework around the class relaxationZone, where combinations of relaxation techniques and the shape of relaxation zones can be chosen. See details below.
  • convexPolyhedral This set of files carries out intersection routines between faces/convex polyhedrals and the water surface given in terms of e.g. an algebraic equation such as \eta=a\sin (\omega t - \mathbf{k}\cdot\mathbf{x}), where \eta is the water surface elevation, a is the wave amplitude, \omega is the cyclic frequency, t is time, \mathbf{k} is the horizontal wave number vector, and \mathbf{x} is a spatial coordinate. It should be noted that the intersection routine is not implemented in convexPolyhedral, but rather the relaxation zones and boundary conditions is derived from this class, and the virtual methods for the distance function is implemented. These again are based a pointer, namely autoPtr<waveTheories::waveTheory>, hence there is a decoupling of the relaxation zone techniques/boundary conditions and the actual wave theory used in the simulation.
  • Furthermore, available trough this library is:
    • Boundary conditions for the velocity, the void fraction ratio and the pressure gradient (the last is not fully implemented in all wave theories)
    • A class for setting initial conditions
    • A class which is used for either runTime or post-processing of the surface elevation

2.2 Available Wave Theories

A set of different wave theories are implemented in waves2Foam. Besides stating the required wave type in the waveProperties.input file, each wave theory have different additional required information, such as wave height, wave period, water depth, etc. The detailed information are gather here:

Wave Theories and Specifications.

The following wave theories are implemented to date:

  • Current type
    • Potential current
  • Regular waves
    • Stokes first order theory
    • Stokes first order theory (standing)
    • Stokes second order theory
    • Modulated stokes second order theory
    • Stokes fifth order theory
    • First order cnoidal theory
    • Stream function wave theory
  • Solitary waves
    • Solitary first
  • Irregular waves
    • First order bichromatic wave (wave group)
    • Second order bichromatic wave
    • First order irregular super-position
  • Other
    • Mixed boundary

2.3 Relaxation Techniques

Relaxation techniques generally cover the method of removing reflected or internally generated wave components adjacent to vertical boundaries. One method is currently fully functioning and the framework have been made ready for another type. Both of these are a part of the overall relaxation framework, which is implemented into relaxationZone. The latter is the one implemented into the solvers to add the relaxation functionalities.

The relaxation zones are updated each and every time step in case a topological change has found place. It is updated based on mesh.changing(). The relaxation weight is recomputed each time step to accommodate for small changes in the cell position originating from mesh motion. Big mesh motions are not recommended inside the relaxation zones.

The relaxation methods are:

2.3.1 Explicit Relaxation

The explicit relaxation techniques is performed before the momentum equation is solved in the following manner:

\mathbf{u} = (1-w)\mathbf{u}_{target}+w\mathbf{u}_{computed}

\alpha = (1-w)\alpha_{target}+w\alpha_{computed}

where w\in[0,\,1] is a weigthing function. One particular method is implemented, however, everything is done with runTime-selection, so it should be rather easy to make another method and test it.

Interface:

void relaxationZone::correct()

2.3.2 Numerical Beach

The numerical beach considers the addition of an artificial viscosity into the momentum equation.

A framework has been made ready with runTime selection, however, presently only a dummy-beach is implemented, which does not alter the artificial viscosity from the default value of 0.0. The numerical beach has direct access to the local distance function, \sigma, in the relaxation zone, thus it ought to be straight forward to implement a given method.

Interface:

tmp<volScalarField> relaxationZone::numericalBeach()

2.3.3 Relaxation Weights

Several relaxation weights are implemented into the current framework, where all of them can also be subject to a correction, which make the weight dependent on the local Courant number (see below).

2.3.3.1 Exponential Weight (Default)

The exponential weight is given as [1]

w = 1 - \frac{\exp(\sigma^{p})-1}{\exp(1) - 1}

where the exponent p\in\mathcal{R}_+. Default value is 3.5.

2.3.3.2 Free Polynomial Weight

The free polynomial weight is given as [2]

\quad{}w = 1 - \sigma^{p}

where p\in\mathcal{N}. There is no default value.

2.3.3.3 Third Order Polynomial Weight

The third order polynomial weight is given as [2]

w = -2 \tilde{\sigma}^3 + 3 \tilde{\sigma}^2

where \tilde{\sigma} = 1 - \sigma. This shape is particularly derived to be used for relaxation zones, which are both generating and absorption waves.

2.3.3.4 Additional Temporal correction

The temporal correction is that of Sopheak Seng et al.[3], and is based on the local Courant number, Co, where the corrected weight, \tilde{w} is given as

\tilde{w}=1 - (1 - w^*)^{Co/Co_{max}}

where w^* = 1 - w.

2.3.4 Relaxation Shapes

Relaxation shapes defines the shape and relaxation direction of the relaxation zone. The available shapes and their input format are

2.3.4.1 Rectangular
relaxationZone
{
    relaxationShape Rectangular;

    relaxType   INLET;
    startX      (90 90 0);
    endX        (100 100 0);
    orientation (0 1 0);
}

Generates a rectangular relaxation zone, which primary axis in the plane is along orientation. If the target solution is wanted in startX, then relaxType should read INLET. If the target solution is wanted in endX, then relaxType should read OUTLET. It holds for the inner product (\mathbf{x}_{end}-\mathbf{x}_{start})\boldsymbol{\cdot}\mathbf{e}_{orientation}>0.

2.3.4.2 Cylindrical
relaxationZone
{
    relaxationShape Cylindrical;
   
    centre   (70 70 0);
    rInner   15;
    rOuter   25;
}

Generates a cylindrical relaxation zone, where the target solution is enforced along the outer radii.

2.3.4.3 SemiCylindrical
relaxationZone
{
    relaxationShape SemiCylindrical;
    
    centre             (30 30 0);
    rInner             5;
    rOuter             25;
    zeroAngleDirection (1 0 0);
    angleStart         45;
    angleEnd           220;
}

Generates a semi-cylindrical relaxation zone, where the target solution is enforced along the outer radii. In addition the user needs to specify the direction of primary axis in the unit circle, zeroAngleDirection. The two angles, angleStart and angleEnd, must be in the interval [-180^\circ,\,+180^\circ].

3 Applications

3.1 waveFoam

waveFoam is based on the original implementation of interFoam. Modifications are made to make it possible to use the relaxation zone framework with the solver.

3.2 waveFoam - How to Modify interFoam

For more recent versions of OpenFoam, the toolbox is not straightforward applicable, as the user (for the time being), needs to create waveFoam him-/herself from interFoam. Here are the necessary steps:

  • Copy the files, which belong to interFoam into a new folder. E.g. disregard all files related to the derived multiphase solvers. Rename interFoam.C to waveFoam.C
  • Add the following line in waveFoam.C
#include "relaxationZone.H"
  • Inside main in waveFoam.C add the following two lines just below #include "initContinuityErrs.H" and above createFields.H
#include "readGravitationalAcceleration.H"
#include "readWaveProperties.H"
  • After the line in waveFoam.C stating #include "alphaEqnSubCycle.H" add
relaxing.correct();
  • Furthermore in createFields.H, one should delete the line stating
#include "readGravitationalAcceleration.H"
  • And add the following at the very bottom
relaxationZone relaxing(mesh, U, alpha1);
  • The output should be placed in FOAM_USER_APPBIN, so modify Make/files so it reads
waveFoam.C

EXE = $(FOAM_USER_APPBIN)/waveFoam
  • In order to make it compilable one should add the following in Make/options under EXE_INC:
-DOFVERSION=<Replace brackets with the first three digits in the OF-version number> \
-I./../../../../src/lnInclude

If the version number only contain 2 digits, then add a third digit being 0.

  • and similar below the EXE_LIBS part:
-L$(FOAM_USER_LIBBIN) \
-lwaves2Foam
  • Do remember to add the necessary "\" in Make/options for it to read the additional lines.

3.3 waveDyMFoam - How to couple waves2Foam with dynamic mesh motion

Step-by-step guide about how to couple the CFD ToolBox waves2Foam with dynamic mesh motion

1. Copy the folder of solver interDyMFoam in the wave2Foam solver folder for version which you use, for example, for version 1.7.1:

cp -r $WM_PROJECT_DIR/applications/solvers/multiphase/interFoam/interDyMFoam $WM_PROJECT_USER_DIR/applications/solvers/waves2Foam/applications/solvers/solvers17/waveFoam/

2. Now modify the name of copied folder to waveDyMFoam (or whatever name you want... but it looks fine):

cd $WM_PROJECT_USER_DIR/applications/solvers/waves2Foam/applications/solvers/solvers17/waveFoam
mv interDyMFoam/ waveDyMFoam

3. Clean the compiled solver and modify the name of C file:

cd waveDyMFoam
wclean
mv interDyMFoam.C waveDyMFoam.C

4. Now we must follow the guidelines in section 3.2 (but with some difference, as for example, we don’t need modify createFields.H since it’s read from one level-up):

  • Add the following line in waveDyMFoam.C
#include "relaxationZone.H"
  • Inside main in waveDyMFoam.C add the following two lines just below #include "initContinuityErrs.H" and above createFields.H
#include "readGravitationalAcceleration.H"
#include "readWaveProperties.H"
  • After the line in waveDyMFoam.C stating #include "alphaEqnSubCycle.H" add
relaxing.correct();

5. Now we need set properly the Make files. First, open and modify ‘Make/files’:

waveDyMFoam.C

EXE = $(FOAM_USER_APPBIN)/waveDyMFoam

6. And in ‘Make/options’ do:

  • After -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ add:
-I./../../../../../src/lnInclude
  • And add the following lines at the very bottom
-L$(FOAM_USER_LIBBIN) \
-lwaves2Foam
  • REMEMBER to add the two new needed \ at the end of lines:
-I$(LIB_SRC)/meshTools/lnInclude
-ltopoChangerFvMesh

7. At main directory, compile the new solver typing:

wmake

8. It’s done ;)

This tutorial section is an adaptation to wiki from:

https://sites.google.com/site/jordimuela/openfoam/how-to-couple-waves2foam-with-dynamic-mesh-motion

4 Utilities

4.1 Pre-processing

4.1.1 setWaveParameters

This utility runs through every sub-dictionary (SD) in the dictionary waveProperties.input. A pointer to a derived class of setWaveProperties is generated for each SD; the pointer is based on the entry waveType. If the necessary input is available, the additional wave parameters are computed.

The derived data and the other needed input are written to the file waveProperties, which is subsequently used in the simulations.

As of revision 1982 the utility has become independent on the mesh, so unnecessary time for loading the computational mesh is avoided. This loading could potentially take a long time and on really big meshes prevent the execution on a serial machine.

4.1.2 relaxationZoneLayout

A tool for visualising the relaxation fields in the computational domain. It also depicts the orientation of the relaxation zone. A tutorial is availabel.

4.1.3 setWaveField

This utility sets the initial condition in the computational domain. The entry initializationName in waveProperties defines which sub-dictionary is used for initialising the wave field.

NB! Note that the ramp-up factor is multiplied onto the expressions also during initialization of the computational domain. Hence, in order not to get a horizontal water surface and stagnant water, the parameter Tsoft should be given a value of 0.0; Tsoft is typically set to the wave period as default and is not required by most of the wave theories.

4.2 Post / Run-Time Data Extraction

4.2.1 surfaceElevation

This utility is a specialisation of the OpenFoam/src/sampling/sampledSet/sampledSets in such a way that the sampled (scalar) quantity is integrated along a line defined in the file surfaceElevationDict. The utility is intended to by used as a post-processing utility, where the void ratio field is integrated along a vertical line, which yields the location of the free surface.

Since it is a specialisation of the native sample-utility, it runs both in serial and parallel modes. The two calls are as

surfaceElevation [-latestTime] [-time ranges]
mpirun -np NPROCS surfaceElevation -parallel [-latestTime] [-time ranges]
4.2.1.1 Input File

An example of the input file is placed in applications/utilities/postProcessing/surfaceElevation. The rules are the same as for sampleDict, however, it only makes sense to sample the void ratio field, e.g. gamma or alpha1.

The utility only considers scalar fields.

4.2.1.2 Output File

The output file is placed in surfaceElevation/startTime/surfaceElevation.dat, and it contains all the sampled data for all sampled time steps. The formatting is as follows:

Time lineName0 lineName1 lineName2 // Merely some string references
-1   x0        x1        x2        // The x-coordinates of the first point on the sampling line. -1 has no meaning.
-2   y0        y1        y2        // The y-coordinates of the first point on the sampling line. -2 has no meaning. 
-3   z0        z1        z2        // The y-coordinates of the first point on the sampling line. -3 has no meaning.
0.0  eta0      eta1      eta2      // The elevation for Time = 0.0 s
0.1  eta0      eta1      eta2      // The elevation for Time = 0.1 s
0.2  eta0      eta1      eta2      // The elevation for Time = 0.2 s
0.3  eta0      eta1      eta2      // The elevation for Time = 0.3 s
0.4  eta0      eta1      eta2      // The elevation for Time = 0.4 s
0.5  eta0      eta1      eta2      // The elevation for Time = 0.5 s
4.2.1.3 Why -1e15 ?

The value -1e15 is written to the output file under the following circumstances:

  • The number of points along the integration line is less than 2.
  • Both the top and the bottom integration points are either 0 or 1 within a tolerance of 0.0001. -1e15 is preferred as this suggests the integration line to be fully inside or outside of the water column.
4.2.1.4 Used as FunctionObject

The utility can also be used as a functionObject. The tutorial waveFlume includes an example on how to use it.

In this mode a couple of additional time controls has been implemented into surfaceElevation. These are

samplingStartTime <scalar>; // Default value: 0.0

This stalls the sampling of the interface location until the specified starting time is exceeded.

surfaceSampleDeltaT <scalar>; // Default value: -1.0

This value only has an effect, if it is strictly larger than 0.0. It modifies the output time for the sampling, so it is not control by neither a constant number of time steps nor the global output time. This allows for a sub-time step output of the surface elevation and thus saves disk space. This delta time does not feed back into the global setting of the time step, thus the output is only at intervals of approximately surfaceSampleDeltaT, where the accuracy obviously increases with decreasing deltaT / surfaceSampleDeltaT. So forth this ratio exceeds 1, one or more outputs is simply omitted.

For optimal uses of the surfaceSampleDeltaT, it is also recommended to specify the following

outputControl timeStep;
outputInterval 1;
4.2.1.5 Compatibility

This utility has been tested for compatibility with OF-1.6, OF-1.7, OF-2.0 and OF-2.1.

The utility does not compile with OF-1.5.

5 waveProperties File

The file: waveProperties is to be placed in constant and must contain the following:

seaLevel 0.0; // Defines the still water level
wind (0.0 0.0 0.0); // Defines the velocity in the air part. Not needed. Default value:= vector::zero.
relaxationNames ( <word0> <word1> ); // The list of names of the relaxation zones used in the simulation
initializationName <wordN>; // Used by setWaveField and it is the sub-dictionary, 
                            // which defines which wave theory to be used for initialization
pName <word>;

Furthermore, sub-dictionaries are needed for every boundary, which uses any of the boundary conditions:

waveAlphaFvPatchScalarField    (type: waveAlpha)
wavePressureFvPatchScalarField (type: wavePressure)
waveVelocityFvPatchVectorField (type: waveVelocity)

and for all of the relaxationNames and the initializationName. The name of the sub-dictionaries are e.g.

<word0>+Coeffs

Please note that if an boundary called inlet uses one or several of the boundary conditions, then it is allowed for instance to have a relaxation zone called inlet in order not to duplicate the input.

An example of a combined boundary and relaxation zone input is given here, where Stokes first order wave theory (Airy wave) is the input

inletCoeffs
{
   // Wave type to be used at boundary "inlet" and in relaxation zone "inlet"
   waveType    stokesFirst;  
    
   // Ramp time of 2 s
   // Foam::sin(2 * mathematicalConstant::pi / (4.0 * Tsoft_) * Foam::min(Tsoft_, runTime.time().value() ))
   // and explicitly "1" for Tsoft = 0
   Tsoft       2;

   // Water depth at the boundary and in the relaxation zone
   depth       0.400000;

   // Period - needed by setWaveParameters -> yields omega
   period      2.0;

   // Cyclic wave frequency
   omega       3.141593;

   // Phase shift in the wave
   phi         0.000000;

   // Wave propagation direction - needed by setWaveParameters -> yields k with period and depth
   direction   (1 0 0);

   // Wave number vector, k. 
   waveNumber  (1.70048 0.0 0.0);

   // Wave height
   height      0.1;
    
   // Specifications on the relaxation zone shape and relaxation scheme
   relaxationZone
   {
       relaxationScheme Spatial;
       relaxationShape  Rectangular;
       beachType        Empty;
   
       startX           (0 0.0 -1);
       endX             (5 0.0  1);
       orientation      (1.0 0.0 0.0);

       // Additional optional arguments
       relaxationWeight Exponential; //Default and otherwise: FreePolynomial, ThirdOrderPolynomial
       courantCorrection off; // Default and otherwise: on
   }
};

6 Tutorials

6.1 Overview

This table shows, which tutorials are are set up to use the different functionalities functionalities:

Name of tutorial relaxationZoneLayout relaxationZones setWaveParameters setWaveField waveFoam surfaceElevation
relaxationZoneLayout Yes Yes No No No No
waveFlume No Yes No Yes Yes Yes (runTime)
standingWave No Yes No Yes Yes No
3Dwaves No Yes Yes Yes Yes No
periodicSolitary No No No Yes Yes No
squarePile No Yes No Yes Yes No

6.2 Use of relaxationZoneLayout

6.2.1 Relaxation Zone Layout

  • Name: tutorials/relaxationZoneLayout
  • Utility: relaxationZoneLayout
  • Description: This tutorial will show how to use the utility to obtain a visual on the relaxation zones. This could be helpful to detect potential problems in the setup.

6.3 Use of waveFoam

6.3.1 Wave Flume

  • Name: tutorials/waveFoam/waveFlume
  • Solver: waveFoam
  • Description: This tutorial will show the user how to use the constant/waveProperties dictionary to set-up the wave properties, relaxation zones and initialization specifications.

6.3.2 Standing Wave

  • Name: tutorials/waveFoam/standingWave
  • Solver: waveFoam
  • Description: This tutorial shows how to handle wave generation and a fully reflecting sea wall utilising the relaxation zone technique.

6.3.3 3D Wave Flume with a Seawall

An example of the surface elevation with waves from 3 directions onto a vertical structure.
  • Name: tutorials/waveFoam/3Dwaves
  • Solver: waveFoam
  • Description: This tutorial shows the use of relaxation zones in 3 dimensions. There are 3 inlet relaxation zones and one outlet relaxation zone. In the middle of the wave tank there is a vertical internal wall on which the waves are reflected. The waves, which are generated in the 3 inlet relaxation zones, have different directions relative to the x-axis.

NB: Some reflection does occur on the wall perpendicular to the wave outlet.

6.3.4 Periodic Solitary

  • Name: tutorials/waveFoam/periodicSolitary
  • Solver: waveFoam
  • Description: This tutorial uses the method for initialising a wave profile, which is different from a flat water surface with a sea-level, which differs from 0 m. The computational domain is cyclic in the direction of wave propagation and the initial field is a solitary wave.

NB: In the simulation a portion of the wave propagates in the opposite direction of the actual wave propagation. It is considered to be due to the fact that the solitary wave theory does not fulfil the non-linear wave problem accurately enough, which is why a part of the wave energy is reflected on the wave itself. It has been tested to initialise with and without the analytical expression for the excess pressure, however, it does not make a difference. Experimental evidence of this behaviour is reported in [4].

6.3.5 Square Pile in Cylindrical Domain

The surface elevation around a square pile in a constant and unidirectional current. The gray area is the relaxation zone.
  • Name: tutorials/waveFoam/squarePile
  • Solver: waveFoam
  • Description: This tutorial shows how to use the cylindrical relaxation zone. A unidirectional current is the target function all the way around, hence one relaxation zone acts as both generation and absorption. The relaxation zone removes the internally generated surface disturbances. It could be interesting to have it tested for ships waves. Alternatively, a better shape for that purpose, e.g. an elliptical relaxation zone shape could be implemented.

NB: Generating waves in the computational domain in this tutorial will give bad results. This is a direct consequence of the huge variation in cells per wave length depending on the location in the domain and not the relaxation method! Particular attention should be given to circular domains with waves.

7 Compatibility

The toolbox has been tested successfully with the following releases of OpenFoam:

  • 1.5.x (up to revision 1950)
  • 1.5-dev (up to revision 1950)
  • 1.6.x (Notice, that the release solves for total pressure, and the pressure boundary condition is given in excess pressure. It ought not change anything, however, it has not been tested)
  • 1.6-ext
  • 1.7.1
  • 2.0.x
  • 2.1.x

Please note that throughout the code, pre-processor statements are used based on the argument OFVERSION, which is given as

if [ `uname` == "Darwin" ]
then
    version=`echo $WM_PROJECT_VERSION"-0" | sed -s 's/\.x/-0/' -e 's/\./\'$'\n/g' -e 's/-/\'$'\n/g' | grep "[0-9]" | head -3 | tr -d '\n'`
else
    version=`echo $WM_PROJECT_VERSION"-0" | sed -e 's/\.x/-0/' -e 's/\./\n/g' -e 's/-/\n/g' | grep "[0-9]" | head -3 | tr -d '\n'`
fi
export WM_PROJECT_VERSION_NUMBER=$version

which strips anything but the first three digits from $WM_PROJECT_VERSION (and in case it only contains 2, it is zero-padded). This also take into account that the scripting arguments are different on Linux and Darwin.

Furthermore note, that the dev/ext branches has an additional library called liblduSolvers.so, hence in the Allwmake script, linking to this particular library is stripped from all solvers, if $WM_PROJECT_VERSION contain neither of the strings dev and ext. When migrating to any of these versions, it is recommended to make a clean checkout.

8 Development / On-going and Future

  • In connection with each of the wave theories in src/waveTheories/, there should be a corresponding file in src/setWaveProperties/, which computes all of the necessary properties based on a minimum number of inputs, e.g. have height, H, water depth, h, and wave period, T.
This work is still ongoing, hence for those waves missing a property-file, the pre-processing tool setWaveParameters will fail.
  • Tests with other outlet boundary types [5][6]
  • The pressure gradient points in the direction of the boundary face, irrespectively of the fact that it should be corrected for the angle between wave propagation and the direction of the boundary face.
  • The pressure gradient is not implemented in all of the wave theories - returns instead \partial p/\partial n = 0.0.

9 Download and Installation

9.1 Dependencies

Besides the standard dependencies in OpenFoam, waves2Foam also depend on Gnu Scientific Library (GSL). This is needed for two reasons:

  • In the cnoidal wave theory one has to evaluate Jacobian elliptic functions and complete elliptic integrals. These are not natively available in OpenFoam.
  • A pre-processing tool, which is currently being developed, computes the needed wave parameters giving the minimal number of input parameters. This quickly results in a set of N non-linear sets of equations in N unknowns. For this purpose GSL is currently being used.

GSL can e.g. be downloaded using the following commands[7]

Ubuntu: sudo apt-get install libgsl0-dev
Fedora: sudo yum install gsl-devel
Suse:   sudo zypper install gsl-devel

Please be aware that the location for GSL might differ between OS's, hence the include paths in the options-files could be wrong. If you have successfully installed GSL and the compilation complains over missing header files or libraries, this is the first place to look.

9.2 SVN on SourceForge

The toolbox is available through the OpenFoam-Extend SourceForge SVN. Check out the code in the following manner:

svn co https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.6/other/waves2Foam

NB! as long as the SVN is down. NB!: Due to some copyright issues the sourceForge for Openfoam-Extend is down. Until further notice a static version of waves2Foam can be downloaded here:

http://www.student.dtu.dk/~ngja/waves2Foam.tar.gz

9.3 Installation

  • Install GSL as described above
  • Obtain the source code via SVN as described above
  • Execute the Allwmake script in the folder waves2Foam

10 Modifications to the Source Code (History)

  • 2012-12-03 12:52:40: (r1984) Added second order bichromatic waves. Set numerical beach type to "Empty" as defalt.
  • 2012-11-29 15:10:18: (r1983) Added wave theory. Automatic enhanced write precision for cnoidal waves parameters. Slight change to waveTheory interface.
  • 2012-11-23 15:52:01: (r1982) Changed setWaveParameters so (i) parameters are read from waveProperties.input and written to waveProperties and (ii) it does not depend on the mesh. The latter speeds up the execution (a lot!).
  • 2012-11-18 21:48:17: (r1981) Added a check for validity of second order stokes in the properties file
  • 2012-10-31 15:29:27: (r1980) Bug in compiling setWaveParameters for OFVERSION >= 17. Added pre-processor statement
  • 2012-10-31 14:38:18: (r1979) (i) Bug in bichromaticFirstProperties.C. (ii) Cosmethics in the *Properties files, when writing waveProperties-file
  • 2012-10-18 17:00:21: (r1977) (i) Added solvers for 2.1. (ii) Changed the approach used by setWaveParameters to write waveProperties file. (iii) Updated headers with publication data on the journal article. (iv) Added the file sourceCodeStructure_r1923.svg in the doc directory.
  • 2012-10-17 12:04:01: (r1976) Removed all pre-processing if's related to version 15. Altered the OFVERSION pre-processor to work on e.g. 211 and 160 rather than 21 and 16.
  • 2012-10-01 11:49:20: (r1975) Modified the tutorials, so they are also running under OF2.1
  • 2012-09-10 21:29:21: (r1973) Corrected infinite loop in the computation of the wave number, when kh > 60 (extreme deep water).
  • 2012-08-16 09:44:50: (r1972) Added an option for a local sealevel in potentialCurrent
  • 2012-07-13 20:51:52: (r1969) Added the following: (i) runTime selection of relaxation zone weights, (ii) a local correction to relaxation weight based on the local Courant number, (iii) update of relaxationZoneLayout to show the weight and (iv) added interface for numerical beach in UEqn.H but still not functional.
  • 2012-06-08 12:09:21: (r1967) Added some post-processing utilities to be used in matlab and modified the misc/matlab file structure. Minor bug-fix in generateStreamFile.m so the output file is consistent with the format in waves2Foam.
  • 2012-05-16 10:44:43: (r1966) Corrected bug in matlab script for stream function theory (previous results correct, if the program could finalise!)
  • 2012-05-15 12:01:18: (r1965) Additional output time control for the surfaceElevation utility. Especially needed under functionObject functionality
  • 2012-05-10 14:37:47: (r1961) Added a optional starting time for the surface elevation sampling
  • 2012-05-09 14:18:23: (r1960) Added phase-lag (phi_) in streamFunction.C
  • 2012-05-03 13:22:43: (r1953) Added functionObject functionality for sampledSurfaceElevation. Included in the tutorial waveFlume.
  • 2012-05-02 10:11:01: (r1952) Modification to Allwmake and src/Allwmake so "sed" also works under Mac OSX.
  • 2012-04-30 21:28:20: (r1951) Added a post-processing utility, which can be used to extract the surface elevation. As of now, version 1.5 is no longer supported.
  • 2012-04-11 10:13:10: (r1947) Bug in Allwmake script
  • 2012-03-26 21:45:20: (r1945) Changed the way setWaveProperties output irregular wave properties. Adjusted irregular waveTheory accordingly.
  • 2012-03-17 15:56:02: (r1944) Solved bug in convexPolyhedral. Furthermore added an addition relaxation shape (semiCircular)
  • 2012-03-13 16:13:42: (r1943) Minor changes
  • 2012-02-19 14:45:14: (r1940) Added the possibility of a wind vector, which is constant in space and time.
  • 2012-01-29 19:15:41: (r1938) Changed the Make/files and Make/options to have the output files in FOAM_USER_LIBBIN and FOAM_USER_APPBIN.
  • 2012-01-28 15:55:34: (r1937) Added a Pierson-Moskowitz spectrum
  • 2012-01-27 13:28:00: (r1936) Added framework for irregular wave spectra - properties and wave theory
  • 2012-01-24 13:20:58: (r1935) Small changes to src/Make/files and the overall Allwmake script in order to avoid the recompilation of waves2Foam on non-dev/ext versions of OF
  • 2012-01-19 16:50:48: (r1934) Modified the code, so PI can be used both in pre- and post-2.0 versions of OpenFoam. It is replaced by PI_(4.0*atan(1.0)) a few neccesary places as a protected member variable.
  • 2011-12-04 20:07:35: (r1932) Added a tutorial showing how to generate a standing wave from a fully reflecting sea wall
  • 2011-11-22 10:02:44: (r1929) Added a tutorial utilising the cylindrical relaxation zone
  • 2011-11-19 01:01:19: (r1928) Added "waveFoam" for 1.7, modified Allwmake script and added necessary files to tutorials due to above change.
  • 2011-11-16 19:22:22: (r1937) setWaveParameters now also works for cnoidalFirst
  • 2011-11-14 20:04:08: (r1926) Added matlab tools for cnoidal and stream function waves
  • 2011-11-14 17:52:52: (r1925) Added a 3D wave tank tutorial
  • 2011-11-10 11:30:30: (r1923) Initial release of waves2Foam - all files

11 References

  1. Jacobsen, N. G., Fuhrman, D. R. and Fredsoe, J. (In print). A Wave Generation Toolbox for the Open-Source CFD Library: OpenFoam® Int. J. of Numerl. Meth. Fluids. DOI: 10.1002/fld.2726
  2. 2.0 2.1 Engsig-Karup, A. P. (2006). Unstructured Nodel DG-FEM Solution of High-order Boussinesq-type Equations. Ph.D. Thesis, Technical University of Denmark.
  3. Seng, S., Jensen, J.J. and Pedersen, P.T. (2012). Numerical prediction of slamming loads. Institution of Mechanical Engineers. Proceedings. Part M: Journal of Engineering for the Maritime Environment, 226(2), 120-134
  4. Grilli, ST, Subramanye, R, Svendsen, IA and Veeramony, J (1994). Shoaling of Solitary Waves on Plane Beaches, Journal of Waterway, Port, Coastal and Ocean Engineering, 120(6), 609-628
  5. Clement, A (1996). Coupling of two absorbing boundary conditions for 2D time-domain simulations of free surface gravity waves. Journal of Computational Physics, pp. 139-151
  6. Ducloc, G, Clement, AH, Chatry, G (2001). Absorption of outgoing waves in a numerical wave tank using a self-adaptive boundary condition. International Journal of Offshore and Polar Engineering, pp. 168-175.
  7. Obtained from: http://lavandula.imim.es/adun-new/?page_id=186


--NGJ 20:10, 04 December 2011 (CET)