1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "angularOscillatingDisplacementPointPatchVectorField.H"
28 #include "pointPatchFields.H"
29 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 angularOscillatingDisplacementPointPatchVectorField::
41 angularOscillatingDisplacementPointPatchVectorField
44 const DimensionedField<vector, pointMesh>& iF
47 fixedValuePointPatchVectorField(p, iF),
49 origin_(vector::zero),
57 angularOscillatingDisplacementPointPatchVectorField::
58 angularOscillatingDisplacementPointPatchVectorField
61 const DimensionedField<vector, pointMesh>& iF,
62 const dictionary& dict
65 fixedValuePointPatchVectorField(p, iF, dict),
66 axis_(dict.lookup("axis")),
67 origin_(dict.lookup("origin")),
68 angle0_(readScalar(dict.lookup("angle0"))),
69 amplitude_(readScalar(dict.lookup("amplitude"))),
70 omega_(readScalar(dict.lookup("omega")))
72 if (!dict.found("value"))
79 p0_ = vectorField("p0", dict , p.size());
83 p0_ = p.localPoints();
88 angularOscillatingDisplacementPointPatchVectorField::
89 angularOscillatingDisplacementPointPatchVectorField
91 const angularOscillatingDisplacementPointPatchVectorField& ptf,
93 const DimensionedField<vector, pointMesh>& iF,
94 const PointPatchFieldMapper& mapper
97 fixedValuePointPatchVectorField(ptf, p, iF, mapper),
100 angle0_(ptf.angle0_),
101 amplitude_(ptf.amplitude_),
107 angularOscillatingDisplacementPointPatchVectorField::
108 angularOscillatingDisplacementPointPatchVectorField
110 const angularOscillatingDisplacementPointPatchVectorField& ptf,
111 const DimensionedField<vector, pointMesh>& iF
114 fixedValuePointPatchVectorField(ptf, iF),
116 origin_(ptf.origin_),
117 angle0_(ptf.angle0_),
118 amplitude_(ptf.amplitude_),
124 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
126 void angularOscillatingDisplacementPointPatchVectorField::updateCoeffs()
133 const polyMesh& mesh = this->dimensionedInternalField().mesh()();
134 const Time& t = mesh.time();
136 scalar angle = angle0_ + amplitude_*sin(omega_*t.value());
137 vector axisHat = axis_/mag(axis_);
138 vectorField p0Rel = p0_ - origin_;
140 vectorField::operator=
142 p0Rel*(cos(angle) - 1)
143 + (axisHat ^ p0Rel*sin(angle))
144 + (axisHat & p0Rel)*(1 - cos(angle))*axisHat
147 fixedValuePointPatchVectorField::updateCoeffs();
151 void angularOscillatingDisplacementPointPatchVectorField::write
156 pointPatchVectorField::write(os);
158 os.writeKeyword("axis")
159 << axis_ << token::END_STATEMENT << nl;
160 os.writeKeyword("origin")
161 << origin_ << token::END_STATEMENT << nl;
162 os.writeKeyword("angle0")
163 << angle0_ << token::END_STATEMENT << nl;
164 os.writeKeyword("amplitude")
165 << amplitude_ << token::END_STATEMENT << nl;
166 os.writeKeyword("omega")
167 << omega_ << token::END_STATEMENT << nl;
168 p0_.writeEntry("p0", os);
169 writeEntry("value", os);
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 makePointPatchTypeField
177 pointPatchVectorField,
178 angularOscillatingDisplacementPointPatchVectorField
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 } // End namespace Foam
185 // ************************************************************************* //