regularWaveModel.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2015 IH-Cantabria
9 Copyright (C) 2016-2018 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "regularWaveModel.H"
30#include "unitConversion.H"
31
32using namespace Foam::constant;
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
38namespace waveModels
39{
41}
42}
43
44
45// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
46
48{
49 scalar waveK = 2.0*mathematical::pi/waveLength_;
50
51 word generation = "Intermediate";
53 {
54 generation = "Deep";
55 }
56 else if (waveK*waterDepthRef_ < 0.1*mathematical::pi)
57 {
58 generation = "Shallow";
59 }
60
61 return generation;
62}
63
64
65// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66
68(
69 const dictionary& dict,
70 const fvMesh& mesh,
71 const polyPatch& patch,
72 const bool readFields
73)
74:
75 irregularWaveModel(dict, mesh, patch, false),
76 waveHeight_(0),
77 waveAngle_(0),
78 wavePeriod_(0),
79 waveLength_(0),
80 wavePhase_(1.5*mathematical::pi)
81{
82 if (readFields)
83 {
85 }
86}
87
88
89// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90
92(
93 const dictionary& overrideDict
94)
95{
96 if (irregularWaveModel::readDict(overrideDict))
97 {
98 waveHeight_ = readWaveHeight();
99 waveAngle_ = readWaveAngle();
100
101 readEntry("wavePeriod", wavePeriod_);
102
103 if (wavePeriod_ < 0)
104 {
106 << "Wave period must be greater than zero. Supplied"
107 << " value wavePeriod = " << wavePeriod_
108 << exit(FatalIOError);
109 }
110
111 readIfPresent("wavePhase", wavePhase_);
112
113 // Note: waveLength to be set in derived classes
114
115 return true;
116 }
117
118 return false;
119}
120
121
123{
125
126 os << " Wave height : " << waveHeight_ << nl
127 << " Wave angle : " << radToDeg(waveAngle_) << nl
128 << " Wave period : " << wavePeriod_ << nl
129 << " Wave length : " << waveLength_ << nl
130 << " Wave phase : " << wavePhase_ << nl;
131}
132
133
134// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
InfoProxy< ensightCells > info() const
Return info proxy.
Definition: ensightCells.H:254
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
scalar waterDepthRef_
Reference water depth / [m].
Definition: waveModel.H:115
virtual word waveType() const
Return word description of wave type.
virtual bool readDict(const dictionary &overrideDict)
Read from dictionary.
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
OBJstream os(runTime.globalPath()/outputName)
constexpr scalar pi(M_PI)
Different types of constants.
Namespace for OpenFOAM.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
constexpr scalar radToDeg() noexcept
Multiplication factor for radians to degrees conversion.
IOerror FatalIOError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
Unit conversion functions.
propsDict readIfPresent("fields", acceptFields)