1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "oscillatingFixedValueFvPatchField.H"
27 #include "mathematicalConstants.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37 scalar oscillatingFixedValueFvPatchField<Type>::currentScale() const
42 sin(2*mathematicalConstant::pi*frequency_*this->db().time().value());
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
52 const DimensionedField<Type, volMesh>& iF
55 fixedValueFvPatchField<Type>(p, iF),
64 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
67 const DimensionedField<Type, volMesh>& iF,
68 const dictionary& dict
71 fixedValueFvPatchField<Type>(p, iF),
72 refValue_("refValue", dict, p.size()),
73 amplitude_(readScalar(dict.lookup("amplitude"))),
74 frequency_(readScalar(dict.lookup("frequency"))),
77 if (dict.found("value"))
79 fixedValueFvPatchField<Type>::operator==
81 Field<Type>("value", dict, p.size())
86 fixedValueFvPatchField<Type>::operator==(refValue_*currentScale());
92 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
94 const oscillatingFixedValueFvPatchField<Type>& ptf,
96 const DimensionedField<Type, volMesh>& iF,
97 const fvPatchFieldMapper& mapper
100 fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
101 refValue_(ptf.refValue_, mapper),
102 amplitude_(ptf.amplitude_),
103 frequency_(ptf.frequency_),
109 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
111 const oscillatingFixedValueFvPatchField<Type>& ptf
114 fixedValueFvPatchField<Type>(ptf),
115 refValue_(ptf.refValue_),
116 amplitude_(ptf.amplitude_),
117 frequency_(ptf.frequency_),
123 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
125 const oscillatingFixedValueFvPatchField<Type>& ptf,
126 const DimensionedField<Type, volMesh>& iF
129 fixedValueFvPatchField<Type>(ptf, iF),
130 refValue_(ptf.refValue_),
131 amplitude_(ptf.amplitude_),
132 frequency_(ptf.frequency_),
137 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 void oscillatingFixedValueFvPatchField<Type>::autoMap
142 const fvPatchFieldMapper& m
145 fixedValueFvPatchField<Type>::autoMap(m);
146 refValue_.autoMap(m);
151 void oscillatingFixedValueFvPatchField<Type>::rmap
153 const fvPatchField<Type>& ptf,
154 const labelList& addr
157 fixedValueFvPatchField<Type>::rmap(ptf, addr);
159 const oscillatingFixedValueFvPatchField<Type>& tiptf =
160 refCast<const oscillatingFixedValueFvPatchField<Type> >(ptf);
162 refValue_.rmap(tiptf.refValue_, addr);
167 void oscillatingFixedValueFvPatchField<Type>::updateCoeffs()
174 if (curTimeIndex_ != this->db().time().timeIndex())
176 Field<Type>& patchField = *this;
178 patchField = refValue_*currentScale();
180 curTimeIndex_ = this->db().time().timeIndex();
183 fixedValueFvPatchField<Type>::updateCoeffs();
188 void oscillatingFixedValueFvPatchField<Type>::write(Ostream& os) const
190 fvPatchField<Type>::write(os);
191 refValue_.writeEntry("refValue", os);
192 os.writeKeyword("amplitude")
193 << amplitude_ << token::END_STATEMENT << nl;
194 os.writeKeyword("frequency")
195 << frequency_ << token::END_STATEMENT << nl;
196 this->writeEntry("value", os);
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 } // End namespace Foam
204 // ************************************************************************* //