1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "mixedFvPatchField.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 mixedFvPatchField<Type>::mixedFvPatchField
39 const DimensionedField<Type, volMesh>& iF
42 fvPatchField<Type>(p, iF),
45 valueFraction_(p.size())
50 mixedFvPatchField<Type>::mixedFvPatchField
52 const mixedFvPatchField<Type>& ptf,
54 const DimensionedField<Type, volMesh>& iF,
55 const fvPatchFieldMapper& mapper
58 fvPatchField<Type>(ptf, p, iF, mapper),
59 refValue_(ptf.refValue_, mapper),
60 refGrad_(ptf.refGrad_, mapper),
61 valueFraction_(ptf.valueFraction_, mapper)
66 mixedFvPatchField<Type>::mixedFvPatchField
69 const DimensionedField<Type, volMesh>& iF,
70 const dictionary& dict
73 fvPatchField<Type>(p, iF, dict),
74 refValue_("refValue", dict, p.size()),
75 refGrad_("refGradient", dict, p.size()),
76 valueFraction_("valueFraction", dict, p.size())
83 mixedFvPatchField<Type>::mixedFvPatchField
85 const mixedFvPatchField<Type>& ptf
88 fvPatchField<Type>(ptf),
89 refValue_(ptf.refValue_),
90 refGrad_(ptf.refGrad_),
91 valueFraction_(ptf.valueFraction_)
96 mixedFvPatchField<Type>::mixedFvPatchField
98 const mixedFvPatchField<Type>& ptf,
99 const DimensionedField<Type, volMesh>& iF
102 fvPatchField<Type>(ptf, iF),
103 refValue_(ptf.refValue_),
104 refGrad_(ptf.refGrad_),
105 valueFraction_(ptf.valueFraction_)
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112 void mixedFvPatchField<Type>::autoMap
114 const fvPatchFieldMapper& m
117 fvPatchField<Type>::autoMap(m);
118 refValue_.autoMap(m);
120 valueFraction_.autoMap(m);
125 void mixedFvPatchField<Type>::rmap
127 const fvPatchField<Type>& ptf,
128 const labelList& addr
131 fvPatchField<Type>::rmap(ptf, addr);
133 const mixedFvPatchField<Type>& mptf =
134 refCast<const mixedFvPatchField<Type> >(ptf);
136 refValue_.rmap(mptf.refValue_, addr);
137 refGrad_.rmap(mptf.refGrad_, addr);
138 valueFraction_.rmap(mptf.valueFraction_, addr);
143 void mixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
145 if (!this->updated())
147 this->updateCoeffs();
150 Field<Type>::operator=
152 valueFraction_*refValue_
154 (1.0 - valueFraction_)*
156 this->patchInternalField()
157 + refGrad_/this->patch().deltaCoeffs()
161 fvPatchField<Type>::evaluate();
166 tmp<Field<Type> > mixedFvPatchField<Type>::snGrad() const
170 *(refValue_ - this->patchInternalField())
171 *this->patch().deltaCoeffs()
172 + (1.0 - valueFraction_)*refGrad_;
177 tmp<Field<Type> > mixedFvPatchField<Type>::valueInternalCoeffs
179 const tmp<scalarField>&
182 return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
188 tmp<Field<Type> > mixedFvPatchField<Type>::valueBoundaryCoeffs
190 const tmp<scalarField>&
194 valueFraction_*refValue_
195 + (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
200 tmp<Field<Type> > mixedFvPatchField<Type>::gradientInternalCoeffs() const
202 return -Type(pTraits<Type>::one)*valueFraction_*this->patch().deltaCoeffs();
207 tmp<Field<Type> > mixedFvPatchField<Type>::gradientBoundaryCoeffs() const
210 valueFraction_*this->patch().deltaCoeffs()*refValue_
211 + (1.0 - valueFraction_)*refGrad_;
216 void mixedFvPatchField<Type>::write(Ostream& os) const
218 fvPatchField<Type>::write(os);
219 refValue_.writeEntry("refValue", os);
220 refGrad_.writeEntry("refGradient", os);
221 valueFraction_.writeEntry("valueFraction", os);
222 this->writeEntry("value", os);
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 } // End namespace Foam
230 // ************************************************************************* //