waveModel.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2017 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 "waveModel.H"
27 #include "mathematicalConstants.H"
28 #include "Time.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(waveModel, 0);
36  defineRunTimeSelectionTable(waveModel, objectRegistry);
37 }
38 
39 
40 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
41 
42 Foam::scalar Foam::waveModel::k() const
43 {
44  return 2*Foam::constant::mathematical::pi/length_;
45 }
46 
47 
48 Foam::scalar Foam::waveModel::sigma() const
49 {
51  db_.lookupObject<uniformDimensionedVectorField>("g");
52 
53  return sqrt(mag(g.value())*k()*tanh(k()*depth()));
54 }
55 
56 
57 Foam::scalar Foam::waveModel::omega(const scalar u) const
58 {
59  return sigma() + k()*u;
60 }
61 
62 
64 (
65  const scalar t,
66  const scalar u,
67  const scalarField& x
68 ) const
69 {
70  return k()*x - omega(u)*t;
71 }
72 
73 
75 {
76  return k()*depth() < log(GREAT);
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
81 
83 :
84  db_(wave.db_),
85  length_(wave.length_),
86  amplitude_(wave.amplitude_, false),
87  phase_(wave.phase_),
88  depth_(wave.depth_)
89 {}
90 
91 
93 :
94  db_(db),
95  length_(readScalar(dict.lookup("length"))),
96  amplitude_(Function1<scalar>::New("amplitude", dict)),
97  phase_(readScalar(dict.lookup("phase"))),
98  depth_(dict.lookupOrDefault<scalar>("depth", GREAT))
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
103 
105 {}
106 
107 
108 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
109 
111 {
112  os.writeKeyword("length") << length_ << token::END_STATEMENT << nl;
113  amplitude_->writeData(os);
114  os.writeKeyword("phase") << phase_ << token::END_STATEMENT << nl;
115  os.writeKeyword("depth") << depth_ << token::END_STATEMENT << nl;
116 }
117 
118 
119 // ************************************************************************* //
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:53
dimensionedScalar tanh(const dimensionedScalar &ds)
dictionary dict
tmp< scalarField > angle(const scalar t, const scalar u, const scalarField &x) const
Angle of the oscillation [rad].
Definition: waveModel.C:64
dimensionedScalar log(const dimensionedScalar &ds)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
dimensionedScalar sqrt(const dimensionedScalar &ds)
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m2/K4].
bool shallow() const
Return whether shallow effects are to be included.
Definition: waveModel.C:74
label k
Boltzmann constant.
scalar sigma() const
The intrinsic angular frequency [rad/s].
Definition: waveModel.C:48
stressControl lookup("compactNormalStress") >> compactNormalStress
Generic base class for waves. Derived classes must implement field functions which return the elevati...
Definition: waveModel.H:55
const Type & value() const
Return const reference to value.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
waveModel(const waveModel &wave)
Construct a copy.
Definition: waveModel.C:82
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:262
const dimensionedVector & g
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
virtual ~waveModel()
Destructor.
Definition: waveModel.C:104
static autoPtr< waveModel > New(const objectRegistry &db, const dictionary &dict)
Select.
Definition: newWaveModel.C:31
scalar omega(const scalar u) const
The observed angular frequency [rad/s].
Definition: waveModel.C:57
dimensioned< scalar > mag(const dimensioned< Type > &)
scalar k() const
The angular wavenumber [rad/m].
Definition: waveModel.C:42
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
virtual void write(Ostream &os) const
Write.
Definition: waveModel.C:110
Namespace for OpenFOAM.