GodaJONSWAP.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) 2024 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 "GodaJONSWAP.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 GodaJONSWAP& spectrum
49 )
50 :
51  waveSpectrum(spectrum),
52  Hs_(spectrum.Hs_),
53  Ts_(spectrum.Ts_),
54  gamma_(spectrum.gamma_)
55 {}
56 
57 
59 (
60  const dictionary& dict,
61  const scalar g
62 )
63 :
64  waveSpectrum(dict, g),
65  Hs_(dict.lookup<scalar>("Hs")),
66  Ts_(dict.lookup<scalar>("Ts")),
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 betaJ =
85  0.0624
86  /(0.230 + 0.0336*gamma_ - 0.185/(1.9 + gamma_))
87  *(1.094 - 0.01915*log(gamma_));
88  const scalar Tp = Ts_/(1 - 0.132*pow(gamma_ + 0.2, -0.559));
89  const scalarField sigma(0.07 + 0.02*pos(f - 1/Tp));
90  const scalarField r(exp(- sqr(Tp*f - 1)/(2*sqr(sigma))));
91  return betaJ*sqr(Hs_)/f/pow4(Tp*f)*exp(- 1.25/pow4(Tp*f))*pow(gamma_, r);
92 }
93 
94 
96 (
97  const scalar fraction
98 ) const
99 {
100  const scalar Tp = Ts_/(1 - 0.132*pow(gamma_ + 0.2, -0.559));
101  const scalar f1 = 1/Tp/pow025(rootSmall/1.25);
102  return waveSpectrum::fFraction(fraction, f1);
103 }
104 
105 
107 {
109 
110  writeEntry(os, "Hs", Hs_);
111  writeEntry(os, "Ts", Ts_);
112  writeEntryIfDifferent(os, "gamma", scalar(3.3), gamma_);
113 }
114 
115 
116 // ************************************************************************* //
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 scalar fFraction(const scalar fraction) const
Return the frequency below which a given fraction of the spectrum's.
Definition: GodaJONSWAP.C:96
virtual void write(Ostream &os) const
Write.
Definition: GodaJONSWAP.C:106
GodaJONSWAP(const GodaJONSWAP &spectrum)
Construct a copy.
Definition: GodaJONSWAP.C:47
virtual tmp< scalarField > S(const scalarField &f) const
Evaluate the wave spectral density at the given frequencies [m^2/Hz].
Definition: GodaJONSWAP.C:80
virtual ~GodaJONSWAP()
Destructor.
Definition: GodaJONSWAP.C:73
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
mathematical constants.
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m^2/K^4].
Namespace for OpenFOAM.
dimensionedScalar pos(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 log(const dimensionedScalar &ds)
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