Transferred copyright to the OpenFOAM Foundation
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvPatchFields / basic / mixed / mixedFvPatchField.C
blobb716d486864972f4ccb5f416a6d1f542dff94d04
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 namespace Foam
33 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
35 template<class Type>
36 mixedFvPatchField<Type>::mixedFvPatchField
38     const fvPatch& p,
39     const DimensionedField<Type, volMesh>& iF
42     fvPatchField<Type>(p, iF),
43     refValue_(p.size()),
44     refGrad_(p.size()),
45     valueFraction_(p.size())
49 template<class Type>
50 mixedFvPatchField<Type>::mixedFvPatchField
52     const mixedFvPatchField<Type>& ptf,
53     const fvPatch& p,
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)
65 template<class Type>
66 mixedFvPatchField<Type>::mixedFvPatchField
68     const fvPatch& p,
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())
78     evaluate();
82 template<class Type>
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_)
95 template<class Type>
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  * * * * * * * * * * * * * //
111 template<class Type>
112 void mixedFvPatchField<Type>::autoMap
114     const fvPatchFieldMapper& m
117     fvPatchField<Type>::autoMap(m);
118     refValue_.autoMap(m);
119     refGrad_.autoMap(m);
120     valueFraction_.autoMap(m);
124 template<class Type>
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);
142 template<class Type>
143 void mixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
145     if (!this->updated())
146     {
147         this->updateCoeffs();
148     }
150     Field<Type>::operator=
151     (
152         valueFraction_*refValue_
153       +
154         (1.0 - valueFraction_)*
155         (
156             this->patchInternalField()
157           + refGrad_/this->patch().deltaCoeffs()
158         )
159     );
161     fvPatchField<Type>::evaluate();
165 template<class Type>
166 tmp<Field<Type> > mixedFvPatchField<Type>::snGrad() const
168     return
169         valueFraction_
170        *(refValue_ - this->patchInternalField())
171        *this->patch().deltaCoeffs()
172       + (1.0 - valueFraction_)*refGrad_;
176 template<class Type>
177 tmp<Field<Type> > mixedFvPatchField<Type>::valueInternalCoeffs
179     const tmp<scalarField>&
180 ) const
182     return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
187 template<class Type>
188 tmp<Field<Type> > mixedFvPatchField<Type>::valueBoundaryCoeffs
190     const tmp<scalarField>&
191 ) const
193     return
194          valueFraction_*refValue_
195        + (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
199 template<class Type>
200 tmp<Field<Type> > mixedFvPatchField<Type>::gradientInternalCoeffs() const
202     return -Type(pTraits<Type>::one)*valueFraction_*this->patch().deltaCoeffs();
206 template<class Type>
207 tmp<Field<Type> > mixedFvPatchField<Type>::gradientBoundaryCoeffs() const
209     return
210         valueFraction_*this->patch().deltaCoeffs()*refValue_
211       + (1.0 - valueFraction_)*refGrad_;
215 template<class Type>
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 // ************************************************************************* //