solitaryWaveModel.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-2017 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 "solitaryWaveModel.H"
30 #include "polyPatch.H"
31 #include "SubField.H"
32 #include "unitConversion.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace waveModels
39 {
40  defineTypeNameAndDebug(solitaryWaveModel, 0);
41 }
42 }
43 
44 
45 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
46 
48 (
49  const scalar t
50 ) const
51 {
52  // Ramping not applicable to solitary waves
53  return 1;
54 }
55 
56 
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 
60 (
61  const dictionary& dict,
62  const fvMesh& mesh,
63  const polyPatch& patch,
64  const bool readFields
65 )
66 :
68  waveHeight_(0),
69  waveAngle_(0),
70  x_
71  (
72  patch.faceCentres().component(0)*cos(waveAngle_)
73  + patch.faceCentres().component(1)*sin(waveAngle_)
74  ),
75  x0_(gMin(x_))
76 {
77  if (readFields)
78  {
79  readDict(dict);
80  }
81 }
82 
83 
84 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 
87 (
88  const dictionary& overrideDict
89 )
90 {
91  if (waveGenerationModel::readDict(overrideDict))
92  {
93  waveHeight_ = readWaveHeight();
94  waveAngle_ = readWaveAngle();
95 
96  return true;
97  }
98 
99  return false;
100 }
101 
102 
104 {
106 
107  os << " Wave height : " << waveHeight_ << nl
108  << " Wave angle : " << radToDeg(waveAngle_) << nl
109  << " x0: " << x0_ << nl;
110 }
111 
112 
113 // ************************************************************************* //
SubField.H
polyPatch.H
Foam::waveModels::solitaryWaveModel::waveHeight_
scalar waveHeight_
Wave height / [m].
Definition: solitaryWaveModel.H:59
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:264
solitaryWaveModel.H
unitConversion.H
Unit conversion functions.
Foam::waveModels::solitaryWaveModel::readDict
virtual bool readDict(const dictionary &overrideDict)
Read from dictionary.
Definition: solitaryWaveModel.C:87
Foam::IOobject::info
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:689
Foam::waveModels::solitaryWaveModel::waveAngle_
scalar waveAngle_
Wave angle / [rad] (read in degrees)
Definition: solitaryWaveModel.H:62
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
Foam::waveModels::solitaryWaveModel::x0_
const scalar x0_
Definition: solitaryWaveModel.H:67
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::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::nl
constexpr char nl
Definition: Ostream.H:404
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::waveModels::solitaryWaveModel::solitaryWaveModel
solitaryWaveModel(const dictionary &dict, const fvMesh &mesh, const polyPatch &patch, const bool readFields=true)
Constructor.
Definition: solitaryWaveModel.C:60
Foam::waveModels::waveGenerationModel
Definition: waveGenerationModel.H:49
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::gMin
Type gMin(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:593
Foam::waveModels::defineTypeNameAndDebug
defineTypeNameAndDebug(waveAbsorptionModel, 0)
Foam::waveModels::solitaryWaveModel::timeCoeff
virtual scalar timeCoeff(const scalar t) const
Return the time scaling coefficient.
Definition: solitaryWaveModel.C:48
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265