angularOscillatingDisplacementPointPatchVectorField.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  axis_(dict.lookup<vector>("axis", dimless)),
48  origin_(dict.lookup<vector>("origin", dimLength)),
49  angle0_(dict.lookup<scalar>("angle0", units::radians)),
50  amplitude_(dict.lookup<scalar>("amplitude", units::radians)),
51  omega_(dict.lookup<scalar>("omega", units::radians/dimTime))
52 {
53  if (!dict.found("value"))
54  {
55  updateCoeffs();
56  }
57 
58  if (dict.found("p0"))
59  {
60  p0_ = vectorField("p0", dimLength, dict, p.size());
61  }
62  else
63  {
64  p0_ = p.localPoints();
65  }
66 }
67 
68 
71 (
73  const pointPatch& p,
75  const fieldMapper& mapper
76 )
77 :
78  fixedValuePointPatchVectorField(ptf, p, iF, mapper),
79  axis_(ptf.axis_),
80  origin_(ptf.origin_),
81  angle0_(ptf.angle0_),
82  amplitude_(ptf.amplitude_),
83  omega_(ptf.omega_),
84  p0_(mapper(ptf.p0_))
85 {}
86 
87 
90 (
93 )
94 :
95  fixedValuePointPatchVectorField(ptf, iF),
96  axis_(ptf.axis_),
97  origin_(ptf.origin_),
98  angle0_(ptf.angle0_),
99  amplitude_(ptf.amplitude_),
100  omega_(ptf.omega_),
101  p0_(ptf.p0_)
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
108 (
109  const pointPatchVectorField& ptf,
110  const fieldMapper& mapper
111 )
112 {
114  refCast<const angularOscillatingDisplacementPointPatchVectorField>(ptf);
115 
116  fixedValuePointPatchVectorField::map(aODptf, mapper);
117 
118  mapper(p0_, aODptf.p0_);
119 }
120 
121 
123 (
124  const pointPatchVectorField& ptf
125 )
126 {
128  refCast<const angularOscillatingDisplacementPointPatchVectorField>(ptf);
129 
130  fixedValuePointPatchVectorField::reset(aODptf);
131 
132  p0_.reset(aODptf.p0_);
133 }
134 
135 
137 {
138  if (this->updated())
139  {
140  return;
141  }
142 
143  const polyMesh& mesh = this->internalField().mesh()();
144  const Time& t = mesh.time();
145 
146  scalar angle = angle0_ + amplitude_*sin(omega_*t.value());
147  vector axisHat = axis_/mag(axis_);
148  vectorField p0Rel(p0_ - origin_);
149 
151  (
152  p0Rel*(cos(angle) - 1)
153  + (axisHat ^ p0Rel*sin(angle))
154  + (axisHat & p0Rel)*(1 - cos(angle))*axisHat
155  );
156 
157  fixedValuePointPatchVectorField::updateCoeffs();
158 }
159 
160 
162 (
163  Ostream& os
164 ) const
165 {
167  writeEntry(os, "axis", axis_);
168  writeEntry(os, "origin", origin_);
169  writeEntry(os, "angle0", angle0_);
170  writeEntry(os, "amplitude", amplitude_);
171  writeEntry(os, "omega", omega_);
172  writeEntry(os, "p0", p0_);
173  writeEntry(os, "value", *this);
174 }
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
180 (
183 );
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace Foam
188 
189 // ************************************************************************* //
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...
void reset(const Field< Type > &)
Reset the field values to the given field.
Definition: Field.C:456
friend Ostream & operator(Ostream &, const Field< vector > &)
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
angularOscillatingDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
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.
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
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 & dimless
Definition: dimensions.C:138
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.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dimensionedScalar cos(const dimensionedScalar &ds)
dictionary dict
volScalarField & p