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 "oscillatingVelocityPointPatchVectorField.H"
28 #include "pointPatchFields.H"
29 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 oscillatingVelocityPointPatchVectorField::
41 oscillatingVelocityPointPatchVectorField
44 const DimensionedField<vector, pointMesh>& iF
47 fixedValuePointPatchVectorField(p, iF),
48 amplitude_(vector::zero),
54 oscillatingVelocityPointPatchVectorField::
55 oscillatingVelocityPointPatchVectorField
58 const DimensionedField<vector, pointMesh>& iF,
59 const dictionary& dict
62 fixedValuePointPatchVectorField(p, iF, dict),
63 amplitude_(dict.lookup("amplitude")),
64 omega_(readScalar(dict.lookup("omega")))
66 if (!dict.found("value"))
73 p0_ = vectorField("p0", dict , p.size());
77 p0_ = p.localPoints();
82 oscillatingVelocityPointPatchVectorField::
83 oscillatingVelocityPointPatchVectorField
85 const oscillatingVelocityPointPatchVectorField& ptf,
87 const DimensionedField<vector, pointMesh>& iF,
88 const PointPatchFieldMapper& mapper
91 fixedValuePointPatchVectorField(ptf, p, iF, mapper),
92 amplitude_(ptf.amplitude_),
98 oscillatingVelocityPointPatchVectorField::
99 oscillatingVelocityPointPatchVectorField
101 const oscillatingVelocityPointPatchVectorField& ptf,
102 const DimensionedField<vector, pointMesh>& iF
105 fixedValuePointPatchVectorField(ptf, iF),
106 amplitude_(ptf.amplitude_),
112 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 void oscillatingVelocityPointPatchVectorField::updateCoeffs()
121 const polyMesh& mesh = this->dimensionedInternalField().mesh()();
122 const Time& t = mesh.time();
123 const pointPatch& p = this->patch();
125 Field<vector>::operator=
127 (p0_ + amplitude_*sin(omega_*t.value()) - p.localPoints())
131 fixedValuePointPatchVectorField::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 // ************************************************************************* //