Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / fvMotionSolver / pointPatchFields / derived / angularOscillatingDisplacement / angularOscillatingDisplacementPointPatchVectorField.C
blobe9c4c8e8b512730a85a594b4c659d4458f4da02d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 "angularOscillatingDisplacementPointPatchVectorField.H"
28 #include "pointPatchFields.H"
29 #include "addToRunTimeSelectionTable.H"
30 #include "Time.H"
31 #include "polyMesh.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
40 angularOscillatingDisplacementPointPatchVectorField::
41 angularOscillatingDisplacementPointPatchVectorField
43     const pointPatch& p,
44     const DimensionedField<vector, pointMesh>& iF
47     fixedValuePointPatchVectorField(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 angularOscillatingDisplacementPointPatchVectorField::
58 angularOscillatingDisplacementPointPatchVectorField
60     const pointPatch& p,
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"))
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 angularOscillatingDisplacementPointPatchVectorField::
89 angularOscillatingDisplacementPointPatchVectorField
91     const angularOscillatingDisplacementPointPatchVectorField& ptf,
92     const pointPatch& p,
93     const DimensionedField<vector, pointMesh>& iF,
94     const PointPatchFieldMapper& mapper
97     fixedValuePointPatchVectorField(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 angularOscillatingDisplacementPointPatchVectorField::
108 angularOscillatingDisplacementPointPatchVectorField
110     const angularOscillatingDisplacementPointPatchVectorField& ptf,
111     const DimensionedField<vector, pointMesh>& iF
114     fixedValuePointPatchVectorField(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 angularOscillatingDisplacementPointPatchVectorField::updateCoeffs()
128     if (this->updated())
129     {
130         return;
131     }
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=
141     (
142         p0Rel*(cos(angle) - 1)
143       + (axisHat ^ p0Rel*sin(angle))
144       + (axisHat & p0Rel)*(1 - cos(angle))*axisHat
145     );
147     fixedValuePointPatchVectorField::updateCoeffs();
151 void angularOscillatingDisplacementPointPatchVectorField::write
153     Ostream& os
154 ) const
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 // ************************************************************************* //