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 -------------------------------------------------------------------------------
11 License
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 
32 using namespace Foam::constant;
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace 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";
52  if (waveK*waterDepthRef_ > mathematical::pi)
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 
67 Foam::waveModels::regularWaveModel::regularWaveModel
68 (
69  const dictionary& dict,
70  const fvMesh& mesh,
71  const polyPatch& patch,
72  const bool readFields
73 )
74 :
76  waveHeight_(0),
77  waveAngle_(0),
78  wavePeriod_(0),
79  waveLength_(0),
80  wavePhase_(1.5*mathematical::pi)
81 {
82  if (readFields)
83  {
84  readDict(dict);
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 {
124  irregularWaveModel::info(os);
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 // ************************************************************************* //
Foam::waveModels::irregularWaveModel
Definition: irregularWaveModel.H:49
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::waveModels::regularWaveModel::readDict
virtual bool readDict(const dictionary &overrideDict)
Read from dictionary.
Definition: regularWaveModel.C:92
Foam::constant
Different types of constants.
Definition: atomicConstants.C:38
unitConversion.H
Unit conversion functions.
Foam::FatalIOError
IOerror FatalIOError
regularWaveModel.H
Foam::IOobject::info
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:689
Foam::waveModels::regularWaveModel::waveType
virtual word waveType() const
Return word description of wave type.
Definition: regularWaveModel.C:47
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::radToDeg
constexpr scalar radToDeg(const scalar rad) noexcept
Conversion from radians to degrees.
Definition: unitConversion.H:54
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Definition: ReadFieldsTemplates.C:312
Foam::constant::mathematical::pi
constexpr scalar pi(M_PI)
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)