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 "fixedMeanValueFvPatchField.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 fixedMeanValueFvPatchField<Type>::fixedMeanValueFvPatchField
41 const DimensionedField<Type, volMesh>& iF
44 fixedValueFvPatchField<Type>(p, iF),
45 meanValue_(pTraits<Type>::zero),
51 fixedMeanValueFvPatchField<Type>::fixedMeanValueFvPatchField
53 const fixedMeanValueFvPatchField<Type>& ptf,
55 const DimensionedField<Type, volMesh>& iF,
56 const fvPatchFieldMapper& mapper
59 fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
60 meanValue_(ptf.meanValue_),
66 fixedMeanValueFvPatchField<Type>::fixedMeanValueFvPatchField
69 const DimensionedField<Type, volMesh>& iF,
70 const dictionary& dict
73 fixedValueFvPatchField<Type>(p, iF),
74 meanValue_(pTraits<Type>(dict.lookup("meanValue"))),
77 if (dict.found("value"))
79 fixedValueFvPatchField<Type>::operator==
81 Field<Type>("value", dict, p.size())
86 fixedValueFvPatchField<Type>::operator==(meanValue_);
92 fixedMeanValueFvPatchField<Type>::fixedMeanValueFvPatchField
94 const fixedMeanValueFvPatchField<Type>& ptf,
95 const DimensionedField<Type, volMesh>& iF
98 fixedValueFvPatchField<Type>(ptf, iF),
99 meanValue_(ptf.meanValue_),
104 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 void fixedMeanValueFvPatchField<Type>::autoMap
110 const fvPatchFieldMapper& m
113 Field<Type>::autoMap(m);
117 // Reverse-map the given fvPatchField onto this fvPatchField
119 void fixedMeanValueFvPatchField<Type>::rmap
121 const fvPatchField<Type>& ptf,
122 const labelList& addr
125 fixedValueFvPatchField<Type>::rmap(ptf, addr);
129 // Update the coefficients associated with the patch field
131 void fixedMeanValueFvPatchField<Type>::updateCoeffs()
138 if (curTimeIndex_ != this->db().time().timeIndex())
140 Field<Type>& patchField = *this;
142 Field<Type> pif = this->patchInternalField();
144 patchField = meanValue_ - gAverage(pif) + pif;
146 curTimeIndex_ = this->db().time().timeIndex();
149 fixedValueFvPatchField<Type>::updateCoeffs();
155 void fixedMeanValueFvPatchField<Type>::write(Ostream& os) const
157 fvPatchField<Type>::write(os);
158 os.writeKeyword("meanValue")
159 << meanValue_ << token::END_STATEMENT << nl;
160 this->writeEntry("value", os);
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 } // End namespace Foam
168 // ************************************************************************* //