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 "angularOscillatingVelocityPointPatchVectorField.H"
28 #include "pointPatchFields.H"
29 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 angularOscillatingVelocityPointPatchVectorField::
41 angularOscillatingVelocityPointPatchVectorField
44 const DimensionedField<vector, pointMesh>& iF
47 fixedValuePointPatchVectorField(p, iF),
49 origin_(vector::zero),
57 angularOscillatingVelocityPointPatchVectorField::
58 angularOscillatingVelocityPointPatchVectorField
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 angularOscillatingVelocityPointPatchVectorField::
89 angularOscillatingVelocityPointPatchVectorField
91 const angularOscillatingVelocityPointPatchVectorField& 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 angularOscillatingVelocityPointPatchVectorField::
108 angularOscillatingVelocityPointPatchVectorField
110 const angularOscillatingVelocityPointPatchVectorField& 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 angularOscillatingVelocityPointPatchVectorField::updateCoeffs()
133 const polyMesh& mesh = this->dimensionedInternalField().mesh()();
134 const Time& t = mesh.time();
135 const pointPatch& p = this->patch();
137 scalar angle = angle0_ + amplitude_*sin(omega_*t.value());
138 vector axisHat = axis_/mag(axis_);
139 vectorField p0Rel = p0_ - origin_;
141 vectorField::operator=
145 + p0Rel*(cos(angle) - 1)
146 + (axisHat ^ p0Rel*sin(angle))
147 + (axisHat & p0Rel)*(1 - cos(angle))*axisHat
152 fixedValuePointPatchVectorField::updateCoeffs();
156 void angularOscillatingVelocityPointPatchVectorField::write
161 pointPatchField<vector>::write(os);
162 os.writeKeyword("axis")
163 << axis_ << token::END_STATEMENT << nl;
164 os.writeKeyword("origin")
165 << origin_ << token::END_STATEMENT << nl;
166 os.writeKeyword("angle0")
167 << angle0_ << token::END_STATEMENT << nl;
168 os.writeKeyword("amplitude")
169 << amplitude_ << token::END_STATEMENT << nl;
170 os.writeKeyword("omega")
171 << omega_ << token::END_STATEMENT << nl;
172 p0_.writeEntry("p0", os);
173 writeEntry("value", os);
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 makePointPatchTypeField
181 pointPatchVectorField,
182 angularOscillatingVelocityPointPatchVectorField
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 } // End namespace Foam
189 // ************************************************************************* //