oscillatingVelocityPointPatchVectorField.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 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
40 (
41  const pointPatch& p,
43  const dictionary& dict
44 )
45 :
46  fixedValuePointPatchVectorField(p, iF, dict),
47  amplitude_(dict.lookup<vector>("amplitude", dimLength)),
48  omega_(dict.lookup<scalar>("omega", units::radians/dimTime))
49 {
50  if (!dict.found("value"))
51  {
52  updateCoeffs();
53  }
54 
55  if (dict.found("p0"))
56  {
57  p0_ = vectorField("p0", dimLength, dict, p.size());
58  }
59  else
60  {
61  p0_ = p.localPoints();
62  }
63 }
64 
65 
68 (
70  const pointPatch& p,
72  const fieldMapper& mapper
73 )
74 :
75  fixedValuePointPatchVectorField(ptf, p, iF, mapper),
76  amplitude_(ptf.amplitude_),
77  omega_(ptf.omega_),
78  p0_(mapper(ptf.p0_))
79 {}
80 
81 
84 (
87 )
88 :
89  fixedValuePointPatchVectorField(ptf, iF),
90  amplitude_(ptf.amplitude_),
91  omega_(ptf.omega_),
92  p0_(ptf.p0_)
93 {}
94 
95 
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97 
99 (
100  const pointPatchVectorField& ptf,
101  const fieldMapper& mapper
102 )
103 {
105  refCast<const oscillatingVelocityPointPatchVectorField>(ptf);
106 
107  fixedValuePointPatchVectorField::map(oVptf, mapper);
108 
109  mapper(p0_, oVptf.p0_);
110 }
111 
112 
114 (
115  const pointPatchVectorField& ptf
116 )
117 {
119  refCast<const oscillatingVelocityPointPatchVectorField>(ptf);
120 
121  fixedValuePointPatchVectorField::reset(oVptf);
122 
123  p0_.reset(oVptf.p0_);
124 }
125 
126 
128 {
129  if (this->updated())
130  {
131  return;
132  }
133 
134  const polyMesh& mesh = this->internalField().mesh()();
135  const Time& t = mesh.time();
136  const pointPatch& p = this->patch();
137 
139  (
140  (p0_ + amplitude_*sin(omega_*t.value()) - p.localPoints())
141  /t.deltaTValue()
142  );
143 
144  fixedValuePointPatchVectorField::updateCoeffs();
145 }
146 
147 
149 {
151  writeEntry(os, "amplitude", amplitude_);
152  writeEntry(os, "omega", omega_);
153  writeEntry(os, "p0", p0_);
154  writeEntry(os, "value", *this);
155 }
156 
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
161 (
164 );
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 } // End namespace Foam
169 
170 // ************************************************************************* //
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...
Pre-declare SubField and related Field type.
Definition: Field.H:83
void reset(const Field< Type > &)
Reset the field values to the given field.
Definition: Field.C:456
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
scalar deltaTValue() const
Return time step value.
Definition: TimeStateI.H:34
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
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
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void reset(const pointPatchVectorField &)
Reset the pointPatchField to the given pointPatchField.
virtual void map(const pointPatchVectorField &, const fieldMapper &)
Map the given pointPatchField onto this pointPatchField.
oscillatingVelocityPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
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
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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.
makePointPatchTypeField(pointPatchVectorField, angularOscillatingDisplacementPointPatchVectorField)
const dimensionSet & dimLength
Definition: dimensions.C:141
dimensionedScalar sin(const dimensionedScalar &ds)
const dimensionSet & dimTime
Definition: dimensions.C:142
Field< vector > vectorField
Specialisation of Field<T> for vector.
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dictionary dict
volScalarField & p