Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / fvMotionSolver / pointPatchFields / derived / oscillatingVelocity / oscillatingVelocityPointPatchVectorField.C
blob083bd91e9790da26d71b2cbce0d2b4012b80009e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "oscillatingVelocityPointPatchVectorField.H"
27 #include "pointPatchFields.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "Time.H"
30 #include "polyMesh.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
37 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
39 oscillatingVelocityPointPatchVectorField::
40 oscillatingVelocityPointPatchVectorField
42     const pointPatch& p,
43     const DimensionedField<vector, pointMesh>& iF
46     fixedValuePointPatchField<vector>(p, iF),
47     amplitude_(vector::zero),
48     omega_(0.0),
49     p0_(p.localPoints())
53 oscillatingVelocityPointPatchVectorField::
54 oscillatingVelocityPointPatchVectorField
56     const pointPatch& p,
57     const DimensionedField<vector, pointMesh>& iF,
58     const dictionary& dict
61     fixedValuePointPatchField<vector>(p, iF, dict),
62     amplitude_(dict.lookup("amplitude")),
63     omega_(readScalar(dict.lookup("omega")))
65     if (!dict.found("value"))
66     {
67         updateCoeffs();
68     }
70     if (dict.found("p0"))
71     {
72         p0_ = vectorField("p0", dict , p.size());
73     }
74     else
75     {
76         p0_ = p.localPoints();
77     }
81 oscillatingVelocityPointPatchVectorField::
82 oscillatingVelocityPointPatchVectorField
84     const oscillatingVelocityPointPatchVectorField& ptf,
85     const pointPatch& p,
86     const DimensionedField<vector, pointMesh>& iF,
87     const pointPatchFieldMapper& mapper
90     fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
91     amplitude_(ptf.amplitude_),
92     omega_(ptf.omega_),
93     p0_(ptf.p0_, mapper)
97 oscillatingVelocityPointPatchVectorField::
98 oscillatingVelocityPointPatchVectorField
100     const oscillatingVelocityPointPatchVectorField& ptf,
101     const DimensionedField<vector, pointMesh>& iF
104     fixedValuePointPatchField<vector>(ptf, iF),
105     amplitude_(ptf.amplitude_),
106     omega_(ptf.omega_),
107     p0_(ptf.p0_)
111 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
113 void oscillatingVelocityPointPatchVectorField::autoMap
115     const pointPatchFieldMapper& m
118     fixedValuePointPatchField<vector>::autoMap(m);
120     p0_.autoMap(m);
124 void oscillatingVelocityPointPatchVectorField::rmap
126     const pointPatchField<vector>& ptf,
127     const labelList& addr
130     const oscillatingVelocityPointPatchVectorField& oVptf =
131         refCast<const oscillatingVelocityPointPatchVectorField>(ptf);
133     fixedValuePointPatchField<vector>::rmap(oVptf, addr);
135     p0_.rmap(oVptf.p0_, addr);
139 void oscillatingVelocityPointPatchVectorField::updateCoeffs()
141     if (this->updated())
142     {
143         return;
144     }
146     const polyMesh& mesh = this->dimensionedInternalField().mesh()();
147     const Time& t = mesh.time();
148     const pointPatch& p = this->patch();
150     Field<vector>::operator=
151     (
152         (p0_ + amplitude_*sin(omega_*t.value()) - p.localPoints())
153        /t.deltaTValue()
154     );
156     fixedValuePointPatchField<vector>::updateCoeffs();
160 void oscillatingVelocityPointPatchVectorField::write(Ostream& os) const
162     pointPatchField<vector>::write(os);
163     os.writeKeyword("amplitude")
164         << amplitude_ << token::END_STATEMENT << nl;
165     os.writeKeyword("omega")
166         << omega_ << token::END_STATEMENT << nl;
167     p0_.writeEntry("p0", os);
168     writeEntry("value", os);
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 makePointPatchTypeField
176     pointPatchVectorField,
177     oscillatingVelocityPointPatchVectorField
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 } // End namespace Foam
184 // ************************************************************************* //