initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / finiteVolume / fields / fvPatchFields / basic / mixed / mixedFvPatchField.C
blobc5c019537b82d4513b90b1a34356f2d37412760e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 "mixedFvPatchField.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
36 template<class Type>
37 mixedFvPatchField<Type>::mixedFvPatchField
39     const fvPatch& p,
40     const DimensionedField<Type, volMesh>& iF
43     fvPatchField<Type>(p, iF),
44     refValue_(p.size()),
45     refGrad_(p.size()),
46     valueFraction_(p.size())
50 template<class Type>
51 mixedFvPatchField<Type>::mixedFvPatchField
53     const mixedFvPatchField<Type>& ptf,
54     const fvPatch& p,
55     const DimensionedField<Type, volMesh>& iF,
56     const fvPatchFieldMapper& mapper
59     fvPatchField<Type>(ptf, p, iF, mapper),
60     refValue_(ptf.refValue_, mapper),
61     refGrad_(ptf.refGrad_, mapper),
62     valueFraction_(ptf.valueFraction_, mapper)
66 template<class Type>
67 mixedFvPatchField<Type>::mixedFvPatchField
69     const fvPatch& p,
70     const DimensionedField<Type, volMesh>& iF,
71     const dictionary& dict
74     fvPatchField<Type>(p, iF, dict),
75     refValue_("refValue", dict, p.size()),
76     refGrad_("refGradient", dict, p.size()),
77     valueFraction_("valueFraction", dict, p.size())
79     evaluate();
83 template<class Type>
84 mixedFvPatchField<Type>::mixedFvPatchField
86     const mixedFvPatchField<Type>& ptf
89     fvPatchField<Type>(ptf),
90     refValue_(ptf.refValue_),
91     refGrad_(ptf.refGrad_),
92     valueFraction_(ptf.valueFraction_)
96 template<class Type>
97 mixedFvPatchField<Type>::mixedFvPatchField
99     const mixedFvPatchField<Type>& ptf,
100     const DimensionedField<Type, volMesh>& iF
103     fvPatchField<Type>(ptf, iF),
104     refValue_(ptf.refValue_),
105     refGrad_(ptf.refGrad_),
106     valueFraction_(ptf.valueFraction_)
110 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
112 template<class Type>
113 void mixedFvPatchField<Type>::autoMap
115     const fvPatchFieldMapper& m
118     fvPatchField<Type>::autoMap(m);
119     refValue_.autoMap(m);
120     refGrad_.autoMap(m);
121     valueFraction_.autoMap(m);
125 template<class Type>
126 void mixedFvPatchField<Type>::rmap
128     const fvPatchField<Type>& ptf,
129     const labelList& addr
132     fvPatchField<Type>::rmap(ptf, addr);
134     const mixedFvPatchField<Type>& mptf =
135         refCast<const mixedFvPatchField<Type> >(ptf);
137     refValue_.rmap(mptf.refValue_, addr);
138     refGrad_.rmap(mptf.refGrad_, addr);
139     valueFraction_.rmap(mptf.valueFraction_, addr);
143 template<class Type>
144 void mixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
146     if (!this->updated())
147     {
148         this->updateCoeffs();
149     }
151     Field<Type>::operator=
152     (
153         valueFraction_*refValue_
154       +
155         (1.0 - valueFraction_)*
156         (
157             this->patchInternalField()
158           + refGrad_/this->patch().deltaCoeffs()
159         )
160     );
162     fvPatchField<Type>::evaluate();
166 template<class Type>
167 tmp<Field<Type> > mixedFvPatchField<Type>::snGrad() const
169     return
170         valueFraction_
171        *(refValue_ - this->patchInternalField())
172        *this->patch().deltaCoeffs()
173       + (1.0 - valueFraction_)*refGrad_;
177 template<class Type>
178 tmp<Field<Type> > mixedFvPatchField<Type>::valueInternalCoeffs
180     const tmp<scalarField>&
181 ) const
183     return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
188 template<class Type>
189 tmp<Field<Type> > mixedFvPatchField<Type>::valueBoundaryCoeffs
191     const tmp<scalarField>&
192 ) const
194     return
195          valueFraction_*refValue_
196        + (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
200 template<class Type>
201 tmp<Field<Type> > mixedFvPatchField<Type>::gradientInternalCoeffs() const
203     return -Type(pTraits<Type>::one)*valueFraction_*this->patch().deltaCoeffs();
207 template<class Type>
208 tmp<Field<Type> > mixedFvPatchField<Type>::gradientBoundaryCoeffs() const
210     return
211         valueFraction_*this->patch().deltaCoeffs()*refValue_
212       + (1.0 - valueFraction_)*refGrad_;
216 template<class Type>
217 void mixedFvPatchField<Type>::write(Ostream& os) const
219     fvPatchField<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 // ************************************************************************* //