JONSWAP.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "JONSWAP.H"
27 #include "mathematicalConstants.H"
29 
30 using namespace Foam::constant::mathematical;
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace waveSpectra
37 {
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 (
48  const JONSWAP& spectrum
49 )
50 :
51  waveSpectrum(spectrum),
52  U10_(spectrum.U10_),
53  F_(spectrum.F_),
54  gamma_(spectrum.gamma_)
55 {}
56 
57 
59 (
60  const dictionary& dict,
61  const scalar g
62 )
63 :
64  waveSpectrum(dict, g),
65  U10_(dict.lookup<scalar>("U10")),
66  F_(dict.lookup<scalar>("F")),
67  gamma_(dict.lookupOrDefault<scalar>("gamma", 3.3))
68 {}
69 
70 
71 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
72 
74 {}
75 
76 
77 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
78 
80 (
81  const scalarField& f
82 ) const
83 {
84  const scalar alpha = 0.076*pow(sqr(U10_)/(F_*g()), 0.22);
85  const scalarField w(twoPi*f);
86  const scalar wp = 22*pow(sqr(g())/(U10_*F_), 1.0/3.0);
87  const scalarField sigma(0.07 + 0.02*pos(w - wp));
88  const scalarField r(exp(- sqr(w - wp)/(2*sqr(sigma)*sqr(wp))));
89  return twoPi*alpha*sqr(g())/pow5(w)*exp(- 1.2*pow4(wp/w))*pow(gamma_, r);
90 }
91 
92 
93 Foam::scalar Foam::waveSpectra::JONSWAP::fFraction(const scalar fraction) const
94 {
95  const scalar wp = 22*pow(sqr(g())/(U10_*F_), 1.0/3.0);
96  const scalar f1 = wp/pow025(rootSmall/1.2)/twoPi;
97  return waveSpectrum::fFraction(fraction, f1);
98 }
99 
100 
102 {
104 
105  writeEntry(os, "U10", U10_);
106  writeEntry(os, "F", F_);
107  writeEntryIfDifferent(os, "gamma", scalar(3.3), gamma_);
108 }
109 
110 
111 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for managing temporary objects.
Definition: tmp.H:55
virtual ~JONSWAP()
Destructor.
Definition: JONSWAP.C:73
JONSWAP(const JONSWAP &spectrum)
Construct a copy.
Definition: JONSWAP.C:47
virtual scalar fFraction(const scalar fraction) const
Return the frequency below which a given fraction of the spectrum's.
Definition: JONSWAP.C:93
virtual void write(Ostream &os) const
Write.
Definition: JONSWAP.C:101
virtual tmp< scalarField > S(const scalarField &f) const
Evaluate the wave spectral density at the given frequencies [m^2/Hz].
Definition: JONSWAP.C:80
Base class for wave spectra.
Definition: waveSpectrum.H:50
scalar fFraction(const scalar fraction, const scalar f1) const
Return the frequency below which a given fraction of the spectrum's.
Definition: waveSpectrum.C:105
virtual void write(Ostream &os) const
Write.
Definition: waveSpectrum.C:207
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
mathematical constants.
const scalar twoPi(2 *pi)
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m^2/K^4].
Namespace for OpenFOAM.
dimensionedScalar pos(const dimensionedScalar &ds)
dimensionedScalar pow5(const dimensionedScalar &ds)
dimensionedScalar exp(const dimensionedScalar &ds)
void writeEntryIfDifferent(Ostream &os, const word &entryName, const EntryType &value1, const EntryType &value2)
Helper function to write the keyword and entry only if the.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
defineTypeNameAndDebug(combustionModel, 0)
dimensionedScalar pow4(const dimensionedScalar &ds)
dimensionedScalar pow025(const dimensionedScalar &ds)
labelList f(nPoints)
dictionary dict