Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvPatchFields / derived / fixedMeanValue / fixedMeanValueFvPatchField.C
blobca5d3c1b750aaaac01d936eee6513ce6c64065bd
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 "fixedMeanValueFvPatchField.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 template<class Type>
38 fixedMeanValueFvPatchField<Type>::fixedMeanValueFvPatchField
40     const fvPatch& p,
41     const DimensionedField<Type, volMesh>& iF
44     fixedValueFvPatchField<Type>(p, iF),
45     meanValue_(pTraits<Type>::zero),
46     curTimeIndex_(-1)
50 template<class Type>
51 fixedMeanValueFvPatchField<Type>::fixedMeanValueFvPatchField
53     const fixedMeanValueFvPatchField<Type>& ptf,
54     const fvPatch& p,
55     const DimensionedField<Type, volMesh>& iF,
56     const fvPatchFieldMapper& mapper
59     fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
60     meanValue_(ptf.meanValue_),
61     curTimeIndex_(-1)
65 template<class Type>
66 fixedMeanValueFvPatchField<Type>::fixedMeanValueFvPatchField
68     const fvPatch& p,
69     const DimensionedField<Type, volMesh>& iF,
70     const dictionary& dict
73     fixedValueFvPatchField<Type>(p, iF),
74     meanValue_(pTraits<Type>(dict.lookup("meanValue"))),
75     curTimeIndex_(-1)
77     if (dict.found("value"))
78     {
79         fixedValueFvPatchField<Type>::operator==
80         (
81             Field<Type>("value", dict, p.size())
82         );
83     }
84     else
85     {
86         fixedValueFvPatchField<Type>::operator==(meanValue_);
87     }
91 template<class Type>
92 fixedMeanValueFvPatchField<Type>::fixedMeanValueFvPatchField
94     const fixedMeanValueFvPatchField<Type>& ptf,
95     const DimensionedField<Type, volMesh>& iF
98     fixedValueFvPatchField<Type>(ptf, iF),
99     meanValue_(ptf.meanValue_),
100     curTimeIndex_(-1)
104 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
106 // Map from self
107 template<class Type>
108 void fixedMeanValueFvPatchField<Type>::autoMap
110     const fvPatchFieldMapper& m
113     Field<Type>::autoMap(m);
117 // Reverse-map the given fvPatchField onto this fvPatchField
118 template<class Type>
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
130 template<class Type>
131 void fixedMeanValueFvPatchField<Type>::updateCoeffs()
133     if (this->updated())
134     {
135         return;
136     }
138     if (curTimeIndex_ != this->db().time().timeIndex())
139     {
140         Field<Type>& patchField = *this;
142         Field<Type> pif = this->patchInternalField();
144         patchField = meanValue_ - gAverage(pif) + pif;
146         curTimeIndex_ = this->db().time().timeIndex();
147     }
149     fixedValueFvPatchField<Type>::updateCoeffs();
153 // Write
154 template<class Type>
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 // ************************************************************************* //