Contrib/waves2Foam

From OpenFOAMWiki
< Contrib
Revision as of 18:04, 10 November 2011 by NGJ (Talk | contribs)

Valid versions: OF version 15.png OF Version 15dev.png OF Version 16ext.png OF Version 171.png OF Version 17x.png

Please report on other successful application of the toolbox

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 Referencing

Whenever used please do make prober 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 = {2011},
Volume = {In print},
Pages = {},
}

2 Distributed Library

2.1 Overview of Content

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 pressure gradient. It is optional to implement the actual pressure. The set of wave theories presently available is given below.
  • 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. Set below.
  • A relaxation framework around the class relaxationZone, where combinations of relaxation techniques and the shape of relaxation zones can be chosen.
  • 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 boundary conditions and a class for setting initial conditions are part of the library.

2.2 Available Wave Theories

The library is distributed with the following wave theories

2.2.1 Current-type

2.2.1.1 Potential current type (uniform velocity distribution from bottom to seaLevel)
+++ Example - setWaveParameters and Running +++
waveType potentialCurrent;
Tsoft    <scalar>;
U        <vector>;

2.2.2 Regular waves

2.2.2.1 Stokes first order wave theory (Airy wave)
+++ Example - setWaveParameters +++
waveType   stokesFirst;
height     <scalar>;
period     <scalar>;
phi        <scalar>;
depth      <scalar>;
direction  <vector>;
Tsoft      <scalar>; // Not required

+++ Example - Running +++
waveType   stokesFirst;
height     <scalar>;
omega      <scalar>;
phi        <scalar>;
depth      <scalar>;
waveNumber <vector>;
Tsoft      <scalar>; // Not required
2.2.2.2 First order Stokes standing wave theory
+++ Example - setWaveParameters +++
waveType   stokesFirstStanding;
height     <scalar>;  // The height of each wave component
period     <scalar>;
phi        <scalar>;
depth      <scalar>;
direction  <vector>;
Tsoft      <scalar>; // Not required

+++ Example - Running +++
waveType   stokesFirstStanding;
height     <scalar>;  // The height of each wave component
omega      <scalar>;
phi        <scalar>;
depth      <scalar>;
waveNumber <vector>;
Tsoft      <scalar>; // Not required
2.2.2.3 Stokes second order wave theory
+++ Example - setWaveParameters +++
waveType   stokesSecond;
height     <scalar>;
period     <scalar>;
phi        <scalar>;
depth      <scalar>;
direction  <vector>;
Tsoft      <scalar>; // Not required

+++ Example - Running +++
waveType   stokesSecond;
height     <scalar>;
omega      <scalar>;
phi        <scalar>;
depth      <scalar>;
waveNumber <vector>;
Tsoft      <scalar>; // Not required
2.2.2.4 Stokes fifth order wave theory
2.2.2.5 First order cnoidal theory
2.2.2.6 Stream function wave theory

2.2.3 Irregular waves

2.2.3.1 First order bi-chromatic wave train (wave group)

2.2.4 Other

2.2.4.1 combinedWaves, which allows for a combination of any of the above

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 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()

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.

4 Utilities

4.1 Pre-processing

4.1.1 setWaveParameters

This utility runs through every sub-dictionary (SD) in the dictionary waveProperties. 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, any additional wave parameter, which is needed in the simulation is written to SD.

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.

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
relaxationNames ( <word0> <word1> ); // The list of names of the relaxation zones used in the simulation
initializationName <wordN>; // Used by setWaveField and is the sub-dictionary, 
                            // which defines what wave theory to use for initialization

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;

   // Cyclic wave frequency
   omega       3.141593;

   // Phase shift in the wave
   phi         0.000000;

   // 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;
   
       startX           (0 0.0 -1);
       endX             (5 0.0  1);
       orientation      (1.0 0.0 0.0);
   }
};

6 Tutorials

6.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.2 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 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.

7 Compatibility

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

  • 1.5.x
  • 1.5-dev
  • 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

Because of considerable changes in the source code of OpenFoam between version 1.5 and 1.6, there exist a solvers15 and a solvers directory. Please also note that throughout the code, pre-processor choice are made based on the argument OFVERSION, which is given as

OFVERSION=`echo $WM_PROJECT_VERSION | sed -e 's/\./\n/g' -e 's/-/\n/' | grep "[0-9]" | tr -d '\n'`

which strips anything but the numbers from $WM_PROJECT_VERSION.

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. Moving to these versions it is henceforth 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 [1][2]
  • 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[3]

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

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 References

  1. 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
  2. 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.
  3. Obtained from: http://lavandula.imim.es/adun-new/?page_id=186

--NGJ 22:30, 08 November 2011 (CET)