Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvPatchFields / derived / oscillatingFixedValue / oscillatingFixedValueFvPatchField.C
blob6ec05f6e1dcfe47f4850e3b56757464cd5686025
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
37 template<class Type>
38 scalar oscillatingFixedValueFvPatchField<Type>::currentScale() const
40     return
41         1.0
42       + amplitude_*
43         sin(2*mathematicalConstant::pi*frequency_*this->db().time().value());
47 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
49 template<class Type>
50 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
52     const fvPatch& p,
53     const DimensionedField<Type, volMesh>& iF
56     fixedValueFvPatchField<Type>(p, iF),
57     refValue_(p.size()),
58     amplitude_(0.0),
59     frequency_(0.0),
60     curTimeIndex_(-1)
64 template<class Type>
65 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
67     const fvPatch& p,
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"))),
76     curTimeIndex_(-1)
78     if (dict.found("value"))
79     {
80         fixedValueFvPatchField<Type>::operator==
81         (
82             Field<Type>("value", dict, p.size())
83         );
84     }
85     else
86     {
87         fixedValueFvPatchField<Type>::operator==(refValue_*currentScale());
88     }
92 template<class Type>
93 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
95     const oscillatingFixedValueFvPatchField<Type>& ptf,
96     const fvPatch& p,
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_),
105     curTimeIndex_(-1)
109 template<class Type>
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_),
119     curTimeIndex_(-1)
123 template<class Type>
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_),
134     curTimeIndex_(-1)
138 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
140 template<class Type>
141 void oscillatingFixedValueFvPatchField<Type>::autoMap
143     const fvPatchFieldMapper& m
146     fixedValueFvPatchField<Type>::autoMap(m);
147     refValue_.autoMap(m);
151 template<class Type>
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);
167 template<class Type>
168 void oscillatingFixedValueFvPatchField<Type>::updateCoeffs()
170     if (this->updated())
171     {
172         return;
173     }
175     if (curTimeIndex_ != this->db().time().timeIndex())
176     {
177         Field<Type>& patchField = *this;
179         patchField = refValue_*currentScale();
181         curTimeIndex_ = this->db().time().timeIndex();
182     }
184     fixedValueFvPatchField<Type>::updateCoeffs();
188 template<class Type>
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 // ************************************************************************* //