Loading...
Searching...
No Matches
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;
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
38namespace waveModels
39{
40 defineTypeNameAndDebug(regularWaveModel, 0);
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 }
61 return generation;
62}
63
64
65// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66
67Foam::waveModels::regularWaveModel::regularWaveModel
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// ************************************************************************* //
constexpr scalar pi(M_PI)
propsDict readIfPresent("fields", acceptFields)
InfoProxy< IOobject > info() const noexcept
Return info proxy, for printing information to a stream.
Definition IOobject.H:1041
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect,...
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
scalar waterDepthRef_
Reference water depth / [m].
Definition waveModel.H:143
virtual bool readDict(const dictionary &overrideDict)
Read from dictionary.
virtual word waveType() const
Return word description of wave type.
scalar waveHeight_
Wave height / [m].
scalar waveAngle_
Wave angle / [rad] (read in degrees).
virtual bool readDict(const dictionary &overrideDict)
Read from dictionary.
scalar readWaveAngle() const
Helper function to read the wave angle from the coeff dictionary.
scalar readWaveHeight() const
Helper function to read the wave height from the coeff dictionary.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
OBJstream os(runTime.globalPath()/outputName)
Mathematical constants.
constexpr scalar pi(M_PI)
Different types of constants.
Namespace for OpenFOAM.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
constexpr scalar radToDeg() noexcept
Multiplication factor for radians to degrees conversion.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict
Unit conversion functions.