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 "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
68 const DimensionedField<Type, volMesh>& iF,
69 const dictionary& dict
72 fixedValueFvPatchField<Type>(p, iF),
73 refValue_("refValue", dict, p.size()),
74 amplitude_(readScalar(dict.lookup("amplitude"))),
75 frequency_(readScalar(dict.lookup("frequency"))),
78 if (dict.found("value"))
80 fixedValueFvPatchField<Type>::operator==
82 Field<Type>("value", dict, p.size())
87 fixedValueFvPatchField<Type>::operator==(refValue_*currentScale());
93 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
95 const oscillatingFixedValueFvPatchField<Type>& ptf,
97 const DimensionedField<Type, volMesh>& iF,
98 const fvPatchFieldMapper& mapper
101 fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
102 refValue_(ptf.refValue_, mapper),
103 amplitude_(ptf.amplitude_),
104 frequency_(ptf.frequency_),
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 // ************************************************************************* //