1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
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
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
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"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 oscillatingVelocityPointPatchVectorField::
40 oscillatingVelocityPointPatchVectorField
43 const DimensionedField<vector, pointMesh>& iF
46 fixedValuePointPatchField<vector>(p, iF),
47 amplitude_(vector::zero),
53 oscillatingVelocityPointPatchVectorField::
54 oscillatingVelocityPointPatchVectorField
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"))
72 p0_ = vectorField("p0", dict , p.size());
76 p0_ = p.localPoints();
81 oscillatingVelocityPointPatchVectorField::
82 oscillatingVelocityPointPatchVectorField
84 const oscillatingVelocityPointPatchVectorField& ptf,
86 const DimensionedField<vector, pointMesh>& iF,
87 const pointPatchFieldMapper& mapper
90 fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
91 amplitude_(ptf.amplitude_),
97 oscillatingVelocityPointPatchVectorField::
98 oscillatingVelocityPointPatchVectorField
100 const oscillatingVelocityPointPatchVectorField& ptf,
101 const DimensionedField<vector, pointMesh>& iF
104 fixedValuePointPatchField<vector>(ptf, iF),
105 amplitude_(ptf.amplitude_),
111 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 void oscillatingVelocityPointPatchVectorField::autoMap
115 const pointPatchFieldMapper& m
118 fixedValuePointPatchField<vector>::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()
146 const polyMesh& mesh = this->dimensionedInternalField().mesh()();
147 const Time& t = mesh.time();
148 const pointPatch& p = this->patch();
150 Field<vector>::operator=
152 (p0_ + amplitude_*sin(omega_*t.value()) - p.localPoints())
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 // ************************************************************************* //