initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / derived / oscillatingFixedValue / oscillatingFixedValueFvPatchField.C
blobe1b4016818fc23e4283e03079da9e8123274db94
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 oscillatingFixedValueFvPatchField<Type>& ptf,
68     const fvPatch& p,
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_),
77     curTimeIndex_(-1)
81 template<class Type>
82 oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
84     const fvPatch& p,
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"))),
93     curTimeIndex_(-1)
95     if (dict.found("value"))
96     {
97         fixedValueFvPatchField<Type>::operator==
98         (
99             Field<Type>("value", dict, p.size())
100         );
101     }
102     else
103     {
104         fixedValueFvPatchField<Type>::operator==(refValue_*currentScale());
105     }
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 // ************************************************************************* //