initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / fvMotionSolver / pointPatchFields / derived / oscillatingVelocity / oscillatingVelocityPointPatchVectorField.C
blobc6a8c067b12b48d0ad710fd84a3a541db71b42cc
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 "oscillatingVelocityPointPatchVectorField.H"
28 #include "pointPatchFields.H"
29 #include "addToRunTimeSelectionTable.H"
30 #include "Time.H"
31 #include "polyMesh.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
40 oscillatingVelocityPointPatchVectorField::
41 oscillatingVelocityPointPatchVectorField
43     const pointPatch& p,
44     const DimensionedField<vector, pointMesh>& iF
47     fixedValuePointPatchField<vector>(p, iF),
48     amplitude_(vector::zero),
49     omega_(0.0),
50     p0_(p.localPoints())
54 oscillatingVelocityPointPatchVectorField::
55 oscillatingVelocityPointPatchVectorField
57     const pointPatch& p,
58     const DimensionedField<vector, pointMesh>& iF,
59     const dictionary& dict
62     fixedValuePointPatchField<vector>(p, iF, dict),
63     amplitude_(dict.lookup("amplitude")),
64     omega_(readScalar(dict.lookup("omega")))
66     if (!dict.found("value"))
67     {
68         updateCoeffs();
69     }
71     if (dict.found("p0"))
72     {
73         p0_ = vectorField("p0", dict , p.size());
74     }
75     else
76     {
77         p0_ = p.localPoints();
78     }
82 oscillatingVelocityPointPatchVectorField::
83 oscillatingVelocityPointPatchVectorField
85     const oscillatingVelocityPointPatchVectorField& ptf,
86     const pointPatch& p,
87     const DimensionedField<vector, pointMesh>& iF,
88     const pointPatchFieldMapper& mapper
91     fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
92     amplitude_(ptf.amplitude_),
93     omega_(ptf.omega_),
94     p0_(ptf.p0_)
98 oscillatingVelocityPointPatchVectorField::
99 oscillatingVelocityPointPatchVectorField
101     const oscillatingVelocityPointPatchVectorField& ptf,
102     const DimensionedField<vector, pointMesh>& iF
105     fixedValuePointPatchField<vector>(ptf, iF),
106     amplitude_(ptf.amplitude_),
107     omega_(ptf.omega_),
108     p0_(ptf.p0_)
112 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
114 void oscillatingVelocityPointPatchVectorField::updateCoeffs()
116     if (this->updated())
117     {
118         return;
119     }
121     const polyMesh& mesh = this->dimensionedInternalField().mesh()();
122     const Time& t = mesh.time();
123     const pointPatch& p = this->patch();
125     Field<vector>::operator=
126     (
127         (p0_ + amplitude_*sin(omega_*t.value()) - p.localPoints())
128        /t.deltaT().value()
129     );
131     fixedValuePointPatchField<vector>::updateCoeffs();
135 void oscillatingVelocityPointPatchVectorField::write(Ostream& os) const
137     pointPatchField<vector>::write(os);
138     os.writeKeyword("amplitude")
139         << amplitude_ << token::END_STATEMENT << nl;
140     os.writeKeyword("omega")
141         << omega_ << token::END_STATEMENT << nl;
142     p0_.writeEntry("p0", os);
143     writeEntry("value", os);
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 makePointPatchTypeField
151     pointPatchVectorField,
152     oscillatingVelocityPointPatchVectorField
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 } // End namespace Foam
159 // ************************************************************************* //