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 "mixedFaPatchField.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
37 mixedFaPatchField<Type>::mixedFaPatchField
40 const DimensionedField<Type, areaMesh>& iF
43 faPatchField<Type>(p, iF),
46 valueFraction_(p.size())
51 mixedFaPatchField<Type>::mixedFaPatchField
53 const mixedFaPatchField<Type>& ptf,
55 const DimensionedField<Type, areaMesh>& iF,
56 const faPatchFieldMapper& mapper
59 faPatchField<Type>(ptf, p, iF, mapper),
60 refValue_(ptf.refValue_, mapper),
61 refGrad_(ptf.refGrad_, mapper),
62 valueFraction_(ptf.valueFraction_, mapper)
67 mixedFaPatchField<Type>::mixedFaPatchField
70 const DimensionedField<Type, areaMesh>& iF,
71 const dictionary& dict
74 faPatchField<Type>(p, iF),
75 refValue_("refValue", dict, p.size()),
76 refGrad_("refGradient", dict, p.size()),
77 valueFraction_("valueFraction", dict, p.size())
84 mixedFaPatchField<Type>::mixedFaPatchField
86 const mixedFaPatchField<Type>& ptf
89 faPatchField<Type>(ptf),
90 refValue_(ptf.refValue_),
91 refGrad_(ptf.refGrad_),
92 valueFraction_(ptf.valueFraction_)
97 mixedFaPatchField<Type>::mixedFaPatchField
99 const mixedFaPatchField<Type>& ptf,
100 const DimensionedField<Type, areaMesh>& iF
103 faPatchField<Type>(ptf, iF),
104 refValue_(ptf.refValue_),
105 refGrad_(ptf.refGrad_),
106 valueFraction_(ptf.valueFraction_)
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 void mixedFaPatchField<Type>::autoMap
115 const faPatchFieldMapper& m
118 Field<Type>::autoMap(m);
119 refValue_.autoMap(m);
121 valueFraction_.autoMap(m);
126 void mixedFaPatchField<Type>::rmap
128 const faPatchField<Type>& ptf,
129 const labelList& addr
132 faPatchField<Type>::rmap(ptf, addr);
134 const mixedFaPatchField<Type>& mptf =
135 refCast<const mixedFaPatchField<Type> >(ptf);
137 refValue_.rmap(mptf.refValue_, addr);
138 refGrad_.rmap(mptf.refGrad_, addr);
139 valueFraction_.rmap(mptf.valueFraction_, addr);
144 void mixedFaPatchField<Type>::evaluate(const Pstream::commsTypes)
146 if (!this->updated())
148 this->updateCoeffs();
151 Field<Type>::operator=
153 valueFraction_*refValue_
155 (1.0 - valueFraction_)*
157 this->patchInternalField()
158 + refGrad_/this->patch().deltaCoeffs()
162 faPatchField<Type>::evaluate();
167 tmp<Field<Type> > mixedFaPatchField<Type>::snGrad() const
171 *(refValue_ - this->patchInternalField())
172 *this->patch().deltaCoeffs()
173 + (1.0 - valueFraction_)*refGrad_;
178 tmp<Field<Type> > mixedFaPatchField<Type>::valueInternalCoeffs
180 const tmp<scalarField>&
183 return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
189 tmp<Field<Type> > mixedFaPatchField<Type>::valueBoundaryCoeffs
191 const tmp<scalarField>&
195 valueFraction_*refValue_
196 + (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
201 tmp<Field<Type> > mixedFaPatchField<Type>::gradientInternalCoeffs() const
203 return -Type(pTraits<Type>::one)*valueFraction_*this->patch().deltaCoeffs();
208 tmp<Field<Type> > mixedFaPatchField<Type>::gradientBoundaryCoeffs() const
211 valueFraction_*this->patch().deltaCoeffs()*refValue_
212 + (1.0 - valueFraction_)*refGrad_;
217 void mixedFaPatchField<Type>::write(Ostream& os) const
219 faPatchField<Type>::write(os);
220 refValue_.writeEntry("refValue", os);
221 refGrad_.writeEntry("refGradient", os);
222 valueFraction_.writeEntry("valueFraction", os);
223 this->writeEntry("value", os);
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 } // End namespace Foam
231 // ************************************************************************* //