waveDisplacementPointPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 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 
28 #include "Time.H"
29 #include "polyMesh.H"
30 #include "OneConstant.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
36 (
37  const pointPatch& p,
39  const dictionary& dict
40 )
41 :
42  fixedValuePointPatchVectorField(p, iF, dict),
43  amplitude_(dict.lookup<vector>("amplitude", dimLength)),
44  omega_(dict.lookup<scalar>("omega", units::radians/dimTime)),
45  waveNumber_
46  (
47  dict.lookupOrDefault<vector>("waveNumber", dimless/dimLength, Zero)
48  ),
49  startRamp_
50  (
51  dict.found("startRamp")
52  ? Function1<scalar>::New("startRamp", dimless, dimless, dict)
53  : autoPtr<Function1<scalar>>
54  (
55  new Function1s::OneConstant<scalar>("startRamp")
56  )
57  ),
58  endRamp_
59  (
60  dict.found("endRamp")
61  ? Function1<scalar>::New("endRamp", dimless, dimless, dict)
62  : autoPtr<Function1<scalar>>
63  (
64  new Function1s::OneConstant<scalar>("endRamp")
65  )
66  ),
67  timeRamp_
68  (
69  dict.found("timeRamp")
70  ? Function1<scalar>::New("timeRamp", dimTime, dimless, dict)
71  : autoPtr<Function1<scalar>>
72  (
73  new Function1s::OneConstant<scalar>("timeRamp")
74  )
75  )
76 {
77  if (!dict.found("value"))
78  {
79  updateCoeffs();
80  }
81 }
82 
83 
86 (
88  const pointPatch& p,
90  const fieldMapper& mapper
91 )
92 :
93  fixedValuePointPatchVectorField(ptf, p, iF, mapper),
94  amplitude_(ptf.amplitude_),
95  omega_(ptf.omega_),
96  waveNumber_(ptf.waveNumber_)
97 {}
98 
99 
102 (
105 )
106 :
107  fixedValuePointPatchVectorField(ptf, iF),
108  amplitude_(ptf.amplitude_),
109  omega_(ptf.omega_),
110  waveNumber_(ptf.waveNumber_)
111 {}
112 
113 
114 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
115 
117 {
118  if (this->updated())
119  {
120  return;
121  }
122 
123  const polyMesh& mesh = this->internalField().mesh()();
124  const Time& t = mesh.time();
125 
126  const scalarField points(waveNumber_ & patch().localPoints());
127 
128  const scalar timeRamp = timeRamp_->value(t.value());
129 
130  const scalarField startRamp(startRamp_->value(points));
131 
132  const scalarField endRamp
133  (
134  endRamp_->value(points[points.size() - 1] - points)
135  );
136 
138  (
139  timeRamp*startRamp*endRamp*amplitude_*cos(omega_*t.value() - points)
140  );
141 
142  fixedValuePointPatchVectorField::updateCoeffs();
143 }
144 
145 
147 {
149  writeEntry(os, "amplitude", amplitude_);
150  writeEntry(os, "omega", omega_);
151  writeEntry(os, "waveNumber", waveNumber_);
152 
153  if (!isType<Function1s::OneConstant<scalar>>(startRamp_()))
154  {
155  writeEntry(os, startRamp_());
156  }
157 
158  if (!isType<Function1s::OneConstant<scalar>>(endRamp_()))
159  {
160  writeEntry(os, endRamp_());
161  }
162 
163  if (!isType<Function1s::OneConstant<scalar>>(timeRamp_()))
164  {
165  writeEntry(os, timeRamp_());
166  }
167 
168  writeEntry(os, "value", *this);
169 }
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 namespace Foam
175 {
177  (
180  );
181 }
182 
183 // ************************************************************************* //
bool found
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Run-time selectable general function of one variable.
Definition: Function1.H:62
Templated function that returns the corresponding 1 (one).
Definition: OneConstant.H:59
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const Type & value() const
Return const reference to value.
Abstract base class for field mapping.
Definition: fieldMapper.H:48
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:433
Abstract base class for point-mesh patch fields.
virtual void write(Ostream &) const
Write.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:61
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
waveDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const pointField & points
const dimensionSet dimless
const unitSet radians
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
makePointPatchTypeField(pointPatchVectorField, angularOscillatingDisplacementPointPatchVectorField)
const dimensionSet & dimLength
Definition: dimensions.C:141
bool isType(const Type &t)
Check the typeid.
Definition: typeInfo.H:170
const dimensionSet & dimTime
Definition: dimensions.C:142
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dimensionedScalar cos(const dimensionedScalar &ds)
dictionary dict
volScalarField & p