PiersonMoskowitz.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 "PiersonMoskowitz.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 PiersonMoskowitz& spectrum
49 )
50 :
51  waveSpectrum(spectrum),
52  U19_5_(spectrum.U19_5_),
53  alpha_(spectrum.alpha_),
54  beta_(spectrum.beta_)
55 {}
56 
57 
59 (
60  const dictionary& dict,
61  const scalar g
62 )
63 :
64  waveSpectrum(dict, g),
65  U19_5_(dict.lookup<scalar>("U19_5")),
66  alpha_(dict.lookupOrDefault<scalar>("alpha", 8.1e-3)),
67  beta_(dict.lookupOrDefault<scalar>("beta", 0.74))
68 {}
69 
70 
71 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
72 
74 {}
75 
76 
77 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
78 
80 (
81  const scalarField& f
82 ) const
83 {
84  const scalarField w(twoPi*f);
85  const scalar w0 = g()/U19_5_;
86  return twoPi*alpha_*sqr(g())/pow5(w)*exp(- beta_*pow4(w0/w));
87 }
88 
89 
91 (
92  const scalarField& f
93 ) const
94 {
95  const scalarField w(twoPi*f);
96  const scalar w0 = g()/U19_5_;
97  const scalar integralSInf = twoPi*alpha_*sqr(g())/(4*beta_*pow4(w0))/twoPi;
98  return integralSInf*exp(- beta_*pow4(w0/w));
99 }
100 
101 
103 (
104  const scalar fraction
105 ) const
106 {
107  const scalar w0 = g()/U19_5_;
108  return w0/pow025(- log(fraction)/beta_)/twoPi;
109 }
110 
111 
113 {
115 
116  writeEntry(os, "U19_5", U19_5_);
117  writeEntryIfDifferent<scalar>(os, "alpha", 8.1e-3, alpha_);
118  writeEntryIfDifferent<scalar>(os, "beta", 0.74, beta_);
119 }
120 
121 
122 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define w0
Definition: blockCreate.C:30
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 ~PiersonMoskowitz()
Destructor.
PiersonMoskowitz(const PiersonMoskowitz &spectrum)
Construct a copy.
virtual scalar fFraction(const scalar fraction) const
Return the frequency below which a given fraction of the spectrum's.
virtual void write(Ostream &os) const
Write.
virtual tmp< scalarField > integralS(const scalarField &f) const
Evaluate the integral of the wave spectral density at the given.
virtual tmp< scalarField > S(const scalarField &f) const
Evaluate the wave spectral density at the given frequencies [m^2/Hz].
Base class for wave spectra.
Definition: waveSpectrum.H:50
virtual void write(Ostream &os) const
Write.
Definition: waveSpectrum.C:207
mathematical constants.
const scalar twoPi(2 *pi)
Namespace for OpenFOAM.
dimensionedScalar pow5(const dimensionedScalar &ds)
dimensionedScalar exp(const dimensionedScalar &ds)
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar log(const dimensionedScalar &ds)
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