1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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 "oscillatingFixedValueFvPatchField.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
38 scalar oscillatingFixedValueFvPatchField<Type>::currentScale() const
43 sin(2*mathematicalConstant::pi*frequency_*this->db().time().value());
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
53 const DimensionedField<Type, volMesh>& iF
56 fixedValueFvPatchField<Type>(p, iF),
65 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
67 const oscillatingFixedValueFvPatchField<Type>& ptf,
69 const DimensionedField<Type, volMesh>& iF,
70 const fvPatchFieldMapper& mapper
73 fixedValueFvPatchField<Type>(p, iF),
74 refValue_(ptf.refValue_, mapper),
75 amplitude_(ptf.amplitude_),
76 frequency_(ptf.frequency_),
82 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
85 const DimensionedField<Type, volMesh>& iF,
86 const dictionary& dict
89 fixedValueFvPatchField<Type>(p, iF),
90 refValue_("refValue", dict, p.size()),
91 amplitude_(readScalar(dict.lookup("amplitude"))),
92 frequency_(readScalar(dict.lookup("frequency"))),
95 if (dict.found("value"))
97 fixedValueFvPatchField<Type>::operator==
99 Field<Type>("value", dict, p.size())
104 fixedValueFvPatchField<Type>::operator==(refValue_*currentScale());
110 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
112 const oscillatingFixedValueFvPatchField<Type>& ptf
115 fixedValueFvPatchField<Type>(ptf),
116 refValue_(ptf.refValue_),
117 amplitude_(ptf.amplitude_),
118 frequency_(ptf.frequency_),
124 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
126 const oscillatingFixedValueFvPatchField<Type>& ptf,
127 const DimensionedField<Type, volMesh>& iF
130 fixedValueFvPatchField<Type>(ptf, iF),
131 refValue_(ptf.refValue_),
132 amplitude_(ptf.amplitude_),
133 frequency_(ptf.frequency_),
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 void oscillatingFixedValueFvPatchField<Type>::autoMap
143 const fvPatchFieldMapper& m
146 fixedValueFvPatchField<Type>::autoMap(m);
147 refValue_.autoMap(m);
152 void oscillatingFixedValueFvPatchField<Type>::rmap
154 const fvPatchField<Type>& ptf,
155 const labelList& addr
158 fixedValueFvPatchField<Type>::rmap(ptf, addr);
160 const oscillatingFixedValueFvPatchField<Type>& tiptf =
161 refCast<const oscillatingFixedValueFvPatchField<Type> >(ptf);
163 refValue_.rmap(tiptf.refValue_, addr);
168 void oscillatingFixedValueFvPatchField<Type>::updateCoeffs()
175 if (curTimeIndex_ != this->db().time().timeIndex())
177 Field<Type>& patchField = *this;
179 patchField = refValue_*currentScale();
181 curTimeIndex_ = this->db().time().timeIndex();
184 fixedValueFvPatchField<Type>::updateCoeffs();
189 void oscillatingFixedValueFvPatchField<Type>::write(Ostream& os) const
191 fvPatchField<Type>::write(os);
192 refValue_.writeEntry("refValue", os);
193 os.writeKeyword("amplitude")
194 << amplitude_ << token::END_STATEMENT << nl;
195 os.writeKeyword("frequency")
196 << frequency_ << token::END_STATEMENT << nl;
197 this->writeEntry("value", os);
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 } // End namespace Foam
205 // ************************************************************************* //