initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / fvMotionSolver / pointPatchFields / derived / angularOscillatingVelocity / angularOscillatingVelocityPointPatchVectorField.C
blob89a331837e5062431508279391579fca25ef6bf0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
30 #include "Time.H"
31 #include "polyMesh.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
40 angularOscillatingVelocityPointPatchVectorField::
41 angularOscillatingVelocityPointPatchVectorField
43     const pointPatch& p,
44     const DimensionedField<vector, pointMesh>& iF
47     fixedValuePointPatchField<vector>(p, iF),
48     axis_(vector::zero),
49     origin_(vector::zero),
50     angle0_(0.0),
51     amplitude_(0.0),
52     omega_(0.0),
53     p0_(p.localPoints())
57 angularOscillatingVelocityPointPatchVectorField::
58 angularOscillatingVelocityPointPatchVectorField
60     const pointPatch& p,
61     const DimensionedField<vector, pointMesh>& iF,
62     const dictionary& dict
65     fixedValuePointPatchField<vector>(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"))
73     {
74         updateCoeffs();
75     }
77     if (dict.found("p0"))
78     {
79         p0_ = vectorField("p0", dict , p.size());
80     }
81     else
82     {
83         p0_ = p.localPoints();
84     }
88 angularOscillatingVelocityPointPatchVectorField::
89 angularOscillatingVelocityPointPatchVectorField
91     const angularOscillatingVelocityPointPatchVectorField& ptf,
92     const pointPatch& p,
93     const DimensionedField<vector, pointMesh>& iF,
94     const pointPatchFieldMapper& mapper
97     fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
98     axis_(ptf.axis_),
99     origin_(ptf.origin_),
100     angle0_(ptf.angle0_),
101     amplitude_(ptf.amplitude_),
102     omega_(ptf.omega_),
103     p0_(ptf.p0_)
107 angularOscillatingVelocityPointPatchVectorField::
108 angularOscillatingVelocityPointPatchVectorField
110     const angularOscillatingVelocityPointPatchVectorField& ptf,
111     const DimensionedField<vector, pointMesh>& iF
114     fixedValuePointPatchField<vector>(ptf, iF),
115     axis_(ptf.axis_),
116     origin_(ptf.origin_),
117     angle0_(ptf.angle0_),
118     amplitude_(ptf.amplitude_),
119     omega_(ptf.omega_),
120     p0_(ptf.p0_)
124 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
126 void angularOscillatingVelocityPointPatchVectorField::updateCoeffs()
128     if (this->updated())
129     {
130         return;
131     }
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=
142     (
143         (
144             p0_
145           + p0Rel*(cos(angle) - 1)
146           + (axisHat ^ p0Rel*sin(angle))
147           + (axisHat & p0Rel)*(1 - cos(angle))*axisHat
148           - p.localPoints()
149         )/t.deltaT().value()
150     );
152     fixedValuePointPatchField<vector>::updateCoeffs();
156 void angularOscillatingVelocityPointPatchVectorField::write
158     Ostream& os
159 ) const
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 // ************************************************************************* //